

//--------------------------all javascript functions---------------------


//------------------------county line mouse over events------------------

function newImage(arg) {
  if (document.images) {
    rslt = new Image();
    rslt.src = arg;
    return rslt;
  }
}

function changeImages() {
  if (document.images && (preloadFlag == true)) {
    for (var i=0; i<changeImages.arguments.length; i+=2) {
      document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
    }
  }
}

var preloadFlag = false;
function preloadImages() {
  if (document.images) {
    menu_realtor_over = newImage("http://www.countylineproperties.com/images/content_pages/menu_realtor_over.gif");
    menu_showcase_over = newImage("http://www.countylineproperties.com/images/content_pages/menu_showcase_over.gif");
    menu_about_over = newImage("http://www.countylineproperties.com/images/content_pages/menu_about_over.gif");
    menu_agents_over = newImage("http://www.countylineproperties.com/images/content_pages/menu_agents_over.gif");
    menu_tips_over = newImage("http://www.countylineproperties.com/images/content_pages/menu_tips_over.gif");
    menu_trib_over = newImage("http://www.countylineproperties.com/images/content_pages/menu_trib_over.gif");
    menu_home_over = newImage("http://www.countylineproperties.com/images/content_pages/menu_home_over.gif");
    
    menu_realtor_out = newImage("http://www.countylineproperties.com/images/content_pages/menu_realtor.gif");
    menu_showcase_out = newImage("http://www.countylineproperties.com/images/content_pages/menu_showcase.gif");
    menu_about_out = newImage("http://www.countylineproperties.com/images/content_pages/menu_about.gif");
    menu_agents_out = newImage("http://www.countylineproperties.com/images/content_pages/menu_agents.gif");
    menu_tips_out = newImage("http://www.countylineproperties.com/images/content_pages/menu_tips.gif");
    menu_trib_out = newImage("http://www.countylineproperties.com/images/content_pages/menu_trib.gif");
    menu_home_out = newImage("http://www.countylineproperties.com/images/content_pages/menu_home.gif");
    
    preloadFlag = true;
  }
}

//--------------------------end county line-----------------------




function go_back()
 {
  window.history.go(-1); 
 }

function print_win()
 {
  window.print();
 }
 
function makePopUp(whereTo, winWidth, winHeight) 
 {
  remote = window.open("","remotewin","width="+winWidth+",height="+winHeight+",menubar=0,toolbar=no,scrollbars=yes,resizable=1");
  remote.location.href = whereTo; 
  remote.focus();
 }
 
function mort_calc(LP,LN)
{
  remote = window.open("","remotewin","width=250,height=325,menubar=0,toolbar=no,scrollbars=yes");
  remote.location.href = "pop_mort_calc.asp?LP="+LP+"&LN="+LN; 
  remote.focus();
 }

function submit_form(form_name, form_action)
 {
  window.document.forms[form_name].action = form_action; 
  window.document.forms[form_name].submit(); 
 }
 
function close_win()
 {
  window.close(); 
 }
 
function delete_customer(customerID)
 { 
  if(confirm("Are you sure you want to delete this record?"))
       {
        window.document.location="customer_delete.asp?customerID="+customerID; 
       }
 }  
   
  
//---------------------------opens the visual tours window----------------------

   var agt=navigator.userAgent.toLowerCase(); 
      var is_aol   = (agt.indexOf("aol") != -1); 
      var is_Win2K = (agt.indexOf("nt 5") != -1); 

  function showVT(tourID) {
    if (is_aol && is_Win2K) {
       x=0;
       y=0;
    } else {
       x=139;
       y=80;       
    } 

    window.open('http://visualtour.com/showvt.asp?t='+ tourID,'VirtualTour','width=522,height=440,left=' + x + ',top=' + y + ',resizable=no,scrollbars=no,toolbar=no'); 
 
  }
 
//-----------deletes the visual/virtual tours information in the admin----------


function delete_tour(app_type, tourID, clientID)
 { 
  if(confirm("Are you sure you want to delete this record?"))
       {
        if(app_type == "visual")
         {
            window.document.location="delete_visual_tour.asp?app_type="+app_type+"&tourID="+tourID+"&clientID="+clientID; 
         }
        else if(app_type == "360virtual")
         {
           window.document.location="delete_360virtual_tour.asp?tourID="+tourID+"&clientID="+clientID; 
         }       
       }
 } 
 
