﻿
<!--
// This code was taken from another website
// If you are so bold, feel free to use it as well
function popup_keyword()
 {
	window.open("../../investor/popup/Pop Up keyword search.aspx", "", "location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=0, screenY=0, width=700, height=700");
}

function EmailSelected(PFDIDS)
{
	if (PFDIDS!=''){
		window.open('../searches/DailyDeals.SendEmail/DailyDeals.aspx?username=jeremy@mycastleindy.com&userid=1132&user=N&propid=' + PFDIDS, '', 'location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=0, screenY=0, width=720, height=700');
	}
}

function DetailEmailSelected(PFDIDS)
{
	if (PFDIDS!=''){
		window.open('../searches/DailyDeals.SendEmail/DailyDeals.aspx'+ PFDIDS, '', 'location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=0, screenY=0, width=720, height=700');
	}
}

function popup33() {
	window.open("../../investor/popup/popup3.aspx", "", "location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=0, screenY=0, width=550, height=550");
}
function popup2() {
	window.open("../../investor/popup/popup2.aspx", "", "location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=0, screenY=0, width=550, height=550");
}
function popup4() {
	window.open("../../investor/popup/popup4.aspx", "", "location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=0, screenY=0, width=550, height=550");
}
function popup1() {
	window.open("../../investor/popup/popup1.aspx", "", "location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=0, screenY=0, width=550, height=550");
}

function popup10() {
	window.open("../../investor/popup/popup10.aspx", "", "location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=0, screenY=0, width=550, height=550");
}
function popup17() {
	window.open("../../investor/popup/popup17.aspx", "", "location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=0, screenY=0, width=550, height=550");
}
function popupPriceDrop() {
	window.open("../../investor/popup/popupPriceDrop.aspx", "", "location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=0, screenY=0, width=550, height=550");
}
//

// carries info over
function selectall(thisobj) {
	for (var i=0; i < thisobj.options.length; i++) {
		thisobj.options[i].selected = true;
	}
}

// Netscape 4+ detect
var ns4 = (document.layers)? true:false;
		
// dummy script: moves info if they did not
function validate(aform) {
	var thisLS = aform.SearchCriteriaSection1_1_DDLSearchCriteriaSection1SearchBy.value;
	if (thisLS == "city" || thisLS == "county" || thisLS == "township" || thisLS == "mls_area" || thisLS == "school_district" || thisLS == "zip") {
		if (aform.thislocation.value == "") {
			moveinfo(document.MySearch.SearchCriteriaSection1_1$LstSearchCriteriaSection1From,document.MySearch.thislocation,15);
		}
	}
	if (!ns4) {
	return validateform(aform);
	}
	else {
	return validateNS(aform);
	}
}


bTrue=true;
bFalse=false;
bState=true;
var bAlertFlag = true;

var bNetscape = ((navigator.appName == "Netscape") ? true : false);

function CheckInteger(e) {
   // Grab the keystroke entered
   if (bNetscape == true) {
      kStroke = e.which;
      }
   else {
      kStroke = e.keyCode;
      }
//alert("kStroke = " + kStroke);
   if ((kStroke > 47) && (kStroke < 58)) {
      return true;
      }
   if (kStroke == 8) return true; // Backspace
   if (kStroke == 9) return true; // Tab

   alert("      **** Integer Number Field ****\n\n" +
         "Only integer numbers allowed in this field.");
   return false;
}

