/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-07-21 18:45:56 -0500 (Sat, 21 Jul 2007) $
 * $Rev: 2447 $
 *
 * Version 2.1.1
 */
(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);

/********************* Bgiframe ends ****************************/

/* start function to redraw the inheader slide & horizontal menu level 2 list */
$(function(){

if($('.in-header ul').length)
{
	margTop1='19px';
	margTop2='20px';
	margTop3='21px';
	
	if($('.in-header .btnYellowLrg').length==0)
	{
		margTop1='79px';
		margTop2='80px';
		margTop3='81px';
	}
	
	var oldImageURL = $('.in-header img').eq(0).attr('src')
	if(oldImageURL)
	{
	var newBGURL = "url('"+oldImageURL+"') no-repeat left top #7E5F31"

	$('.in-header>span').css('display','none');
	$('.in-header img').eq(0).css('display','none');
if($.browser.msie && $.browser.version==6)
{
	$('.in-header ul').css({'float':'left','position':'static','margin-top':margTop2,'clear':'both'})	
$('.in-header').css({"background":newBGURL,"float":"left","display":"inline-block","height":"200px",'overflow':'visible'})


}
else if($.browser.msie && $.browser.version==7)
{
	$('.in-header ul').css({'float':'left','position':'static','margin-top':margTop2,'clear':'both'})
$('.in-header').css({"background":newBGURL,"float":"left","display":"inline-block","min-height":"240px",'height':'auto','overflow':'visible'})
	

}
else if($.browser.msie && $.browser.version==8)
{
	$('.in-header ul').css({'float':'left','position':'static','margin-top':margTop3,'clear':'both'})
$('.in-header').css({"background":newBGURL,"float":"left","display":"inline-block","min-height":"240px",'height':'auto','overflow':'visible'})
	

}

else{

	
	$('.in-header').css({"background":newBGURL,"display":"inline-block","min-height":"240px",'height':'auto'})
	$('.in-header ul').css({'position':'relative','float':'left','margin-top':margTop1,'clear':'both'})
}
	$('.in-header .slide').css({'position':'static'})
	
	}
	
}
});
/* end: function to redraw the inheader slide & horizontal menu level 2 list */





