// JavaScript Document

var BannerRotatorActive = 0;
//var ContentBodyActive = 0;
var FooterCounter = 0;
var FooterOnFocus = '';
var ContentVisible = 0;
var footerLoaded = 0;

var onFocus=0;
var mouseover_cntr=0;
var currentNav =  '';
var cntr=0;
var img_gallery_count=0;


var weatherCounter=1; //weather counter 
var weatherLocCount=3; //Total number of wheater Locations (dubai, abu dhabi, sharjah....)


function topMenuOver(navToShow)
{
	
	BannerRotatorActive = 0;
	
	if(currentNav != navToShow)
	{
		mouseover_cntr = 0;
		currentNav = navToShow;
	}
	else
	{
		mouseover_cntr++;	
	}
		
	jQuery('div#menuEffectsBG').css("visibility","visible");
	
	//var tmp = document.getElementById('contentBody');

	//if(tmp !='' || tmp!=null)
	
		setOpacityEffects('contentBody','in');
		bookingIEFixIN();	

		//document.getElementById('contentBody').className = "contentBody opacityEffectMenu";

	//alert(document.getElementById('contentBody').className);
	var navObj = jQuery('ul#'+navToShow);
	 

	
	if(mouseover_cntr == 0)
	{
		var navObj = jQuery('ul#'+navToShow);
		navObj.fadeIn("slow");
		
		
	} 
	else
	{
		navObj.css("display","block");
	}
}


function setOpacityEffects(id,stat)
{ 	
	if(jQuery('#'+id).length > 0)
	{

		var x = document.getElementById(id);
		
		var c_name = x.className;
		
		
		if(stat=='in')
		{
			x.className = c_name + ' opacityEffectMenu';
			//jQuery('div.'+c_name).addClass('opacityEffectMenu');
		}
		else
		{
			x.className = c_name.replace('opacityEffectMenu','');
			//jQuery('div.'+c_name).removeClass('opacityEffectMenu');
			
		}
			//alert(x.className);
		
	}
	
}


function bookingIEFixIN()
{
	
	
	
	if(jQuery('div.form_col1').length > 0)
	{
		jQuery('div.form_col1').addClass('opacityEffectMenu');
		jQuery('div.form_col2').addClass('opacityEffectMenu');
		
	}
}

function bookingIEFixOUT()
{
	if(jQuery('div.form_col1').length > 0)
	{
		jQuery('div.form_col1').removeClass('opacityEffectMenu');
		jQuery('div.form_col2').removeClass('opacityEffectMenu');
	}		
}



function topMenuOut (navToShow)
{
	

	BannerRotatorActive = 1;

	var navObj = jQuery('ul#'+navToShow);
	
	
	navObj.css("display","none");
	
	jQuery('div#menuEffectsBG').css("visibility","hidden");
	
	setOpacityEffects('contentBody','out');
	bookingIEFixOUT();
		//document.getElementById('contentBody').className="contentBody";

	
}


function showUpItems()
{
	
	if(ContentVisible == 0)
	{

		jQuery('div#contentBody').fadeIn("slow");
		//jQuery('div#contentBody').show();
		jQuery('div#weather').fadeIn("slow");
		BannerRotatorActive = 1;
	}
	ContentVisible = 1;
}

var counter=1;

function slideY_Up (id, step, final_H, pause) {
	/*
	var h=0;
	
  	obj = document.getElementById(id);
   	FooterCounter++;
   
 	h =  parseInt(obj.offsetHeight);
	h += step;
	
	if (h <= final_H && FooterOnFocus==0) {
			
		if(FooterCounter>=pause)
		{
			obj.style.height = (h+'px');
		}
		setTimeout("slideY_Up('" + id + "'," + step + "," + final_H + "," + pause + ")",50);
	  }
	  
	  document.getElementById('cntr').innerHTML = 'h=' + h + ' final_H=' + final_H;
		BannerRotatorActive = 0;
		
		
		if(h >= final_H )
			BannerRotatorActive = 1; //Enable Banner Rotation when Done
		else
			BannerRotatorActive = 0; //Disable Banner Rotation
		*/
}


function slideY_Down (id, step, final_H, pause) {
	
	
	
	/*
	var h=0;
	
  	obj = document.getElementById(id);
   	FooterCounter++;
   
 	h =  parseInt(obj.offsetHeight);
	h -= step;
	
	if (h >= final_H) {
			
		if(FooterCounter>=pause)
		{
			obj.style.height = (h+'px');
		}
		setTimeout("slideY_Down('" + id + "'," + step + "," + final_H + "," + pause + ")",50);
	  }
	  
	  document.getElementById('cntr').innerHTML = 'h=' + h + ' final_H=' + final_H;

		if(h < final_H )
		{
			footerLoaded = 1;
			FooterCounter = 0;
			showUpItems(); //Next Animation When Finish
			BannerRotatorActive = 1; //Enable Banner Rotation when Done
		}
		else
			BannerRotatorActive = 0; //Disable Banner Rotation
	*/
}

function showFooter()
{
		
		/*cntr=0;
		if(footerLoaded == 1)
		slideY_Up('footerContainer',20, 160, 2);
		*/
}

