// <summary>
// Global function calls
// </summary>
function executeHandler(){
$(document).ready(function(){
	AssignCSSSelectors();
	AssignLinks();
	$(".Column1 .Navigation2>li:odd").css({marginRight: "0px"});
	$(".Listing td:odd").addClass("Second"); //adding css class "second" to all odd td's in ".Listing" table
 $(".Packages td:odd").addClass("Second");
 $(".CartTable tr:second").addClass("CartTablesecondtr");
	$("#Master").addClass("FooterBg"); //adding footer background. this method is to prevent image preaload issue with the master div
 ToggleListItem();
 InitializeMenu();
 FixFont();
});
}

// <summary>
//  Setting the dropdown Navigation
// </summary>

function InitializeMenu()
{
	$("#Navigation1 ul").children().each(function()
	{
		$(this).hover(
		function(){
		 //if (!$(this).hasClass("Highlight"))
		 //{
        //$(this).children("ul").animate( { width:"175px"},{queue:false, duration:100,easing: "easeOutQuad",complete:function(){}});  
     $(this).children(".Holder1").css({display:"block"});
		 		$(this).addClass("Active");

	//	 }	
			
		},
		function(){
		 //if (!$(this).hasClass("Highlight"))
		  //{
		 	 	 $(this).css({position:"static"});
		     //$(this).children("ul").animate( { width:"0px"},{queue:false, duration:100,easing: "easeInQuint",complete:function(){$(this).css({display:"none"});}});  
 		     $(this).children(".Holder1").css({display:"none"});
        $(this).removeClass("Active");
		//}	
	}
		);
	});
}

// <summary>
//  to fix Home css/layout related issues
// </summary>
function FixLayout()
{
var Cell1Height = $(".Cell1").height();
var Cell2Height = $(".Cell2").height();
var Cell3Height = $(".Content").height()-100;
var CommonHeight;
if ((Cell1Height > Cell2Height) && (Cell1Height > Cell3Height))
{
 CommonHeight = Cell1Height;
} 
if ((Cell2Height > Cell1Height) && (Cell2Height > Cell3Height))
{
 CommonHeight = Cell2Height;
}
if ((Cell3Height > Cell1Height) && (Cell3Height > Cell2Height))
{
 CommonHeight = Cell3Height;
}

$(".Cell1").height(CommonHeight);
$(".Cell2").height(CommonHeight);
$(".Summary:last").addClass("LastItem");
}

// <summary>
//  to fix Inner css/layout related issues
// </summary>

function FixInnerLayout()
{
var Cell1Height = $(".Column1").height();
var Cell2Height = $(".Column2").height();
if ($("#Master").height()<$(window).height())
{
	$(".Content").height($(window).height()-270);
}

if ((Cell2Height > Cell1Height))
{
 $(".Column1").height(Cell2Height);
}
}

// <summary>
//  Dropdown Navigation initialize function
// </summary>

function Rollover(ImageObject)
{
	try
	{
		var RolloverImage = ImageObject.src;
		RolloverImage = RolloverImage.replace(".gif","Active.gif")
		ImageObject.src = RolloverImage;
	}
	catch (ExceptionObject)
	{
	}
}

function Rollout(ImageObject)
{
	try
	{
		var RolloutImage = ImageObject.src;
		RolloutImage = RolloutImage.replace("Active.gif",".gif")
 	ImageObject.src = RolloutImage;
	}
	catch (ExceptionObject)
	{
	}
}

function RolloverEffect (MenuRootNodeGroupTagId,TagType)
{
	try
	{
		if (document.getElementById(MenuRootNodeGroupTagId))
		{
			var MenuRootNodeGroupTag = document.getElementById(MenuRootNodeGroupTagId);
			var MenuNodeTag = MenuRootNodeGroupTag.getElementsByTagName("LI");
			for (var i = 0; i < MenuNodeTag.length; i++)
			{
				var MenuChildNodeGroupTag = MenuNodeTag[i].getElementsByTagName(TagType);
				if (MenuChildNodeGroupTag.length > 0)
				{
					if(MenuChildNodeGroupTag[0].src.indexOf("Active.gif")<0)
					{					
						MenuChildNodeGroupTag[0].onmouseover = new Function("Rollover(this);");
						MenuChildNodeGroupTag[0].onmouseout = new Function("Rollout(this);");
					}
				}
			}
		}
  $("#Navigation1 ul").children().hover(
  function(){
   $(this).addClass("Active");
  },
  function(){
   $(this).removeClass("Active");
  });  
	}
	catch (ExceptionObject)
	{
	}
}

// <summary>
//  Function to attach css class to dropdown element on hover
// </summary>
$.fn.hoverClass = function(c) {
 return this.each(function(){
  $(this).hover( 
   function() { $(this).addClass(c);  },
   function() { $(this).removeClass(c); }
  );
 });
};    