function ValInteger(sBox, szLabel, iMin, iMax) {
   var i,
       szVal,
       bBad = false;

   if (typeof(sBox) == "undefined") {
      bAlertFlag = true;
      return true;
      }
   szVal = new String(sBox.value);
   
   for (i = 0; i < szVal.length; i++) {
      if ((szVal.charCodeAt(i) < 47) || (szVal.charCodeAt(i) > 57)) {
         bBad = true;
         break;
         }
      }
      
   if ((bBad == true) && (bAlertFlag == true)) {
      bAlertFlag = false;  // Turn off the alert cycle.
      if (typeof(szLabel) != "undefined") {
         alert("      **** Integer Number Field ****\n\n" +
               "Only integer numbers allowed in the field:\n\n" +
               szLabel);
         }
      else {
         alert("      **** Integer Number Field ****\n\n" +
               "Only integer numbers allowed in this field.");
         }
      if (sBox.disabled == false) {sBox.focus();}
      if (sBox.disabled == false) {sBox.select();}
      return false;
      }
   iVal = sBox.value;
   iVal = parseInt(iVal,10);
   iMax = parseInt(iMax,10);
   iMin = parseFloat(iMin,10);
   if (isNaN(iMin) == true) {
      bAlertFlag = true;
      return true;
      }
      
   if (isNaN(iMax) == false) {
      if ((iVal < iMin) || (iVal > iMax)) {
         if (typeof(szLabel) != "undefined") {
            alert("      **** Number Out of Range ****\n\n" +
                  "The value for the field " + szLabel + " is out of range.\n\n" +
                  "The valid range is from " + iMin + " to " + iMax + ".");
            }
         else {
            alert("      **** Number Out of Range ****\n\n" +
                  "The value for the field is out of range.\n\n" +
                  "The valid range is from " + iMin + " to " + iMax + ".");
            }
		 if (sBox.disabled == false) {sBox.focus();}
		 if (sBox.disabled == false) {sBox.select();}
         return false;
         }
      }
   else {
      if (iVal < iMin) {
         if (typeof(szLabel) != "undefined") {
            alert("      **** Number Out of Range ****\n\n" +
                  "The value for the field " + szLabel + " is out of range.\n\n" +
                  "The lowest value allowed is " + iMin + ".");
            }
         else {
            alert("      **** Number Out of Range ****\n\n" +
                  "The value for the field is out of range.\n\n" +
                  "The lowest value allowed is " + iMin + ".");
            }
		 if (sBox.disabled == false) {sBox.focus();}
		 if (sBox.disabled == false) {sBox.select();}
         return false;
         }
      }
      
   bAlertFlag = true;
   return true;
}

function SetCheckBox(f){
	for(i = 0; i < f.elements.length; i++)
	{
	f.elements[i].checked = bState;
	}
	bState = !bState;
	
	if(bState == true)
	{
		f.elements.CheckAll1.value = "  Check All  ";
		f.elements.CheckAll2.value = "  Check All  ";
	}
	else
	{
		f.elements.CheckAll1.value = "Uncheck All";
		f.elements.CheckAll2.value = "Uncheck All";
	}
	
	return true;
}

