var InvalidControls = '';

// copied from powersearch.aspx
var win_01;

function isEmpty(s) {
    if (s == null || s == "" || s == "null" || s == "undefined") {
        return (true);
    }
    return (false);
}

//Copied from Slide Show Page
var slideShowSpeed = 2000
var crossFadeDuration = 2
var Pic = new Array()

var t
var j = -1
var state = 'manual'
var preLoad = new Array()
var p

function preloadimages() {
	p = Pic.length
	for (i = 0; i < p; i++){
		preLoad[i] = new Image()
		preLoad[i].src = Pic[i]
	}
	
}
//New Overloaded function for Slide Show, Parameter Pic is pass by UCMorePhotos 
function preloadimagesArray(Pic) {
	p = Pic.length
	for (i = 0; i < p; i++){
		preLoad[i] = new Image()
		preLoad[i].src = Pic[i]
	}
	
}
function loadImage(picIndex) {
	document.images.SlideShow.src = preLoad[picIndex].src
	j = picIndex - 1
	showCount(picIndex , p)
}

function showCount(indexVal, totVal)
{
	if(navigator.appName.indexOf("Netscape")>(-1))
		{
			document.getElementById("recCount").innerHTML =  parseInt(indexVal)+1 +" of "+ totVal						
		}
		else
		{
			document.getElementById("recCount").innerText = parseInt(indexVal)+1 +" of "+ totVal
		}
}

function runSlideShow(){
   if ( state != 'auto' ) return
   j = j + 1
   if (j > (p-1)) j=0
   //if (document.all){
      //document.images.SlideShow.style.filter="blendTrans(duration=2)";
      //document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
      //document.images.SlideShow.filters.blendTrans.Apply()
   //}
   if(preLoad[j])
   {
     document.images.SlideShow.src = preLoad[j].src  
   }
   //if (document.all){
      //document.images.SlideShow.filters.blendTrans.Play()
   //}
   t = setTimeout('runSlideShow()', slideShowSpeed)
   showCount(j,p)
}

function ss_start() {
   if ( state != 'auto' ) {
      state = 'auto'
      runSlideShow()
      switchImages(true)
   }
}
function ss_stop() {
   if ( state != 'manual' ) {
      state = 'manual'
      switchImages(false)
   }
}
function ss_prev() {
   ss_stop()
   j = j - 1
   if ( j < 0 ) j = p - 1
   transitionimage()
   showCount(j , p)
}
function ss_next() {
   ss_stop()
   j = j + 1
   if ( j > (p-1) ) j=0
   transitionimage()
   showCount(j, p)
}

function transitionimage() {
   //if (document.all){
      //document.images.SlideShow.style.filter="blendTrans(duration=2)";   
      //document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
      //document.images.SlideShow.filters.blendTrans.Apply()
   //}
   if(preLoad[j])
   {
      document.images.SlideShow.src = preLoad[j].src 
   }   
   //if (document.all){
      //document.images.SlideShow.filters.blendTrans.Play()
   //}
}
function switchImages(play) {
   if ( play ) {
      document.images.start.src = "/TheSystemSharedUserControls/Themes/AWS/images/play_on.jpg"
      document.images.pause.src = "/TheSystemSharedUserControls/Themes/AWS/images/pause.jpg"
   }
   else {
      document.images.start.src = "/TheSystemSharedUserControls/Themes/AWS/images/play.jpg"
      document.images.pause.src = "/TheSystemSharedUserControls/Themes/AWS/images/pause_on.jpg"
   }
}

// Till here from Slide Show page

// get an element
function GetElement(id)
{
	var elm = null;
	if (document.getElementById)
	{
		// browser implements part of W3C DOM HTML
		// Gecko, Internet Explorer 5+, Opera 5+
		elm = document.getElementById(id);
	}
	else if (document.all)
	{
		// Internet Explorer 4 or Opera with IE user agent
		elm = document.all[id];
	}
	else if (document.layers)
	{
		// Navigator 4
		elm = document.layers[id];
	}
	return elm;
}


// set the value of a group
function SetGroupValue(group, value)
{
	var ControlList = Controls.split('|');
	var Control;
	for(i = 0; i < ControlList.length-1; i++)
	{
		Control = ControlList[i].split('/');
		if(Control[0] == group)
		{
			GetElement(Control[1]).value = value;
		}
	}
}

function OpenNewWindowContactMe(url)
{
	var popUpWindow = window.open(url,null,'height=400,width=550,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes'); 
	popUpWindow.focus();
}

function OpenNewWindow(url)
{
	var popUpWindow = window.open(url,null,'height=300,width=600,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes'); 
	popUpWindow.focus();
}

function OpenNewWindowForPrint(url,windowName)
{
	var popUpWindow = window.open(url,windowName,'height=500,width=800,status=no,toolbar=yes,menubar=yes,location=no,scrollbars=yes,resizable=yes'); 
	popUpWindow.focus();
}

function OpenNewWindow(url, windowName, windowDetails)
{
	var popUpWindow = window.open(url,windowName,windowDetails); 
	popUpWindow.focus();
	
}

function OpenNewPopupWindow(url,windowDetails)
{
	var popUpWindow = window.showModalDialog(url,windowDetails); 
	popUpWindow.focus();
	
}
function OpenNewPropertyWindow(url,windowname)
{
	window.open(url,windowname,'height=600,width=600,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,left=100,screenX=200');
}

