function OpenNewSite(newLocation) {
    newwin=window.open(newLocation, "dispwin","width=800,height=500,scrollbars,resizable,menubar,location");
}

function NavBarClick( tableCellRef, navStyle, url ) {
	NavBar( tableCellRef, 0, navStyle );
	GoTo( url );
}

function OpenSlideShow(propertyID) {
    newwin=open("intermediate_listingDetailsSlideShow.jsp?searchType=slideShow&listingNumber="+propertyID, "dispwin","width=800,height=500,scrollbars=yes,menubar=no,location=no,resize=yes,top=20,left=20')");
}

function OpenVirtualTour(propertyID) {
    newwin=open("intermediate_listingDetailsVirtualTour.jsp?searchType=virtualTour&listingNumber="+propertyID, "dispwin","width=800,height=500,scrollbars=yes,menubar=no,location=no,resize=yes,top=20,left=20");
}

function OpenMortgageCalc(price, propertyTax) {
    newwin=open("mortgage_calc.jsp?price="+price+"&propertyTax="+propertyTax, "dispwin","width=800,height=550,scrollbars=yes,menubar=no,location=no,resize=yes,top=20,left=20");
}
function OpenNewWindow(location) {
    newwin = open(location, "dispwin","width=800,height=550,scrollbars=yes,menubar=no,resize=yes,top=20,left=20");
}
function OpenPrivacyWindow(location) {
    newwin = open(location, "dispwin","width=620,height=500,scrollbars=yes,menubar=no,resize=yes,top=20,left=20");
}
function OpenTosWindow(location) {
    newwin = open(location, "dispwin","width=620,height=500,scrollbars=yes,menubar=no,resize=yes,top=20,left=20");
}
function swapImage(imgName,imgObjName) {
   if (document.images) {
     document.images[imgName].src = eval(imgObjName + ".src");
   }
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function OpenLinksWindow(location) {
    newwin = open(location, "dispwin","width=420,height=440,scrollbars=no,menubar=no,resize=yes");
}
function openMainMortCalc() {
	window.open('main_mortgage_calc.jsp', 'new_window', 'width=550,height=475');
}
function openMainEmailMe() {
	window.open('main_email_me.jsp', 'new_window', 'width=550,height=450');
}
function openSuperMainEmailMe(text) {
	window.open('main_email_me.jsp?emailMessage='+text, 'new_window', 'width=550,height=450');
}
function jumpTo(URL_List){
   var URL = URL_List.options[URL_List.selectedIndex].value;
   window.location.href = URL;
}
function swapSlideImage(imgName, type, newImageNum) {
	if (type==next){
		if (!document.images)
			return;
		if (curImage<numImages) {
			curImage++; 
		} else {
			curImage=0;
		}
		document.images[imgName].src = eval("image"+curImage+".src");
		document.getElementById(imgName).href = eval("image"+curImage+".src");
	} else if (type==prev){
		if (!document.images)
			return;
		if (curImage>0) {
			curImage--; 
		} else {
			curImage=numImages;
		}
		document.images[imgName].src = eval("image"+curImage+".src");
		document.getElementById(imgName).href = eval("image"+curImage+".src");
	} else if (type==swap){
		document.images[imgName].src = eval("image"+newImageNum+".src");
		document.getElementById(imgName).href = eval("image"+newImageNum+".src");
	}
}

// This function is included to overcome a bug in Netscape's implementation
// of the escape () function:
function myunescape (str)
{
	str = '' + str;
	while (true)
	{
		var i = str . indexOf ('+');
		if (i < 0)
			break;
		str = str . substring (0, i) + ' ' + str . substring (i + 1, str . length);
	}
	return unescape (str);
}



// This function creates the args [] array and populates it with data
// found in the URL's search string:
function args_init ()
{
	args = new Array ();
	var argstring = window . location . search;
	if (argstring . charAt (0) != '?')
		return;
	argstring = argstring . substring (1, argstring . length);
	var argarray = argstring . split ('&');
	var i;
	var singlearg;
	for (i = 0; i < argarray . length; ++ i)
	{
		singlearg = argarray [i] . split ('=');
		if (singlearg . length != 2)
			continue;
		var key = myunescape (singlearg [0]);
		var value = myunescape (singlearg [1]);
		args [key] = value;
	}
}
function jumpToNewTour(URL_List){
   var URL = URL_List.options[URL_List.selectedIndex].value;
   window.location.href = URL;
}
function hideShowFields(defOn){
	if (defOn){
		document.getElementById('optionalOn').className = 'fieldsShow'; 
		document.getElementById('optionalOff').className = 'fieldsHide';		
	}else{
		document.getElementById('optionalOn').className = 'fieldsHide'; 
		document.getElementById('optionalOff').className = 'fieldsShow';		
	}		
}
function agentOfficeTabs(defOn){
	if (defOn){
		document.getElementById('resourceKit').className = 'fieldsShow'; 
		document.getElementById('personalProfile').className = 'fieldsHide';		
	}else{
		document.getElementById('resourceKit').className = 'fieldsHide'; 
		document.getElementById('personalProfile').className = 'fieldsShow';		
	}		
}

// Verifys that both the tos and agency explanation have been agreed to in Alberta or just
// the toc in bc.
// If this is the case the "I Agree" button will be enabled otherwise it will be disabled.
// regType is one of Basic / Client. If it's basic only tos needs to be agreed to regardless of wether
// or not we are in ab or bc.
function verifyAck( provinceString, regType ) {
	
	if(regType == 'Basic') {
		if(document.clientRegister.tosCheckBox.checked) {
			return true;
		} else {
			alert ("You must agree to the Acknowledgement(s)");
			return false;
		}
	}
	
	if(provinceString == 'Alberta') {
		if((document.clientRegister.tosCheckBox.checked) && (document.clientRegister.agencyAckCheckBox.checked)) {
			return true;
		} else {
			alert ("You must agree to the Acknowledgement(s)");
			return false;
		}
	} else if(provinceString == 'British Columbia') {
		if(document.clientRegister.tosCheckBox.checked) {
			return true;
		} else {
			alert ("You must agree to the Acknowledgement(s)");
			return false;
		}
	}
}