// <summary>
//  This function to assign target blank to the external link. html target blank is not a standard w3c validated code. insted of using target="_blank" we use rel="external" and replace the rel with javascript.
// </summary>
function AssignLinks() 
{
	$("a[rel='external']").attr("target","_blank");
	$("a[href='#']").click(function(){
		//return false;
	});
}

// <summary>
//  This function to attach non-ie css selectors to the html elements
// </summary>
function AssignCSSSelectors()
{
	if(jQuery.browser.msie)
	{
		$("li:first-child").addClass("FirstChild");
		$("li:last-child").addClass("LastChild");
		$("td:last").addClass("LastChild");
  $("tr:first").addClass("FirstChild");
	}
}


// <summary>
//  sifr replacement script.
// </summary>
function  FixFont(){
//Cufon.replace('#Navigation li a', {hover: true, fontFamily: 'TitilliumText'});
Cufon.replace('h2 span.FontNormal',{fontFamily: 'ITCSymbolBook'});
Cufon.replace('h2 span.FontBold',{fontFamily: 'ITCSymbolBold'});
Cufon.replace('#Navigation1 ul li a',{hover: true, fontFamily: 'ITCSymbolMedium'});
Cufon.replace('h2 span.FontNormalItalic',{fontFamily: 'ITC SymbolBookItalic'});
Cufon.replace('h2 span.FontBoldItalic',{fontFamily: 'ITC SymbolBoldItalic'});
Cufon.replace('ul#Attractions strong',{fontFamily: 'ITCSymbolBold'});
Cufon.replace('.ThemeCaption',{fontFamily: 'ITC SymbolBookItalic'});
//Cufon.replace('.ThemeCaption .Style1',{fontFamily: 'ITCSymbolMedium'});

}


// <summary>
//  window resize call
// </summary>
function winResize(){
 $(window).resize(function(){
  fixScreen();
 });
}

/// <summary>
///  These functions handle events generated by an Input Text box
/// </summary>

function InputTextOnFocusHandler (InputTag, DefaultText,TextType)
{
	try
	{  		
		if (InputTag.value == DefaultText)
		{
			InputTag.value = "";
			if (TextType=="Password")
			{
				//changeInputType(InputTag, "password",DefaultText,TextType);
			}
		}
		
	}
	catch (ExceptionObject)
	{

	}
}

function InputTextOnBlurHandler (InputTag, DefaultText,TextType)
{
	try
	{
		if (InputTag.value == "")
		{
			InputTag.value = DefaultText;	
			if (TextType=="Password")
			{
				//changeInputType(InputTag, "text",DefaultText,TextType);
			}
		}
	}
	catch (ExceptionObject)
	{
		//alert();
	}
}

// <summary>
//  These function changes input types dynamically
// </summary>
function changeInputType(OldObject, ObjectType,DefaultText,TextType) 
{
  var NewObject = document.createElement('input');
  NewObject.type = ObjectType;
  if(OldObject.size) NewObject.size = OldObject.size;
  if(OldObject.value) NewObject.value = OldObject.value;
  if(OldObject.name) NewObject.name = OldObject.name;
  if(OldObject.id) NewObject.id = OldObject.id;
  if(OldObject.className) NewObject.className = OldObject.className;
  NewObject.focus();
 	NewObject.onfocus = new Function("InputTextOnFocusHandler(this,'" + DefaultText + "','" + TextType +"' );");
	NewObject.onmouseout = new Function("InputTextOnBlurHandler(this,'" + DefaultText + "','" + TextType +"' );");
  OldObject.parentNode.replaceChild(NewObject,OldObject);
}

// <summary>
//  Google map function
// </summary>
function googleMapInitialize()
{
 if (GBrowserIsCompatible()) {
  $("#GoogleMap").css({display: "block"});
  var map = new GMap2(document.getElementById("GoogleMap"));
  var point;
  map.setCenter(new GLatLng(25.068648,55.306245), 13);
  point = new GLatLng(25.068648,55.306245);
  map.openInfoWindow(map.getCenter(),"<p><strong>Global Village</strong></p><p>P.O. Box 117777, Dubai<br />United Arab Emirates</p>");
  map.addOverlay(new GMarker(point));

  
 }
}

// <summary>
// this function toggles the content. Used in FAQ module
// </summary>
function ToggleListItem()
{
 $(".Toggle").find("div").hide();
 $(".Toggle").children().each(function(){
  $(this).find("a").click(function(){
  if ($(this).parent().hasClass("Clicked"))
  {
   $(this).parent().find("div").slideUp(500);
  }
  else
  {
   $(this).parent().find("div").slideDown(500);
  }
  $(this).parent().toggleClass("Clicked");
 });
 });
}

// <summary>
//  setting the lightbox for image gallery
// </summary>
function SetLightBox()
{
 $('.ImageGallery a').lightBox();
}

