
// *** Globals
var dateNow = new Date();


// *** Functions



function checkForm(objForm) {
	
	var strICID;		
		strICID = getParamFA("icid");
if (strICID.length == 0) { strICID = getCookieFA("icid")}
		
		if (strICID.length == 0) {
			if (window.location.pathname.indexOf("googleadwords") > -1) {
				strICID = "googleadwords";}
				else {strICID = "lcplc";}
		}
		
		objForm.elements["icid"].value = strICID;
		return true;
	
}

function getParamFA(strParam) {

	var iStart, iEnd, iLen;
	var strValue = "";
	var strURL = window.location.href + "&";
	iStart = strURL.toLowerCase().indexOf("&" + strParam + "=");

	if (iStart < 0) {
		iStart = strURL.toLowerCase().indexOf("?" + strParam + "=");
	}

	if (iStart > -1) {
		iStart += strParam.length + 2;
		strURL = strURL.substr(iStart);
		iEnd = strURL.toLowerCase().indexOf("&");
		if (iEnd > 0) {
			strValue = strURL.substr(0, iEnd);
		}

	}

	if (strValue != "") {
		setCookieFA(strParam.toLowerCase(), strValue);
	} else {
		strValue = getCookieFA(strParam.toLowerCase());
	}

	return strValue;
}

function getCookieFA(name) {

	var start = document.cookie.indexOf(name+"=");
	var len = start+name.length+1;
	if ((!start) && (name != document.cookie.substring(0,name.length))) return "";
	if (start == -1) return "";
	var end = document.cookie.indexOf(";",len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len,end));
}

	

function setCookieFA(name,value,expires,path,domain,secure) {
	var cookie;
	cookie = name + "=" + escape(value);
	cookie += ((expires) ? ";expires=" + new Date(expires).toGMTString() : "");
	cookie += ((path) ? ";path=" + path : "");
	cookie += ((domain) ? ";domain=" + domain : "");
	cookie += ((secure) ? ";secure" : "");
	document.cookie = cookie;
}