function hideFooter()
{
		
		/*cntr++;
		
		var h = parseInt(document.getElementById('footerContainer').offsetHeight)
		
		//alert(h);
		if(h>=20 && cntr == 1 )
		{
			slideY_Down('footerContainer',20, 20, 2);
		}*/
		
		
	
}

function toggleFooter()
{
		jQuery('#footerContainer').toggle('clip');
	
		if(jQuery('#showhidetext').html()=='Hide') 
			jQuery('#showhidetext').html('Show');
		else
			jQuery('#showhidetext').html('Hide');
}


function loadImageGalleryContainer()
{
		
		var scr_width =  screen.width;
		var scr_height = screen.height;
		
		if(jQuery(document).height()>scr_height)
			scr_height =jQuery(document).height();

		
		jQuery('div#imageGalleryContainer').css("height",scr_height);
		
		if(scr_width >= 1024)
			scr_width += 400;
		else
			scr_width += 1000;

}


function loadVideoContainer()
{
		
		var scr_width =  screen.width;
		var scr_height = screen.height;
		
		if(jQuery(document).height()>scr_height)
			scr_height =jQuery(document).height();
			

		//alert('document height=' + jQuery(document).height() + 'screen hieght=' + (screen.height) );		
		
		jQuery('div#videoContainer').css("height",scr_height);
		
		if(scr_width >= 1024)
			scr_width += 400;
		else
			scr_width += 1000;
}



function Gallery_MoveToPrevious()
{
  new Effect.Move('imageGallerySlider', { x: 190, y: 0, transition: Effect.Transitions.sinoidal });
}

function Gallery_MoveToNext()
{
  new Effect.Move('imageGallerySlider', { x: -190, y: 0, transition: Effect.Transitions.sinoidal });
}


function setBGEffects(container, stat)
{
	BannerRotatorActive = 0;
	var curClass = document.getElementById(container).className;
	var newClass = curClass + ' ' + 'bgTransparent';
	
	
	document.getElementById(container).className = newClass;


}

function removeBGEffects(container)
{
	BannerRotatorActive = 1;
	var curClass = document.getElementById(container).className;
	var newClass = curClass.replace('bgTransparent','');
	
	
	document.getElementById(container).className = newClass;

}

function loadWeather()
{
	jQuery.ajaxSetup ({
		cache: false
	});
	var ajax_load = "<img src='images/loading.gif' alt='loading...' />";
	
//	load() functions
	var loadUrl = "weather.php";
	
		jQuery("#weather").html(ajax_load).load(loadUrl);
	

}




function rotateWeather()
{
	jQuery('div#weatherItem'+(weatherCounter-1)).css("display",'none');
	
	if(weatherCounter==1)
		jQuery('div#weatherItem'+weatherLocCount).css("display",'none');
	
	//jQuery('div#weatherItem'+weatherCounter).css("display",'block');
	jQuery('div#weatherItem'+weatherCounter).fadeIn("slow");

}


 
 jQuery(document).ready(function() {		
 	var zIndex = 0;  
 	FooterActive=1;
   //slideY_Down('footerContainer',20, 20, 10);
   showUpItems();
   
});
 
 
function openBooking()
{
	myLightWindow.activateWindow({href: 'balloon_forms/', width: 640});
}
 
function loadVideo(flvfile, prev_image, flvtitle)
{
	var tmp_url = "flvplayer/index.php?file=" + flvfile;
	
		//tmp_url =escape(tmp_url);
		
		
	//alert(tmp_url);
	myLightWindow.activateWindow(
								 {href:tmp_url , width: 575, height:435, title:flvtitle}); //Actual Video Size = 570x420
}



function downloadimage(img_path)
{
	file_downloader = '/filedownloader.php?file=' + img_path;	
	
	//alert(file_downloader);	
	window.location.href = file_downloader;
}





/*** BEGIN PROMOTIONS **/
jQuery(document).ready(function(){
  jQuery.ajax({
	dataType: 'json',
	url: "balloon_forms/getSeats.php?lang="+PageLang,
	success: function(resp)
	{		
			if(parseInt(resp.isActive)==1)
				decorate_promo(resp);
	}
	});
  
});

function decorate_promo(jsonData)
{
  $str = '<a href="?page=booking">';
  $str += '<div id="promo_container" class="promo_container">';
  $str += '<div class="promo_seats"><span class="seats_num">'+ jsonData.seats +'</span> <br /> <span class="seats_title">'+jsonData.seats_text+'</span> </div>';
  $str += '<p>'+jsonData.title+' <br />'+jsonData.updated+'<br />';
  $str += '<img class="book_now_gif" src="/images/booknowanimated.gif" /></p>';
  $str += '<div class="clearFloat"></div>';
  $str += '</div>';
  $str += '</a>';
  jQuery(".communityGroup").prepend($str);
}
/*** END PROMOTIONS **/

function highlightText(obj) {
	//alert(obj);	
	//alert('highlight');
	
	if (obj == 'undefined')
		obj = document.getElementById('contentHL');
	else
		obj = document.getElementById(obj);
		
	obj.className = "highlightText";
}

function unhighlightText(obj) {
	//alert(obj);	
	//alert('un-highlight');
	if (obj == 'undefined')
		obj = document.getElementById('contentHL');
	else
		obj = document.getElementById(obj);
		
	obj.className = "unhighlightText";
}