//
function validateform(aform) {
	var thisLS = aform.SearchCriteriaSection1_1_DDLSearchCriteriaSection1SearchBy.value;
	if (thisLS == "city" || thisLS == "county" || thisLS == "township" || thisLS == "mls_area" || thisLS == "school_district" || thisLS == "zip") {
		if (aform.thislocation.length > 0) {
			if ((document.MySearch.MinPrice.value != "") && (document.MySearch.MaxPrice.value != "")) {
				if (parseInt(document.MySearch.MinPrice.value) <= parseInt(document.MySearch.MaxPrice.value)) {
					if (document.MySearch.PropType.value == "residential") {
						if ((document.MySearch.MinPriceSqFt.value != "") && (document.MySearch.MaxPriceSqFt.value != "")) {
							if (parseInt(document.MySearch.MinPriceSqFt.value) <= parseInt(document.MySearch.MaxPriceSqFt.value)) {
								selectall(aform.thislocation);
								submitpage();
								return true;
							}
							else {
								window.alert ("Please set the \"Minimum Price/Sqft\" lower than the \"Maximum Price/Sqft\"");
							}
						}
						else {
							selectall(aform.thislocation);
							submitpage();
							return true;
						}
					}
					else {
						selectall(aform.thislocation);
						submitpage();
						return true;
					}
				}
				else {
					window.alert ("Please set the \"Minimum Price\" lower than the \"Maximum Price\"");
				}
			}
			else {
				if (document.MySearch.PropType.value == "residential") {
					if ((document.MySearch.MinPriceSqFt.value != "") && (document.MySearch.MaxPriceSqFt.value != "")) {
						if (parseInt(document.MySearch.MinPriceSqFt.value) <= parseInt(document.MySearch.MaxPriceSqFt.value)) {
							selectall(aform.thislocation);
							submitpage();
							return true;
						}
						else {
							window.alert ("Please set the \"Minimum Price/Sqft\" lower than the \"Maximum Price/Sqft\"");
						}
					}
					else {
						selectall(aform.thislocation);
						submitpage();
						return true;
					}
				}
				else {
					selectall(aform.thislocation);
					submitpage();
					return true;
				}
			}
		}
		else {
			window.alert ("Please choose at least one option from \"Location Selection\"");
		}
	}
	if (thisLS =="address") {
		if (document.MySearch.HouseNumber.value =="" && document.MySearch.Street.value =="" && document.MySearch.City.value =="" && document.MySearch.ZIP.value =="") {
			window.alert ("Please Fill in at least one field");
			document.MySearch.HouseNumber.focus();
		}
		else {
			submitpage();
		}
	}
	if (thisLS =="mls_number") {
		if (document.MySearch.MLSNumber1.value =="" && document.MySearch.MLSNumber2.value =="" && document.MySearch.MLSNumber3.value =="" && document.MySearch.MLSNumber4.value =="" && document.MySearch.MLSNumber5.value =="" && document.MySearch.MLSNumber6.value =="") {
			window.alert ("Please enter at least one MLS Numbers");
			document.MySearch.MLSNumber1.focus();
		}
		else {
			submitpage();
		}
	}
	if (thisLS =="radius") {
		if (document.MySearch.HouseNumber.value =="" || document.MySearch.Street.value =="" || document.MySearch.ZIP.value =="") {
			window.alert ("Please Fill in House Number, Street and Zip for Radius");
		}
		else {
			checkprice();
		}
	}
	if (thisLS =="street") {
		if (document.MySearch.Street.value =="") {
			window.alert ("Please Fill in street name for Street");
			document.MySearch.Street.focus();
		}
		else {
			checkprice();
		}
	}
	if (thisLS =="map_coords") {
		checkprice();
	}
	if (thisLS =="subdivision") {
		if (document.MySearch.Subdivision.value =="") {
			window.alert ("Please Fill in subdivision name for Subdivision");
			document.MySearch.Subdivision.focus();
		}
		else {
			checkprice();
		}
	}
}

//Validation for price and price/sqft
function checkprice () {
			if ((document.MySearch.MinPrice.value != "") && (document.MySearch.MaxPrice.value != "")) {
				if (parseInt(document.MySearch.MinPrice.value) <= parseInt(document.MySearch.MaxPrice.value)) {
					if (document.MySearch.PropType.value == "residential") {
						if ((document.MySearch.MinPriceSqFt.value != "") && (document.MySearch.MaxPriceSqFt.value != "")) {
							if (parseInt(document.MySearch.MinPriceSqFt.value) <= parseInt(document.MySearch.MaxPriceSqFt.value)) {
								submitpage();
							}
							else {
								window.alert ("Please set the \"Minimum Price/Sqft\" lower than the \"Maximum Price/Sqft\"");
							}
						}
						else {
							submitpage();
						}
					}
					else {
						submitpage();
					}
				}
				else {
					window.alert ("Please set the \"Minimum Price\" lower than the \"Maximum Price\"");
				}
			}
			else {
				if (document.MySearch.PropType.value == "residential") {
					if ((document.MySearch.MinPriceSqFt.value != "") && (document.MySearch.MaxPriceSqFt.value != "")) {
						if (parseInt(document.MySearch.MinPriceSqFt.value) <= parseInt(document.MySearch.MaxPriceSqFt.value)) {
							submitpage();
						}
						else {
							window.alert ("Please set the \"Minimum Price/Sqft\" lower than the \"Maximum Price/Sqft\"");
						}
					}
					else {
						submitpage();
					}
				}
				else {
					submitpage();
				}
			}
}

function submitpage() {
	/*if (maxsavereached == 1 && document.MySearch.Save.value !== "") {
		window.alert ("You can save a maximum of 50 searches. Please delete a search before saving this one.");
	}
	else {*/
		document.MySearch.hidden1.value = "1";
		document.MySearch.submit();
	//}
}



