// JavaScript Document
var newwindow;
function popforgot(url)
{
	newwindow=window.open(url,'name','height=360,width=600,scrollbars=no,resize=no,');
	if (window.focus) {newwindow.focus()}
}

function popChart(url)
{
	newwindow=window.open(url,'name','height=555,width=525,scrollbars=no,resize=no,');
	if (window.focus) {newwindow.focus()}
}

function popupVideo(url)
{
	newwindow=window.open(url,'name','height=500,width=800,scrollbars=no,resize=no,');
	if (window.focus) {newwindow.focus()}
}

function popStats(url)
{
	newwindow=window.open(url,'name','height=500,width=800,scrollbars=no,resize=no,');
	if (window.focus) {newwindow.focus()}
}

function popSample(url)
{
	newwindow=window.open(url,'name','height=500,width=800,scrollbars=yes,resize=no,');
	if (window.focus) {newwindow.focus()}
}

function showhide(d) {
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block";}
else { document.getElementById(d).style.display = "none"; }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function getUrlAndSetCookie() {
  url = window.location.href;
  param = url.match(/\bSWITCHID\b/ig);
  if(param != null) {
	var regexS = "[\\?&]"+param+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if (results == null)
		return "";
	else {
	var cookie_name = "switchid";
	var cookie_value = results[1];
	var expirationDate = new Date();
	expirationDate.setTime(expirationDate.getTime()+(24*60*60*1000));
	var expirationString = "; expires="+expirationDate.toGMTString();
	document.cookie = cookie_name+"="+cookie_value+expirationString+"; path=/";
	}
  }
}

window.onload=function() {
	MM_preloadImages();
	getUrlAndSetCookie();
}