//----------------------------end visual tours functions-------------------------- 


    
//-----------------------pop up window at mapquest---------------------------

  /* Side panel generator  */
  /* Source: www.chicago.tribune.com/homes/ */
function make_Win (targurl, width, height, winopts) {
if (window.sidebars == null) {
sidebars = new Object;
sidebars.length = 1;
}
allopts = "width=" + width + ",height=" + height + "," + winopts;
var tempref = window.open(targurl, "sidebar" + sidebars.length, allopts);
sidebars[sidebars.length] = tempref;
sidebars.length++;
}
function killwins() {
if (navigator.appName != "Microsoft Internet Explorer") {
if (window.sidebars != null) {     
for (i = 1; i < sidebars.length; i++) {sidebars[i].close();}
}}}


//--------------------------360virual tours from realtor.com-------------------------------


// ----- BEGIN: FOR OPENING GENERAL POPUP WINDOWS -----
function OpenPopup(URL, width, height) {
	window.self.name = "main";
	var now = new Date();
	var remote = window.open(URL, "popup" + now.getTime(), "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=1,status=1,menubar=0,scrollbars=0");
}

function OpenScrollingPopup(URL, width, height) {
	window.self.name = "main";
	var now = new Date();
	var remote = window.open(URL, "popup" + now.getTime(), "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=1,status=1,menubar=0,scrollbars=yes");
}
// ----- END: FOR OPENING GENERAL POPUP WINDOWS -----



// ----- BEGIN: FOR OPENING SPECIAL POPUP WINDOWS -----
function openPopUnder() {
	if(getCookie('PopUnder') == ''  &&  getCookie('HSID') != ''  &&  parseInt(navigator.appVersion) >= 4  &&  navigator.userAgent.indexOf('AOL') == -1) {
		var dtmExp = new Date();
		dtmExp.setTime(dtmExp.getTime() + (24 * 60 * 60 * 1000));  // 24-hour expiry
		setCookieWithPath('PopUnder', 'true', '/', dtmExp.toGMTString());

		var strURL = addStdArgsToURL('/Ads/PopUnderPop.asp');

		var winPopUnder = window.open(strURL, 'PopUnder', 'resizable=yes,status=no,toolbar=no,location=no,menu=no,scrollbars=no,width=730,height=310');

		if(navigator.appName.indexOf('Microsoft') == -1 || parseInt(navigator.appVersion) > 4)
			winPopUnder.blur();
		window.self.focus();
	}
}

function openMessenger(agentID,agentScreenName,emailURL,promoURL,ftmlsid,ftmlsalias,fthsid,ftspg,ftsid,ftaid,ftlid,ftctype){
	var url = "http://homestoreimlink.facetime.net/messengerLaunch.html" + "?agentID=" + agentID + "&agentScreenName=" + escape(agentScreenName) + "&emailURL=\"" + emailURL + "\"" + "&promoURL=\"" + promoURL + "\"" + "&mlsid=" + escape(ftmlsid) + "&mlsalias=" + escape(ftmlsalias) + "&aid=" + escape(ftaid) + "&lid="  + escape(ftlid) + "&ctype=" + escape(ftctype) + "&spg="  + escape(ftspg) + "&HSID=" + escape(fthsid) + "&sid=" + escape(ftsid);

	var urlRD = addStdArgsToURL("/Redir/Redir.asp?target=" + escape(url) );
	window.open(urlRD,'_blank','width=3,height=3');

}