//validation for Nestcape 4+ browsers
function validateNS(aform) {
	var thisLS = document.MySearch.SearchCriteriaSection1_1_DDLSearchCriteriaSection1SearchBy.options[document.MySearch.SearchCriteriaSection1_1_DDLSearchCriteriaSection1SearchBy.selectedIndex].value;
	if (thisLS == "city" || thisLS == "county" || thisLS == "township" || thisLS == "mls_area" || thisLS == "school_district" || thisLS == "zip") {
		if (aform.thislocation.length > 0) {
			SelectAll(aform.thislocation);
			document.MySearch.hidden1.value = "1";
			document.MySearch.submit();
			return true;
		}
		else {
			window.alert("Please select at least one area to search.");
			return false;
		}
	}
	else {
		if (aform.thislocation.value == "") {
			window.alert("Please enter your search criteria.");
			return false;
		}
		else {
			document.MySearch.hidden1.value = "1";
			document.MySearch.submit();
			return true;
		}
	}
}

//////////////////////////////////////////////////////////
//Transfer Fieldson Back Event...I.E :History.Go(-1)/////
////////////////////////////////////////////////////////
function MoveSelected(SelectedFieldsArr,SelectedFieldsArrText,ListBoxObj)
	{
	if (SelectedFieldsArr !=''){
		var a =SelectedFieldsArr.split(",");
		var b =SelectedFieldsArrText.split(",");
		for (i=0;i < a.length;i++)
		{
			x=new Option(b[i],a[i],false,false);
			ListBoxObj.options[i]=x;
			ListBoxObj.options[i].selected=true;
		}
	}
}



//////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
////////////////////////////////////////////////////////


// transfers data from one field to the next
function moveinfo(afield,bfield,max) {
	var thisalert = "";
	var thisfirst = true;
	var addvalue = "";
	var addtext = "";
	var addindex = "";
	var thisdupe = false;
	var setmax = true;
	if (afield.options)
	{
		for (var i=0; i < afield.options.length; i++) {
			
			if (afield.options[i].selected) {
				if (bfield.options.length < max) {
					addvalue = afield.options[i].value;
					addtext = afield.options[i].text;
					if (!entrydupe(afield.options[i].value,bfield)) {
						addindex = bfield.options.length;
						bfield.options[addindex] = new Option (addtext,addvalue);
						bfield.options[addindex].selected = true;
						///////////////////////////////////////////////////////////
						////Editing the Hidden Fields for the Selected Values.////
						/////////////////////////////////////////////////////////
						if (document.all.SelectedFields.value==''){
							document.all.SelectedFields.value=addvalue;
							document.all.SelectedFieldsText.value=addtext;

						}
						else {
							document.all.SelectedFields.value=document.all.SelectedFields.value + ',' + addvalue;
							document.all.SelectedFieldsText.value=document.all.SelectedFieldsText.value + ',' + addtext;
						}
						///////////////////////////////////////////////////////////
						//////////////////////////////////////////////////////////
						/////////////////////////////////////////////////////////
					}
					else {
						if (thisfirst) {
							thisalert += "The following areas were duplicated:\n";
							thisfirst = false;
						}
						thisalert +=addtext+"\n";
						thisdupe = true;
					}
				}
				else {
					if (setmax) {
						thisalert += "You may only add "+max+" items.\n";
						setmax = false;
					}
				}
			}
		}
		if (thisdupe || !setmax) {
			window.alert(thisalert+"\nPlease try again.");
		}
	}

}



