
				/*****************Constants******************/
	var sDefaultColor = "#ECF2F9";
	var sDefaultFont  = '10px';
	var sDefaultHeight = '136px';
	var sDefaultWidth = '392px';
	var sSelectColor = "WHITE"
	var sSelectFont = '12px'
				/*****************Constants******************/

    var xmlHttp; 
    var oCtrl = null;			//Control name to fill data
    var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0; 
    var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0; 
    var is_opera = ((navigator.userAgent.indexOf("Opera6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0; 
    //netscape, safari, mozilla behave the same??? 
    var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0; 

    function show_data(requestURL, sMethod, sCtrlName){ 
        if (sMethod.length > 0){ 
            //Append the name to search for to the requestURL
           // if requestURL="http://localhost/CapitalPacificHomes/homesearchwizardresults.aspx?sState=TX&CommunityCityID=17&min#ofbedrooms=0&homepricerangeid=price%20range&sValue=TX&amp;sMethodName="             
           // {
			//	requestURL=requestURL.replace("?","&")
           // }
            var url = requestURL + sMethod; 
            oCtrl = sCtrlName;            
            //Create the xmlHttp object to use in the request 
            //stateChangeHandler will fire when the state has changed, i.e. data is received back 
            // This is non-blocking (asynchronous) 
            xmlHttp = GetXmlHttpObject(stateChangeHandler); 
             
            //Send the xmlHttp get to the specified url 
            xmlHttp_Get(xmlHttp, url); 
        } 
        else { 
            //Textbox blanked out, clear the results              
            document.getElementById(sCtrlName).innerHTML = '';             
        } 
    } 

    //stateChangeHandler will fire when the state has changed, i.e. data is received back 
    // This is non-blocking (asynchronous) 
    function stateChangeHandler() 
    { 
		document.body.style.cursor = "wait";
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
		{ 				
			FillRecords(oCtrl)
			document.body.style.cursor = "default";
		} 
    } 
	
	function FillRecords(sCtrlName)
	{		
		try
		{			
			//Gather the results from the callback 
			var str = new String;
			str = xmlHttp.responseText; 
						
			window.status = '';
			//Detecting error message from server side
			var oElem = document.getElementById(sCtrlName);
			
			if (str == null || str == "")
			{
				if (oElem.type == undefined && oElem.tagName == "DIV")
					SetDivStyle(sCtrlName, true);
				oElem.innerHTML = "";
				return;
			}			
			
			if (str.substring(0, 6).toLowerCase()  == "error:")
			{
				oElem.innerHTML = '';
				window.status =  str;
				return;
			}
			
			if (oElem.type == "select-one" || oElem.type == "select-multiple" )
			{				
				
				oElem.innerText = "" ;	
				var arr = new Array();
				arr = str.split("*NextRow*");			
				for(var i=0; i < arr.length ; i++)
				{
					var arrText = new Array();
					arrText = arr[i].split("*Break*");
					if (arrText.length==2)
						oElem[i] = new Option(arrText[1], arrText[0]);
				}								
			}
			else if (oElem.type == "text")
				oElem.value = str;
			else if (oElem.type == undefined && oElem.tagName == "SPAN")
				oElem.innerHTML = str;
			else
			{	
				if (oElem.type == undefined && oElem.tagName == "DIV")
					SetDivStyle(sCtrlName, false, sDefaultColor);
				oElem.innerHTML = str;
			}	
		}
		catch(ex)
		{
			window.status = "Error: "  + ex.message;
		}
	}
    // XMLHttp send GET request 
    function xmlHttp_Get(xmlhttp, url) { 
        xmlhttp.open('GET', url, true); 
        xmlhttp.send(null); 
    } 

    function GetXmlHttpObject(handler) { 
        var objXmlHttp = null;    //Holds the local xmlHTTP object instance 

        //Depending on the browser, try to create the xmlHttp object 
        if (is_ie){ 
            //The object to create depends on version of IE 
            //If it isn't ie5, then default to the Msxml2.XMLHTTP object 
            var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP'; 
             
            //Attempt to create the object 
            try{ 
                objXmlHttp = new ActiveXObject(strObjName); 
                objXmlHttp.onreadystatechange = handler; 
            } 
            catch(e){ 
            //Object creation errored 
                alert('IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled'); 
                return; 
            } 
        } 
        else if (is_opera){ 
            //Opera has some issues with xmlHttp object functionality 
            alert('Opera detected. The page may not behave as expected.'); 
            return; 
        } 
        else{ 
            // Mozilla | Netscape | Safari 
            objXmlHttp = new XMLHttpRequest(); 
            objXmlHttp.onload = handler; 
            objXmlHttp.onerror = handler; 
        } 
         
        //Return the instantiated object 
        return objXmlHttp; 
    } 
	
	function GetDivValue(sDivID, oOutputIDCtrl, oOutputDescCtrl, setStyle)
	{
		try
		{
			var InnerDiv = document.getElementById(sDivID);						
			var str = new String;
			
			setStyle = (setStyle==null) ? true : setStyle;
			
			if (is_netscape)
			{				
				str += GetFireFoxID(InnerDiv.innerHTML);				
				str += " - "
				str += GetFireFoxDesc(InnerDiv.innerHTML);												
				if (setStyle)
				{
					SetDivStyle(oCtrl, true);					
				}
			}
			else
			{
				str = InnerDiv.innerText;		//Error with firefox browser
				if (setStyle)
					SetDivStyle(oCtrl, true);					
			}			
			oOutputIDCtrl.value = str.substring(0, str.search("-"))
			oOutputDescCtrl.value = str.substring(str.search("-")+2, str.length);
			oOutputDescCtrl.focus;
		}
		catch(ex)
		{
			window.status = "Error: "  + ex.message;
		}
	}
	
	function GetFireFoxID(str)
	{
		try
		{
			var sRemaining = new String;			
			var	sHandler = new String("firefoxidhandler=");	
			sRemaining = str.substring(str.indexOf("firefoxidhandler=")+sHandler.length+1);			
			return (sRemaining.substring(0, sRemaining.indexOf(String.fromCharCode(34))));
		}
		catch(ex)
		{
			window.status = "Error: "  + ex.message;
		}
		
	}
	
	function GetFireFoxDesc(str)
	{
		try
		{
			var sRemaining = new String;
			var	sHandler = new String("firefoxdeschandler=");
			sRemaining = str.substring(str.indexOf("firefoxdeschandler=")+sHandler.length+1);
			return (sRemaining.substring(0, sRemaining.indexOf(String.fromCharCode(34))));
		}
		catch(ex)
		{
			window.status = "Error: "  + ex.message;
		}
		
	}	
		
	function BackColor(oCtrlID, color)
	{
		var oDiv = document.getElementById(oCtrl);
		var oChildNodes = oDiv.childNodes;
		var SelectedDiv = GetSelectedDivIndex(oCtrl, true);
		
		if (SelectedDiv>-1)
			oChildNodes[SelectedDiv].style.backgroundColor=sDefaultColor;
			
		for(var i=0; i<oChildNodes.length; i++)
		{
			if (GetFireFoxID(oChildNodes[i].innerHTML).toLowerCase()==oCtrlID.toLowerCase())
				oChildNodes[i].style.backgroundColor=color;					
		}		
	}

/**********	Key Handling	******************/
function checkArrows(evt) 
{
	return (document.layers ? evt.which : document.all ? event.keyCode : document.getElementById ? evt.keyCode : 0);  	
}

function KeyUpHandler(idField, DescField, evt, requestURL, sMethod, ListName)
{
	try
	{
		var keyCode = checkArrows(evt);
		
		var oParent = document.getElementById(ListName);
		var oChildNodes = oParent.childNodes;
		var oCtrlID = document.getElementById(idField);
		var oCtrlDesc = document.getElementById(DescField);
		var nextDiv=-1;
		nextDiv = GetSelectedDivIndex(ListName, true);
		
		if (keyCode == 40)	//arrow down
		{					
			if (oChildNodes.length<=0) return;
			
			nextDiv = nextDiv >= oChildNodes.length-1 ? -1 : nextDiv;		
			
			oChildNodes[nextDiv+1].style.backgroundColor=sSelectColor;												
			GetDivValue(GetFireFoxID(oChildNodes[nextDiv+1].innerHTML), oCtrlID, oCtrlDesc, false)
		}
		else if (keyCode == 38)	//arrow down
		{					
			if (oChildNodes.length<=0) return;
			
			nextDiv = nextDiv <= 0 ? oChildNodes.length : nextDiv;		
			
			oChildNodes[nextDiv-1].style.backgroundColor=sSelectColor;												
			GetDivValue(GetFireFoxID(oChildNodes[nextDiv-1].innerHTML), oCtrlID, oCtrlDesc, false)
		}
		else if (keyCode == 39)	//arrow right
		{
		}
		else if (keyCode == 37)	//arrow left
		{
		}
		else
		{
			sDefaultWidth = oCtrlDesc.style.width;
			show_data(requestURL, sMethod, ListName);
		}
	}
	catch(ex)
	{
		window.status = "Error: "  + ex.message;
	}
}

function KeyDownHandler(evt, ListName, Hide)
{
	var keyCode = checkArrows(evt);	
	if (keyCode == 9)	//TAB
	{
		SetDivStyle(ListName, Hide);
	}
}

function GetSelectedDivIndex(ParentList, setOrignal)
{
	var oParent = document.getElementById(ParentList);
	var oChildNodes = oParent.childNodes;
	var SelectIndex = -1;
	for (var i=0; i<oChildNodes.length; i++)
	{
		if (oChildNodes[i].style.backgroundColor.toUpperCase()==sSelectColor)
			SelectIndex = i;
		if (setOrignal)
			oChildNodes[i].style.backgroundColor=oParent.style.backgroundColor;
	}
	return SelectIndex;
}

function SetDivStyle(DivName, Hidden, BackColor, Height, Width, ShowScroll, FontSize, FontWeight)
{
	try
	{
		var Div = document.getElementById(DivName);
		with (Div.style)
		{
			/********** Display Style **********/
			Hidden = (Hidden==null) ? 'block' : (Hidden==false) ? 'block' : 'none' ;
			display = Hidden;
			/********** Display Style **********/
			
			/********** Border Style **********/
			borderRightWidth='2px';	
			borderRightColor='black';
			borderRightStyle='groove';
							
			borderBottomWidth='2px';	
			borderBottomColor='black';
			borderBottomStyle='solid';

			borderTopWidth='1px';	
			borderTopColor='#cccccc';
			borderTopStyle='solid';

			borderLeftWidth='1px';	
			borderLeftColor='#cccccc';
			borderLeftStyle='solid';
			/********** Border Style **********/
		 	
			/********** Font Style **********/
 			fontFamily = 'Verdana';
 			fontSize = (FontSize == null) ? sDefaultFont : FontSize; 
 			fontWeight = (FontWeight==null) ? 'bold' : FontWeight;
			/********** Font Style **********/
		 	if(Height != null) 
 				height = Height;
 			
 			width = (Width == null) ? sDefaultWidth : Width; 
		 	
		 	ShowScroll = (ShowScroll == null) ? 'hidden' : ShowScroll;
		 		
 			overflow = ShowScroll;
 			cursor='hand'; 		
			
			BackColor = (BackColor==null) ? sDefaultColor : BackColor;
			backgroundColor=BackColor; //'#ECF2F9';
		}					
	}
	catch(ex)
	{
		window.status = "Error: "  + ex.message;
	}
}
function moves(from,to,value,FastSubDivID,dec)
			{	
			
			var flag='false';
				//alert("yes");		
			var ofrom = document.forms["Form1"].elements[from];
			var oto = document.forms["Form1"].elements[to];
			var objListSelectedFields;
			objListSelectedFields=oto;
		
	
		
			
			for ( i=0;i<ofrom.length;i++)
				{	
					flag='false';
					for(j=0;j<oto.length;j++)
					{
					
					if(ofrom.options[i].value==oto.options[j].value)
					{
					flag='true';
					
					}
					
					}	
							
					if(ofrom.options[i].selected)
						{   
							if (flag=='false')
							
						{	
							var newOpt = new Option();
							newOpt.text= ofrom.options[i].text;
							newOpt.value= ofrom.options[i].value;
								if (dec==1)
								{
															
							var i;
							for(i=ofrom.options.length-1;i>=0;i--)
							{   
								if(ofrom.options[i].selected)
							    ofrom.remove(i);
								
							}
							
					document.forms["Form1"].elements[value].value='';
					document.forms["Form1"].elements[FastSubDivID].value='';
					
					for ( i=0;i<ofrom.length;i++)
				{	
					
							
					
					
							var newOpt = new Option();
							newOpt.text= ofrom.options[i].text;
							newOpt.value= ofrom.options[i].value;
							document.forms["Form1"].elements[value].value+=newOpt.value+","
							document.forms["Form1"].elements[FastSubDivID].value+=newOpt.text+","
							//oto.options[oto.length]=newOpt;
							//ofrom.options[i]=null;
							//i=i-1;
							
					}
					}
					
								else
								{
							document.forms["Form1"].elements[value].value+=newOpt.value+","
							document.forms["Form1"].elements[FastSubDivID].value+=newOpt.text+","
							
							oto.options[oto.length]=newOpt;
							ofrom.options[i]=null;
							i=i-1;
							
								}
							
							
							}
						}
				}
			}
			
			
			
		

function HideFloorPlan()	
	{
		var oComboImgType = document.getElementById('cmb_ImageType');		
		var oFileFloorPlan = document.getElementById('FileFloorPlan');				
		var otdCaption = document.getElementById('tdIntrectiveFloorPlan');
		//alert(oFileFloorPlan);						
		if (oComboImgType.item(oComboImgType.selectedIndex).text != "Floor plan image")
		{
			oFileFloorPlan.style.display = "none";
			otdCaption.style.display = "none";
		}
		else
		{			
			oFileFloorPlan.style.display = "block";
			otdCaption.style.display = "block";
		}
	}
	
	
	function Test2(from)
	{			
		var oImg =  document.getElementById("from");
		if (Form1.File1.value != "")
			oImg.src = Form1.File1.value;
		else
			oImg.src = "../admin/images/fake-banner.gif";		
	}
	
	function Tests()
	{			
	var oImg =  document.getElementById("Img3");
	var selectedvalue=document.getElementById("lst_Results").value;

		if (Form1.lst_Results.value != "")
			oImg.src="../images/imageslibrary/" + selectedvalue;
			
		else
			oImg.src = "../admin/images/fake-banner.gif";	
	}
	
	 function doSubmit() {
	 
		        var theForm = document.forms.form1;
				var stateid_selectedvalue=document.getElementById("cmb_State").value;
				var cityid_selectedvalue=document.getElementById("cmb_city").value;
				
		        if (theForm.cmb_State.selectedIndex <= 0) {
		            alert('Please select a valid State');
		            return false;
		            }
				
		         if (theForm.cmb_city.selectedIndex <= 0) {
		            alert('Please select a valid City');
		            return false;
		           
		        }
			//	alert('enter');
		       theForm.submit();

		        //return false;
		    }
			
		    
		    
var ie4 = document.all && (navigator.userAgent.indexOf("Opera") == -1);
var ns6 = document.getElementById && !document.all;
var ns4 = document.layers;
		function getLayer( commId ) {

			return  (ie4) ? document.all["commInfoLayer" + commId] : 
					(ns6) ? document.getElementById("commInfoLayer" + commId) : 
					(ns4) ? document["commInfoLayer" + commId] : "";
									}

		    
		function changeCommInfo( commId,commId1 ) 
		  {
		//alert(commId);
		var i=0;
		var chec=0;
		var ch="featuredHomeImg"+commId;
		var ch1="featuredHomeImg"+commId1;
		var Image1=document.getElementById(ch1)
		Image1.style.borderWidth = '0px';
		Image1.style.borderColor = '';
		
		var Divid=document.getElementById("Parent")
		//var display=document.getElementById(commId)
		var oCall=Divid.children;	
		var Image=document.getElementById(ch)
		//document.all[Image].style.borderWidth = '2px';
		//document.all[Image].style.borderColor = '#666633';
		Image.style.borderWidth = '2px';
		Image.style.borderColor = '#666633';
		for(i=0;i<oCall.length;i++)
		{
			if (oCall(i).id == commId)		
			{
				
				chec=i;
				
				
				//oCall(i).style.display = "Block";				
			}
			else
				oCall(i).style.display = "none";
			
		}
		oCall(chec).style.display= "Block";
	
	
			
			}
			
			
			function HideMe(commId)
			
			{
				var ch="featuredHomeImg"+commId;
				var Image=document.getElementById(ch)
				Image.style.borderWidth = '0px';
				Image.style.borderColor = '';
	
			
			
			}
			
		//map methods	
			

					
