var interstitialTimeout;

function fabrixAJAXstart(){
	showFormCheck();
}

function fabrixAJAXend(){
	hideFormCheck();
}

function showFormCheck() {
	var interstitialMask = document.getElementById("searchInterstitialMask");
	//document.body.appendChild(interstitialMask);
	interstitialMask.style.display = "block";
	showFormInterstitial();
}

function showFormInterstitial() {
	var interstitialFloat = document.getElementById("searchInterstitialFloat");
	//document.body.appendChild(interstitialFloat);
	interstitialFloat.style.display = "block";
	centerBox("searchInterstitialFloat");
}

function hideFormCheck() {
	var interstitialMask = document.getElementById("searchInterstitialMask");
	var interstitialFloat = document.getElementById("searchInterstitialFloat");
	interstitialMask.style.display = "none";
	interstitialFloat.style.display = "none";
}

function showFormCheckCosting() {
	showFormCheck();
}

function showFormInterstitialCosting() {
	showFormCheck();
}

function hideFormCheckCosting() {
	hideFormCheck();
}

function centerBox(id) {
	var helpBox = document.getElementById(id);
	if (self.innerHeight) {	// all except Explorer
		var offsetX = (self.innerWidth - helpBox.offsetWidth) / 2;
		var offsetY = (self.innerHeight - helpBox.offsetHeight) / 2;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		var offsetX = (document.documentElement.clientWidth - helpBox.offsetWidth) / 2;
		var offsetY = (document.documentElement.clientHeight - helpBox.offsetHeight) / 2;
	} else if (document.body) { // other Explorers
		var offsetX = (document.body.clientWidth - helpBox.offsetWidth) / 2;
		var offsetY = (document.body.clientHeight - helpBox.offsetHeight) / 2;
	}
	helpBox.style.left = offsetX + "px";
	helpBox.style.top = offsetY + "px";
}

function toggleOptionalsByIds(panelId, linkShow, linkHide) {
	var optionals = document.getElementById(panelId);
	$("#"+panelId).stop(true,true).slideToggle('slow');
	$("#"+linkHide).hide(0, function() {
			$("#"+linkShow).show();
	});
	return false;
}

function showFlightLegInfo(id) {
	$("#"+id).fadeIn("slow");
}

function hideFlightLegInfo(id) {
	$("#"+id).hide(1000);
}

function toggleFlightLegInfo(panelId, linkShow, linkHide) {
	var optionals = document.getElementById(panelId);
	$("#"+panelId).toggle();
	$("#"+linkHide).hide(0, function() {
			$("#"+linkShow).show();
	});
	return false;
}

function TickerObject(name,tickspeed){
	this.posts = $("#"+name+" .FabrixTickerPost");
	this.show = 0;
	this.timerDelay = tickspeed;
	this.newsTickerTimer;
	
	this.tickUp = function(){
		this.show = (this.show+1)%this.posts.length;
		this.posts.fadeOut(1000);
		setTimeout("$("+name+".posts["+name+".show]).fadeIn(1000);",500);
	}
	this.tickDown = function(){
		this.show--;
		if(this.show<0)
			this.show=this.posts.length-1;
		this.posts.fadeOut(1000);
		setTimeout("$("+name+".posts["+name+".show]).fadeIn(1000);",500);
	}
	this.stopTimer = function(){
		clearInterval(this.newsTickerTimer);
		$("#"+name+" .Autotick").toggle();
	}
	this.startTimer = function(){
		this.stopTimer();
		this.newsTickerTimer = setInterval(name+".tickUp()",this.timerDelay);
	}

	this.posts.hide();
	$(this.posts[this.show]).show();
	this.startTimer();
}

function ScrollerObject(id){
	this.id = id;
	this.maxScroll = $(this.id).attr("scrollWidth") - $(this.id).outerWidth();
	this.x =  this.maxScroll/2;
	
	$(this.id).attr({
		scrollLeft:this.x
	});

	this.scroller = function(vel){
		if(this.x+vel <= this.maxScroll && this.x+vel >= 0)
			this.x+=vel;
		$(this.id).stop();
		$(this.id).animate({
			scrollLeft:this.x
			},300);
	}

	this.reset = function(){
		this.scroller(this.maxScroll/2 - this.x)
	}
}

function confCall(conf) {
        var tag = ".conf-"+conf;
        if ($('#control-'+conf).hasClass('active')) {
            $('.conf-'+conf).animate({top:'-79px'},350);
            $('#control-'+conf).removeClass('active');
        } else {
            $.each(['reset', 'save', 'cancel'], function(index, value) { 
            if ($('.conf-'+value).css('top') == "0px") {
                $('.conf-'+value).stop(true,true).animate({top:'-79px'},350);
                $('#control-'+value).removeClass('active');
            }
            });    
            $('#control-'+conf).addClass('active');
            $(tag).stop(true,true).animate({top:'0px'},600);    
        }  
}
function cancelCall(conf) {
            var tag = ".conf-"+conf;
            $('#control-'+conf).removeClass('active');
            $(tag).stop(true,true).animate({top:'-79px'},350);   
}
function removeLightBox() {
	parent.$.fn.colorbox.close()
	//$.colorbox.close();
	return false;
}
function togglePrefDrawer(value) {
        
}
