<!--

/*This file contains all the global JavaScript functions*/


	/*##################################################################
	Function "selectOption" is used to select an option from the select list 
	The function can be used while retrieving values from the DB on to Form
	INPUT PARAMS:	# objSelect - Object reference (SELECT)
					# optValue - Value to be selected */
	function selectOption(objSelect, optValue)
	{
		for(i=0; i<=objSelect.options.length-1; i++)
		{
			if (objSelect.options[i].value == optValue)
			{
				objSelect.options.selectedIndex = i;
				break;
			}	
		}
	}
	//##################################################################


	/*##################################################################
	Function "checkFeatures" will Check the list of check boxes
	The function can be used while retrieving values from the DB on to Form
	INPUT PARAMS:	# objFeatures - Object reference (check box)
					# strFeatures - Features value string */
	function checkFeatures(objFeatures, strFeatures)
	{
		for (i=0; i<=objFeatures.length-1; i++)
		{
			if (strFeatures.indexOf(objFeatures[i].value) >= 0)
				objFeatures[i].checked = true;
		} 
	}

	//##################################################################


	/*##################################################################
	The following code defines the LTrim, RTrim and Trim functions*/
	
	function LTrim(str) 
	{
		for (var i=0; str.charAt(i)==" "; i++);
		return str.substring(i,str.length);
	}
	function RTrim(str) 
	{
		for (var i=str.length-1; str.charAt(i)==" "; i--);
		return str.substring(0,i+1);
	}
	function Trim(str) 
	{
		return LTrim(RTrim(str));
	}

	//##################################################################


	/*##################################################################
	Function "openPopup" will open the pop-up window
	INPUT PARAMS:	# sURL - URL to open
					# sName - Name of the new window
					# nWidth - Width of the popup
					# nHeight - Height of the popup */
	function openPopup(sURL, bScroll, nWidth, nHeight, windowName, menuOn, locationOn, toolBar)
	{
		
		if (windowName == null)	windowName = "_blank"
		
		var temp = window.open(sURL, windowName, "height=" + nHeight + ",width=" + nWidth + ",resizable=yes,status=no,toolbar=" + (toolBar == true ? "yes" : "no") + ",menubar=" + (menuOn == true ? "yes" : "no") + ",location=" + (locationOn == true ? "yes" : "no") + ",scrollbars=" + (bScroll == true ? "yes" : "no"));
		
		temp.opener = self
		
	}

	function openerHREF(sURL)
	{
		if(!opener.closed) {
			
			opener.location.href = sURL
			opener.focus()
		}
		else {
			
			window.open(sURL)
			
		}
	}
		
	/*##################################################################
	!!!! IE ONLY !!!!
	Function "openDialog" will open the pop-up modal dialog window
	INPUT PARAMS:	# sURL - URL to open
					# nWidth - Width of the popup
					# nHeight - Height of the popup */
	function openDialog(sURL, nWidth, nHeight)
	{
		var popup_window = window.showModalDialog(sURL, "", "edge:raised;status:no;help:no;dialogWidth:" + nWidth + "px;dialogHeight:" + nHeight + "px;");
	}
	
	//##################################################################


	/*##################################################################
	Functions for mouse roll-overs
	INPUT PARAMS:	# sText - URL to open */
	function fnOnMouseOver(sText){window.status = text; return true;}
	function fnOnMouseOut() {window.status = ""; return true;}
	
	//##################################################################


	/*##################################################################
	Function "submitShortcuts" checks for shortcut search field validity
	INPUT PARAMS:	NONE*/
	/*function submitSearch(inEspanol, inShortcuts)
	{
		if (inShortcuts == true)
		{
			if (Trim(document.frmQuickPropSearch.txtSearch.value) == "")
			{
				openPopup("/popups/shortcuts_error.aspx", false, 360, 410)
				return false;
			}
		}

		var strClickWrap = getCookie("ClickWrap");
		if (strClickWrap == null)
		{
			var sURL;
			
			if (inEspanol == true)
				sURL = "/buy/click_wrap.aspx?language=espanol"
			else
				sURL = "/buy/click_wrap.aspx"
		
			var clickwrap = window.open(sURL, "_blank", "height=410,width=360,status=no,toolbar=no,menubar=no,location=no,scrollbars=no");
			clickwrap.shortcut = inShortcuts
			return false;
		}

		return true;
	}
	*/
	function submitSearch(inEspanol, inShortcuts)
	{
		if (inShortcuts == true)
		{
			if (Trim(document.frmQuickPropSearch.txtSearch.value) == "")
			{
				openPopup("/popups/shortcuts_error.aspx", false, 360, 410)
				return false;
			}
		}

		var strClickWrap = getCookie("ClickWrap");
		if (strClickWrap == null)
		{
			var sText;
			
			if (inEspanol == true)
				sText = "Estoy realizando esta b" + "\xFA" + "squeda para mi beneficio personal.\n" +
						"Entiendo que la informaci" + "\xF3" + "n que recibir" + "\xE9" + " es propiedad de Century 21 Real Estate Corporation.\n" +
						"No entregar" + "\xE9" + " la informaci" + "\xF3" + "n recibida a terceros.\n"
			else
				sText = "I am doing this search for my own benefit.\n" +
						"I understand the information I receive belongs to Century 21 Real Estate Corporation.\n" +
						"I will not provide the information I receive to any third party.\n";
		
			if (confirm(sText))
			{
				var Expiration = new Date();
				Expiration.setYear(Expiration.getYear() + 10);
				setCookie("ClickWrap", "agree", Expiration, "/");
				return true;
			}
			else
				return false;

			/*var clickwrap = window.open(sURL, "_blank", "height=410,width=360,status=no,toolbar=no,menubar=no,location=no,scrollbars=no");
			clickwrap.shortcut = inShortcuts
			return false;*/
		}
		return true;
	}
	//##################################################################

	/*##################################################################
	Function "printWindow" prints the current window
	INPUT PARAMS:	NONE*/
	function printWindow()
	{
		if (window.print) { window.print() } else alert('To print his page press Ctrl-P on your keyboard \nor choose print from your browser or device after clicking OK');
	}
	//##################################################################
	
	/*##############################
		Navigation drop down (CIN)
	  ##############################
	*/
	function buyPage(where)
	{
		switch (where)
		{
			case "B": document.location.href = "/buy/default.aspx";
					break;				
			case "A": document.location.href = "/buy/buy_advanced.aspx";
					break;
			case "S": document.location.href = "/buy/buy_search_comm_sale.aspx";
					break;
			case "L": document.location.href = "/buy/buy_search_comm_lease.aspx";
					break;
			case "I": document.location.href = "/buy/international.aspx";
					break;
		}		
	}

//-->