function OpenNewMapthisPropertyWindow(url,windowname)
{
	window.open(url,windowname,'height=600,width=700,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,left=100,screenX=200');
}

function OpenNewEmailWindow(url,windowname)
{
	window.open(url,windowname,'height=450,width=550,status=yes,toolbar=no,menubar=no,location=no,scrollbars=no');
}
	
function OpenFavouritesWindow(url,windowname,showwindow)
{
	if(showwindow=='True')
	{
		window.open(url,windowname,'width=525,height=230,left=500,top=250');
		//return true;
	}
	else
	{
		if(confirm('This functionality is limited to registered users.  Would you like to register for your free \"My Long & Foster\" account now?' ))
		{
			newWindow=window.location='../../Register.aspx';
		}
	}
	
}

/*function comparePassword(sender,args)
{
	if(document.getElementById("UserRegistration1_txtPassword").value != document.getElementById("UserRegistration1_txtPasswordConfirm").value)
	{
		args.IsValid = false;
		return;
	}	
	return true;
}*/

function OpenPage(url)
{
	document.location.href=url;
}

function checkNumber(sender,args)
{
	var ValidChars = "0123456789.";
	var Char;

	if (isNaN(args.Value))
	{
		args.IsValid = false;
		return;
	}
	else
	{
		return true;
	}
}

function ButtonClose()
{
	window.close();
}

/*function SalesAssociate()
{
	if(document.all("ContactOffice1_rbtSalesAssociate_0").checked)
	{		
		document.all("ContactOffice1_txtAssociateName").disabled = false;					
	}
	else
	{
		document.all("ContactOffice1_txtAssociateName").disabled = true;
	}
}*/

function Open_NewWindow(url,windownumber,windowname)
{
	switch (windownumber) 
	{
		case 1: 
			var newwindow=window.open(url,windowname,'height=700,width=600,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,left=100,screenX=200');
			newwindow.focus();
		break
		case 2: 
			var newwindow1=window.open(url,windowname);
			newwindow1.focus();
		break
	}
}

function closeWindow()
{
	window.close();
	
}

function setFocus()
{ 
	window.focus();
}

function loadChildorParent(url, closeSelf)
{
	window.opener.location.href = url;
	if(closeSelf)
	{
	self.close();
	}
}

function loadChildorParent(url)
{
	document.location.href = url;
}
		
	function ValidMapSearchEntries(sender,args)
	{
		if (MinMaxValidate2() == false)
			return false;
		
		if (ValidatePriceRange2() == false)
			return false;

		if (RequiredMinMax2() == false)
			return false;
			
		if (ValidatePropertyTypes2() == false)
			return false;	

		return true;						
	}
	

	function ValidatePriceRange(sender,args)
	{ 
		var priceErrorMessage="";
		if(document.getElementById(sender.controltovalidate).selectedIndex==0 || 
		document.getElementById(sender.controltovalidate).selectedIndex==0)
		{
			priceErrorMessage= "You must select low and high Sale/Rent price";
		}

		if (priceErrorMessage!="")
		{
			//document.getElementById("UCPowerSearch1_custMinMax").style.visibility = "hidden";		
			args.IsValid = false;
			return;
		}
		else
		{
			return true;
		}		
	}

// TODO - make this function generic
	function ValidatePriceRange2(sender,args)
	{ 
		var priceErrorMessage="";
		if(document.getElementById("UCSearchByMap1_MinPrice").selectedIndex==0 ||
		 document.getElementById("UCSearchByMap1_MaxPrice").selectedIndex==0)
		{
			priceErrorMessage= "You must select low and high Sale/Rent price";
		}

		if (priceErrorMessage!="")
		{
			args.IsValid = false;
			return;
		}
		else
		{
			return true;
		}		
	}
	
// TODO - make this function generic
	function RequiredMinMax2(sender,args)
	{
		var min, max;
		min = document.getElementById("UCSearchByMap1_MinPrice").options[document.getElementById("UCSearchByMap1_MinPrice").selectedIndex].value;
		max = document.getElementById("UCSearchByMap1_MaxPrice").options[document.getElementById("UCSearchByMap1_MaxPrice").selectedIndex].value;
		if(parseInt(min)>parseInt(max))
		{
			args.IsValid = false;
			return;
		}
	}
	
	function ValidatePropertyTypes2(sender,args)
	{ 
		var propertyErrorMessage="";
		var selected=0;
		if(document.getElementById("UCSearchByMap1_SingleFamilyHome").checked==true)
		{
			selected += 1;
		}
		if(document.getElementById("UCSearchByMap1_TownHouse").checked==true)
		{
			selected += 1;
		}
		if(document.getElementById("UCSearchByMap1_MultiFamily").checked==true)
		{
			selected += 1;
		}
		if(document.getElementById("UCSearchByMap1_CommercialProperty").checked==true)
		{
			selected += 1;
		}
		if(document.getElementById("UCSearchByMap1_OtherLandFarms").checked==true)
		{
			selected += 1;
		}
		
		if(selected == 0 )
		{
			propertyErrorMessage = "You must select atleast one Property Type.";
		}
		//return propertyErrorMessage;
		if (propertyErrorMessage!="")
		{
			//document.getElementById("UCPowerSearch1_custMinMax").style.visibility = "hidden";		
			args.IsValid = false;
			return;
		}
		else
		{
			return true;
		}				
	}
