
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=600,height=500,left = 390,top = 150');");
}



function ChangeMiniMapSize($incdec){
	var multiplier = 1.2;
	var minimap = document.getElementById("minimap");
	var width = document.getElementById("minimap").style.width.replace('px','');
	var height = document.getElementById("minimap").style.height.replace('px','');
	if($incdec=="increase"){
		newwidth = (width * multiplier) + "px";
		newheight = (height * multiplier) + "px";
		minimap.style.width = newwidth;
		minimap.style.height = newheight;
	}else{
		newwidth = (width / multiplier) + "px";
		newheight = (height / multiplier) + "px";
		minimap.style.width = newwidth;
		minimap.style.height = newheight;			
	}
}





/*                       MLS Home Search Form Functions
------------ Change price based on which button was clicked ------------*/
var SubmitSearchPriceTimeoutVar; //used to allow user to quickly scroll through prices before submitsearch kicks in
function SubmitSearchPriceTimeout(){
	SubmitSearchPriceTimeoutVar = window.setTimeout("submitSearch()", 800); //.8 second of inactivity before search is submitted
}
function ClearSubmitSearchPriceTimeout(){
	window.clearTimeout(SubmitSearchPriceTimeoutVar);
}

function IncreaseDecreasePrice(control, button){
	ClearSubmitSearchPriceTimeout();//stop the submitsearch timeout while clicking the button rapidly
	controlbox = document.getElementById(control);
	//we will add commas at the end of the function so they can be used in switch statement
	NewPrice = removeCommas(controlbox.value) * 1 + button.value * 1;
	controlbox.value = addCommas(NewPrice+""); //"" is to convert to text
	UpdatePriceControls(control); //update buttons
	
	//submitSearch if that is the intention of the onchange property of the control
	onchangetext = "this text ensures we have a string"+controlbox.onchange;
	//GLog.write(onchangetext);
	//alert(onchangetext);
	onchangetext.search(/submitSearch()/)>-1 ? SubmitSearchPriceTimeout() : true; //if the onchange property calls for a submit search, let's initiate the submitSeach timeout (timeout is used to allow for rapid clicking without the map slowing down to submit a search each time)
}
/*                       MLS Home Search Form Functions
------------ Change price based on which button was clicked ------------*/
function UpdatePriceControls(control){
	//GLog.write(control);
	controlbox = document.getElementById(control);
	NewPrice = removeCommas(controlbox.value)*1; //control box should be in comma form; remove them. and convert to number
	if(NewPrice < 0){ //do not allow negatives
		NewPrice *= -1;
		alert("Cannot have a price below zero.  Your value has been reset to a positve number.");
	}
	switch (true){
		case (NewPrice < 10000): //10,000
			precise = 500; precisetext = "500";
			bulk = 1000; bulktext = "1k";
		break;
		case (NewPrice < 50000): //50,000
			precise = 1000; precisetext = "1k";
			bulk = 	5000; bulktext = "5k";
		break;
		case (NewPrice < 100000): //100,000
			precise = 5000; precisetext = "5k";
			bulk = 10000; bulktext = "10k";
		break;
		case (NewPrice < 400000): //400,000
			precise = 10000; precisetext = "10k";
			bulk = 25000; bulktext = "25k";
		break;
		case (NewPrice < 1000000): //1,000,000
			precise = 25000; precisetext = "25k";
			bulk = 50000; bulktext = "50k";
		break;
		case (NewPrice < 2000000): //2,000,000
			precise = 50000; precisetext = "50k";
			bulk = 100000; bulktext = "100k";
		break;
		case (NewPrice >= 2000000): //2,000,000+
			precise = 100000; precisetext = "250k";
			bulk = 1000000; bulktext = "1m";
		break;
		default:
			precise = 0; precisetext = "err";
			bulk = 0; bulktext = "err";			
		break;
	}// end of switch
	document.getElementById(control+'MinusBulk').value = "-"+bulk;
	document.getElementById(control+'MinusBulk').innerHTML = "-"+bulktext;
	document.getElementById(control+'MinusPrecise').value = "-"+precise;
	document.getElementById(control+'MinusPrecise').innerHTML = "-"+precisetext;
	
	document.getElementById(control+'PlusBulk').value = bulk;
	document.getElementById(control+'PlusBulk').innerHTML = "+"+bulktext;
	document.getElementById(control+'PlusPrecise').value = precise;
	document.getElementById(control+'PlusPrecise').innerHTML = "+"+precisetext;
	
	controlbox.value=addCommas(NewPrice+""); //we removed the commas from NewPrice above; add them back.
	CheckMinMaxPrice(); //makes sure the minimum price is less than the maximum price
}

function CheckMinMaxPrice(){
	MinPrice = removeCommas(document.getElementById('PriceMin').value);
	MaxPrice = removeCommas(document.getElementById('PriceMax').value);
	MinPrice*1 > MaxPrice*1 ? document.getElementById('PriceMax').value = document.getElementById('PriceMin').value:true;
}


	
function priceOCSelector(PriceMinMax,OpenClose){
	selector = document.getElementById(PriceMinMax+'Selector');
	//close other selector
	otherselectorname = PriceMinMax=="PriceMin" ? "PriceMaxSelector" : "PriceMinSelector";
	document.getElementById(otherselectorname).style.display='none';
	
	OpenClose=="open" ? selector.style.display='block' : selector.style.display='none';
	//document.getElementById('errorbox').value = selector.style.display;
}
var selectorTimeout; //timeout  variable
function SelectorCloseTimeout(PriceMinMax){
	functiontocall = "priceOCSelector('"+PriceMinMax+"','close')";
	selectorTimeout = window.setTimeout(functiontocall, 800); //.8 second
}
function ClearSelectorTimeout(){
	window.clearTimeout(selectorTimeout);
}