function tab() {
	if($("#survey").position.left == "0px"){ //close tab
		$('#survey').animate({left: '350'}, "slow");
	} else {
		$('#survey').animate({left: '0'}, "slow");
	}
}

function close_tab() {
	$('#survey').animate({left: '-350'}, "slow");
}

function begin_survey() {
	$('#survey').animate({left: '-500'}, "slow");
	$.cookie('times', '4500', { path: '/', domain: '.sabreairlinesolutions.com', expires: 365 });
	window.open('http://www.sabresurveys.com/SE/?SID=SV_2tVvF6zg2RnSN9O','Survey'); 
	return false;
}


$(document).ready(function() {
if($("a[rel='colorbox']").length > 0){
$("a[rel='colorbox']").colorbox({iframe:true, innerWidth:725, innerHeight:415});
}

if($("a[rel^='prettyPhoto']").length>0){
		$("a[rel='prettyPhoto']").colorbox({iframe:true, innerWidth:725, innerHeight:415});
}

$("#login_container").hide();
$("#portal_modal").hide();

$("#portal_login .open_login").click(function(){
	$("#login_container").slideToggle();
	$("#portal_modal").toggle();
});

$("#portal_modal").click(function(){
	$("#login_container").slideUp();
	$("#portal_modal").hide();
});

	var currentTallest = 0;
	$('.content_container h2').each(function(){
		if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
		$('.content_container h2').css({'min-height': currentTallest});
	});
if($("#home").length>0){
	$('#main').equalHeights();
}

//survey
if($("#survey").length > 0){
//var $sentence = "To improve our site, we are conducting a short survey. <br /><br />By completing the survey, you will be entered into a drawing to win one of five $100 gift certificates.";
	//$('#survey p').html($sentence);
	
	if($.cookie('times') != ""){
		var $times = $.cookie('times');
	} else {	
		$.cookie('times', '0', { path: '/', domain: '.sabreairlinesolutions.com', expires: 365 });
		var $times = $.cookie('times');
	}

	if($times == "4500"){
		$('#survey').css('left', '-500px');
	} else {
		$times++;
		$.cookie('times', $times, { path: '/', domain: '.sabreairlinesolutions.com', expires: 365 });
	}

	if ($.cookie('times') == '3') {tab();}
}
//end survey

						   
	$(".slider").hide();
	
	$("#table p a").click(function() {
		var p = $(this).closest("p");
		$(p).find("span").toggle();
		return false
	});
	
	$("#table p span").hide();
	
	
	
	
	
		if($("#slider").length>0){
			var int = setInterval(start_show,5000);
		}
		 $("#slider").mouseover(function(){
			clearInterval(int);
		});
		 
		 $("#slider").mouseout(function(){
			int = setInterval(start_show,5000);
		});
		
		$("#slider ul a").click(function(){
			var href = $(this).attr("href");
			$(".slider").fadeOut(1200);
			$(href).fadeIn(1200);
			$("#current").attr("id","");
			$(this).closest("li").attr("id","current");
			return false;
		});
	
	
function start_show(){
	var curr = $("#current");
	var href= $("#current a").attr("href");
	$(href).fadeOut(1200);
	if($(curr).hasClass("last")) { //loop around to first image
		$(curr).attr("id",""); //remove id from current gallery image
		$(".first").attr("id","current");
	}
	else
	{
		$(curr).attr("id",""); //remove id from current gallery image
		$(curr).next().attr("id","current");
	}
	var href= $("#current a").attr("href");
	$(href).fadeIn(1200);
}

	if($("#slider1").length > 0){
	var href= $("#current a").attr("href");
	$(href).show();
	}


	$("#search label").inFieldLabels();
	$("#community_login label").inFieldLabels();
	
	var body_id = $("body").attr("id");
	var thehash=window.location.hash;
	if(thehash == "#loyalty"){
	$("#li_loyalty_"+body_id).addClass("current");
	}
	else {
	$("#li_"+body_id).addClass("current");
	}
	
	
	if($("#sub_nav li li li.current").length>0){
		$("#sub_nav li li li.current").parent().closest("li").parent().closest("li").addClass("active");
	}
	if($("#sub_nav li li.current").length>0){
		$("#sub_nav li li.current").parent().closest("li").parent().closest("li").addClass("active");
	}
	
	$(".active ul ul").hide();
	$(".active ul ul ul").hide();
	if($(".active ul:first").length > 0){
		$(".active ul:first").show();
	}
	if($(".current ul:first").length > 0){
		$(".current ul:first").show();
	}
	if($("#sub_nav .current").closest("ul").length > 0){
		$("#sub_nav .current").closest("ul").show();
	}
	
	
	
	if($("#sub_nav li:first").length >0){
		$("#sub_nav li:first").addClass("round_top_200");
	}
	if($("#sub_nav li:last").length > 0){
		$("#sub_nav li:last").addClass("round_bottom_200");
	}
	if($("#tertiary_nav li:first").length >0){
		$("#tertiary_nav li:first").addClass("round_top_200");
	}
	if($("#tertiary_nav li:last").length > 0){
		$("#tertiary_nav li:last").addClass("round_bottom_200");
	}

//business issues
	if($("#tabs").length>0){
		$("#tabs div").hide();
		$(".tabs_side").hide();
		var hash=window.location.hash;
		if(hash == ""){
			hash = "#d1";
		}
		$("#tabs "+hash).show();
		$("#tabs_side"+hash.substr(2)).show();
		
		$(".issue_tabs a").click(function(){
			$(".issue_tabs a").removeClass("current");
			$(this).addClass("current");
			$("#tabs div").hide();
			$(".tabs_side").hide();
			var href=$(this).attr("href");
			$("#tabs "+href).show();
			$("#tabs_side"+href.substr(2)).show();
			return false;
		});
		
	}
	
	
	if($.cookie("issues")){
		$("#issues_download").hide();
		if($("#issues_view").length>0){
			$("#issues_view").show();
		}
	}
	else
	{
		$("#issues_view").hide();
	}
	if($.cookie("adi_demo")){
		$("#adi_demo_click").hide();
		$("#adi_demo_view").show();
	}

	if(jQuery.url.segment(2)){
		if($.cookie(jQuery.url.segment(2))){
			//if form cookie - hide form link
			//if form cookie - show links
			$(".podcast_link").show();
			$("#podcasts object").show();
			$(".whitepaper_link").show();
			$(".suite_form").hide();
		}
	}

	$("#nav_bi").mouseover(function() {
		$("#nav_bi ul").show();
	});
	
	$("#nav_bi").mouseout(function() {
		$("#nav_bi ul").hide();
	});
	
	$("#nav_resources").mouseover(function() {
		$("#nav_resources ul").show();
	});
	
	$("#nav_resources").mouseout(function() {
		$("#nav_resources ul").hide();
	});
	
});