function softpop() {
	var strGateway = getGateway();
	if(strGateway == "homestore" || strGateway == "realtor" || strGateway == "" || strGateway.substring(0, 2) == "go" || strGateway.substring(0, 3) == "aol" || strGateway.substring(0, 6) == "excite") {
		if(getCookie('MEMUSER') == ''  &&  getCookie('HSSoftgate') == '') {
			var intRandomNumber = Math.floor(Math.random() * 100 + 1);
			var intMagicNumber = 100;
			if(intRandomNumber <= intMagicNumber) {
				var mydate = new Date();
				mydate.setHours(23);
				mydate.setMinutes(59);
				mydate.setSeconds(59);
				var strSoftGateCookie = "HSSoftgate" + "=" + "True" + ";expires=" + mydate.toGMTString() + "; Path=/" ;
				document.cookie = strSoftGateCookie;
				OpenScrollingPopup("/Redir/Redir_CreateProfile.asp?Target=/persplanout/SignUp1Pop.asp?DSF1=True&gate=" + strGateway,350,550); return true;
			}
		}
	}
}
function softpopUReg(strURL) {
	if(getCookie('HSAuth') == ''  &&  getCookie('HSSoftgate') == '') {
		var strGateway = getGateway();
		if(strGateway == 'homestore' || strGateway == 'realtor' || strGateway == '' || strGateway.substring(0, 2) == 'go' || strGateway.substring(0, 3) == 'aol' || strGateway.substring(0, 6) == 'excite') {
			var intRandomNumber = Math.floor(Math.random() * 100 + 1);
			var intMagicNumber = 100;
			if(intRandomNumber <= intMagicNumber) {
				var mydate = new Date();
				mydate.setHours(23);
				mydate.setMinutes(59);
				mydate.setSeconds(59);
				var strSoftGateCookie = 'HSSoftgate=True;expires=' + mydate.toGMTString() + '; Path=/';
				document.cookie = strSoftGateCookie;
				OpenScrollingPopup(strURL + "?DSF2=True&poe=Realtor&gate=" + strGateway,400,500); 			return true;
			}
		}
	}
}
// ----- END: FOR OPENING SPECIAL POPUP WINDOWS -----



// ----- BEGIN: FOR HIDING/SHOWING LAYERS -----
function showLayer(strLayerName) {
	if(document.all)
		document.all[strLayerName].style.display = 'block';
	else if(document.layers)
		document.layers[strLayerName].display = 'block';
}
function hideLayer(strLayerName) {
	if(document.all)
		document.all[strLayerName].style.display = 'none';
	else if(document.layers)
		document.layers[strLayerName].display = 'none';
}
// ----- END: FOR HIDING/SHOWING LAYERS -----



function swapImage(strImgName, strImgSrc) {
	if(document.images)
		document.images[strImgName].src = strImgSrc;
}



function getQSParam(strName) {
	var strValue = '';
	var strQS = document.location.search;
	var intStart = strQS.indexOf(strName + '=');

	if(intStart != -1) {
		var intEnd = strQS.indexOf('&', intStart);
		if(intEnd == -1) intEnd = strQS.length;
		strValue = strQS.substring(intStart + strName.length + 1, intEnd);
	}
	return unescape(strValue);
}

function addArgToQS(strURL, strArg) {
	if(strURL.indexOf('?') == -1)
		return strURL + '?' + strArg;
	else
		return strURL + '&' + strArg;
}

function addStdArgsToURL(strOrigURL) {
	var strValue, strURL = strOrigURL

	strValue = getQSParam('gate')
	if(strValue != '' && strOrigURL.indexOf('gate=') == -1)
		strURL = addArgToQS(strURL, 'gate=' + strValue);

	strValue = getQSParam('source')
	if(strValue != '' && strOrigURL.indexOf('source=') == -1)
		strURL = addArgToQS(strURL, 'source=' + strValue);

	strValue = getQSParam('poe')
	if(strValue != '' && strOrigURL.indexOf('poe=') == -1)
		strURL = addArgToQS(strURL, 'poe=' + strValue);

	strValue = getQSParam('nnv')
	if(strValue != '' && strOrigURL.indexOf('nnv=') == -1)
		strURL = addArgToQS(strURL, 'nnv=' + strValue);

	return strURL;
}



// ----- BEGIN: FOR GETTING GATEWAY FLAGS -----
function getGateway() {
	return getQSParam('gate');
}
function getGatewayQS() {
	var strGate = getGateway();
	if(strGate == '')
		return '';
	else
		return 'gate=' + strGate;
}
// ----- END: FOR GETTING GATEWAY FLAGS -----



// ----- BEGIN: FOR GETTING COOKIES -----
function getCookie(strName) {
	var strCookie = document.cookie;
	if(strCookie.length == 0) return '';
	var strValue = '';
	var intStart = strCookie.indexOf(strName + '=');
	if(intStart > -1) {
		intStart += strName.length + 1;
		var intEnd = strCookie.indexOf(';', intStart + 1);
		if(intEnd == -1) intEnd = strCookie.length;
		strValue = strCookie.substring(intStart, intEnd);
	}
	return strValue;
}

function setCookie(strName, strValue, strExp) {
	document.cookie = strName + '=' + strValue
			+ (document.location.hostname == 'www.realtor.com' ? ';domain=.realtor.com' : '')
			+ (strExp == '' ? '' : ';expires=' + strExp);
}

