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;
}

getParamFA("icid")


// Search site
function checkSearchFields(objForm)
{	
		if(trim(objForm.keywords.value) == "" | trim(objForm.keywords.value) == "Keyword Search") {
			alert("Please enter your keyword(s)");
			objForm.keywords.value = '';
			objForm.keywords.focus();
			return false;
		}
		else {
			return true;
		}
}
//End Function

// Create Link Code for referral page
function CreateLinkCode(){
	var MPS = document.getElementById('MPSno').value;
	var LinkRef;
	var CodeComment;
	
	document.getElementById('CodeSample').className = "textb";
	if (MPS == "")
		LinkRef = 'http://www.lcplc.co.uk';
	else
		LinkRef = 'http://www.lcplc.co.uk/homepage_1.aspx?id=0:21988&icid=MPSREFERRAL'+MPS;
	CodeComment = "<p>L&ampC, one of the best known UK no fee brokers, offers great mortgage deals from across the whole of the market with exclusive deals not available elsewhere. If you are looking to save money be remortgaging or to purchase a new property then contact , <a href='" + LinkRef + "'>no fee mortgage broker L&amp;C</a> </p> <p><strong>Your home may be repossessed if you do not keep up repayments on your mortgage.</strong></p>";
	document.getElementById('CodeSample').value = CodeComment;
}
//End Function

// Show & Hide
function show(c) {
	if (document.getElementById && document.getElementById(c)!= null) 
		node = document.getElementById(c).style.display='block'; 
	else if (document.layers && document.layers[c]!= null) 
		document.layers[c].display = 'block'; 
	else if (document.all && document.all(c)!= null) 
		document.all[c].style.display = 'block';
} 
//End Function

function hide(c) {	
	if (document.getElementById && document.getElementById(c)!= null)
		node = document.getElementById(c).style.display='none';
	else if (document.layers && document.layers[c]!= null) 
		document.layers[c].display = 'none';
	else if (document.all && document.all(c)!= null) 
		document.all[c].style.display = 'none';
}
//End Function

//Trim string
function trim(str) {
   return str.replace(/^\s*|\s*$/g,"");
}
//End Function

//Right Trim string
function rtrim(str) {
	return str.replace(/\s*$/, ""); 
}
//End Function

//Left Trim string
function ltrim(str) {
	return str.replace(/^\s*/, ""); 
}
//End Function


//print page
function showPrint() {
window.print();  
}
//End Function

//Send to Friend
function sendToFriend(iSessionID) {
window.location = "mailto:?subject=Mortgage Info&body=Take a look at: " + escape(window.location.href);
}
//End Function

//Send job to friend
function sendJobToFriend(iSessionID) {
window.location = "mailto:?subject=Interesting Job&body=Take a look at: " + escape(window.location.href);
}
//End Function

// create pop-up

function createTarget(form) {
var myHeight = 300;
var isResizable = true;

_target = form.target;
_colon = _target.indexOf(":");
if(_colon != -1) {
form.target = _target.substring(0,_colon);
form.args = _target.substring(_colon+1);
} else if(typeof(form.args)=="undefined") {
form.args = "";
}
if(form.args.indexOf("{")!=-1) {
_args = form.args.split("{");
form.args = _args[0];
for(var i = 1; i < _args.length;i++) {
_args[i] = _args[i].split("}");
form.args += eval(_args[i][0]) + _args[i][1];
   }
}
form.args = form.args.replace(/ /g,"");
_win = window.open('',form.target,form.args);
if(typeof(focus)=="function")
_win.focus();
return true;
}
// End function

/*** keep alive ***/
document.write("<script type=\"text/javascript\" src=\"/assets/scripts/EdeptiveAjax.js\"></script>");
var goAjax = null;
function keepAlive() {
	var strUrl = "";

	strUrl = window.location.protocol + "//" + window.location.host + "/webservices/keep_alive.asmx/Ping";
	goAjax = new EdeptiveAjax();
	goAjax.postRequest(strUrl, "", onKeepAliveResponse);
}
function onKeepAliveResponse() {
	if(goAjax.checkReadyState("keepAlive", "ping.", "ping..", "ping...") == "OK") {
		if(document.getElementById("keepAlive")) {
			var response = goAjax.request.responseXML.documentElement;
			document.getElementById("keepAlive").innerText = "sid=" + getText(response.firstChild);
		}
		setTimeout("keepAlive()", 1000*60);
	}
}
setTimeout("keepAlive()", 1000*2);

function doLoad() {
	var objForm = document.forms["feedback"];}
	
function getString(){
    var str = new String(document.location);
    vars =  str.split("?");
    if (vars.length == 2)
        return "?"+vars[1];
    else //
        return "";
}
	