//
//  JS system-level routines
//
//  Clio Soleil (clio@PrettyGetter.TV)
//  PrettyGetter Productions (http://PrettyGetter.TV)
//  

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }

//--------------------------------------------------------------------------------------------------------------------------------------------
function trim(str)
// trims a string of whitespace
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  return str.replace(/^\s+|\s+$/g, '') ;
}

//--------------------------------------------------------------------------------------------------------------------------------------------
function openPopupWindow(url, title, width, height) 
// opens a new window to the specified URL
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  // reasonable defaults
  if (width == undefined)  width  = 800;
  if (height == undefined) height = 600;    
  if (title == undefined)  title  = "PrettyGetter.TV";
  if (url == undefined)    url    = "http://PrettyGetter.TV";
  
  // actually open the window
  popup_window = window.open(url, title, 'resizable=1,width='+width+',height='+height)
}


//--------------------------------------------------------------------------------------------------------------------------------------------
function getQueryVariable(variable) 
// gets the value of a name-value pair from the URL
// (if the name is undefined, this function returns undefined)
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i = 0; i < vars.length; i++) 
  {
    var pair = vars[i].split("=");
    if (pair[0] == variable)
      return unescape(pair[1]);
  }
}