$(function(){
	$("body").focus();
	var mouse_is_inside = false;
	
	$("#footer .callbackSection").css({
			"display":"none"
	});
	$("#requestCallbackRT").css({
			"display":"none"
	});

$(".packages .packageDetail").css({
			"display":"none"
	});	
	
	  if($(".carouselchannel").length){/*fix for channel home background*/
		$('.ls-canvas').addClass('landing');
	}	
	
	 if($(".jNiceSelectWrapper").length){/*fix for channel home background*/
		$(".jNiceSelectWrapper").parent(".jNiceWrapper").addClass("selectBox");

	}	
	
		
	 /*if($.browser.msie){  
	 if($.browser.version == 6){$('body').addClass("ie6_body");}
	 else if ($.browser.version == 7){$('body').addClass("ie7_body");}
	 else if ($.browser.version == 8){ $('body').addClass("ie8_body");}
	 }	 
	 else*/ if ($.browser.webkit) { 
	 	$('body').addClass("webkit_body");
	 }
	
	/*********************************************************************
	add bgIframe for dropdown and select box list z-indexing over IE6 */
	if($.browser.version == 6){ $(".subNav").bgIframe();}
	/*********************************************************************/
	 
	 
	/*********************************************************************
	Register now  detailsPane and  preferencePane dynamic same height code
	**********************************************************************/
		if($(".genericFormPane").length){
			if($(".selectBox").length){
				
				$(".selectBox").parent(".row").addClass("selectrow");
				}
		}
			
	/*********************************
	Calender code
	*********************************/
	if($("#txtDatePicker").length){
	$( "#txtDatePicker" ).datepicker({
			showOn: "button",
			buttonImage: "images/iconCalender.gif",
			buttonImageOnly: true
		});
	}
	/**********************************
	 ** SET SUB MENU EQUAL HEIGHT
	 *********************************/	
	$("#mainNavigation li div.subNav").each(function(){
		var menuChilds = $(this).children().not(".menuFooter");
		var colHeight =[];
		menuChilds.each(function(){
			colHeight.push(parseInt($(this).height()));
		});
		if($.browser.msie && ($.browser.version == 6 || $.browser.version == 7)) {
			menuChilds.css('height',colHeight.getMax())
		}
		else{
		menuChilds.css('min-height',colHeight.getMax())
		}

	});
	
	/**********************************
	 ** Main top navigation dropdowns
	 *********************************/
	 
	/**
	* hoverIntent is similar to jQuery's built-in "hover" function except that
	* instead of firing the onMouseOver event immediately, hoverIntent checks
	* to see if the user's mouse has slowed down (beneath the sensitivity
	* threshold) before firing the onMouseOver event.
	* 
	* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
	* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
	*/
	
	(function($) {
		$.fn.hoverIntent = function(f,g) {
			// default configuration options
			var cfg = {
				sensitivity: 7,
				interval: 100,
				timeout: 0
			};
			// override configuration options with user supplied object
			cfg = $.extend(cfg, g ? { over: f, out: g } : f );

			// instantiate variables
			// cX, cY = current X and Y position of mouse, updated by mousemove event
			// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
			var cX, cY, pX, pY;

			// A private function for getting mouse position
			var track = function(ev) {
				cX = ev.pageX;
				cY = ev.pageY;
			};

			// A private function for comparing current and previous mouse position
			var compare = function(ev,ob) {
				ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
				// compare mouse positions to see if they've crossed the threshold
				if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
					$(ob).unbind("mousemove",track);
					// set hoverIntent state to true (so mouseOut can be called)
					ob.hoverIntent_s = 1;
					return cfg.over.apply(ob,[ev]);
				} else {
					// set previous coordinates for next time
					pX = cX; pY = cY;
					// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
					ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
				}
			};

			// A private function for delaying the mouseOut function
			var delay = function(ev,ob) {
				ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
				ob.hoverIntent_s = 0;
				return cfg.out.apply(ob,[ev]);
			};

			// A private function for handling mouse 'hovering'
			var handleHover = function(e) {
				// copy objects to be passed into t (required for event object to be passed in IE)
				var ev = jQuery.extend({},e);
				var ob = this;

				// cancel hoverIntent timer if it exists
				if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

				// if e.type == "mouseenter"
				if (e.type == "mouseenter") {
					// set "previous" X and Y position based on initial entry point
					pX = ev.pageX; pY = ev.pageY;
					// update "current" X and Y position based on mousemove
					$(ob).bind("mousemove",track);
					// start polling interval (self-calling timeout) to compare mouse coordinates over time
					if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

				// else e.type == "mouseleave"
				} else {
					// unbind expensive mousemove event
					$(ob).unbind("mousemove",track);
					// if hoverIntent state is true, then call the mouseOut function after the specified delay
					if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
				}
			};

			// bind the function to the two event listeners
			return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover);
		};
	})(jQuery);
	
	$(document).ready(function() {
		//On Hover Over
		function megaHoverOver(){
			$(this).find(".subNav, .subNav .main, .subNav .list, .subNav .menuFooter").stop().fadeTo('fast', 1).show(); //Find subNav and fade it in
			var subNavTopPos = ($(this).position().top)+($(this).height());
			$("div.subNav", this).css({'left':'0px','top':subNavTopPos});
			$("div.subNav", this).addClass("displayClass");
		}
		//On Hover Out
		function megaHoverOut(){
			$(this).find(".subNav, .subNav .main, .subNav .list, .subNav .menuFooter").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
			$(this).hide();  //after fading, hide it
			$("div.subNav", this).removeClass("displayClass");
		  });
		}
		//Set custom configurations
		var config = {
			 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
			 interval: 100, // number = milliseconds for onMouseOver polling interval
			 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
			 timeout: 700, // number = milliseconds delay before onMouseOut
			 out: megaHoverOut // function = onMouseOut callback (REQUIRED)
		};

		$("ul#mainNavigation li .subNav, ul#mainNavigation li .subNav .main, ul#mainNavigation li .subNav .list, ul#mainNavigation li .subNav .menuFooter").css({'opacity':'0'}); //Fade subNav nav to 0 opacity on default
		$("ul#mainNavigation li").hoverIntent(config); //Trigger Hover intent with custom configurations
	});
	
	$("#mainNavigation li").hover(
		function(){ 
			$(".subNav").removeClass("menuFocus");
			$("a", this).eq(0).addClass('hover');
			//var subNavTopPos = ($(this).position().top)+($(this).height())
			//$("div.subNav", this).css({'left':'0px','top':subNavTopPos});
			//$("div.subNav", this).addClass("displayClass");
		},
		function(){
			$("a", this).eq(0).removeClass('hover');
			//$("div.subNav", this).css('left' , '-9999%');
			//$("div.subNav", this).removeClass("displayClass");
		}
	);
	$("#mainNavigation .subNav .main a.big4").each(function(){
		$(this).next().css({'margin-top':'10px'});
	})
	
	function collapsePanel(){
	// hide the item you dont want to display
		$("#mainNavigation li .subNav").css('left' , '-9999%');
	}
	
	/*Start: Navigation with Tab forward*/
	$("#mainNavigation li a.nav").focus(function() {
		    $("a.nav").removeClass("hover");									 
		    $(".subNav").removeClass("menuFocus");	 
			$("ul#mainNavigation li .subNav, ul#mainNavigation li .subNav .main, ul#mainNavigation li .subNav .list, ul#mainNavigation li .subNav .menuFooter").css('opacity', '1');	
			$(this).addClass("hover");
			$(this).next(".subNav").addClass("menuFocus");
	});
	/*end*/
	/*Start: Navigation with Shift+Tab [tab backward]*/
	$("#mainNavigation .subNav a").focus(function() {
			$("a.nav").removeClass("hover");
			$(".subNav").removeClass("menuFocus");		 					 
			$("ul#mainNavigation li .subNav, ul#mainNavigation li .subNav .main, ul#mainNavigation li .subNav .list, ul#mainNavigation li .subNav .menuFooter").css('opacity', '1');
			$(this).parents(".subNav").prev("a.nav").addClass("hover");
			$(this).parents(".subNav").addClass("menuFocus");
	});
	
	/*end*/
	
	$(".subNav .menuFooter .routePlaner a:last-child").blur(function(){
			$("a.nav").removeClass("hover");	
			$(".subNav").removeClass("menuFocus");						
	});

	/**********************************
	 ** Iphone , Ipad, Ipod Code
	 *********************************/
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
	  var navItem = jQuery("#mainNavigation li a.nav");
	 navItem.attr('href' , '#a');
	 navItem.click(
			function(){
			navItem.removeClass('hover');
			$("div.subNav").css('left' , '-9999%');
			$(this).attr('href','#a');
			if(($("#mainNavigation li:first-child a.nav").text())== "Home"){ 
				navFirstTitle = $("#mainNavigation li:first-child a.nav").attr('data-rel');
				$("#mainNavigation li:first-child a.nav").attr('href',navFirstTitle);
			 }
   			navTitle = $(this).attr('data-rel');
			if($(this).eq(0).next("div.subNav").hasClass("dropMenu")){ 
				navItem.attr('href',navTitle);
			};
			$("div.subNav").removeClass("dropMenu");
			$(this).addClass('hover');
			$(this).eq(0).next("div.subNav").css('left' , '0');
			$(this).eq(0).next("div.subNav").addClass("dropMenu");
		});
	 
		$('#mainNavigation li').click(function(){ 
        	mouse_is_inside=true; 
    		}, function(){ 
        	mouse_is_inside=false; 
    	});
		$("#headerOuter, #wrapperOuter, #footer").click(function(){
			if(! mouse_is_inside) {collapsePanel();}
		});
		$("#footer").css('width' , '1024px');
		$(".landing").css('width' , '1024px');
		$(".btnBiege Input").wrap('<span class="btnBiegeInner"></span>');
		$(".currentLocation .buttonBlackSm input").wrap('<span class="buttonBlackSmInner"></span>');
		$(".currentLocation .buttonBlackSm input").css("background","none");
		$(".btnYellowLrgWht Input").wrap('<span class="btnYellowLrgWhtInner"></span>');
		$(".btnYellowLrgGrey Input").wrap('<span class="btnYellowLrgGreyInner"></span>');
		$(".btnBiegeLight Input").wrap('<span class="btnBiegeLightInner"></span>');
		$(".btnYellowSm Input").wrap('<span class="btnYellowSmInner"></span>');
		$(".btnGreyLrg Input").wrap('<span class="btnGreyLrgInner"></span>');
		$(".buttonSearchSite Input").wrap('<span class="buttonSearchSiteInner"></span>');
	
	};	
	
	/**********************************
	 ** Android Code
	 *********************************/
	 if((navigator.userAgent.match(/Android/i))) {
	 var navItem = jQuery("#mainNavigation li a.nav");
	 navItem.attr('href' , '#a');
	 navItem.click(
		function(){
			navItem.removeClass('hover');
			$("div.subNav").css('left' , '-9999%');
			$(navItem).attr('href','#a');
			if(($("#mainNavigation li:first-child a.nav").text())== "Home"){ 
				navFirstTitle = $("#mainNavigation li:first-child a.nav").attr('data-rel');
				$("#mainNavigation li:first-child a.nav").attr('href',navFirstTitle);
			 }
   			navTitle = $(this).attr('data-rel');
			if( $(this).eq(0).next("div.subNav").hasClass("dropMenu")){
				navItem.attr('href',navTitle);						
			};
			$("div.subNav").removeClass("dropMenu");
			$(this).addClass('hover');
			$(this).eq(0).next("div.subNav").css('left' , '0px');
			$(this).eq(0).next("div.subNav").addClass("dropMenu");
		});
		$('#mainNavigation li').click(function(){ 
        	mouse_is_inside=true; 
    		}, function(){ 
        	mouse_is_inside=false; 
    	});
		$("#headerOuter, #wrapperOuter, #footer").click(function(){
			if(! mouse_is_inside) {collapsePanel();}
		});
		$("#footer").css('width' , '1024px');
		$(".landing").css('width' , '1024px');
		$(".btnBiege Input").wrap('<span class="btnBiegeInner"></span>');
		$(".currentLocation .buttonBlackSm input").wrap('<span class="buttonBlackSmInner"></span>');
		$(".currentLocation .buttonBlackSm input").css("background","none");
		$(".btnYellowLrgWht Input").wrap('<span class="btnYellowLrgWhtInner"></span>');
		$(".btnYellowLrgGrey Input").wrap('<span class="btnYellowLrgGreyInner"></span>');
		$(".btnBiegeLight Input").wrap('<span class="btnBiegeLightInner"></span>');
		$(".btnYellowSm Input").wrap('<span class="btnYellowSmInner"></span>');$(".btnGreyLrg Input").wrap('<span class="btnGreyLrgInner"></span>');
		$(".buttonSearchSite Input").wrap('<span class="buttonSearchSiteInner"></span>');
		};	
	
	/**********************************
	 ** Travel Slider
	 *********************************/
	 $(".travelProductRight #slidesParent a").click(function(){
		var imgSrc = $(this).attr("href");
		var imgText = $(this).children("img").attr("alt");
		var imgTitle = $(this).children("img").attr("title");
		
		$(".sliderImg").attr("src",imgSrc);
		$(".sliderImg").attr("alt",imgText);
		$(".sliderImg").attr("title",imgTitle);
		$('#imageContainer').css("background-image", "url(" + imgSrc + ")");
		return false;
	 });
	 
	 /**********************************
	 ** Tabs height setting
	 *********************************/ 
	
	 function tabHeightSet(){
		 $(".tabsContainer>.three-col").css('height','auto');
		 $(".tabsContainer>.single-col").css('height','auto');
		 
		 var tabHeight = $(".tabsContainer>.three-col").outerHeight();
		 var tabHeightRight = $(".tabsContainer>.single-col").outerHeight();
		 
		 if (tabHeight > tabHeightRight){
			 $(".tabsContainer>.single-col").outerHeight(tabHeight);
			 $(".tabsContainer .three-col .single-col").css('height','auto');
		 }
		 else{
			 $(".tabsContainer>.three-col").outerHeight(tabHeightRight);
			 $(".tabsContainer .three-col .single-col").css('height','auto');
		 }
	 }
	
	 setTimeout(function() {
			tabHeightSet()
		},250);

	 $(".tabs ul.right-nav li a").click(function(){
	 setTimeout(function() {
			tabHeightSet()
		},500);	 
	 });	 

	/**********************************
	 ** TEXT INPUTS FOCUS IN AND OUT
	 *********************************/
	 $("input[type=text]").each(function(){
		var textBoxTitle = $(this).attr("value");
		$(this).focus(function(){
			if(textBoxTitle == $(this).attr("value"))
			{
				
				if(! mouse_is_inside){
				$(this).attr("value", "");
				mouse_is_inside = true;
				}
			}
		});
		
		$(this).blur(function(){
			mouse_is_inside = false;
			if($(this).attr("value") == "")
			{
				$(this).attr("value", "");
			}
		});
	});
	// package details content
	if($(".breakPanel").length)
	{
		$(".breakPanel a").packageDetail();
	}
	// package details content
	if($(".popWindow").length)
	{
		$(".popWindow ul li a").popWindowToolTip();
	}
	
	if($(".twitter").length)
	{
		getTwitter();
	}
	aaBookmarks(); /*calling bookmark function*/
});


