//
// Display the target image for this thumbnail
//
function displayThumb(src, width, height, title)
{
   var winWidth = 650;
   var winHeight = 510;
   eval("win = window.open('','Thumb', 'toolbar=0,scrollbars=1,location=0,status=0,resizable=1,menubar=0,width="+winWidth+",height="+winHeight+"');");
   // clear the content of the document
   win.document.open();
   win.document.writeln('<html>');
   if(null != title && title != "")
   {
       win.document.writeln('<head><title>' + title + '</title></head>');
   }
   else
   {
       win.document.writeln('<head><title>Thumbnail Image</title></head>');
   }
   win.document.writeln('<body>');
   win.document.writeln('<center><table border="0">');
   if (width == 0)
   {
      win.document.writeln('<tr><td align="center"><img src="'+src+'"></td></tr>');
   }
   else if (height == 0)
   {
      win.document.writeln('<tr><td align="center"><img width="'+width+'" src="'+src+'"></td></tr>');   
   } 
   else
   {
      win.document.writeln('<tr><td align="center"><img width="'+width+'" height="'+height+'" src="'+src+'"></td></tr>');   
   } 
   if(null != title && title != "")
   {
       win.document.writeln('<tr><td align="center">'+title+'</td></tr>');
   }
   win.document.writeln('</table></center>');
   win.document.writeln('</body></html>');
   win.document.close();
}
    function genURL(action,formname)
    {
		var sa = document.getElementById(formname).elements[0].value;
		var cy = document.getElementById(formname).elements[1].value;
		var st = document.getElementById(formname).elements[2].value;
		var pc = document.getElementById(formname).elements[3].value;
		var ct = document.getElementById(formname).elements[4].value;
		var lat =document.getElementById(formname).elements[5].value;
		var lng =document.getElementById(formname).elements[6].value;
		var uid =document.getElementById(formname).elements[7].value;
		var wid =document.getElementById(formname).elements[8].value;
		if(pc=="")
		{
			if(cy=="" || st=="")
			{
				alert("Type a City and State, or a Postal/ZIP Code, and then click Continue.");
				return false;
			}
		}
		var url = action+"&street_address="+sa+"&city="+cy+"&state="+st+"&postal_code="+pc+"&country="+ct+"&latitude="+lat+"&longitude="+lng+"&userid="+uid+"&website_id="+wid;
		popUp(url);
   }
