function printWindow() {
bV = parseInt(navigator.appVersion);
if (bV >= 4) window.print();
}
function popup(newURL)
{
newWindow = window.open(newURL, "", "statusbar,resizable,scrollbars,menubar=0,height=400,width=500")
newWindow.focus();
}	
function removechk(prop)
{
	if (isIE)
	{
		var colla = myform.all.item("save")
		if (colla != null)
		{
			if (colla.length != null)
			{
				for (i=0;i<colla.length;i++)
				{
					if (colla(i).type == "hidden" && colla(i).value == prop)
					{
						colla(i).value = "off";										
					}
						
				}
			}
			else
			{
				if (myform.save.type == "hidden" && myform.save.value == prop)
				{
					myform.save.value = "off";
				}
			}
			
		}
	
	}
	else if (isN6 || isN4)
	{
		var colla = document.myform.elements["save"]
		if (colla != null)
		{
			if (colla.length != null)
			{
				for (i=0;i<colla.length;i++)
				{
					if (colla[i].type == "hidden" && colla[i].value == prop)
					{
						colla[i].value = "off"
					}	
				}
			}
			else
			{
				if (document.myform.save.type == "hidden" && document.myform.save.value == prop)
				{
					document.myform.save.value = "off"
				}
			}
		}		
	
	}
	//else if (isN4)
	//{
	//
	//}

}

function getchecked(qs,page)
{
	checkstr = ""
	//var savename = document.myform.elements["name"]
	if (isIE)
	{
		var savename = document.myform.name.value
		var colla = myform.all.item("save")
		if (colla != null)
		{
			if (colla.length != null)
			{
				for (i=0;i<colla.length;i++)
				{
					if (colla(i).checked == true || colla(i).type == "hidden")
					{
						checkstr = checkstr + '&chk=' + colla(i).value;
										
					}
						
				}
			}
			else
			{
				if (myform.save.checked == true || myform.save.type == "hidden")
				{
					checkstr = checkstr + '&chk=' + myform.save.value;
				}
			}
			
		}
	}
	else if (isN6)
	{
		var savevar = document.myform.elements["name"];
		savename = savevar.value;
		var colla = document.myform.elements["save"]
		if (colla != null)
		{
			if (colla.length != null)
			{
				for (i=0;i<colla.length;i++)
				{
					if (colla[i].checked == true)
					{
						checkstr = checkstr + '&chk=' & colla[i].value;
					}	
				}
			}
			else
			{
				if (document.myform.save.checked == true)
				{
					checkstr = checkstr + '&chk=' & document.myform.save.value;
				}
			}
		}		
	}
	//popup(checkstr+"&savename=" + savename);
	var mypage
	if (mypagetype == "curve")
	{
		mypage = "processsearch.asp?"
		//mypage = "processsearchcurves.asp?"
	}
	else if (mypagetype == "saved")
	{
		mypage = "savedsearch.asp?"
	}
	else
	{
		mypage = "processsearch.asp?"
		//mypage = "processsearchcurves.asp?"
	}
		
	if (allchecked)
	{
		
		window.location.href = mypage + qs + "&abpage=" + page + "&docheckall=0"
	}
	else if (allcheckedoff)
	{	
		window.location.href = mypage + qs + "&abpage=" + page + "&docheckall=0"
	}
	else
	{
		window.location.href = mypage + qs + checkstr + "&abpage=" + page
	}
}