// transfers data from one field to the next
function moveinfoNoAlert(afield,bfield,max) {
	var thisalert = "";
	var thisfirst = true;
	var addvalue = "";
	var addtext = "";
	var addindex = "";
	var thisdupe = false;
	var setmax = true;
	if (afield.options)
	{
		for (var i=0; i < afield.options.length; i++) {
			
			if (afield.options[i].selected) {
				if (bfield.options.length < max) {
					addvalue = afield.options[i].value;
					addtext = afield.options[i].text;
					if (!entrydupe(afield.options[i].value,bfield)) {
						addindex = bfield.options.length;
						bfield.options[addindex] = new Option (addtext,addvalue);
						bfield.options[addindex].selected = true;
						///////////////////////////////////////////////////////////
						////Editing the Hidden Fields for the Selected Values.////
						/////////////////////////////////////////////////////////
						if (document.all.SelectedFields.value==''){
							document.all.SelectedFields.value=addvalue;
							document.all.SelectedFieldsText.value=addtext;

						}
						else {
							document.all.SelectedFields.value=document.all.SelectedFields.value + ',' + addvalue;
							document.all.SelectedFieldsText.value=document.all.SelectedFieldsText.value + ',' + addtext;
						}
						///////////////////////////////////////////////////////////
						//////////////////////////////////////////////////////////
						/////////////////////////////////////////////////////////
					}
					else {
						if (thisfirst) {
							thisalert += "The following areas were duplicated:\n";
							thisfirst = false;
						}
						thisalert +=addtext+"\n";
						thisdupe = true;
					}
				}
				else {
					if (setmax) {
						thisalert += "You may only add "+max+" items.\n";
						setmax = false;
					}
				}
			}
		}
		if (thisdupe || !setmax) {
			window.alert(thisalert+"\nPlease try again.");
		}
	}

}


// checks for duplicate fields
function entrydupe(value,bfield)
{
	for (var j=0; j < bfield.options.length; j++) {
		if (bfield.options[j].value == value) {
			return true;
		}
	}
	return false;
}

// removes data from said field
function removethis(bfield) {
	if (bfield.options.length > 0) {
		var intialfield = bfield.options[bfield.options.selectedIndex].value;
		for (var i=0; i < bfield.options.length; i++) {
			if (bfield.options[i].value == intialfield) {
				bfield.options[i] = null;
			}
		}
		if (bfield.options.length > 0) {
			bfield.options[bfield.options.length-1].selected = true;
		}
		///////////////////////////////////////////////////////
		/////////Initializing the Hidden Fields///////////////
		/////////Filling the Hidden Fields with New Data/////
		////////////////////////////////////////////////////
		document.all.SelectedFields.value='';
		document.all.SelectedFieldsText.value='';

		for (var i=0; i < bfield.options.length; i++) {
			if (document.all.SelectedFields.value==''){
				document.all.SelectedFields.value=bfield.options[i].value;
				document.all.SelectedFieldsText.value=bfield.options[i].text;
			}
			else {
				document.all.SelectedFields.value=document.all.SelectedFields.value + ',' + bfield.options[i].value;;
				document.all.SelectedFieldsText.value=document.all.SelectedFieldsText.value + ',' + bfield.options[i].text;
			}
		}
		///////////////////////////////////////////////////////
		//////////////////////////////////////////////////////
		/////////////////////////////////////////////////////
	}
}

// removes all data from said field
function removeall(obj) {
	while (obj.options.length > 0) {
		obj.options[0] = null;
		document.all.SelectedFields.value='';
		document.all.SelectedFieldsText.value='';
	}
}

// removes empty option if present
function checkthis(obj) {
	if (!ns4)  {
		if (obj.value == 0) {
			obj.options[0] = null;
		}
	}
	else {
		if (obj.options.length > 0) {
			obj.options[0] = null;
		}
	}
}

// Rebate Disclaimer
function rebateDisclaimer() {
	window.open("../includes/rebate_disclaimer.aspx", "rebateDisclaimer_window", "location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=1, screenX=0, screenY=0, width=600, height=300");
}

// Email Window
function EmailWindow() {
	window.open("emailwindow.aspx?propid="+document.mlsdetail.propid.value+"&listnum="+document.mlsdetail.listnum.value+"&ccemail="+document.mlsdetail.ccemail.value, "email_window", "location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=1, screenX=0, screenY=0, width=600, height=520");
}

// Buying Rebate Disclaimer
function buyingrebateDisclaimer() {
	window.open("../buying/buying_rebate.aspx", "BuyingRebate_window", "location=0, menubar=1, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=1, screenX=0, screenY=0");
}

// create pop-up window
function openWin(page, width, height) {
	window.open(''+page+'.aspx','','width='+width+',height='+height+',toolbar=no,status=no,menubar=no,scrollbars=no,resizeable=no');
}

// dummy script: refreshes page when changing between SearchCriteriaSection1_1_DDLSearchCriteriaSection1SearchBy
function ReloadForm() {
	document.MySearch.hidden1.value = "0";
	document.MySearch.submit();
}

//Newwindow function

function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

//-->

