 var pCategories = new Array();
 var EntsExist = false;
 var NumSubCats=0;

function OpenMap(ID) 
      {
        mapWindow=window.open('/ShowMap.php?Map=' + ID,'Map','resizable=1,width=810,height=800,scrollbars');
        mapWindow.focus();
      }

function OpenCoupon(ID) 
      {
        couponWindow=window.open('/Coupon.php?Coupon=' + ID,'Coupon','width=550,height=520,location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=yes,scrollbars');
        couponWindow.focus();
      }

function OpenPrintOptionWindow(town,state,cat) 
      {
   		if (EntsExist)
        	msgWindow=window.open('/ChoosePrintOpt.php?Town=' + town + '&State=' + state + '&Cat=' + cat,'ChoosePrintOptWindow','resizable=0,width=400,height=300');
      	else
      		alert ("There are no listings in this category. Nothing to Print.");
      }
      
function OpenChooseCatWindow(town,state,cat) 
      {
        msgWindow=window.open('/ChoosePrintCat.php?Town=' + town + '&State=' + state + '&Cat=' + cat,'ChooseCatWindow','resizable=0,width=400,height=300');
      }
	
function PrintCategory(category, town, state,catcolor)
	{
	text = '<style type="text/css">';
	text +='p.hang {text-indent: 0em; margin-left: 1em;margin-top:0px}';
	text +='a {color:black; text-decoration: none}';
	text +='p.Category {font-size:120%;font-weight:bold;color:'+catcolor+'}';
	text +='p.SubCat {font-size:100%;font-style:italic;color:'+catcolor+';margin-left:20px;}';
	text +='div.listing  { overflow:hidden;margin-left:83px;}';
	text +='div.listingA { overflow:hidden}';
	text +='div.action { float:left;overflow:hidden;min-width:83px;}';
	text +='li {margin: 0;border-bottom: 0px dashed #ccc;padding: 5px 0px; overflow: hidden;list-style-type:none;}';
	text +='.SubCat img {border-width:0px;margin:0px;padding:0px;display: inline;margin-right:3px;}';
	text +='.Category img {border-width:0px;margin:0px;padding:0px;display: inline;margin-right:3px;}';
	text +='</style>';
	text += '<table align="center" border="0" cellpadding="0" cellspacing="2" width="600">';
    text += '<tr><td align="center"><img src="/Images/LogoSmall.gif"></td></tr>';
    text += '<tr><td align="center"><i><font size="+1">"The Ultimate US Travel, Tourism & Relocation Guide"</font></i></td></tr>';
    text += '<tr><td align="center"><b><font size="+2">' + town + ", " + state+ '</font></b></td></tr></table><br>';
    
    if (window.print)
		{
		switch (category)
			{
			case "Lodging":
				CatColor="#e72000";
				CatName="LODGING";
				break;
			case "Dining":
				CatColor="#0063FF";
				CatName="DINING";
				break;
			case "Attractions":
				CatColor="#009C30";
				CatName="ATTRACTIONS";
				break;
			case "Events":
				CatColor="#FF00FF";
				CatName="ENTERTAINMENT & EVENTS";
				break;
			case "Recreation":
				CatColor="#E72000";
				CatName="RECREATION";
				break;
			case "Shopping":
				CatColor="#0063FF";
				CatName="SPECIALTY SHOPPING";
				break;
			case "Business":
				CatColor="#009C30";
				CatName="BUSINESS DIRECTORY";
				break;
			case "Publications":
				CatColor="#FF00FF";
				CatName="PUBLICATIONS";
				break;
			case "Organizations":
				CatColor="#009C30";
				CatName="ORGANIZATIONS";
				break;
			case "Transportation":
				CatColor="#FF00FF";
				CatName="TRANSPORTATION";
				break;
			case "Relocation":
				CatColor="#0063FF";
				CatName="RELOCATION";
				break;
			} // End Switch
		
		title='<table align="center" width="660" border="0"><tr><td align="left"><b><font color=' + CatColor + ' size="+1">' + CatName + '</font></b></td><tr></table>';
		text += '<hr width="650"><br>';
		text += title + document.all[category].outerHTML; // Get the table data using the table name
        features="resizable=0,scrollbars=0,height=1,width=1";
        winId = window.open('','printwin',features);
        with (winId.document)
        	{
           	write('<html>\n<head>\n');
           	write("<\/script>\n<\/head>");
           	write('<body onLoad="window.focus();window.print();setTimeout(\'window.close()\',2000);">\n'+text);
           	write('\n<\/body><\/html>');
           	close();
         	}
        
    	}   //End Window.Print
	}       //End Function

 function nbyTown()
 {
   f=self.document.NbyTownForm;
   if (f.Town.value != "")
   { 
	   url=f.Town.options[f.Town.selectedIndex].value;
	   window.location=url;
	 }
	 else
	 {
	   return false;
	 }
 }
function ShowHide(listid,imgid,force)
{
	if (typeof force == 'undefined' ) force = 'none';

	if(document.getElementById) 
	{ 
		curlist=document.getElementById(listid);
		action="none";
		actionImg="/Images/icons/expand.gif";
		if ( ((curlist.style.display == "none") || (force == 'show')) && (force != 'hide') )
		{
			action="";
			actionImg="/Images/icons/collapse.gif";
		}		  
		curlist.style.display = action; 
		document.getElementById(imgid).src=actionImg;
	} 
	else if(document.all) 
	{ 
		document.all[listid].style.display = action; 
	} 
}
function CountSubCats(CatID)
{
	var mylist=document.getElementById(CatID)
	NumSubCats=0;
	for (i=0; i<mylist.childNodes.length; i++)
	{
		if (mylist.childNodes[i].nodeName=="UL")
			NumSubCats++;
	}
}
function ShowHideAll(CatIMG,CatID)
{
	if(document.getElementById) 
	{ 
		if (NumSubCats == 0)
			CountSubCats(CatID);
		catbutton=document.getElementById(CatIMG);
		pos = catbutton.src.indexOf( "collapse" );
		force="show";
		actionImg="/Images/icons/collapse.gif";
		if (pos > 0)
		{
			force="hide";
			actionImg="/Images/icons/expand.gif";
		}
		catbutton.src=actionImg;
		for (i=1; i <= NumSubCats;i++)
		{
			listid='SubCat'+i;
			imgid='CE'+i;
			ShowHide(listid,imgid,force)
		}
	}
}