/**********************************
 ** PACKAGE DETAIL show/hide
 *********************************/
	
$.fn.packageDetail = function(){
	$(this).click(function(){
		var currentIndex = $(".breakPanel a").index(this);
		$(".packageDetail").slideUp('fast');
		$(".breakPanel").removeClass("hoverBg");
		if($(".packageDetail").eq(currentIndex).css('display') == "none")
		{
			$(".packageDetail").eq(currentIndex).slideDown('nomal');
			$(".breakPanel").eq(currentIndex).addClass("hoverBg");
		}
		else
		{
			$(".packageDetail").eq(currentIndex).slideUp('nomal');
		}
		return false;
	});
}

/**********************************
 ** PACKAGE DETAIL show/hide END
*********************************/

/**********************************
 ** Tool Tip show/hide
*********************************/
$.fn.popWindowToolTip = function (){
	$(".popWindow ul li a").addClass("toolTipLink");
	$(".popWindow ul li:last-child").addClass("last");
	$('.toolTip a').removeClass("toolTipLink");
	
	$(this).click(function(e){
		$('.toolTip a').removeClass("toolTipLink"); 
	   $('.toolTipBox').hide();
	   var currentIndex = $(".popWindow ul li a.toolTipLink").index(this);
	   var lengthAnchor = $(".popWindow ul li a.toolTipLink").eq(currentIndex).width(); 
	   var leftPos = $(this).position().left;
	   var topPos = $(this).parents("li").position().top;
	   var heightToolBox = $('.toolTipBox').eq(currentIndex).height(); 
	   if( heightToolBox > 500){	
		   	heightToolBox = 500;
			$('.toolTipBox').eq(currentIndex).css("height" , 500)
			$('.toolTip').eq(currentIndex).css("height" , 500)
			$('.toolTip .rteContainer').eq(currentIndex).css({"height":"480","display":"block","padding-right":"20px","width":"305px"})
			$('.toolTip .rteContainer').eq(currentIndex).css("overflow-x" , "hidden")
			$('.toolTip .rteContainer').eq(currentIndex).css("overflow-y" , "scroll")
		}
	 
	   var toolTipTop = heightToolBox/2;
	   var totalLeft = lengthAnchor + leftPos ;
	   
		$(".toolTipBox").eq(currentIndex).css({ 
			left: totalLeft,
			top:(topPos - toolTipTop) + 20
		});
		$(".toolTipBox .arrow").eq(currentIndex).css({ 
			top:toolTipTop - 20
		});
		
	$('.toolTipBox').eq(currentIndex).show();
		return false;
	})
	
	$('.closeThis').click(function(e){
		$('.toolTipBox').hide();
		$(this).parents("li").eq(0).find('a').focus();						  
		return false;
	});
	
	$('.findoutList ul li.last').children(".toolTipBox").children(".toolTip").children('a').blur(function(){
		$("#txtregNumsingle").focus();																								  
	})
	return false;
}