function detpopup(newURL)
{
myheight = screen.height - 100;
mywidth = 800;
mystr = "statusbar,resizable,scrollbars,menubar,height=" + myheight + ",width=" + mywidth + ",top=20,left=20";

newWindow = window.open(newURL, "", mystr)
newWindow.focus();
}	
function showname()
{
	if (isN4)
	{
		document.layers["savenamex"].visibility = "show";
		document.layers["savelink1"].visibility = "hidden";
	}
	else if (isIE)
	{
		var colla = document.all.item("savename");
		if (colla.length != null)
		{
			for (i=0;i<colla.length;i++)
			{
				colla(i).style.display = "block";
			}
		}
		else
		{
			document.all.savename.style.display = "block";
		}
		var collb = document.all.item("savelink1")
		if (collb.length != null)
		{
			for (i=0;i<collb.length;i++)
			{
				collb(i).style.display = "none";
			} 
		}
		else
		{
			document.all.savelink1.style.display = "none";
		}
	}
	else if (isN6)
	{
		
		//var colla = document.getElementById("savename");
		var colla = document.getElementsByName("savename");
		if (colla.length != null)
		{
			for (i=0;i<colla.length;i++)
			{
				colla[i].style.display = "block";
			}
		}
		else
		{
			val1 = document.getElementById("savename");
			val1.style.display = "block";
		}
		var collb = document.getElementsByName("savelink1");
		if (collb.length != null)
		{
			for (i=0;i<collb.length;i++)
			{
				collb[i].style.display = "none";
			}
		}
		else
		{
			val2 = document.getElementById("savelink1");
			val2.style.display = "none";
		}
	}
}
var allchecked = false
var allcheckedoff = false
//var allcheckstr = "Click here to select all properties to be saved and/or printed."
var allcheckstr = "Click here to check mark all properties on this page only."
function checkall(checkstr)
{
	if (isIE)
	{
		var colla = myform.all.item("save")
		if (colla != null)
		{
			if (colla.length != null)
			{
				
				if (allchecked == false)
				{
					for (i=0;i<colla.length;i++)
					{
						colla(i).checked = true;
					}
					allchecked = true;
					allcheckstr = "Click here to deselect all properties."
				}
				else
				{
					for (i=0;i<colla.length;i++)
					{
						
						if (colla(i).type != "hidden")
						{
							colla(i).checked = false;							
						}	
						else
						{
							colla(i).value = "off"
						}
					}
					allchecked = false;
					allcheckedoff = true;
					allcheckstr = "Click here to select all properties to be saved."
								
				}
			}
			else
			{
				if (allchecked == false)
				{
					myform.save.checked = true;
					allchecked = true;
					allcheckstr = "Click here to deselect all properties."
				}
				else
				{
					myform.save.checked = false;
					allchecked = false;
					allcheckstr = "Click here to select all properties to be saved."
				}
			}
		}
	}
	else if (isN6 || isN4)
	{
		var colla = document.myform.elements["save"]
		if (colla != null)
		{
			if (colla.length != null)
			{
				if (allchecked == false)
				{
					for (i=0;i<colla.length;i++)
					{
						colla[i].checked = true;
					}
					allchecked = true;
					allcheckstr = "Click here to deselect all properties."
				}
				else
				{
					for (i=0;i<colla.length;i++)
					{
						colla[i].checked = false;
					}
					allchecked = false;
					allcheckstr = "Click here to select all properties to be saved."
					
					
				}
			}
			else
			{
				if (allchecked == false)
				{
					myform.save.checked = true;
					allchecked = true;
					allcheckstr = "Click here to deselect all properties."
				}
				else
				{
					myform.save.checked = false;
					allchecked = false;
					allcheckstr = "Click here to select all properties to be saved."
				}
			}
		}
	
	}
	for (w=0;w<document.images.length;w++)
	{
		if(document.images[w].getAttribute('id') == 'check'){
			if (allchecked == true)					
			{
				MM_swapImage(document.images[w].getAttribute('name'),'','images/spacer.gif',1);				
			}
			else
			{
				location.reload(); //MM_swapImage(document.images[w].getAttribute('name'),'','images/check.gif',1);
			}
		}
	}
}
var checkstr = "";
var submitmyform = false;

