<script language="JavaScript">
	
	function deleteListing(listnum,address) {
		var msg = "Are you sure you want to delete the following listing from My Favorites:\n\nMLS #: " 
			+ listnum 
			+ "\n\nAddress: " 
			+ unescape(address);
		if (confirm(msg)) {
			document.favorites.mls_num.value = listnum;
			document.favorites.submit();
		}
	}

	function openHelp(HelpID) { 
		helpWin=window.open("/Help/Help.cfm" + "?HelpID=" + HelpID, "Help", "width=350,height=300,resizable,scrollbars,left=50,top=100") ; 
		helpWin.focus();
	}


	
	function openMap( windowURL ) {
			if (screen.availWidth < 710) {
				var mywidth = screen.availWidth - 50;
			}else{
				var mywidth = 710;
			}
			if (screen.availHeight < 600) {
				var myheight = screen.availHeight - 80;  //subtract 80 pixels to allow room for taskbar
			}else{
				var myheight = 600;
			}
			var winl = parseInt((screen.availWidth - mywidth) / 2);
			var wint = parseInt((screen.availHeight - myheight) / 2) - 40; //subtract 40 to move window above the taskbar
			if (wint < 0) {wint = 0;}
			var myWindowName = "ViewMapWin";
			var myURL = windowURL;
			windowFeatures = "height=" + myheight+ ",width=" + mywidth + ",top=" + wint + ",left=" + winl + ",scrollbars,resizable,menubar";
	  		if (window.myWin && window.myWin.open && !window.myWin.closed) {  
				myWin.close();
			}	
		  	myWin = window.open(myURL, myWindowName, windowFeatures);
		  	myWin.focus();
	}


	function openReport(mlsnum,prop_type,url_parameters) {
		if (screen.availWidth < 710) {
			var mywidth = screen.availWidth - 50;
		}else{
			var mywidth = 710;
		}
		if (screen.availHeight < 600) {
			var myheight = screen.availHeight - 80;  //subtract 80 pixels to allow room for taskbar
		}else{
			var myheight = 600;
		}
		var winl = parseInt((screen.availWidth - mywidth) / 2);
		var wint = parseInt((screen.availHeight - myheight) / 2) - 40; //subtract 40 to move window above the taskbar
		if (wint < 0) {wint = 0;}		
		windowFeatures = "height=" + myheight+ ",width=" + mywidth + ",top=" + wint + ",left=" + winl + ",scrollbars,resizable,menubar";
  		if (window.reportWin && window.reportWin.open && !window.reportWin.closed) {  
			reportWin.close();
		}		
		if (prop_type == 0) {
			myURL = "/residential/reports/listing_report.cfm?mls_num=" + mlsnum + url_parameters;			
		}else if (prop_type == 1) {
			myURL = "/lot_land/reports/listing_report.cfm?mls_num=" + mlsnum + url_parameters;					
		}else if (prop_type == 2) {
			myURL = "/multi_family/reports/listing_report.cfm?mls_num=" + mlsnum + url_parameters;					
		}else if (prop_type == 3) {
			myURL = "/commercial/reports/listing_report.cfm?mls_num=" + mlsnum + url_parameters;					
		}
	  	reportWin = window.open(myURL, "Reports", windowFeatures);
	  	reportWin.focus();
	}	

	mynum=1;
	function openTour(myWindowName,myURL) {
		mynum = mynum + 1;
		if(myURL.indexOf("?")!=-1){
			myURL = myURL + "&randval=" + mynum;
		}else{
			myURL = myURL + "?&randval=" + mynum;
		}
		if (screen.availWidth < 710) {
			var mywidth = screen.availWidth - 50;
		}else{
			var mywidth = 710;
		}
		if (screen.availHeight < 600) {
			var myheight = screen.availHeight - 80;  //subtract 80 pixels to allow room for taskbar
		}else{
			var myheight = 600;
		} 
		switch(myWindowName){
			// this is used to open a small window for the actual virtual tour
  			case "TourWin":
				var mywidth = 550;
				var myheight = 350;
  				break;
 			}				
		var winl = parseInt((screen.availWidth - mywidth) / 2);
		var wint = parseInt((screen.availHeight - myheight) / 2) - 40; //subtract 40 to move window above the taskbar
		if (wint < 0) {wint = 0;}		
		windowFeatures = "height=" + myheight+ ",width=" + mywidth + ",top=" + wint + ",left=" + winl + ",scrollbars,resizable,menubar";
  		if (window.myTourWin && window.myTourWin.open && !window.myTourWin.closed) {  
			myTourWin.close();
		}	
	  	myTourWin = window.open(myURL, myWindowName, windowFeatures);
	  	myTourWin.focus();
	}
	

	function IsRatio(myVal,fieldTitle, fieldName) {
		if (myVal.length == 0) {
			return;
		}
		var newStr = "";
		// this function will verify that the string is numeric and has comma separated list
		// if the list is delimited by a ";" then it will be replaced with a ","
		var validStr = "0123456789.";
		var badChar = "";
		var valid = 1;
		for (i = 0 ; i <= (myVal.length - 1) ; i++) {
			if (validStr.indexOf(myVal.charAt(i)) == "-1") {
				valid = 0;
				badChar = myVal.charAt(i);		
				break;
			}
		}
		if (valid == 0) {
			var msg = fieldTitle + " encountered the following invalid character: ' " + badChar + " '\n\n" + 
					  fieldTitle + " requires a valid numeric value.\n\n" + 
									"You entered:\n" + 
									myVal + "\n\n" + 
									"Please correct and re-enter or\ndelete the contents of the field to continue."
			fieldName.value = "";
			fieldName.focus();
			alert(msg);
		}
	}	
		
	function IsNumeric(myVal,fieldTitle, fieldName) {
		if (myVal.length == 0) {
			return;
		}
		var newStr = "";
		var validStr = "0123456789";
		var badChar = "";
		var valid = 1;
		for (i = 0 ; i <= (myVal.length - 1) ; i++) {
			if (validStr.indexOf(myVal.charAt(i)) == "-1") {
				valid = 0;
				badChar = myVal.charAt(i);
				break;
			}
		}
		if (valid == 0) {
			var msg = fieldTitle + " encountered the following invalid character: ' " + badChar + " '\n\n" + 
					  fieldTitle + " requires a valid numeric value.\n" + 
					  			   "e.g. 1\n\n" + 
									"You entered:\n" + 
									myVal + "\n\n" + 
									"Please correct and re-enter or\ndelete the contents of the field to continue."
			fieldName.value = "";
			fieldName.focus();
			alert(msg);
		}
	}	


	function IsNumericList(myVal,fieldTitle, fieldName) {
		if (myVal.length == 0) {
			return;
		}
		var validStr = "0123456789, *%";
		var badChar = "";
		var valid = 1;
		for (i = 0 ; i <= (myVal.length - 1) ; i++) {
			if (validStr.indexOf(myVal.charAt(i)) == "-1") {
				valid = 0;
				badChar = myVal.charAt(i);
				break;
			}
		}
		if (valid == 0) {
			var msg = fieldTitle + " encountered the following invalid character: ' " + badChar + " '\n\n" + 
					  fieldTitle + " requires a valid numeric value.\n\n" + 
					  			   "If you are trying to enter a list of values, " + 
								   "please separate\n the values by commas.\n\n" + 
									"You entered:\n" + 
									myVal + "\n\n" + 
									"Please correct and re-enter or\ndelete the contents of the field to continue."
			fieldName.value = "";
			fieldName.focus();
			alert(msg);
		}
	}

	function IsCharacterList(myVal,fieldTitle, fieldName) {
		if (myVal.length == 0) {
			return;
		}
		var validStr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789, *%";
		var badChar = "";
		var valid = 1;
		for (i = 0 ; i <= (myVal.length - 1) ; i++) {
			if (validStr.indexOf(myVal.charAt(i)) == "-1") {
				valid = 0;
				badChar = myVal.charAt(i);
				break;
			}
		}
		if (valid == 0) {
			var msg = fieldTitle + " encountered the following invalid character: ' " + badChar + " '\n\n" + 
					  fieldTitle + " requires a valid character value.\n\n" + 
					  			   "If you are trying to enter a list of values, " + 
								   "please separate\nthe values by commas.\n\n" + 
									"You entered:\n" + 
									myVal + "\n\n" + 
									"Please correct and re-enter or\ndelete the contents of the field to continue."
			fieldName.value = "";
			fieldName.focus();
			alert(msg);			
		}
	}		

	function showRange(highID, obj, highName) {
		if (obj.value=="to") {	
			if (window.document.ids) {
				eval("document.searchform." + highName + ".focus()");
     		}else{
				eval("document.searchform." + highName + ".focus()");
     		}
		}else{
			eval("document.searchform." + highName + ".value = ''");
			return;
   		}	
	}
	
	function enlargeImage(imageName) {
		var mywidth = 430;
		var myheight = 440;  
		var winl = parseInt((screen.width - mywidth) / 2);
		var wint = parseInt((screen.height - myheight) / 2);
		windowFeatures = "height=" + myheight+ ",width=" + mywidth + ",top=" + wint + ",left=" + winl + ",scrollbars,resizable,menubar";
  		if (window.myWin && window.myWin.open && !window.myWin.closed) {  
			myWin.close();
		}	
	  	myWin = window.open('view_image.cfm?imageName=' + imageName, 'ML_Image', windowFeatures);
	  	myWin.focus();
	}

	function stripSpaces(myVal,fieldName) {
		var RetVal = "";
		if (myVal.indexOf(" ") != -1) { //Only run if space exists
			for (i = 0; i <= (myVal.length - 1); i++) { //Trim all spaces from field
				if (myVal.charCodeAt(i) != 32) {
					RetVal=RetVal + myVal.charAt(i);
				}
			}
			fieldName.value = RetVal;
		}
	}	
</script>

		
		
	
	

		

		

		








	