/**********************************
 ** Tool Tip show/hide END
*********************************/
 
 /**********************************
 ** GET TWITTER
 *********************************/
 
 var getTwitter = function(){
 	var twitter_user = $("#twitter_user").val();
 	var twitter_feeds = $("#twitter_feeds").val();
	var panel = $('.twitter');
	var tweet = '';
 	panel.html("");
	
	
	//url :  window.location.protocol + '//search.twitter.com/search.json?from=' + twitter_user,

	if( panel.length > 0 ) {
	 
	 $.ajax({
		type : 'GET',
		dataType : 'jsonp',
		timeout : 3000,
		
		url :  window.location.protocol + '//api.twitter.com/1/statuses/user_timeline.json?include_entities=true&exclude_replies=true&count=" + twitter_feeds + "&screen_name=' + twitter_user,
		success : function(tweets) {
			if(twitter_feeds > tweets.length)
				twitter_feeds = tweets.length;
			for(var i=0;i<twitter_feeds;i++)
			{
					var text = tweets[i].text;
					var href = window.location.protocol + '//twitter.com/#!/' + twitter_user;
					var img = tweets[i].user.profile_image_url;
					

					var tweetLink = $("<a></a>").attr({
						"href": href,
						"title": text
					});
					
					var tweetImg = $("<img />").attr({
						"src": img,
						"title": twitter_user,
						"alt": twitter_user
					});
					var tweetDiv = $("<div></div>").css("display", "none");
					var tweetText= $("<p></p>").html(text);
					
					tweetLink.append(tweetImg);		
					tweetDiv.append(tweetLink).append(tweetText);					
					panel.append(tweetDiv);
			}
	
			$(panel).cycle({ 
				speedIn:  2000, 
				speedOut: 500, 
				delay:   8000,
				timeout: 10000
			});
		},
		error : function (xhr, ajaxOptions, thrownError){
			var tweetDiv = $('<div class="twittererror"></div>');
			var tweetText= $("<p></p>").html("Twitter Feed unavailable.");
			tweetDiv.append(tweetText);
			panel.append(tweetDiv);
		}
	 });
	 

	
	}
					
			
}
 /**********************************
 ** GET TWITTER ENDS
 *********************************/
