// <summary>
// Global function calls
// </summary>

var AppPath="index.asp";
function ExecuteMethod(){
 if (window.location.href.toLowerCase().indexOf("cmspagemode=edit")>0){
  return false;
 }
 $(document).ready(function(){
	 AssignCSSSelectors();
	 AssignLinks();
  FixFonts();
  HandleScrollarea();
  InitializeMenu();
 });
}

// <summary>
//  Setting the dropdown Navigation
// </summary>

function InitializeMenu()
{
 $("#Navigation").children().each(function(){
  $(this).hover(function(){
   if ($(this).children("ul").length > 0 ){
 	   $(this).find("ul").css({display:"block"});
 	  }	
  },
  function(){
    if ($(this).children("ul").length > 0 ){
 	   $(this).find("ul").css({display:"none"});
 	  }	  	
   }
  );
 });
}


// <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 FixFonts()
{
 var FontPath = AppPath + 'Fonts/Friz';
 // $("h2").sifr({
	//  font: FontPath,
   //color: '#727272'
  //});
  
  //$(".InnerPage h2").sifr({
	//  font:  FontPath,
  // color: '#00a4a7'
 // });
  
  // $("#Caption h2").sifr({
	//  font:  FontPath,
  // color: '#00a4a7'
 // });
  
  $("h3").sifr({
	  font: FontPath,
   color: '#000000'
  });
  $("h4").sifr({
	  font: FontPath,
   color: '#fdb813'
  });
}

// <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 functions handle Homepage Scrollarea animation
// </summary>

function HandleScrollarea(){
 $("#Scrollarea ul").css({height:"40px", overflow: "hidden",opacity: 0});
 $("#Canvas img").css({opacity:0});
 $("#Scrollarea ul").animate({opacity: 1},{queue:false,duration:1000,easing: "easeInQuad",complete:function(){
  $("#Canvas img").animate({opacity: 1},{queue:false,duration:1200,easing: "easeInQuad"}); 
  if(jQuery.browser.msie){
   $("#Scrollarea ul").css({opacity: 0.8});
  }
 }
});

$("#Scrollarea ul li:first").addClass("Active");
$("#Scrollarea ul").children().each(function(){
 $(this).hover(
  function(){
   var ImgName = $(this).find("a").attr("rel");
   if ($(this).hasClass("Active")){
    return false;
   }
   $("#Scrollarea ul li").removeClass("Active");
   $(this).addClass("Active");
   $(this).css({opacity:0.2});
   $(this).animate({opacity: 1},{queue:false,duration:600,easing: "easeInQuad"});
   $("#Canvas img").stop().animate({opacity: 0},{queue:false,duration:600,easing: "easeInQuad",complete:function(){
    $("#Canvas img").attr("src", "Images/Content/" + ImgName + ".jpg");
    $("#Canvas img").animate({opacity: 1},{queue:false,duration:600,easing: "easeInQuad"});
   }});
  },
  function(){
  });
 });
}

// <summary>
//  Update panel loading animation functions
// </summary>
function onUpdatingForm(elementId){
	$.extend($.blockUI.defaults.overlayCSS, { backgroundColor: '#000000' });
 $('#' + elementId).block('<img src="../images/Brotation.gif" border="0" />',{ background: 'transparent', border: '0' });
}

function onUpdatedForm(elementId){
 $('#' + elementId).unblock();
}
