var facDiv;
var facLink;
var facLinkDiv;
var menuArray= new Array(); 
var facObject= new Array;
var facPage;
var amenDiv;
var amenContent = new Array();
var margin;
var amenIndex;
var topMenu;

function amenitiesPage(index){
var menu = new Array(), img = new Array();
	amenDiv=createDiv();
	document.body.appendChild(amenDiv)
	amenIndex=index;
	i=0;	
	//for the amenities
	amenContent[i]= new Object();
	amenContent[i].image=new Array();
	amenContent[i].header= new Array();
	amenContent[i].content= new Array();
	
	
	amenContent[i].image[0]="pool.jpg";
	amenContent[i].header[0]="Swimming Pool with Jacuzzi";		
	
	amenContent[i].content[0]="The pool at Bohol Plaza Resort is tropical oasis accented by "
	amenContent[i].content[1]="awnings, brightly colored flowers and dozens of varieties of leafy"
	amenContent[i].content[2]="palms. The result is a lush paradise that invites a lazy toll by the"
	amenContent[i].content[3]="water. Complimentary towels and lounge chairs are provided ";
	amenContent[i].content[4]="to all guests. The cocktail and the snack bar serve bottled water,"
	amenContent[i].content[5]="juices and sodas. It has television with cable, telephone, children floaters "
	amenContent[i].content[6]="and changing room. It has also sundries, suntan lotion, dive mask"
	amenContent[i].content[7]="and sun glasses available for sale."
	i++;
	//end amenities
	img[0]="carRentalBig.jpg";
	img[1]="touristBusBig.jpg"
	loadImages(img);
	
	//for alwens restaurant 
	amenContent[i]= new Object();
	amenContent[i].image=new Array();
	amenContent[i].header= new Array();
	amenContent[i].content= new Array();
	
	
	amenContent[i].image[0]="AlwensRestaurant2.jpg";
	amenContent[i].header[0]="Alwen's Cafe"		
	
	amenContent[i].content[0]="Enjoy the view while having coffee,"
	amenContent[i].content[1]="snack or dinner at Alwen's Cafe";
	i++;
	//ends alwens restaurant 
	
	//for native restaurant
	amenContent[i]= new Object();
	amenContent[i].image=new Array();
	amenContent[i].header= new Array();
	amenContent[i].content= new Array();
	
	
	amenContent[i].image[0]="nativeRestaurant.jpg";
	amenContent[i].header[0]="KTV Bar Native Restaurant"		
	
	amenContent[i].content[0]="Enjoy your meal near pool side"
	amenContent[i].content[1]="from thursday to saturday with live"
	amenContent[i].content[2]="music in our Native Restaurant"
	i++;
	
	//end native restaurant 
	
	//for aaron funtion hall
	amenContent[i]= new Object();
	amenContent[i].image=new Array();
	amenContent[i].header= new Array();
	amenContent[i].content= new Array();
	
	amenContent[i].image[0]="aaronFunction.jpg";
	amenContent[i].header[0]="Aaron Function Hall"		
	amenContent[i].content[0]="An open function hall with maximum"
	amenContent[i].content[1]="capacity of 100 persons. A great place for"
	amenContent[i].content[2]="dining with friends and loved ones."
	i++;
	//end arron function hall
	
	//for dayo hill
	amenContent[i]= new Object();
	amenContent[i].image=new Array();
	amenContent[i].header= new Array();
	amenContent[i].content= new Array();
	
		
	amenContent[i].image[0]="dayoHill.jpg";
	amenContent[i].header[0]="Dayo Hill Grand Ballroom"		
	
	amenContent[i].content[0]="fully air-conditioned room with maximum "
	amenContent[i].content[1]="capacity of 300 persons and with an"
	amenContent[i].content[2]="overlooking view. A perfect place for"
	amenContent[i].content[3]="wedding receptions and all sorts of parties"
	amenContent[i].content[4]="like birthday, home coming and graduation."
	i++;
	//end dayo hill
	
	//alexis function 
	amenContent[i]= new Object();
	amenContent[i].image=new Array();
	amenContent[i].header= new Array();
	amenContent[i].content= new Array();
	
	
	amenContent[i].image[0]="alexisFunction.jpg";
	amenContent[i].header[0]="Alexis Function Hall"		
	
	amenContent[i].content[0]="A fully air-conditioned room with maximum"
	amenContent[i].content[1]="capacity of 100 persons near Alwen's Cafe."
	amenContent[i].content[2]="Seminars and business-like meetings best held"
	amenContent[i].content[3]="at this comfortable and convenient room";	
	
	i++;
	//end alexis function 
	
	
	//for souvenir
	amenContent[i]= new Object();
	amenContent[i].image=new Array();
	amenContent[i].header= new Array();
	amenContent[i].content= new Array();
	
	amenContent[i].image[0]="souvenir.jpg";
	amenContent[i].header[0]="Souvenir"		
	amenContent[i].content[0]="Before leaving, visitors can also drop by at our souvenir store where a"
	amenContent[i].content[1]="great variety of collectible items are sold. There are colorful souvenir shirts, "
	amenContent[i].content[2]="native bags, fans and many more to choose from."
	i++;
	//end of souvenir
	
	if(index==1 || index==2){
		//for the restaurant sub link 
		menu[0]="Alwen's Cafe";
		menu[1]="KTV Bar";
		topMenu=basicMenu(menu);
		topMenu[0].index=1;
		topMenu[1].index=2;
		//position for the top menu
		for(i=0;i<topMenu.length;i++){
			amenDiv.appendChild(topMenu[i]);
			topMenu[i].group="Facilities";
			topMenu[i].style.color="#cc0000";
			topMenu[i].onclick=subMenuClick;
			topMenu[i].style.visibility="hidden";
		}	
		
		
	}
	
	
	if(index==3 || index==4 || index==5){
		//for the function sub link
		menu[0]="Aaron Funtion";
		menu[1]="Dayo Hill";
		menu[2]="Alexis Function";
		
		topMenu=basicMenu(menu);
		topMenu[0].index=3;
		topMenu[1].index=4;
		topMenu[2].index=5
		
		for(i=0;i<topMenu.length;i++){
			amenDiv.appendChild(topMenu[i]);
			topMenu[i].group="Facilities";
			topMenu[i].style.color="#cc0000";
			topMenu[i].onclick=subMenuClick;
			topMenu[i].style.visibility="hidden";
		}
		
	}
	
	amenContent=subFacilitesPage(amenContent[index]);
	
	//for the picture 
	for(i=0;i<amenContent.picture.length;i++){
	
		amenDiv.appendChild(amenContent.picture[i])
	}
	//for the header
	for(i=0;i<amenContent.header.length;i++){
	
		amenDiv.appendChild(amenContent.header[i])
	}
	//for the text
	for(i=0;i<amenContent.content.length;i++){
	
		amenDiv.appendChild(amenContent.content[i])
	}
	
	amenDiv.resize=resizeAmenities;
	

	return amenDiv; 
}		