Array.prototype.getMax = function()
{
	var max = Number.MIN_VALUE, v, len = this.length, i = 0;
	for (; i < len; ++i)
	if (typeof (v = this[i]) == 'number')
	max = Math.max(max, v);
	return max;
}

 /**********************************
 ** Reset Text Field Value on Blur
 *********************************/
 function setValue(fVal){
	 if(fVal.value == ''){
		 fVal.value=$(fVal).next().val();
	 }
 }
 
 /**********************************
 ** Reset Text Field Value on focus
 *********************************/
 function clearText(field){
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}
 
 /**********************************
 ** Set empty divs height to 0
 *********************************/ 
 if($.browser.msie){  
 	if($.browser.version < 8){
 		if($('div').is(':empty')){ 
							$(this).css({'display' : 'block' , 'line-height' : '0' , 'height' : '0' , 'overflow' : 'hidden' , 'zoom' : '1' });
		}
		if($.trim($(".productsSlider").text()) == "") {
			$(".productsSlider").hide();
		} 
		if($.trim($(".fourColRow").text()) == "") {
			$(".fourColRow").hide();
		} 
	}
  }
  $(function(){
	if($(".landing .contentIn .iw_component").length) {
	//
	 } 
	 else{
	 $('.landing .contentIn').css('padding','0');
	 }
  });
 /*end*/
 /**********************************
 ** Set product slider container 
 	height from js
 *********************************/ 
 $(function(){
	$(".productFooter .productsSlider").css('height','197px');
	$("#ferry_1").show();
	$("#ferry_2").hide();
	$("#ferry_3").hide();
	var Imgheight = $(".findBreak .leftCol img").height();
	$(".findBreak").height($(".findBreak").outerHeight());
	$(".findBreak .leftCol img").css('top',$(".findBreak").outerHeight()-Imgheight );
	/*back to top link*/
	$(".topLink").click(function(){
		$('html, body').animate({scrollTop:0}, 'slow');
		return false;
	});
	
	/*tabcontent internal bookmarking based on text*/
	$(".tabContent .tableOfContent a").click(function(){
		var scrollToElement = $(this).children().text();
		$('html, body').animate({scrollTop: $("h3[title='" + scrollToElement + "']").offset().top }, 1000); 
		return false;
	});
	
	

	 /**********************************
	 ** New Tabs for special offer page
	 *********************************/ 
	$(".newtabArea .tabContent").hide();
	
	var newtabLiCount = $(".newtabArea ul.tabs_nav li").length;
	
	$(".newtabArea ul.tabs_nav li").css("height","136px");
	$(".newtabArea ul.tabs_nav li a.visited").click(function(){
	$(".newtabArea ul.tabs_nav li").removeClass("selected");
	$(this).parent("li").addClass("selected");
	$(this).focus();
	$(".newtabArea .tabContent").hide();
	$(".newtabArea .selected .tabContent").show();
	if (newtabLiCount <= 3){
	$(".newtabArea ul.tabs_nav").height($(".newtabArea .selected .tabContent").outerHeight()+5);
	}
	});
	$(".newtabArea .tabContent").addClass("tabReady");
	var newTabLI = $(".newtabArea ul.tabs_nav li").index($("li.selected"));
	setTimeout(function() {
			
			$(".newtabArea .tabContent").hide();
			$(".newtabArea .selected .tabContent").show();
			if (newtabLiCount <= 3){
			$(".newtabArea ul.tabs_nav").height($(".newtabArea .selected .tabContent").outerHeight()+5);
			}
			if (newtabLiCount > 3){
			$(".newtabArea ul.tabs_nav").height(newtabLiCount*($(".newtabArea ul.tabs_nav li").height()));
			}
		},250);
	
	$(".newtabArea .tabContent a").click(function(){
		  location.href=$(this).attr('href');
		  return false;
		  });
	/**********************************/ 


});

