function FindSource(){
var params=location.search.substring(1);
if (params != ""){
	var param=new Array();
	param=params.split("=");
	SetCookie("Referrer",param[1]);
	}
}

function OnlyValidChars(validchars,teststring){
var newstring="";
for (i=0;i<teststring.length; i++)
	if (validchars.indexOf(teststring.substring(i,i+1)) != -1)
		newstring+=teststring.substring(i,i+1);
return newstring;
}

function GetCookie(name) {
 var result = null;
 var myCookie = " " + document.cookie + ";";
 var searchName = " " + name + "=";
 var startOfCookie = myCookie.indexOf(searchName);
 var endOfCookie;
 if (startOfCookie != -1) {
  startOfCookie += searchName.length; // skip past name of cookie
  endOfCookie = myCookie.indexOf(";", startOfCookie);
  result = unescape(myCookie.substring(startOfCookie, endOfCookie));
 }
 return result;
}

function SetCookie(name, value) {
var never = new Date();
never.setTime(never.getTime() + 90*24*60*60*1000); // Keep referrer cookie for 90 days
var expString = "; expires=" + never.toGMTString();
document.cookie = name + "=" + escape(value) + expString;
}

function formValid(){
var x = 0;
var FormOk  = true;
if (document.forms[0].referrerID.value == "")
	document.forms[0].referrerID.value=" ";
while ((x < (document.forms[0].elements.length-1)) && (FormOk)){
	 if (document.forms[0].elements[x].value == ""){ 
        alert('Please enter information in ALL fields.');
        document.forms[0].elements[x].focus();
        FormOk = false;
     	}
    x++;
   }
Calcprice();
return FormOk;
}

function register(){
var PopWin=window.open("http://10.1.0.1/idalot/promotion/register.htm","NewMember","toolbar=no,directories=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=450,height=380,left=15,top=15,screenX=15,screenY=15");
}

function Calcprice(){
var totval=0;
if (document.sufm.analysis.checked){
	document.sufm.sufmtxt1.value="Analysis: Bht 4,500";
	totval=4500;
	}
else
	document.sufm.sufmtxt1.value="Analysis: n.a.";
if (document.sufm.promotion.checked){
	document.sufm.sufmtxt2.value="Promotion: Bht 9,000";
	totval+=9000;
	}
else
	document.sufm.sufmtxt2.value="Promotion: n.a.";
document.sufm.amount.value="Total: Bht "+totval;
}
