	//setup stat cookie
	var numrnd = Math.floor((Math.random()*5) * 10000);
	var today = new Date();
	var sDay = today.getDate()<10?'0'+today.getDate():today.getDate();
	var sMonth = today.getMonth()<10?'0'+today.getMonth():today.getMonth();
	var sYear = ''+today.getYear();
	var sHour = today.getHours()<10?'0'+today.getHours():today.getHours();
	var sMinute = today.getMinutes()<10?'0'+today.getMinutes():today.getMinutes();
	var sSecond = today.getSeconds()<10?'0'+today.getSeconds():today.getSeconds();
	var sMillisecond = today.getMilliseconds();
	if (sMillisecond<10) sMillisecond='00'+sMillisecond; else if(sMillisecond<100) sMillisecond='0'+sMillisecond;
	var sStat = sYear+sMonth+sDay+'_'+sHour+sMinute+sSecond+sMillisecond+'_'+numrnd;

	//init. returnCookie value
	var bReturn = 0;
	var returnCookie = (getCookie("laysmusketeer_returnCookie")==''||getCookie("laysmusketeer_returnCookie")==null)?'':getCookie("laysmusketeer_returnCookie");
	if (returnCookie=='')	{
		bReturn = 0;
		returnCookie = sStat;
	}else{
		bReturn = 1;
	}
	setCookie("laysmusketeer_returnCookie", returnCookie, "day", 365);
	
	//init. sessionCookie value
	var sessionCookie = (getCookie("laysmusketeer_sessionCookie")==''||getCookie("laysmusketeer_sessionCookie")==null)?'':getCookie("laysmusketeer_sessionCookie");
	if (sessionCookie=='') {
		sessionCookie = sStat;
	}
	setCookie("laysmusketeer_sessionCookie", sessionCookie, "minute", 60);
	
	function getQueryVariable(variable) {
		var query = window.location.search.substring(1);
		//alert("substring: " +  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) {
				//alert(pair[1]);
				return pair[1];
			}  
		}
	}

	function getQueryVariableParent(variable) {
		var query = top.location.search.substring(1);
		//alert("substring: " +  top.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) {
				//alert(pair[1]);
				return pair[1];
			}  
		}
	}

	function setCookie(c_name,value,expireperiod,expirevalue){
		var exdate=new Date();

		//alert(exdate);

		if (expireperiod=="minute") {
			exdate.setMinutes(exdate.getMinutes()+expirevalue);
		}else if (expireperiod=="hour") {
			exdate.setHours(exdate.getHours()+expirevalue);
		}else if (expireperiod=="day") {
			exdate.setDate(exdate.getDate()+expirevalue);
		}else{
			exdate.setDate(exdate.getDate()+expirevalue);
		}

		//alert(exdate);

		document.cookie=c_name+ "=" +escape(value)+((expirevalue==null) ? "" : ";expires="+exdate.toGMTString());
	} 

	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 "";
	}