//-----------
// BEGIN SCRIPTS FOR NAV MENUS
//-----------
// MENU GLOBALS
//var navcontname='navcontainer';
var navcontname;
var menumainwidth=100;
var navmode=0;
// 0 is right 1 is left
var fldr=0;
var fldrorg=0;
//containing menu ids
var menuids=new Array();
//item that opens this menu
var menuparitem=new Array();
var menuparindex=new Array();
var itemchildren=new Array();
var timerID;
var menuactv=0;
//item ids
var itemids=new Array();
var itemparids=new Array();
var itemchild=new Array();
var linkarr=new Array();
var xSize=0;
var ySize=0;
//index to menuids and menuparitem arrays
var menuids_ct=1;
//index to itemids and itemmenu arrays
var itemids_ct=0;
var step_ct=0;
var nodeposition=new Array();
var nodelength=new Array();
var absdepth=0;
var deptharr=new Array();
function parseMenus() {
	if (document.getElementById('nav-left')) {
		navmode=0;
		fldr=0;
	} else if (document.getElementById('nav-right')) {
		navmode=1;
		fldr=1;
	} else if (document.getElementById('nav-top')) {
		navmode=2;
		fldr=0;
	}
	fldrorg=fldr;
navcontname=document.getElementById('navcontainer');
menuids[0]=navcontname;
menuparitem[0]=navcontname;
deptharr[0]=navcontname;
nodeposition[0]=0;
nodelength[0]=deptharr[0].childNodes.length;
do {
 if (deptharr[absdepth].childNodes[nodeposition[absdepth]].tagName=="DIV") {
      if (deptharr[absdepth].childNodes[nodeposition[absdepth]].className.indexOf("submenu")!=-1) {
        menuids[menuids_ct]=deptharr[absdepth].childNodes[nodeposition[absdepth]];
        deptharr[absdepth+1]=menuids[menuids_ct];
        menuparitem[menuids_ct]=itemids[itemids_ct-1];
        menuparindex[menuids_ct]=itemids_ct;
        itemchildren[menuids_ct]=menuids[menuids_ct];
        itemchild[itemids_ct-1]=menuids[menuids_ct];
	
		//linkarr[itemids_ct].className="tertiary linkHasSub"; // use to apply arrows to subs using class "linkHasSub"
		
        rolladd="rollMenu(" + menuids_ct +")";
		rolladdout="rollMenu(0)";
		
        eval('menuparitem[menuids_ct].onmouseover=function(){' + rolladd + '}');
		eval('menuparitem[menuids_ct].onmouseout=function(){' + rolladdout + '}');
        nodelength[absdepth+1]=deptharr[absdepth].childNodes[nodeposition[absdepth]].childNodes.length-1;
        absdepth++;
        nodeposition[absdepth]=-1;
        menuids_ct++;
} else {
     itemids[itemids_ct]=deptharr[absdepth].childNodes[nodeposition[absdepth]];
     itemparids[itemids_ct]=menuids[menuids_ct-1];
     nodelength[absdepth+1]=deptharr[absdepth].childNodes[nodeposition[absdepth]].childNodes.length-1;
     absdepth++;
     deptharr[absdepth]=itemids[itemids_ct];
     nodeposition[absdepth]=-1;
  	 itemids_ct++;
	 }
 } else if (deptharr[absdepth].childNodes[nodeposition[absdepth]].tagName=="A") {
	 deptharr[absdepth].childNodes[nodeposition[absdepth]].id="sublink" + itemids_ct;
     linkarr[itemids_ct]=deptharr[absdepth].childNodes[nodeposition[absdepth]];
	}
    nodeposition[absdepth]++;
    if (nodeposition[absdepth]>nodelength[absdepth]) {
    do {
        absdepth--;
        nodeposition[absdepth]++;
    } while (nodeposition[absdepth]>nodelength[absdepth]);
    }
} while (nodeposition[0]<nodelength[0]);
}
function positionMenus() {
//menumainwidth=document.getElementById('navcontainer').clientWidth;
menumainheight=document.getElementById('navcontainer').clientHeight;
// Nav-Left
if (navmode==0) {
	
	for (i=1; i<menuids.length; i++) {
		ofst=0;
		ofsl=0;
		ofsw=0;
		
		menuids[i].style.position="absolute";
	    menuids[i].style.zIndex="10000" + i;
		ofsw=menuids[i].clientWidth;
		menuids[i].style.width=ofsw;
		
		ofst=linkarr[menuparindex[i]].offsetTop;
		ofsl=menuparitem[i].offsetLeft + menuparitem[i].clientWidth;
		
		edgeAdjuster(ofsl + 600,ofst + 100 ,ofsw + 150,i);
	}
	
// Nav-Right	
} else if (navmode==1) {
	
	for (i=1; i<menuids.length; i++) {
		ofst=0;
		ofsl=0;
		ofsw=0;
		
		menuids[i].style.position="absolute";
		menuids[i].style.zIndex="10000" + i;
		ofsw=menuids[i].clientWidth;
		menuids[i].style.width=ofsw;
		
		ofst=linkarr[menuparindex[i]].offsetTop;
		ofsl=menuparitem[i].offsetLeft - menuids[i].clientWidth;
		edgeAdjuster(ofsl,ofst,ofsw,i);
	}
// Nav-Top
} else if (navmode==2) {
 	
 	for (i=1; i<menuids.length; i++) {
	     ofst=0;
 		 ofsl=0;
 		 ofsw=0;
 		 
    	 menuids[i].style.zIndex="10000" + i;
 		 ofsw=menuparitem[i].clientWidth;
 		 
 		 if (menuparitem[i].offsetParent.id) {
 		 ofst=menumainheight + 2;
	     } else {
	     ofst=linkarr[menuparindex[i]].offsetTop;
         ofsl=menuparitem[i].offsetLeft + menuparitem[i].clientWidth;
	     }
	     
	     
	     edgeAdjuster(ofsl,ofst,ofsw,i);
	}
 }
}
function edgeAdjuster(xfs,yfs,wdt,i) {
  
  getPageSizes();
  
        xpg=0;
		ypg=0;
		myobj=menuids[i];
		do {
		xtest = myobj.offsetLeft;
		ytest = myobj.offsetTop;
		if (myobj.offsetLeft>0) xpg += myobj.offsetLeft;
		if (myobj.offsetTop>0) ypg += myobj.offsetTop;
		myobj= myobj.offsetParent;
		} while ((myobj.tagName!="BODY")&&(myobj.tagName!="HTML"));
  
if((navmode==0)||(navmode==2)) {
  if (fldr==0) {
  if ((xpg + xfs + wdt)>xSize) {
  
  if(xpg>wdt) xfs-=wdt*2;
 
  fldr=1;
  }
  } else {
  if ((xpg -xfs)<0) {
  
  fldr=0;
  } else {
  
  xfs-=wdt*2;
  
  }
  }
}
if (navmode==1) {
	 if (fldr==0) {
  if ((xpg + wdt*2)>=xSize) {
   
  fldr=1;
  } else {
  
  xfs+=wdt*2;
  
  }
  
  
  } else {
  if ((xpg-wdt)<=-1) {
  xfs+=wdt*2;
  fldr=0;
  
  }
  
  }
}
  if(navmode==2) {
  
  if(menuids[i].offsetParent.offsetParent.id!="navcontainer") {
  menuids[i].style.left=xfs + "px";
  }
  
  } else {
  
  menuids[i].style.left=xfs + "px";
  }	
  menuids[i].style.top=yfs + "px";
  menuids[i].style.visibility="hidden";
  
}
//--end  function menuSetPositions() --
function getPageSizes() {
	if(typeof(window.innerWidth)=='number') {
    //IE
    xSize=window.innerWidth;
    ySize=window.innerHeight;
  } else if(document.documentElement &&
      (document.documentElement.clientWidth||document.documentElement.clientHeight)) {
    //IE 6 xhtml
    xSize=document.documentElement.clientWidth;
    ySize=document.documentElement.clientHeight;
  } else if(document.body&&(document.body.clientWidth||document.body.clientHeight)) {
    //IE 4 5 or 6 standard
    xSize=document.body.clientWidth;
    ySize=document.body.clientHeight;
  }
}
function processMenus() {
	parseMenus();
	positionMenus();
}
function resetMenus() {
	
	for (i=1; i<menuids.length; i++) {
	
  		menuids[i].style.left= "0px";
 	
	}
	fldr=fldrorg;
	positionMenus();
}
function rollMenu(ref)
{
olx=xSize;
oly=ySize;
getPageSizes();
if ((olx!=xSize)||(oly!=ySize)) resetMenus();
  if(ref>0) {
	clearTimeout(timerID);
	turnOff(ref);
    menuactv=1;
    itemchildren[ref].style.visibility="visible";
  }
  else
  {
    menuactv=0;
    clearTimeout(timerID);
    timerID = setTimeout('turnOff()', 300);
  }
}
function turnOff(ref)
{
 if (menuactv==0) {
   for (i=0; i<itemchildren.length; i++) {
        if ((itemchildren[i]) && (i!=ref)) itemchildren[i].style.visibility="hidden";
   }
  }
}
//-----------
// END SCRIPTS FOR NAV MENUS
//-----------
//var colheightofs = 31;
var colheightofs = 0;
var pngXOffset=0;
var pngYOffset=0;
function sizeColumns() {
if (window.pngHeight) {
	pngHeight();
}
if (!document.getElementById('column1') ){
	return;
}
coldvht1=document.getElementById('column1').offsetHeight;
coldvht2=document.getElementById('column2').offsetHeight;
coldvht3=document.getElementById('column3').offsetHeight;
if (coldvht1>coldvht2) coldvht2=coldvht1;
else if (coldvht2>=coldvht1) coldvht1=coldvht2;
if (coldvht3>=coldvht1) 
{
  coldvht1=coldvht3;
  coldvht2=coldvht3;
}
else 
{
  coldvht3=coldvht1;
}
coldvht3=coldvht1;
coldvht2=coldvht1;
document.getElementById('colbody1').style.height = (coldvht1 - colheightofs) + 'px';
document.getElementById('colbody2').style.height = (coldvht2 - colheightofs) + 'px';
document.getElementById('colbody3').style.height = (coldvht3 - colheightofs) + 'px';
}