// Copied from SearchResult.aspx

			
function openWindow(coId,mlsNumber)
{
	var saveFav;					
	saveFav = "SaveFavorite.aspx?CoId=" + coId + "&MlsNumber=" + mlsNumber;
	window.open(saveFav,"SaveFavorite","width=350,height=300,left=500,top=300");
}

function SetPrintPreview(page,pageNo,recordsPerPage)
{
	var url;
	var settings;
	var windowName;
	if (page != "")
		windowName = page.replace(".","");
	//url = "SearchResultsPrint.aspx?PageNo=" + pageNo + "&RecordsPerPage=" + recordsPerPage;
	if (pageNo>=0 && recordsPerPage >=0)
	{
		url = page + "?PageNo=" + pageNo + "&RecordsPerPage=" + recordsPerPage;
		settings="";
		window.open(url,windowName,settings);
	}
}

function OpenSaveFavorite(page,coId,mlsNumber)
{
	var url;
	var settings;
	var windowName;
	if (page != "")
		windowName = page.replace(".","");
	//url = "SearchResultsPrint.aspx?PageNo=" + pageNo + "&RecordsPerPage=" + recordsPerPage;
	if (coId>0 && mlsNumber != "")
	{
		url = page + "?CoId=" + coId + "&MlsNumber=" + mlsNumber;					
	}
	else
	{
		url = page;					
	}	
	settings = "width=525,height=230,left=500,top=250";
	window.open(url,windowName,settings);
}



function InvalidUser()
{
	if (confirm('This functionality is limited to registered users. Would you like to register for your free "My Long & Foster" Account?') == true)
	{
		window.location.href="Register.aspx";
		window.focus();
	}
}

function OpenContactMeNow(page,mlsNumber,listingAgentNo)
{
	var url;
	var settings;
	var windowName;
	if (page != "")
		windowName = page.replace(".","");
	//url = "SearchResultsPrint.aspx?PageNo=" + pageNo + "&RecordsPerPage=" + recordsPerPage;
	if (mlsNumber != "")
	{
	//	url = page + "?MLSNumber=" + mlsNumber + "&ListingAgentNo=" + listingAgentNo;
	    url = page + "?MLSNumber=" + mlsNumber ;
		settings = "width=530,height=600,left=360,top=100,scrollbars=yes";
	}
	else
	{
		url = page;
		settings = "width=350,height=300,left=500,top=250";
	}	
	window.open(url,windowName,settings);
}

function OpenMakeAnInquiry(page,mlsNumber,addr)
{
	var url;
	var settings;
	var windowName;
	if (page != "")
		windowName = page.replace(".","");
	if (mlsNumber != "")
	{
		url = page + "?MLSNumber=" + mlsNumber + "&StreetAddress=" + addr;
		settings = "width=550,height=700,left=360,top=100,scrollbars=yes,status=yes";
	}
	window.open(url,windowName,settings);
}

function OpenMapIt(page,coId,mlsNumber)
{
	var url;
	var settings;
	var windowName;
	if (page != "")
		windowName = mlsNumber + 'Map';
		
	if (coId>0 && mlsNumber != "")
	{
		url = page + "?MlsCompanyID=" + coId + "&MlsNumber=" + mlsNumber;					
	}
	else
	{
		url = page;					
	}	
	settings = "height=600,width=700,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,left=100,screenX=200"; //"width=350,height=400,left=500,top=250";
	window.open(url,windowName,settings);
}

function OpenScheduleShowing(page,coId,mlsNumber)
{
	var url;
	var settings;
	var windowName;
	if (page != "")
		windowName = mlsNumber + 'Sch';
	if (coId>0 && mlsNumber != "")
	{
		url = page + "?coId=" + coId + "&mlsNum=" + mlsNumber;					
	}
	else
	{
		url = page;					
	}	
	settings = "width=550,height=900,left=500,top=30,scrollbars=yes";
	window.open(url,windowName,settings);
}


// Copied from Powersearch.aspx
function OpenWindow(showWindow)
{
	if (showWindow=='True')
	{ 	
		//win_01 = window.showModelessDialog("InputSearchName.aspx","dialogHeight:250;dialogWidth:250;center:Yes;help:No;resizable:No;status:No;")
		win_01 = window.open("InputSearchName.aspx","InputSearchName1","height=246,width=530")
		return true;
	}
	else
	{
		if (confirm('This functionality is limited to registered users. Would you like to register for your free "My Long & Foster" Account?') == true)
		{
			window.location.href="Register.aspx";				
		}
		return false;
	}
	//return true;
}

function isUndefined(a) 
{
	return typeof a == 'undefined';
} 

//function showHelpWindow()
//{
//	var objWindow;
//	objWindow = window.open("LnFPriceRangeHelp.aspx","PriceHelpWindow","width=500,height=250,left=500,top=200");
//}

//Will be called from the login control 
function Signout()
{
	document.location.href = "Default.aspx?signout=true";
}

//Fires the submit button click event of Login control if pressed 'Enter' key in 
//any one of the text boxes in Login control 
function handleEnter(button,field, event) 
{
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    if (keyCode == 13) 
    {
		if (field.id == 'QuickSearch1_Zip' && field.value == '')
		{
			field.value = defaultZipText;
		}		
		if(navigator.appName.indexOf("Netscape")>(-1))
		{
			var bt = document.getElementById(button); 
			bt.click();		
		}
		else
		{
			document.all(button).focus();	
		}
    } 
}