var currentTallest = 0;
$.fn.equalHeights = function(px) {

 $(this).each(function(){
					    
  $(this).each(function(i){
   if ($(this).height() > currentTallest) { 
     currentTallest = $(this).height(); 
     }
  });
  //if (!px || !Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm(); //use ems unless px is specified
  // for ie6, set height since min-height isn't supported
  if ($.browser.msie && $.browser.version == 6.0) { $(this).css({'height': currentTallest}); }
  $(this).css({'height': currentTallest}); 
  //jQuery(this).css('display','inline-block');  
 });
 return this;
};


 /**********************************
 ** Text Area Character Count
 *********************************/ 
 $(function(){
	// controls character input/counter
	$('textarea#txtSummary').keyup(function() {
	var charLength = $(this).val().length;
	// Displays count
	$('span#charCount').html(charLength + ' of 1450 characters used');
	// Alerts when 250 characters is reached
	if($(this).val().length > 1450)
	$('span#charCount').html('<strong>You have exceeded 1450 characters.</strong>');
	});
 });
 $(function(){
	if($('#charCount').text().length){
	 $('.textareaGeneric').next().css({'position':'relative','top':'15px'});
	 if($.browser.msie){  
 		if($.browser.version < 7){
		$('.textareaGeneric').next().css({'position':'relative','top':'0px'});
		}
	 }
	}
 });
 
