// JavaScript Document
var undefined;

var args = new Array();

function GetQuery()
	{
	query = location.search.substring(1);
	pairs = query.split("&");
	for (i=0;i<pairs.length;i++) {
		args[i] = pairs[i].split('=');
		}
	}

GetQuery();
		
function Request(myVariable)
	{
	for (i=0;i<args.length;i++) {
		if (args[i][0]==myVariable) return args[i][1];
		}
	}


function getName(spanId) {
	window.alert(document.getElementById(spanId).getAttribute('id'));
}

function getContent(spanId) {
	window.alert(document.getElementById(spanId).innerHTML);
}

function getexpirydate( nodays){
	var UTCstring;
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+nodays*24*60*60*1000);
	UTCstring = Today.toUTCString();
	return UTCstring;
	}

//function getcookie(cookiename) {
// 	var cookiestring=""+document.cookie;
// 	var index1=cookiestring.indexOf(cookiename);
// 	if (index1==-1 || cookiename=="") return ""; 
// 	var index2=cookiestring.indexOf(';',index1);
// 	if (index2==-1) index2=cookiestring.length; 
// 	return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
//	}

function getcookie(cookiename) {
	var cookiestring = "" + document.cookie;
	args = Array();
	args = cookiestring.split(";");
	for (i=0;i<args.length;i++) {
		args[i] = args[i].split("=");
		if (trimAll(args[i][0])==cookiename) return args[i][1];
		}
	}

function setcookie(name,value,duration){
	cookiestring=name+"="+escape(value)+";"; //+";EXPIRES="+getexpirydate(duration); // uncomment this to add tell the cookie whent to expire
	document.cookie=cookiestring;
	if(!getcookie(name)){
		return false;
		}
	else {
		return true;
		}
	}

function trimAll(sString) 	{
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
		}
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
		}
	return sString;
	}

if (Request('source')!="" && Request('source')!=undefined) setcookie('source',Request('source'));

function HREF(URL, target, attributes) {
	if (URL!="" && URL!=undefined) window.open(URL, target, attributes);
	}