//Function to Disable the controls in Preview Welcome Page.
function DisableNavigation()
{
    for (i = 0; i < document.links.length; i++)
    {
		document.links[i].onclick = function(){window.status=""; return false;}
		document.links[i].onmouseover = function(){window.status="";}
		document.links[i].onmousemove = function(){window.status="";}
		document.links[i].oncontextmenu = function(){return false;}
    }
    
    //This function is written within quicksearch user control
    //22-01-2008
    DisableQuickSearchControl();
}

// Function to Trim Empty space
function trimSpace(obj)
{
	var txtLength;
	var txtValue;
	var txtFinalValue;
	txtValue = document.all[obj].value;
	if(txtValue != "")
	{
		txtLength = txtValue.length;
		txtFinalValue = "";
		for (i = 0; i < txtLength; i++) 
		{
			if (txtValue.charAt(i) != " ")
			{
				txtFinalValue = txtFinalValue + txtValue.charAt(i);
			}	
		}
		document.all[obj].value = txtFinalValue;	
	}

	//alert(txtFinalValue);
}

function trimQSZipSpace(obj)
{
	var txtLength;
	var txtValue;
	var txtFinalValue;
	txtValue = document.all[obj].value;
	if(txtValue != "" && txtValue.length > 5 && txtValue != "Zip, Zip, Zip,...")
	{
		txtLength = txtValue.length;
		txtFinalValue = "";
		for (i = 0; i < txtLength; i++) 
		{
			if (txtValue.charAt(i) != " ")
			{
				txtFinalValue = txtFinalValue + txtValue.charAt(i);
			}	
		}
		document.all[obj].value = txtFinalValue;	
	}
}

//Open REIN property details page while doing Listing Number Search
function OpenNewReinWindow(windowUrl)
{
	window.open(windowUrl);
}

function Trim(obj)
{
	var result;
	TRIM_VALUE = document.all[obj].value;
	if(TRIM_VALUE.length < 1){
		result = "";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		result = "";
	}
	else{
		result = TRIM_VALUE;
	}
	
	document.all[obj].value = result;
} //End Function

function RTrim(VALUE)	
{
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} //End While
	return strTemp;

} //End Function

function LTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function

function ValidatePhone(PhoneNo)
{
	var re = /^((\(\d{3}\)\s?)|(\d{3}[\-?|\.?|\s?]?))\d{3}[\-?|\.?|\s?]?\d{4}$/; 
				
	if(!re.test(PhoneNo)) 
	{
		return false;		
	}
	
	var splitHypPhoneNo = PhoneNo.split("-");
	var splitDotPhoneNo = PhoneNo.split(".");
	
    if(splitHypPhoneNo.length == 2 && splitDotPhoneNo.length == 2)
	{	
		return false;		
	}	
	
	if(splitHypPhoneNo.length == 2 && splitDotPhoneNo.length == 1)		
	{	
		if(PhoneNo.indexOf('(') == -1 && PhoneNo.indexOf(')')== -1 )
		{
			return false;				
		}
	}
	if(splitHypPhoneNo.length == 1 && splitDotPhoneNo.length == 2)
	{	
		if(PhoneNo.indexOf('(') == -1 && PhoneNo.indexOf(')')== -1 )
		{
			return false;				
		}
	}
	return true;		 
}


function ValidateZip(zip)
{
	var re = /(\d{5}(-\d{4})?)/;
	var zip = document.getElementById(zip).value;
	if(zip != '' && !re.test(zip)) 
	{
		return false;		
	}
	return true;
}

function SetImageHeightWidth(controlHeight,controlWidth,picHeight,picWidth,controlName)
{
	if(document.getElementById(controlName) != null)
	{
		var leastValue;
		var height = (controlHeight/picHeight);
		var width = (controlWidth/picWidth);

		if(height < width)
		{
			leastValue = height;
		}
		else
		{
			leastValue = width;
		}

		document.getElementById(controlName).width = leastValue * picWidth;
		document.getElementById(controlName).height = leastValue * picHeight;
	}
	
}

// Code to display a random animated gif for the affiliated businesses
var affAdImages = new Array(4);
//affAdImages[0] = "themes/images/ad_01.gif";
//affAdImages[1] = "themes/images/ad_02.gif";
//affAdImages[2] = "themes/images/ad_03.gif";
//affAdImages[3] = "themes/images/ad_04.gif";
affAdImages[0] = "/TheSystemSharedUserControls/Themes/AWS/images/ad_05_HomeServiceConn_animate.gif";
affAdImages[1] = "/TheSystemSharedUserControls/Themes/AWS/images/ad_06_ProsperityMortgage_animate.gif";
affAdImages[2] = "/TheSystemSharedUserControls/Themes/AWS/images/ad_07_LFI_animate.gif";
affAdImages[3] = "/TheSystemSharedUserControls/Themes/AWS/images/ad_08_PresitgePartners_animate.gif";

var affAdLink = new Array(4);
affAdLink[0] = "Real-Estate-Services.aspx#HSC";
affAdLink[1] = "Real-Estate-Services.aspx#Mortgage";
affAdLink[2] = "Real-Estate-Services.aspx#Insurance";
affAdLink[3] = "Real-Estate-Services.aspx#Settlement";