function resizeAmenities(){
var width, topPos;

	width=bgImage.offsetWidth;
	//required 
	amenDiv.style.width=bgImage.offsetWidth + "px";
	amenDiv.style.height=bgImage.offsetHeight + "px";
	amenDiv.style.top=bgImage.offsetTop + "px";
	amenDiv.style.left=bgImage.offsetLeft + "px";
	//amenDiv.style.backgroundColor="#CFCFCF";
	
	if(!scaleToWidth(amenContent.picture[0], width *.4)){
	
		return false;
	}
	else{
	//for the picture 
		amenContent.picture[0].style.left=leftPos;
		amenContent.picture[0].style.top=topDistance;
		amenContent.picture[0].style.visibility="visible";
	//	window.status=amenContent.picture[0].offsetLeft+"" + bgImage.offsetLeft;
	}
	
	// for the header 
	amenContent.header[0].style.fontSize=headerSize;
	amenContent.header[0].style.left=leftPos;
	amenContent.header[0].style.top=amenContent.picture[0].offsetTop + amenContent.picture[0].offsetHeight + margin +"px";
	amenContent.header[0].style.visibility="visible";
	
	topPos=amenContent.header[0].offsetTop + amenContent.header[0].offsetHeight + margin;
	
	//for all the text content 
	i=0;
	
	while(i<amenContent.content.length){
		//for the text content
		amenContent.content[i].style.fontSize=textSize;
		amenContent.content[i].style.left=leftPos;
		amenContent.content[i].style.top= topPos + "px";
		amenContent.content[i].style.visibility="visible";
		topPos=amenContent.content[i].offsetTop + amenContent.content[i].offsetHeight;
		
	i++
	}
	
	//we call the menu if top menu is present 
	if(typeof(topMenu)=="object"){
		facMenuResize();
	}
	return true;
}



function facilitiesMenu(){
var i;
		
	facLinkDiv=createDiv()
	facLinkDiv.style.zIndex=0;
//	document.body.appendChild(facLinkDiv);
	
	//our menu
		//for amenities	
	i=0;
	menuArray[i] = new Object();
	menuArray[i].path="amenitiesThumb.jpg"
	menuArray[i].caption="Amenities";
	i++;
		//for reataurant
	menuArray[i] = new Object();
	menuArray[i].path="restaurantThumb.jpg"
	menuArray[i].caption="Restaurant";
	i++;
		////for functions
	menuArray[i] = new Object();
	menuArray[i].path="functionThumb.jpg"
	menuArray[i].caption="Functions";
	i++;
		//for souvenir
	menuArray[i] = new Object();
	menuArray[i].path="souvenirThumb.jpg"
	menuArray[i].caption="Souvenir";
	i++;
	//end menu
	
	facLink=subMenu(menuArray);
	
	for(i=0;i<facLink.length;i++){
	//append into the div element
		facLinkDiv.appendChild(facLink[i].picture)
		facLinkDiv.appendChild(facLink[i].caption)
	}
	
	facLinkDiv.resize=resizeFacilitiesMenu;
	
	
return facLinkDiv;
}

