/*
 * 
 *
 * @author		MetalSoftware, Inc. $Author$
 * @copyright	MetalSoftware, Inc. 2003-2005
 * @date    	$Date$
 * @version		9.$Revision$
 * @package		
 * @id		    $Id$ 
 * @required     http://localhost:8888/
 */ 

	document.write('<script type="text/javascript" language="javascript1.1" src="lib/ext/scriptaculous/lib/prototype.js"></script>');
	document.write('<script type="text/javascript" language="javascript1.1" src="lib/ext/scriptaculous/src/scriptaculous.js?load=effects"></script>');

	var idlist = new Array();
	idlist[0] = "buy";
	idlist[1] = "sell";
	idlist[2] = "hide1";
	idlist[3] = "hide2";
	idlist[4] = "hide3";

document.menuTimer = 0;

writeCookie();

function writeCookie()
{
var today = new Date();
var the_date = new Date("December 31, 2023");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_resolution="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie

} 


function outBound(url) {
	    
var w = 650;
var h = 450; 

        window.open('http://' + url,'newWIN','toolbar=yes,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,location=yes,status=yes,width=' + w + ',height=' + h + ',screenX=0,screenY=0,left=0,top=0');

}  

function goToSchool(zip,distance) { /* goToSchool(12345,5) */
	
	var w = 650;
	var h = 450; 
	        window.open('http://www.schoolmatters.com/app/search/q/stype=SM/stid=3/llid=118/stridx=0/srtname=/srto=A/locname=/ctyname=/zip='+zip+'/dst='+distance+'/cntyname=/distname=/distid=/adv=false/page=25/site=pes','newWIN','toolbar=yes,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,location=yes,status=yes,width=' + w + ',height=' + h + ',screenX=0,screenY=0,left=0,top=0');
	
	
}

function goToMap(zip) { /* goToMap(12345) */
	
	var w = 650;
	var h = 450; 

	        window.open('http://maps.google.com/maps?q=' + zip,'newWIN','toolbar=yes,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,location=yes,status=yes,width=' + w + ',height=' + h + ',screenX=0,screenY=0,left=0,top=0');
	
}

function goToInfo(zip,city,state) { /* goToInfo(12345,This_Place,State) */
	
	var w = 650;
	var h = 450; 

	        window.open('http://en.wikipedia.org/wiki/' + city + '%2C_'+ state,'newWIN','toolbar=yes,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,location=yes,status=yes,width=' + w + ',height=' + h + ',screenX=0,screenY=0,left=0,top=0');
	
}

function cBox(chbox) {
    box = eval(chbox);
box.checked = !box.checked;
}

function linkto(n) {
    top.window.location=document.forms[0][n].options[document.forms[0][n].selectedIndex].value;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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 checkDaBox(mls) {
    box = eval(mls);
    box.checked = !box.checked;
} 

function setLyr(obj,lyr)
{
	var newX = findPosX(obj);
	var x = new getObj(lyr);
	x.style.left = newX + 'px';
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function getObj(name)
{
 if (document.getElementById)
 {
	   this.obj = document.getElementById(name);
	   this.style = document.getElementById(name).style;
 }
 else if (document.all)
 {
	   this.obj = document.all[name];
	   this.style = document.all[name].style;
 }
 else if (document.layers)
 {
	   if (document.layers[name])
	   {
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	   }
	   else
	   {
	    this.obj = document.layers.testP.layers[name];
	    this.style = document.layers.testP.layers[name];
	   }
 }
}

function hide (name) {	
	Element.hide(document.getElementById(name));	
	return false;
}

function show (name) {	
	Element.show(document.getElementById(name));
	return false;	
}

 function hide2 ( name ) {
	NS4 = (document.layers) ? 1 : 0;
	IE4 = (document.all) ? 1 : 0;
	W3C = (document.getElementById) ? 1 : 0;        
	if (W3C) {
		document.getElementById(name).style.display = "none";
	} else if (NS4) {
		document.layers[name].display = "none";
	} else {
		document.all[name].style.display = "none";
	}
}
function show2 (name ) {
	var ele;                //points to the popup element

	NS4 = (document.layers) ? 1 : 0;
	IE4 = (document.all) ? 1 : 0;
	W3C = (document.getElementById) ? 1 : 0;

	if ( W3C ) {
		ele = document.getElementById(name);
	} else if ( NS4 ) {
		ele = document.layers[name];
	} else {        // meant for IE4
		ele = window.opener.document.all[name];
	}

	if ( NS4 ) {
		ele.display = "block";
	} else {  // IE4 & W3C
		ele.style.display = "block";
	}
}

function menuOut() {
	document.menuTimer = setTimeout('menuHide()', 4500);
}

function menuOutSub() {
	document.menuTimer = setTimeout('menuHide()', 2500);
}

function menuHide() {
	
	for (i=0;i<idlist.length;i++)
	{
	  //window.alert("menuHide::hide: "+idlist[i]);
	  hide(idlist[i]);
	}
	// FIX for I.E. conflicts with select form boxes
	show('hide1');
	show('hide2');
	show('hide3');
	
}

function menuToggle(itemid) {
		
		/*var temp = "";
		for (x in itemid) {
			temp += x + ": " + itemid[x] + "\n";
		}
		document.write ("<pre>menuToggle: " + temp + "</pre>\n");
		*/
		

	for (i=0;i<idlist.length;i++)
	{
		if (idlist[i] == itemid.id) {
			clearTimeout(document.menuTimer);
			show(idlist[i]);
			//window.alert("menuToggle::show: "+idlist[i]);
		} else {
			hide(idlist[i]);
			//window.alert("menuToggle::hide: "+idlist[i]);
		}
	}

}

function imageZoom(chosen){ 
 
 if (chosen == true)
 { 
 show('big');
 hide('small');
 }
 else
 { 
 hide('big');
 show('small');
 }
 
}

function scheduleSelect(){ 
 
 if (document.forms[0].alertperiod[0].selected == true)
 { 
 show('daily');
 hide('periodic');
 }
 if (document.forms[0].alertperiod[1].selected == true)
 { 
 hide('daily');
 show('periodic');
 }
 
}

function allPhoto(url)
       {
      /*  var w = screen.availWidth||screen.width;
	   var h = screen.availHeight||screen.height; */
	    
var w = 680;
var h = 400; 

        window.open(url,'newWIN','toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no,width=' + w + ',height=' + h + ',screenX=0,screenY=0,left=0,top=0');
}  

function delit(name,url) {
 ask=window.confirm("Are you sure you want to DELETE "+name+"? This action cannot be undone!");
 if(ask==true){
  window.location=url;
 }
}

var phone_field_length=0;
function TabNext(obj,event,len,next_field) {
	if (event == "down") {
		phone_field_length=obj.value.length;
		}
	else if (event == "up") {
		if (obj.value.length != phone_field_length) {
			phone_field_length=obj.value.length;
			if (phone_field_length == len) {
				next_field.focus();
				}
			}
		}
	}
	
	function calcHeight()
	{
	  //find the height of the internal page
	  var the_height=document.getElementById('the_iframe').contentWindow.document.body.scrollHeight;

	  //change the height of the iframe
	  document.getElementById('the_iframe').height=the_height;
	
	}	