var affOfficeAdLink = new Array(4);
affOfficeAdLink[0] = "LongAndFosterServices.aspx#HSC";
affOfficeAdLink[1] = "LongAndFosterServices.aspx#Mortgage";
affOfficeAdLink[2] = "LongAndFosterServices.aspx#Insurance";
affOfficeAdLink[3] = "LongAndFosterServices.aspx#Settlement";

var randomIndex = 0;
randomIndex = Math.floor(Math.random() * affAdImages.length);

function setRandomAffAdGif(imgCtrl, anchorLink) {
	imgCtrl.src = affAdImages[randomIndex];
	anchorLink.href = affAdLink[randomIndex];
}

function setRandomAffAdGif2(imgCtrl, anchorLink) {
	var randomIndex2 = randomIndex + 1;
	if (randomIndex2 >= affAdImages.length) {
		randomIndex2 = randomIndex2 - 2;
	}
	imgCtrl.src = affAdImages[randomIndex2];
	anchorLink.href = affAdLink[randomIndex2];

}
// Function for Displaying Random Gif images for Office

function setOfficeRandomAffAdGif(imgCtrl, anchorLink) {
	imgCtrl.src = affAdImages[randomIndex];	
	anchorLink.href = affOfficeAdLink[randomIndex];
}

function setOfficeRandomAffAdGif2(imgCtrl, anchorLink) {
	var randomIndex2 = randomIndex + 1;
	if (randomIndex2 >= affAdImages.length) {
		randomIndex2 = randomIndex2 - 2;
	}
	imgCtrl.src = affAdImages[randomIndex2];	
	anchorLink.href = affOfficeAdLink[randomIndex2];
}


function TrimInputValue(inputValue)
{
	var result;
	//TRIM_VALUE = document.all[obj].value;
	TRIM_VALUE = inputValue;
	if(TRIM_VALUE.length < 1){
		result = "";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		result = "";
	}
	else{
		result = TRIM_VALUE;
	}
	
	//document.all[obj].value = result;
	return result;
} //End Function


function IsNumeric(strString)
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
   
// End - Code to display a random animated gif for the affiliated businesses

/*
	Start of JS to make menu items visible & hide in Office site.
*/

var hideIn = 800; // milliseconds
var timerId;
var level1Showing=null;

function level1Show(objectName){
	
	level1Hide(level1Showing);
	if (timerId){
		window.clearTimeout(timerId);
	}	
	
	var item=document.getElementById(objectName);
	
	for(i=0; i<item.childNodes.length; i++){
		var child=item.childNodes[i];
		if(child.tagName==null || child.tagName.toLowerCase()!="ul"){
			continue;
		}
			
		child.className="level2";	
	}
	level1Showing=objectName;
	
	// timer
	//collapseMenu(objectName);

}


function level1Hide(objectName){
	if(objectName==null){
		return;
	}
	var item = document.getElementById(objectName);
		
	for(i=0; i<item.childNodes.length; i++){
		var child=item.childNodes[i];
		if(child.tagName==null || child.tagName.toLowerCase()!="ul"){
			continue;
		}
			
		child.className="level2Hidden";		
	}
	
	if(level1Showing=objectName){
		level1Showing=null;
	}
	
	//timer = null;
}

/*
	End of JS to make menu items visible & hide in Office site.
*/



    function KeyDownHandler(btn)
    {
		 var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
        // process only the Enter key
        if (keyCode == 13)
        {
			if(navigator.appName.indexOf("Netscape")>(-1))
			{
				var bt = document.getElementById(btn); 
				bt.click();		
			}
			else
			{
				document.all(btn).focus();	
			}            
        }
    }


function ShowBigImage(imageId,imgSrc)
{
    imgSrc=imgSrc.replace('size=1','size=2');
    var img = -40;
    var bg1 = -70;
    var bg2 = -60;
    var imgt=imageId.replace('img','imgt');
    var imgb=imageId.replace('img','imgb');    
    if(window.pageYOffset)
    {
        coordY=coordY-window.pageYOffset;
    }
    if(coordY<60)
    {
        img = img + coordY + 20;
        bg1 = bg1 + coordY + 20;
        bg2 = bg2 + coordY + 20;
        document.getElementById(imageId).style.marginTop = img + 'px';
        document.getElementById(imgt).style.marginTop = bg1 + 'px';
        document.getElementById(imgb).style.marginTop = bg2 + 'px';
    }
    if(coordY>350)
    { 
        img = img - (coordY-350) + 10;
        bg1 = bg1 - (coordY-350) + 10;
        bg2 = bg2 - (coordY-350) + 10;        
        document.getElementById(imageId).style.marginTop = img + 'px';
        document.getElementById(imgt).style.marginTop = bg1 + 'px';
        document.getElementById(imgb).style.marginTop = bg2 + 'px'; 
    }    
    document.getElementById(imageId).setAttribute('src',imgSrc); 
    var layer = document.getElementById(imgt);     
    document.getElementById(imgt).style.visibility ='visible';
    document.getElementById(imgb).style.visibility ='visible';
    document.getElementById(imageId).style.visibility ='visible';
    var ht=document.getElementById(imageId).height;
    if(ht>210)
    {
        document.getElementById(imageId).height=200;
    }
}