//this function is responsible for resizing the menu 
function resizeFacilitiesMenu(){
var topPos, xWidth, leftPos;
	
	xWidth=bgImage.offsetWidth;
	topPos=bgImage.offsetTop + Math.round(bgImage.offsetHeight/3.5);//4.5
	leftPos= bgImage.offsetLeft + (bgImage.offsetWidth/6) ;
	i=0;
	while(i<facLink.length){
		if(!scaleToWidth(facLink[i].picture, xWidth*.1)){
			return false;
		}
	i++;
	}
//debugger;
	i=0;
	while(i<facLink.length){
		//position for teh link and pictures	
		facLink[i].picture.style.top=topPos +"px";
		facLink[i].picture.style.left=leftPos + "px";
		facLink[i].picture.group="Facilities";
		facLink[i].picture.onclick=subMenuClick;
		showObject(facLink[i].picture)
		
		facLink[i].caption.style.fontSize=Math.round(bgImage.offsetWidth/70) + "px";
		facLink[i].caption.style.left=leftPos + "px";
		facLink[i].caption.style.top=facLink[i].picture.offsetTop + facLink[i].picture.offsetHeight + "px"
		facLink[i].caption.group="Facilities";
		facLink[i].caption.onclick=subMenuClick;
		showObject(facLink[i].caption);
		topPos=facLink[i].caption.offsetTop  + facLink[i].caption.offsetHeight + Math.round(xWidth/100);
		
	i++
	}
//it has a different index coz there are link  has a sub link	
	facLink[0].picture.index=0;
	facLink[0].caption.index=0;
	
	facLink[1].picture.index=1;
	facLink[1].caption.index=1;
	
	facLink[2].picture.index=3;
	facLink[2].caption.index=3;
	
	facLink[3].picture.index=6;
	facLink[3].caption.index=6;
	
return true
}


//this function is return a obj has a picture header and content array
//not only use by the facilities sub page but in alll pages except home 
// i think this function can be put on the function file
function subFacilitesPage(obj){
var contentobj =new Object(), i, pic, text, header;
	
	contentobj.picture= new Array();
	contentobj.header= new Array();
	contentobj.content= new Array();
	
	for(i=0;i<obj.image.length;i++){
		//for the picture
//		contentobj.picture[i] = new Image();	
//		contentobj.picture[i].src=obj.image[i];
		contentobj.picture[i] = xImage(obj.image[i]);
		contentobj.picture[i].style.position="absolute";
		contentobj.picture[i].style.visibility="hidden";
		contentobj.picture[i].style.zIndex=i+3;
		contentobj.picture[i].id=obj.image[i];
		clearMargins(contentobj.picture[i]);
		contentobj.picture[i].style.border="2px solid white";
	}
	for(i=0;i<obj.header.length;i++){
		//for the header 
		contentobj.header[i]=displayText(obj.header[i]);
		contentobj.header[i].style.color="#CC0000";
		contentobj.header[i].style.visibility="hidden";
		contentobj.header[i].style.zIndex=i+3;
		contentobj.header[i].style.fontStyle="italic";
	}	
	
	for(i=0;i<obj.content.length;i++){
		// for the text content 
		contentobj.content[i]=displayText(obj.content[i]);
		contentobj.content[i].style.zIndex=i+10;
		contentobj.content[i].style.visibility="hidden";
	}
	
	
	
return contentobj;
}


function facMenuResize(){
var i, left, top;
		//for the subMenu 
		top=logo.offsetHeight + Math.round(bgImage.offsetWidth/50);
		left=logo.offsetWidth;
		
		i=0;
		while(i<topMenu.length){
		
			topMenu[i].style.fontSize=Math.round(bgImage.offsetWidth/50)  + "px";
			topMenu[i].style.left=left + "px";
			topMenu[i].style.top= top + "px";
			topMenu[i].style.visibility="visible";
			if(browserSnipper()){
			//	topMenu[i].style.width=Math.round(bgImage.offsetWidth/7) + "px";
			}				
			left=topMenu[i].offsetLeft + topMenu[i].offsetWidth + Math.round(bgImage.offsetWidth/50);
		i++
		}

return; 
}


function displayText(str){
var p;
	//return p element
	p=document.createElement("span");
	p.style.position="absolute";
	p.style.fontFamily=fontFamily1;
	p.style.color="#000000";
	p.innerHTML=str;
	clearMargins(p);

return p;
}