/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
*/
jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend( jQuery.easing,
{
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	}
});

(function ($, undefined) {
		
	// External Link
	$(".external").click( function() {
    	window.open(this.href);
    	$(this).addClass("external");
    	return false;
    });
	
	//banner feature
	if($("#banner").length != 0){
		var bannerTimeOut;
		var menu_items = $(".sub-menu li a");
		
		function hideBanner(banner) {
			if($(banner).data("status") == false){
				$(banner).css("z-index","9").slideUp("fast");
			}
		}
		
		function showBanner(banner, tis) {
			clearTimeout(bannerTimeOut);
			if($(banner).data("status") == true){
				$(banner).stop(true, true).slideDown("fast").css("z-index","99");
				
				tis.addClass("active"); 
			}
		}
		
		// Section banner
		$(".sub-menu li").mouseover(function(){
			var tis = $(this).find("a");
			var index = menu_items.index(tis);
			var banner = $(".banners div.banner:eq("+index+")").data("status",true);
			
			menu_items.height(73).removeClass("active");
			$(".banners div.banner").not(banner).stop(true, true).slideUp("fast").css("z-index","9");
			
			showBanner(banner, tis);
			
		}).mouseleave(function(){
			var tis = $(this).find("a");
			var index = menu_items.index(tis);				
			var banner = $(".banners div.banner:eq("+index+")").data("status",false);
			
			var bannerTimeOut = setTimeout(function(){
				hideBanner(banner);
			},500); 
		});
		
		$(".banners div.banner").mouseenter(function(){
			$(this).data("status",true);
		});
		
		$(".banners div.banner").mouseleave(function(){
			hideBanner($(this).data("status",false));
			menu_items.height(73).removeClass("active");	
		});	
		
		$(".featureArea").mouseleave(function(){
			var bannerTimeOut = setTimeout(function(){
				hideBanner($(".banners div.banner"));
				menu_items.height(73).removeClass("active");
			},500); 
		});	
						
	}
	
	//slider feature
	if($("#contact_form").length != 0){
		$("#contact_form").validate();
	}
	
		
	$(".facilityBox, .fancyBox").fancybox({
		'titleShow'		: 	true,
		'width'			: 	640,
		'height'		:	390,
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'titlePosition'  :  'over',
		'onComplete'	 :	function() {
			$("#fancybox-wrap").hover(function() {
				$("#fancybox-title").show();
			}, function() {
				$("#fancybox-title").hide();
			});
		}
	});
	
	window.setTimeout(function() {
		$('.skype_pnh_container').html('');
		$('.skype_pnh_print_container').removeClass('skype_pnh_print_container');
	}, 800);
	
}(jQuery));