/*skip to content implemented*/
$(function(){
	if ($.browser.msie && $.browser.version == 6.0){
		$('.skipToContent').focus(function(){
			$(this).css('left','130px')					
		});		
		$('.skipToContent').blur(function(){
			$(this).css('left','-9999px')					
		});	
	}
	
	/*contact us tab hover functionality on focus */
	if ($.browser.msie && $.browser.version < 8){
	
		/*** start focus on tab functionality   ***/
		
		$('#tab-history-links li a').focus(function(){
		
			$(this).addClass('tabFocus');
		});
		$('#tab-history-links li a').blur(function(){
			//alert('in')
			$(this).removeClass('tabFocus');
		});
		
		/***  start focus on tab functionality  ***/
	}
	
});
/*end*/

/* start: function to change shift/shift tab functionality on tool tip box */
var openerLinkIndex;
$(function(){
$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());
if($.browser.chrome)
{

$('a.toolTipLink').bind('click',shiftfocusToArticle);
}
else{
$('a.toolTipLink').bind('click',shiftfocus)
	$('a.toolTipLink').bind('keydown',shiftfocus)
	$('.toolTipBox .closeThis').bind('keydown',shiftfocus)
	$('.toolTipBox .rteContainer').bind('keydown',focusNext)
}
});
function shiftfocusToArticle(e){
	var linkHTML = '<a href="#" class="focusLink" title="focusLink" style="height:0px;overflow:hidden;line-height:0;text-decoration:none;position:relative;top:18px;left:0">&nbsp;</a>'
	$(e.target).parent().parent().next().find('div.rteContainer').find('a.focusLink').remove().end().prepend(linkHTML);
	

}
function shiftfocus(e)
{		 
	 if(!($('.toolTipBox .rteContainer a').length))
	{
		 	if ((e.type =="keydown" && e.keyCode === 13) || e.type =="click")
			 {				 
				 openerLinkIndex = $('a.toolTipLink').index($(e.target))
					//alert(openerLinkIndex);
			}
		 if($(this).hasClass('closeThis'))
		 {
			 if (e.keyCode === 9 && e.shiftKey === false)
			 {				 
				 e.preventDefault();
				$(this).next().next().focus();
			}
			if (e.keyCode === 9 && e.shiftKey === true)
			 {				 
				 e.preventDefault();
				$(this).parent().parent().prev().find('.toolTipLink').focus();
				 openerLink=true;
			}
			
		}
		else if(($(this).hasClass('toolTipLink')) && ($('a.toolTipLink').index($(e.target)) ==(openerLinkIndex+1)))
		{
			if (e.keyCode === 9 && e.shiftKey === true)
			 {				 
				
				//if(($('a.toolTipLink').index($(e.target))) ==(openerLinkIndex+1))
				{				
					e.preventDefault();
					$(this).parent().parent().parent().prev().find('div.rteContainer').focus();
				}
			}
		}
	}
}
function focusNext(e)
{
	if (e.keyCode === 9 && e.shiftKey === true)
	 {				 
		
		//if(($('a.toolTipLink').index($(e.target))) ==(openerLinkIndex+1))
		{				
			e.preventDefault();
			$('.toolTipBox .closeThis').focus();
		}
	}
	if (e.keyCode === 9 && e.shiftKey === false)
	 {				 
		
		//if(($('a.toolTipLink').index($(e.target))) ==(openerLinkIndex+1))
		{				
			e.preventDefault();
			$('a.toolTipLink').eq(openerLinkIndex+1).focus();
		}
	}
}