function HideImage(imageId)
{
    var browserName = navigator.appName;
    var imgt=imageId.replace('img','imgt');
    var imgb=imageId.replace('img','imgb');
    document.getElementById(imgt).style.visibility='hidden';
    document.getElementById(imgb).style.visibility='hidden';
    document.getElementById(imageId).style.visibility='hidden';
    document.getElementById(imageId).style.marginTop ='-40px';
    document.getElementById(imgt).style.marginTop ='-70px';
    document.getElementById(imgb).style.marginTop ='-60px';    
}

// correctly handle PNG transparency in Win IE 5.5 or higher.
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
function fixPNG(myImage) 
{
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
       myImage.outerHTML = strNewHTML	  
    }
}
//sIFR font for header
/*	sIFR 2.0.1
	Copyright 2004 - 2005 Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben
	This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/
var hasFlash=function(){var a=6;if(navigator.appVersion.indexOf("MSIE")!=-1&&navigator.appVersion.indexOf("Windows")>-1){document.write('<script language="VBScript"\> \non error resume next \nhasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & '+a+'))) \n</script\> \n');if(window.hasFlash!=null)return window.hasFlash}if(navigator.mimeTypes&&navigator.mimeTypes["application/x-shockwave-flash"]&&navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){var b=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;return parseInt(b.charAt(b.indexOf(".")-1))>=a}return false}();String.prototype.normalize=function(){return this.replace(/\s+/g," ")};if(Array.prototype.push==null){Array.prototype.push=function(){var i=0,a=this.length,b=arguments.length;while(i<b){this[a++]=arguments[i++]}return this.length}}if(!Function.prototype.apply){Function.prototype.apply=function(a,b){var c=[];var d,e;if(!a)a=window;if(!b)b=[];for(var i=0;i<b.length;i++){c[i]="b["+i+"]"}e="a.__applyTemp__("+c.join(",")+");";a.__applyTemp__=this;d=eval(e);a.__applyTemp__=null;return d}}function named(a){return new named.Arguments(a)}named.Arguments=function(a){this.oArgs=a};named.Arguments.prototype.constructor=named.Arguments;named.extract=function(a,b){var c,d;var i=a.length;while(i--){d=a[i];if(d!=null&&d.constructor!=null&&d.constructor==named.Arguments){c=a[i].oArgs;break}}if(c==null)return;for(e in c)if(b[e]!=null)b[e](c[e]);return};var parseSelector=function(){var a=/^([^#.>`]*)(#|\.|\>|\`)(.+)$/;function r(s,t){var u=s.split(/\s*\,\s*/);var v=[];for(var i=0;i<u.length;i++)v=v.concat(b(u[i],t));return v}function b(c,d,e){c=c.normalize().replace(" ","`");var f=c.match(a);var g,h,i,j,k,n;var l=[];if(f==null)f=[c,c];if(f[1]=="")f[1]="*";if(e==null)e="`";if(d==null)d=document;switch(f[2]){case "#":k=f[3].match(a);if(k==null)k=[null,f[3]];g=document.getElementById(k[1]);if(g==null||(f[1]!="*"&&!o(g,f[1])))return l;if(k.length==2){l.push(g);return l}return b(k[3],g,k[2]);case ".":if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;k=f[3].match(a);if(k!=null){if(g.className==null||g.className.match("\\b"+k[1]+"\\b")==null)continue;j=b(k[3],g,k[2]);l=l.concat(j)}else if(g.className!=null&&g.className.match("\\b"+f[3]+"\\b")!=null)l.push(g)}return l;case ">":if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;if(!o(g,f[1]))continue;j=b(f[3],g,">");l=l.concat(j)}return l;case "`":h=m(d,f[1]);for(i=0,n=h.length;i<n;i++){g=h[i];j=b(f[3],g,"`");l=l.concat(j)}return l;default:if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;if(!o(g,f[1]))continue;l.push(g)}return l}}function m(d,o){if(o=="*"&&d.all!=null)return d.all;return d.getElementsByTagName(o)}function o(p,q){return q=="*"?true:p.nodeName.toLowerCase().replace("html:", "")==q.toLowerCase()}return r}();var sIFR=function(){var a="http://www.w3.org/1999/xhtml";var b=false;var c=false;var d;var ah=[];var al=document;var ak=al.documentElement;var am=window;var au=al.addEventListener;var av=am.addEventListener;var f=function(){var g=navigator.userAgent.toLowerCase();var f={a:g.indexOf("applewebkit")>-1,b:g.indexOf("safari")>-1,c:navigator.product!=null&&navigator.product.toLowerCase().indexOf("konqueror")>-1,d:g.indexOf("opera")>-1,e:al.contentType!=null&&al.contentType.indexOf("xml")>-1,f:true,g:true,h:null,i:null,j:null,k:null};f.l=f.a||f.c;f.m=!f.a&&navigator.product!=null&&navigator.product.toLowerCase()=="gecko";if(f.m)f.j=new Number(g.match(/.*gecko\/(\d{8}).*/)[1]);f.n=g.indexOf("msie")>-1&&!f.d&&!f.l&&!f.m;f.o=f.n&&g.match(/.*mac.*/)!=null;if(f.d)f.i=new Number(g.match(/.*opera(\s|\/)(\d+\.\d+)/)[2]);if(f.n||(f.d&&f.i<7.6))f.g=false;if(f.a)f.k=new Number(g.match(/.*applewebkit\/(\d+).*/)[1]);if(am.hasFlash&&(!f.n||f.o)){var aj=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;f.h=parseInt(aj.charAt(aj.indexOf(".")-1))}if(g.match(/.*(windows|mac).*/)==null||f.o||f.c||(f.d&&(g.match(/.*mac.*/)!=null||f.i<7.6))||(f.b&&f.h<7)||(!f.b&&f.a&&f.k<124)||(f.m&&f.j<20020523))f.f=false;if(!f.o&&!f.m&&al.createElementNS)try{al.createElementNS(a,"i").innerHTML=""}catch(e){f.e=true}f.p=f.c||(f.a&&f.k<312)||f.n;return f}();function at(){return{bIsWebKit:f.a,bIsSafari:f.b,bIsKonq:f.c,bIsOpera:f.d,bIsXML:f.e,bHasTransparencySupport:f.f,bUseDOM:f.g,nFlashVersion:f.h,nOperaVersion:f.i,nGeckoBuildDate:f.j,nWebKitVersion:f.k,bIsKHTML:f.l,bIsGecko:f.m,bIsIE:f.n,bIsIEMac:f.o,bUseInnerHTMLHack:f.p}}if(am.hasFlash==false||!al.getElementsByTagName||!al.getElementById||(f.e&&f.p))return{UA:at()};function af(e){if((!k.bAutoInit&&(am.event||e)!=null)||!l(e))return;b=true;for(var i=0,h=ah.length;i<h;i++)j.apply(null,ah[i]);ah=[]}var k=af;function l(e){if(c==false||k.bIsDisabled==true||((f.e&&f.m||f.l)&&e==null&&b==false)||(al.body==null||al.getElementsByTagName("body").length==0))return false;return true}function m(n){if(f.n)return n.replace(new RegExp("%\d{0}","g"),"%25");return n.replace(new RegExp("%(?!\d)","g"),"%25")}function as(p,q){return q=="*"?true:p.nodeName.toLowerCase().replace("html:", "")==q.toLowerCase()}function o(p,q,r,s,t){var u="";var v=p.firstChild;var w,x,y,z;if(s==null)s=0;if(t==null)t="";while(v){if(v.nodeType==3){z=v.nodeValue.replace("<","&lt;");switch(r){case "lower":u+=z.toLowerCase();break;case "upper":u+=z.toUpperCase();break;default:u+=z}}else if(v.nodeType==1){if(as(v,"a")&&!v.getAttribute("href")==false){if(v.getAttribute("target"))t+="&sifr_url_"+s+"_target="+v.getAttribute("target");t+="&sifr_url_"+s+"="+m(v.getAttribute("href")).replace(/&/g,"%26");u+='<a href="asfunction:_root.launchURL,'+s+'">';s++}else if(as(v,"br"))u+="<br/>";if(v.hasChildNodes()){y=o(v,null,r,s,t);u+=y.u;s=y.s;t=y.t}if(as(v,"a"))u+="</a>"}w=v;v=v.nextSibling;if(q!=null){x=w.parentNode.removeChild(w);q.appendChild(x)}}return{"u":u,"s":s,"t":t}}function A(B){if(al.createElementNS&&f.g)return al.createElementNS(a,B);return al.createElement(B)}function C(D,E,z){var p=A("param");p.setAttribute("name",E);p.setAttribute("value",z);D.appendChild(p)}function F(p,G){var H=p.className;if(H==null)H=G;else H=H.normalize()+(H==""?"":" ")+G;p.className=H}function aq(ar){var a=ak;if(k.bHideBrowserText==false)a=al.getElementsByTagName("body")[0];if((k.bHideBrowserText==false||ar)&&a)if(a.className==null||a.className.match(/\bsIFR\-hasFlash\b/)==null)F(a, "sIFR-hasFlash")}function j(I,J,K,L,M,N,O,P,Q,R,S,r,T){if(!l())return ah.push(arguments);aq();named.extract(arguments,{sSelector:function(ap){I=ap},sFlashSrc:function(ap){J=ap},sColor:function(ap){K=ap},sLinkColor:function(ap){L=ap},sHoverColor:function(ap){M=ap},sBgColor:function(ap){N=ap},nPaddingTop:function(ap){O=ap},nPaddingRight:function(ap){P=ap},nPaddingBottom:function(ap){Q=ap},nPaddingLeft:function(ap){R=ap},sFlashVars:function(ap){S=ap},sCase:function(ap){r=ap},sWmode:function(ap){T=ap}});var U=parseSelector(I);if(U.length==0)return false;if(S!=null)S="&"+S.normalize();else S="";if(K!=null)S+="&textcolor="+K;if(M!=null)S+="&hovercolor="+M;if(M!=null||L!=null)S+="&linkcolor="+(L||K);if(O==null)O=0;if(P==null)P=0;if(Q==null)Q=0;if(R==null)R=0;if(N==null)N="#FFFFFF";if(T=="transparent")if(!f.f)T="opaque";else N="transparent";if(T==null)T="";var p,V,W,X,Y,Z,aa,ab,ac;var ad=null;for(var i=0,h=U.length;i<h;i++){p=U[i];if(p.className!=null&&p.className.match(/\bsIFR\-replaced\b/)!=null)continue;V=p.offsetWidth-R-P;W=p.offsetHeight-O-Q;aa=A("span");aa.className="sIFR-alternate";ac=o(p,aa,r);Z="txt="+m(ac.u).replace(/\+/g,"%2B").replace(/&/g,"%26").replace(/\"/g, "%22").normalize() + S + "&w=" + V + "&h=" + W + ac.t;F(p,"sIFR-replaced");if(ad==null||!f.g){if(!f.g)p.innerHTML=['<embed class="sIFR-flash" type="application/x-shockwave-flash" src="',J,'" quality="best" wmode="',T,'" bgcolor="',N,'" flashvars="',Z,'" width="',V,'" height="',W,'" sifr="true"></embed>'].join("");else{if(f.d){ab=A("object");ab.setAttribute("data",J);C(ab,"quality","best");C(ab,"wmode",T);C(ab,"bgcolor",N)}else{ab=A("embed");ab.setAttribute("src",J);ab.setAttribute("quality","best");ab.setAttribute("flashvars",Z);ab.setAttribute("wmode",T);ab.setAttribute("bgcolor",N)}ab.setAttribute("sifr","true");ab.setAttribute("type","application/x-shockwave-flash");ab.className="sIFR-flash";if(!f.l||!f.e)ad=ab.cloneNode(true)}}else ab=ad.cloneNode(true);if(f.g){if(f.d)C(ab,"flashvars",Z);else ab.setAttribute("flashvars",Z);ab.setAttribute("width",V);ab.setAttribute("height",W);ab.style.width=V+"px";ab.style.height=W+"px";p.appendChild(ab)}p.appendChild(aa);if(f.p)p.innerHTML+=""}if(f.n&&k.bFixFragIdBug)setTimeout(function(){al.title=d},0)}function ai(){d=al.title}function ae(){if(k.bIsDisabled==true)return;c=true;if(k.bHideBrowserText)aq(true);if(am.attachEvent)am.attachEvent("onload",af);else if(!f.c&&(al.addEventListener||am.addEventListener)){if(f.a&&f.k>=132&&am.addEventListener)am.addEventListener("load",function(){setTimeout("sIFR({})",1)},false);else{if(al.addEventListener)al.addEventListener("load",af,false);if(am.addEventListener)am.addEventListener("load",af,false)}}else if(typeof am.onload=="function"){var ag=am.onload;am.onload=function(){ag();af()}}else am.onload=af;if(!f.n||am.location.hash=="")k.bFixFragIdBug=false;else ai()}k.UA=at();k.bAutoInit=true;k.bFixFragIdBug=true;k.replaceElement=j;k.updateDocumentTitle=ai;k.appendToClassName=F;k.setup=ae;k.debug=function(){aq(true)};k.debug.replaceNow=function(){ae();k()};k.bIsDisabled=false;k.bHideBrowserText=true;return k}();

if(typeof sIFR == "function" && !sIFR.UA.bIsIEMac){
	sIFR.setup();
};

//Function to autotab telephone fields		
function autoTab(input,len) 
{
	if(input.value.length >= len) 
	{
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}
	function getIndex(input) 
	{
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
			if (input.form[i] == input)
				index = i;
			else
				i++; 
			return index;
	}
}


function EnableErrorDiv(divID, iFrameID, divCustomErrorMsg)
{    
     if (Page_IsValid && Custom_Page_IsValid) 
     {	    
        var iframe = document.getElementById(iFrameID);
        iframe.style.display = 'none';
        iframe.style.visibility = 'hidden';
        
        document.getElementById(divID).style.visibility = 'hidden';
        document.getElementById(divID).style.display = 'none'; 
               
     }else{	              
        
        document.getElementById(divID).style.visibility = 'visible';
        document.getElementById(divID).style.display = 'block';
        
        var iframe = document.getElementById(iFrameID);
        var layer = document.getElementById(divID);
        iframe.style.display = 'block';
        iframe.style.visibility = 'visible';
        iframe.style.width = layer.offsetWidth;
        iframe.style.height = layer.offsetHeight;
        iframe.style.left = layer.offsetLeft;
        iframe.style.top = layer.offsetTop;
      
        Custom_Page_IsValid = 'true';
     }
     
     if (!Page_IsValid) 
     {
        var obj = document.getElementById(divCustomErrorMsg);
        obj.style.visibility = 'hidden';
     }
     else if (!Custom_Page_IsValid)
     {
         var obj = document.getElementById('divCustomErrorMsg');
         obj.style.visibility = 'visible';
     }
}


function HideDiv(divID, iFrameID)
{
    var iframe = document.getElementById(iFrameID);
    iframe.style.display = 'none';
    iframe.style.visibility = 'hidden';
    
	document.getElementById(divID).style.display = "none";
	document.getElementById(divID).style.visibility = 'hidden';	
}

function ShowLength(commenttxtBoxId, lengthTextId)
{ 
    var strValue = document.getElementById(commenttxtBoxId).value;    
    var charLeft = 250-strValue.length;
    if(strValue.length > 250)
    {        
        document.getElementById(commenttxtBoxId).value = strValue.substring(0,250);
        charLeft = 0;     
    }   
    document.getElementById(lengthTextId).innerHTML = charLeft;
}
