// JavaScript Document
	function menuSwapIn(id,img) {
		document.getElementById(id).src='imagesdev/menu/' + img + '1.gif'
	}
	
	function menuSwapOut(id,img) {
		document.getElementById(id).src='imagesdev/menu/' + img + '0.gif'
	}
	
	function loadCities(city) {
		displayContent.init(['forms/citycombo.php?name=County&id=cities&selected='+ city +'&force=<?=time();?>'],['citycombo']);
	}

	function CheckBooking() {
		if(!document.FindHotel) return;
		var RType      = document.FindHotel.RoomType.value;
		var RoomCount  = document.FindHotel.Rooms.value;
		var Occupants  = parseInt(document.FindHotel.Children.value) + parseInt(document.FindHotel.Adults.value);
			
		if(RType == 'Single')
		{
			var Capacity = RoomCount * 1;		
		}
		else if(RType == 'Double' || RType == 'Twin' || RType == 'Suite')
		{
			var Capacity = RoomCount * 2;
		}
		else if(RType == 'Triple')
		{
			var Capacity = RoomCount * 3;
		}
		//Family
		else
		{	
			var Capacity = RoomCount * 4;
		}
		
		if(Occupants > Capacity)
		{			
			alert("The number of rooms of the chosen room type does not accommodate the number of people selected ("+Occupants+"). Please use the help icon next to the room type");
			return false;
		}
		
		var today = new Date();
		var Arr = document.FindHotel.Arrival.value;
		var SptArr = Arr.split("/");
		var refDate = new Date(SptArr[0], (SptArr[1] - 1), SptArr[2], 0, 0, 0, 0);
	
		if (refDate.setHours(0,0,0,0) < today.setHours(0,0,0,0))
		{
			alert('Must select a future date')
			return false;
		}
	}
	
	function CheckBooking_Details() // for -details.php
	{
		if(!document.FindHotel) return;
		var today = new Date();
		var Arr = document.FindHotel.Arrival.value;
		var SptArr = Arr.split("/");
		var refDate = new Date(SptArr[0], (SptArr[1] - 1), SptArr[2], 0, 0, 0, 0);
		if (refDate.setHours(0,0,0,0) < today.setHours(0,0,0,0))
		{
			alert("Invalid date selected");
			return false;
		}
		//
		if(document.FindHotel.location.value == 0)
		{
			alert("Please select a location");
			return false;
		}
		//
		if(document.FindHotel.RoomType.value == 0)
		{
			alert("Please select a room type");
			return false;
		}
		//
		var RType      = document.FindHotel.RoomType.value;
		var Rarr 	   = RType.split(' ');
		var Field  	   = Rarr.join('_');
		var RoomCount  = document.FindHotel.Rooms.value;
		var Occupants  = parseInt(document.FindHotel.Children.value) + parseInt(document.FindHotel.Adults.value);
		var Cap 	   = document.getElementById(Field);
		//var Cap 	   = 'document.FindHotel.'+Field+'.value';
		var Capacity   = eval(Cap.value*RoomCount);
		if(Occupants > Capacity)
		{			
			alert("The number of rooms of the chosen room type does not accommodate the number of people selected ("+Occupants+" : Adults & Children). Please use the help icon next to the room type");
			return false;
		}
		//
	}

	function AddFav(title, url)
	{
		if (document.all)
		{
			window.external.AddFavorite(url, title);
		}
		else if (window.sidebar)
		{
			window.sidebar.addPanel(title, url, '');
		}
	}
	
	function OpenWin(Link,W,H)
	{
		$Features = "width="+W+",height="+H+",scrollbars=yes";
		window.open(Link,'Special',$Features);
	}
	function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
	}
	MM_reloadPage(true);
	
	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 load_value(x) {
		 x=x+1;
		if(x==0)  {document.FindHotel.County.selectedIndex = 0; } //All County
		else if(x==1)  {document.FindHotel.County.selectedIndex = 1; } //All Connemara
		else if(x==2)  {document.FindHotel.County.selectedIndex = 2; } //Galway City
		else if(x==3)  {document.FindHotel.County.selectedIndex = 3; } //Aran Island
		else if(x==4)  {document.FindHotel.County.selectedIndex = 4; } //Athenry
		else if(x==5)  {document.FindHotel.County.selectedIndex = 5; } //Ballinasloe
		else if(x==6)  {document.FindHotel.County.selectedIndex = 6; } //Barna
		else if(x==7)  {document.FindHotel.County.selectedIndex = 7; } //Carna
		else if(x==8)  {document.FindHotel.County.selectedIndex = 8; } //Claddaghduff
		else if(x==9)  {document.FindHotel.County.selectedIndex = 9; } //Claregalway
		else if(x==10) {document.FindHotel.County.selectedIndex = 10;} //Clarinbridge
		else if(x==11) {document.FindHotel.County.selectedIndex = 11;} //Cleggan
		else if(x==12) {document.FindHotel.County.selectedIndex = 12;} //Clifden
		else if(x==13) {document.FindHotel.County.selectedIndex = 13;} //Dunmore
		else if(x==14) {document.FindHotel.County.selectedIndex = 14;} //Glenamaddy
		else if(x==15) {document.FindHotel.County.selectedIndex = 15;} //Gort
		else if(x==16) {document.FindHotel.County.selectedIndex = 16;} //Headford
		else if(x==17) {document.FindHotel.County.selectedIndex = 17;} //Inis Boffine
		else if(x==18) {document.FindHotel.County.selectedIndex = 18;} //Invern
		else if(x==19) {document.FindHotel.County.selectedIndex = 19;} //Kinvama
		else if(x==20) {document.FindHotel.County.selectedIndex = 20;} //Leenan
		else if(x==21) {document.FindHotel.County.selectedIndex = 21;} //Letterfrack
		else if(x==22) {document.FindHotel.County.selectedIndex = 22;} //Loughrea
		else if(x==23) {document.FindHotel.County.selectedIndex = 23;} //Milltown
		else if(x==24) {document.FindHotel.County.selectedIndex = 24;} //Moycullen
		else if(x==25) {document.FindHotel.County.selectedIndex = 25;} //Moylough
		else if(x==26) {document.FindHotel.County.selectedIndex = 26;} //Mt. Bellew
		else if(x==27) {document.FindHotel.County.selectedIndex = 27;} //Oranmore
		else if(x==28) {document.FindHotel.County.selectedIndex = 28;} //Oughterard
		else if(x==29) {document.FindHotel.County.selectedIndex = 29;} //Portumna
		else if(x==30) {document.FindHotel.County.selectedIndex = 30;} //Recess
		else if(x==31) {document.FindHotel.County.selectedIndex = 31;} //Renvyle
		else if(x==32) {document.FindHotel.County.selectedIndex = 32;} //Rossaveel	
		else if(x==33) {document.FindHotel.County.selectedIndex = 33;} //Roundstone
		else if(x==34) {document.FindHotel.County.selectedIndex = 34;} //Salthill	
		else if(x==35) {document.FindHotel.County.selectedIndex = 35;} //Spiddal
		else if(x==36) {document.FindHotel.County.selectedIndex = 36;} //Tuam
		else if(x==37) {document.FindHotel.County.selectedIndex = 37;} //Woodford		
		else if(x==38) {document.FindHotel.County.selectedIndex = 38;} //Woodford		
	
							
	}
	function AddDays()
	{
		if(!document.forms['FindHotel']) return;
		var thisform = document.forms['FindHotel'];
		var NNights = thisform.Nights.value;
		var Arr = thisform.elements['Arrival'].value;
		var SptArr = Arr.split("/");
		var ETA = new Date();	
		ETA = new Date(SptArr[0], (SptArr[1] - 1), SptArr[2], 12, 0, 0, 0)
				
		ETA = Date.parse(ETA);
		ETA = parseInt(ETA, 10);
		ETA = ETA + NNights*(24*60*60*1000);
		Depart = new Date(ETA);
			 
		var Mn = eval(parseInt(Depart.getMonth())+1);
		var month;
		switch (Mn)
		{
		 case 1:
			 month = 'Jan';
			 break;
		  case 2:
			 month = 'Feb';
			 break;
		  case 3:
			 month = 'Mar';
			 break;
		  case 4:
			 month = 'Apr';
			 break;
		  case 5:
			 month = 'May';
			 break;
		  case 6:
			 month = 'Jun';
			 break;
		  case 7:
			 month = 'Jul';
			 break;
		  case 8:
			 month = 'Aug';
			 break;
		  case 9:
			 month = 'Sep';
			 break;
		  case 10:
			 month = 'Oct';
			 break;
		  case 11:
			 month = 'Nov';
			 break;
		  case 12:
			 month = 'Dec';
			 break;
		  } 
		
		var PadM = (Mn < 10) ? '0' + Mn : Mn;	
		var PadD = (Depart.getDate() < 10) ? '0' + Depart.getDate() : Depart.getDate();
		thisform.Departure.value = Depart.getFullYear()+"/"+PadM+"/"+PadD;
		
		var DepTxt = document.getElementById("Dep");
		DepTxt.firstChild.nodeValue= Depart.getDate()+" "+month+" "+Depart.getFullYear();
		
		thisform.SearchBooking.disabled = false;
	}
	function ShowPointer()
	{
		var Layer;
		var Past;
		var PastI = document.getElementById("Past");
		Past  = PastI.value;
		Layer = document.FindHotel.County.value;
		
		if(Layer == 'Renvyle' || Layer == 'Letterfrack' || Layer == 'Cleggan' || Layer == 'Claddaghduff' || Layer == 'Carna' || Layer == 'Recess')
		{
			MM_showHideLayers('ConnemaraHotels','','show');
		}
		else
		{
			MM_showHideLayers('ConnemaraHotels','','hide');
		}
		
		MM_showHideLayers(Past,'','hide');
		MM_showHideLayers(Layer,'','show');
		PastI.value = Layer;	
	}
	function HidePast()
	{
		var Past;
		var PastI = document.getElementById("Past");
		Past  = PastI.value;
		MM_showHideLayers(Past,'','hide');
	}
	
	function MM_showHideLayers() { //v9.0
	  var i,p,v,obj,args=MM_showHideLayers.arguments;
	  for (i=0; i<(args.length-2); i+=3) 
	  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
		obj.visibility=v; }
	}

	function toggleDisplay(tbl) {
	   var btn = document.getElementById('btn');
	   if(btn.firstChild.nodeValue=='Show Details') { 
			btn.firstChild.nodeValue = 'Hide Details'; 
			tbl.style.display="";
	   } else { 
			btn.firstChild.nodeValue='Show Details'; 
			tbl.style.display="none";
	   }
	}
