function getConsultantID(url) {	pos1 = 0	pos2 = 0		url = url.toLowerCase()		pos1 = url.indexOf( "consultantpages" )	if (pos1 < 0)  return("")		pos1 = pos1 + 16	pos2 = url.indexOf("/", pos1)	return( url.substring( pos1, pos2 ) )}function getConsultantDetails(path, consultant, detail) {		//Build up the XML object to pass to the agent	if (window.ActiveXObject) { // IE		var objDOM = new ActiveXObject("Microsoft.XMLDOM")				RootEl = objDOM.createNode(1, "RootElement", "")		objDOM.documentElement = RootEl			objHeaders = objDOM.createNode(1, "XMLConsultant", "")		objHeaders.text = consultant		RootEl.appendChild(objHeaders)				objHeaders = objDOM.createNode(1, "XMLDetails", "")		objHeaders.text = detail		RootEl.appendChild(objHeaders)	} else { //Mozilla, Safari, etc		var parser = new DOMParser();		xmlString = "<?xml version=\"1.0\"?>"		xmlString = xmlString + "<XMLVariables>"		xmlString = xmlString + "<XMLConsultant>" + consultant + "</XMLConsultant>"		xmlString = xmlString + "<XMLDetails>" + detail + "</XMLDetails>"		xmlString = xmlString + "</XMLVariables>"				var objDOM = parser.parseFromString(xmlString, "text/xml");	}		//Call the agent	if (window.ActiveXObject) { // IE		objHTTP = new ActiveXObject("Microsoft.XMLHTTP");	} else { //Mozilla, Safari, etc		objHTTP = new XMLHttpRequest();	}	//if (path == "") path = "http://www.smartline.com.au/"	if (path == "") path = "http://" + location.hostname + "/"	strUrl = path + 'web/Profiles.nsf/getAdviserDetails?OpenAgent';		objHTTP.open("POST", strUrl, false, null, null);	objHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");	objHTTP.send(objDOM);	response = objHTTP.responseText;	if (response != "")  return(response)	objHTTP = null;}function openAdviserSite() {	if( !document.getElementById("select-adviser") )  return false	var adviser = document.getElementById( "select-adviser" );	var adviserID = adviser.options[adviser.selectedIndex].value;	if( adviserID == " " )  return false	window.location = "http://www.smartline.com.au/web/profiles.nsf/ProfilesSortByRegion/" + adviserID + "?OpenDocument";}function switchState(state) {	makeRequest( 'http://www.smartline.com.au/web/profiles.nsf/ProfilesSortByRegion2', 'RegionView', true, false, state );}function getSiteDetails() {	var defPhoneNo = "1800 020 066";	var chocChip = getCookie( "cSmartlineConsultant" );	if( chocChip == null )  return defPhoneNo		var suburb = getConsultantDetails( "", chocChip, "area" );	var phoneNo = getConsultantDetails( "", chocChip, "phone" );	if( phoneNo.indexOf( "Error" ) > -1 )  return defPhoneNo	if( window.parent.document ) {		if( suburb ) {			window.parent.document.title = "Mortgage Broker " + suburb + " - Smartline Home Loans"		}	}	return phoneNo;}function redirectToAdviserSite() {	var currLocation = window.location + ""; 	if( currLocation.indexOf( "?" ) > 0 ) { 		var cgiArray = currLocation.split( "?", 2 ); 		var pgFormat = getConsultantDetails("", cgiArray[1], "format"); 		if( pgFormat.indexOf("HTML") > -1 ) { 			if (getCookie("cFindAConsultant") == null && getCookie("cSmartlineConsultant") == null ) { 				document.cookie = "cSmartlineConsultant=" + cgiArray[1] + ";Path=/"; 			}		}	}	var chocChip = getCookie("cSmartlineConsultant");	if( chocChip != null )  location = "http://www.smartline.com.au/consultantpages/" + chocChip + "/home.html"}function captureLandingPage() {	var currLocation = window.location + ""; 	if( currLocation.indexOf( "landing-page-" ) > 0 ) { 		var lpArray = currLocation.split( "landing-page-", 2 );		if( lpArray[1].indexOf( ".html" ) > 0 )  lpArray[1] = lpArray[1].substring(0,lpArray[1].indexOf(".html"))		document.cookie = "cLandingPage=" + lpArray[1] + ";Path=/"; 	}}function setCookie(cookieName, cookieValue, cookiePath, cookieExpires)  {	cookieValue = escape(cookieValue);	if (cookieExpires == "")  {		var nowDate = new Date();		nowDate.setMonth(nowDate.getMonth() + 6);		cookieExpires = nowDate.toGMTString();	}		if (cookiePath != "")  cookiePath = ";Path=" + cookiePath	document.cookie = cookieName + "=" + cookieValue +  ";expires=" + cookieExpires + cookiePath;}function getCookie(name)  {	var cookieString = document.cookie;	var index = cookieString.indexOf(name + "=");	if (index == -1)  return null			index = cookieString.indexOf("=", index) + 1;	var endstr = cookieString.indexOf(";", index);	if (endstr == -1)  endstr = cookieString.length	return unescape(cookieString.substring(index, endstr));}