function setCookieWithPath(strName, strValue, strPath, strExp) {
	document.cookie = strName + '=' + strValue
			+ (document.location.hostname == 'www.realtor.com' ? ';domain=.realtor.com' : '')
			+ (strPath == '' ? '' : ';path=' + strPath)
			+ (strExp == '' ? '' : ';expires=' + strExp);
}

function deleteCookie(strName) {
	var dtmExp = new Date();
	dtmExp.setTime(dtmExp.getTime() - 3600000); // 1 hr ago
	setCookieWithPath(strName, '', '/', dtmExp.toGMTString())
}
// ----- END: FOR GETTING COOKIES -----



function isLoggedOn() { return ( document.cookie.indexOf('FormsAuth=') != -1 ); }
function logOffPlanner() {
	deleteCookie('FormsAuth');
	deleteCookie('MEMUSER');
	deleteCookie('NAME');
}



// ----- BEGIN: FOR STRING/NUMBER CONVERSIONS -----
function isNumericString(strOrig) {
	if(strOrig.length==0) return false;

	var strChar;
	var strValidChars = "1234567890$,";
	for (var i = 0; i < strOrig.length; i++) {
		strChar = strOrig.substring(i, i+1);
		if (strValidChars.indexOf(strChar, 0) == -1)
			return false;
	}
	return true;
}

function isValidEmail(strEmail) {
	var strBadChars, strChar, strSuffix, intNumBadChars, intCount, intPos, intPosPeriod

	// --- CHECKING FOR BAD CHARACTERS ---
	strBadChars = ' /:,#\'"`$~!%^&*();<>?\\|{}[]';
	intNumBadChars = strBadChars.length
	for(intCount = 0;  intCount < intNumBadChars;  ++intCount) {
		strChar = strBadChars.substring(intCount, 1);
		if(strEmail.indexOf(strChar) > 0)
			return false;
	}

	// --- CHECKING FOR THE @ SIGN ---
	intPos = strEmail.indexOf('@')
	if(intPos == -1)
		return false;

	// --- CHECKING FOR A . AFTER THE @ SIGN ---
	intPosPeriod = strEmail.indexOf('.', intPos);
	if(intPosPeriod == -1)
		return false;

	// --- CHECKING FOR AT LEAST 2 AFTER THE PERIOD ---
	if(strEmail.length - intPosPeriod < 3)
		return false;

	// --- ALL CHECKS OUT - MUST BE OKAY ---
	return true;
}
// ----- END: FOR STRING/NUMBER CONVERSIONS -----

//-----------------------------end virtual tour javascript------------------------


//--------------------------search functions--------------------------------
//------------------suburban clicks between text areas----------------------


//-------------------------------search start page-------------------------------

function SubmitSearchForm() {  // Called from search page
  
    ARs = document.frmSearch.areas;
	temp = "";
	for (i=0;i<ARs.length;i++) {  // save area selected
	  if(ARs.options[i].value != '') {   //if area not [all areas]
		temp += ARs.options[i].value + ",";
		}
	}
	document.frmSearch.AR.value = temp.substr(0,temp.length-1); //get rid of last comma
	document.frmSearch.submit();
	return false;
 }

function AddList() {
	SL = document.frmSearch.AreaList;
	ARs = document.frmSearch.areas;	
	if (SL.selectedIndex==-1) {
		alert('Please make a selection first');
		return false;
	}
	for (i=0;i<ARs.length;i++) {
	 if (ARs.options[i].value == SL.options[SL.selectedIndex].value) 
		return false;
	}	

	switch (ARs.length) {
	case 1:
	    if (ARs.options[0].text == "[All Areas]")
			ARs.options[0] = null;
		break;
	case 10:
		alert('Only five areas are allowed for this search');
		return false;
		break;
	}
	
	if (SL.selectedIndex ==0) {
		
		for(i=0;i<ARs.length;) {
			ARs.options[0] = null;  // eliminate all entries if "All Areas" is selected
		}
	}
	
	ARs.options[ARs.length] = new Option(SL.options[SL.selectedIndex].text,SL.options[SL.selectedIndex].value);
	return true;
}

function RemList() {
  ARs = document.frmSearch.areas;

if (ARs.length > 0 && ARs.selectedIndex != -1) // -1 indicates no selection
	ARs.options[ARs.selectedIndex] = null;
return true;
}


//-----------------------------end search start page------------------------------- 
   


// --> 



