function getRequest(name) {
	var pairs = location.search.slice(1).split("&");
	for (var i = 0; i < pairs.length; i++) {
		var pair = pairs[i].split("=");
		if (pair[0] == name) return pair[1];
	}
	return false;
}

function debugAtStatus(_str) {
  window.status = _str;
  
  var _task = "debugAtStatus('" + _str + "');";
  setTimeout(_task, 500);
}

function keepOutOfFrame() {
  if (window.top.location != window.self.location) window.top.location = window.self.location;
}

function forceIntoFrame(_fileFrameset) {
  if (window.top.location == window.self.location) window.top.location.href = _fileFrameset;
}

function getPlatform() {
  if (navigator.platform.indexOf("Win") >= 0) return "win";
  else if (navigator.platform.indexOf("Mac") >= 0) return "mac";
  else return "";
}

function getBrowserType() {
  if (navigator.appName.indexOf("Explorer") >= 0) return "ie";
  else if (navigator.appName.indexOf("Netscape") >= 0) return "nn";
  else return "";
}

function getBrowserVer() {
  return parseInt(navigator.appVersion);
}

function preloadImgs(dir, names, ext) {
  var namesArr = names.split();
  var objsArr = new Array();
  
  for (i = 0; i < namesArr.length; i++) {
    objsArr[i] = new Image();
    objsArr[i].src = dir + namesArr[i] + "." + ext;
  }
}

//---- Flash Player

function detectFlash(ver) {
  var is = false;

  if (getBrowserType() == "nn") {
    is = detectFlashJs(ver);
  } else if (getBrowserType() == "ie") {
    if (getPlatform() == "win") {
      is = detectFlashVb(ver);
    } else if (getPlatform() == "mac") {
      if (ver >= 4) is = detectFlashJs(ver);
    }
  }
  
  return is;
}

function detectFlashJs(ver) {
  var is = false;
  for (var i = 0; i < navigator.plugins.length; i++) {
  	if (navigator.plugins[i].name.indexOf("Shockwave Flash") >= 0)  {
      if (parseInt(navigator.plugins[i].description.substr(16, 1)) >= ver) is = true;
  	}
  }
  return is;
}

function detectFlashVb(ver) {
  gIs = false;
  
  document.writeln('<script language=VBScript>');
  document.writeln('  On Error Resume Next');
  document.writeln('  If Not IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.' + ver + '")) Then');
  document.writeln('    gIs = false');
  document.writeln('  Else');
  document.writeln('    gIs = true');
  document.writeln('  End If');
  document.writeln('</scr' + 'ipt>');
  
  return gIs;
}


//---- Windows Media Player

function detectWmpJs() {
  var is = false;
  for (var i = 0; i < navigator.plugins.length; i++) {
  	if (navigator.plugins[i].name.indexOf("Windows Media") >= 0) is = true;
  }
  return is;
}

function detectWmpVb() {
  gIs = false;

  document.writeln('<script language=VBScript>');
  document.writeln('  On Error Resume Next');
  document.writeln('  If  IsObject(CreateObject("MediaPlayer.MediaPlayer.1")) Then');
  document.writeln('    gIs = true');
  document.writeln('  End If');
  document.writeln('</scr' + 'ipt>');

  return gIs;
}



//---- Cookies

function setCookie(name, value, expY, expM, expD, path, domain, secure) {
	var cookie = name + "=" + escape(value);
	
	if (expY) {
		var expires = new Date(expY, expM, expD);
		cookie += "; expires=" + expires.toGMTString();
	}
	
	if (path) cookie += "; path=" + escape(path);
	
	if (domain)	cookie += "; domain=" + escape(domain);
	
	if (secure)	cookie += "; secure";
	
	document.cookie = cookie;
}

function getCookie(name) {
	var pair = document.cookie.match(name + '=(.*?)(;|$)');
	
	if (pair) return unescape(pair[1]);
	else return null;
}

function deleteCookie(name) {
	var past = new Date();
	past.setTime(past.getTime() - 1);
	document.cookie = name + "=; expires=" + past.toGMTString();
}