/* end: function to change shift/shift tab functionality on tool tip box */

/*Social Bookmarking Code*/
function aaBookmarks() {
var path = window.location.href;
var title = document.title;
var aaBookmarks_div = document.getElementById("aaBookmarks");
if(aaBookmarks_div) {
aaBookmarks_div.innerHTML = '<h3>Save this link on:</h3>' +
'<ul>' +
'<li class="delicious"><a href="http://del.icio.us/post?url='+path+'&amp;title='+title+'" target="_blank">del.icio.us</a></li>' +
'<li class="digg"><a href="http://digg.com/submit?url='+path+'&amp;title='+title+'" target="_blank">digg</a></li>' +
'<li class="reddit"><a href="http://reddit.com/submit?url='+path+'&amp;title='+title+'" target="_blank">Reddit</a></li>' +
'<li class="facebook"><a href="http://www.facebook.com/sharer.php?u='+path+'&amp;title='+title+'" target="_blank">facebook</a></li>' +
'<li class="stumbleupon"><a href="http://www.stumbleupon.com/submit?url='+path+'&amp;title='+title+'" target="_blank">StumbleUpon</a></li>' +
'<li class="twitterlink"><a href="http://twitter.com/home?status= %23 '+title+' '+path+'" target="_blank">Twitter</a></li>' +
'</ul>';
}
else {
return false;
}
} 

function writeDart(sz, pos,adType) {}