function checksave(mybutton)
{
	//var formname = true;
	var formname = false;
	if (isIE)
	{
		var colla = myform.all.item("save")
		if (colla != null)
		{
			if (colla.length != null)
			{
				for (i=0;i<colla.length;i++)
				{
					if (colla(i).type == "checkbox" && colla(i).checked == true)
					{
						submitmyform = true;
						checkstr = checkstr + '&chk=' + colla(i).value;
						//break
					}
					if ((colla(i).type == "hidden") && (!isNaN(parseInt(colla(i).value))))
					{
						submitmyform = true;
						checkstr = checkstr + '&chk=' + colla(i).value;
					}	
				}
			}
			else
			{
				if (myform.save.checked == true || colla(i).type == "hidden")
				{
					submitmyform = true;
					checkstr = checkstr + '&chk=' + myform.save.value;
				}
			}
		}
		var collb = myform.all.item("name")
		if (collb.length != null)
		{
			for (i=0;i<collb.length;i++)
			{
				//collb(i).style.display = "none";
				if (collb(i).value != "")
				{
					formname = true;
					break;
				}
			} 
		}
		else
		{
			if (myform.name.value != "")
			{
				formname = true;		
			}
		}
		//if (myform.name.value == "")
		//{
		//	formname = false;		
		//}
		
	}
	else if (isN6 || isN4)
	{
		var colla = document.myform.elements["save"]
		if (colla != null)
		{
			if (colla.length != null)
			{
				for (i=0;i<colla.length;i++)
				{
					if (colla[i].checked == true)
					{
						submitmyform = true;
						checkstr = checkstr + '&chk=' + colla[i].value
						//break
					}
				}
			}
		}
		var collb = document.myform.elements["name"]
		if (collb.length != null)
		{
			for (i=0;i<collb.length;i++)
			{
				if (collb[i].value != "")
				{
					formname = true;
				}
			} 
		}
		else
		{
			if (document.myform.elements["name"].value != "")
			{
				formname = true;
			}
		}
		
		
	}
	if (mybutton == "one")
	{
		if (submitmyform == false)
		{
			//alert("Please select at least one property to save.")
			//alert("Check mark the boxes to the left of property pictures for those you want to save.\nThen click on Save My Favorites button.")
			myalert('psalert.asp?action=save')
		}
		else
		{
			if (isIE || isN6)
			{
				showname();
			}		
		}		
	}
	if (formname == false && mybutton == "two")
	{
		alert("Please enter a name for your saved choices.")
		submitmyform = false;
	}
	if ((formname == false) && isN4 && (submitmyform == true))
	{
		alert("Please enter a name for your saved choices.")
		submitmyform = false;
	}
	//return submitmyform;
}
function subgo(dowhat,where)
{
	var savename = ""
	if (dowhat == "go" && submitmyform == true)
	{
		document.myform.submit();
	}
	else if (dowhat == "register")
	{
		//var savename = document.myform.name.value;
		var savename = new String()
		var colla = document.myform.elements["name"]
		for (i=0;i<colla.length;i++)
		{
			if (colla[i].value != "")
			{
				savename = colla[i].value;
				break;
			}
		}
		checkstr = where + checkstr + "&savename=" + savename
		//alert(checkstr)
		popup(checkstr);
		checkstr = ""
	}
	
}	
function printChecked()
{
	if (isIE)
	{
		var colla = myform.all.item("save")
		var pdstr = ""
		if (colla != null)
		{
			if (colla.length != null)
			{
				for (i=0;i<colla.length;i++)
				{
					if (colla(i).checked == true)
					{
						mypropid = colla(i).value;
						pdstr = pdstr + 'propid=' + mypropid + '&';
					}						
				}
				if (pdstr == "")
				{
					//alert("Please select at least one or more properties to print\nPicture/Info brochures(s) all at once.")
					//alert("Check mark the box(es) to the left of property pictures\nfor the Picture/Info brochures you want to print.\nThen click on the Print All icon.")
					myalert('psalert.asp?action=pall');
				}
				else
				{
					newWindow = window.open('propdetailmulti.asp?' + pdstr, "", "statusbar,scrollbars,menubar=yes,height=10,width=370");
				}
			}
			
		}
	}
	else if (isN6 || isN4)
	{
		var colla = document.myform.elements["save"]
		var pdstr = ""
		if (colla != null)
		{
			if (colla.length != null)
			{
				for (i=0;i<colla.length;i++)
				{
					if (colla[i].checked == true)
					{
						mypropid = colla[i].value;
						pdstr = pdstr + 'propid=' + mypropid + '&';
					}
				}
				if (pdstr == "")
				{
					//alert("Please select at least one or more properties to print\nPicture/Info brochures(s) all at once.")
					myalert('psalert.asp?action=pall');
				}
				else
				{
					newWindow = window.open('propdetailmulti.asp?' + pdstr, "", "statusbar,scrollbars,menubar=no,height=10,width=370");
				}
			}
		}
	}	
}
function openNewWindow(URLtoOpen, windowName, windowFeatures)
{ 
	newWindow=window.open(URLtoOpen, windowName, windowFeatures);
}
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function swapcheck()
{
	var colla = document.myform.elements["save"];
	if (colla != null)
		{
			if (colla.length != null)
			{
				for (i=0;i<colla.length;i++)
				{
					mypropid = colla[i].value;
					if (colla[i].checked == true)					{
						
						MM_swapImage('check' + mypropid,'','images/spacer.gif',1)						
					}
					else
					{
						MM_swapImage('check' + mypropid,'','images/check.gif',1)		
					}
				}
			}
		}
	//if (document.myform.save.checked == true)
	//{
	//	MM_swapImage('check' + pid,'','images/spacer.gif',1)
	//}
	//else
	//{		
	//	MM_swapImage('check' + pid,'','images/check.gif',1)		
	//}	
}
function myalert(URL)
{
	newWindow = window.open(URL, "", "statusbar,resizable,menubar=0,height=230,width=365")
	newWindow.focus();
}
