
var popupDiv = 0;
var popupDivHeight = 0;

var callbackDiv = 0;
var callbackDivHeight = 0;

var beforeShowDuration = 1000;
var showDuration = 500;
var aliveDuration = 1900;
var hideDuration = 500;

var popupHideTimeout = 0;
var popupShowTimeout = 0;

$(document).ready(function(){
	if($('#blockPopUp').length >= 1){
		popupDiv = $('#blockPopUp');
		popupDivHeight = popupDiv.height();
		popupDiv.css({
			'top': -(popupDivHeight)
		});
		if(popupDiv.find('.content').html() != '' && popupDiv.find('.content').html() != undefined){
			showPopupText('',beforeShowDuration);
		}
	}
});


function showPopupText(text,b,s,a,h){

	if(b == 0 || b == undefined ) b=beforeShowDuration;
	if(s == 0 || s == undefined ) s=showDuration;
	if(a == 0 || a == undefined ) a=aliveDuration;
	if(h == 0 || h == undefined ) h=hideDuration;

	if(popupDiv != 0){

		if(popupHideTimeout != 0 && popupHideTimeout != undefined) clearTimeout(popupHideTimeout);
		if(popupShowTimeout != 0 && popupShowTimeout != undefined) clearTimeout(popupShowTimeout);

		popupDiv.css('display','none');

		if(text != '' && text != undefined){
			popupDiv.find('.content').html(text);
			popupDivHeight = popupDiv.height();
			popupDiv.stop().css({
					'top': -(popupDivHeight)
			});
		}

		popupDiv.css('display','block');

		if(b >= 1){
			popupShowTimeout = window.setTimeout('animatePopup('+s+','+a+','+h+')',b);
		}else{
			animatePopup(s,a,h)
		}
	}
}

function animatePopup(s,a,h){
	popupDiv.animate({
		top: 0 
	},s,function(){					
		popupHideTimeout = window.setTimeout('popupDiv.animate({top: -(popupDivHeight)}, '+h+')',a);
	});
}

function showCallbackText(text,b,s,a,h){

	if(b == 0 || b == undefined ) b=beforeShowDuration;
	if(s == 0 || s == undefined ) s=showDuration;
	if(a == 0 || a == undefined ) a=aliveDuration;
	if(h == 0 || h == undefined ) h=hideDuration;

	if(popupDiv != 0){

		if(popupHideTimeout != 0 && popupHideTimeout != undefined) clearTimeout(popupHideTimeout);
		if(popupShowTimeout != 0 && popupShowTimeout != undefined) clearTimeout(popupShowTimeout);

		popupDiv.css('display','none');

		if(text != '' && text != undefined){
			popupDiv.find('.content').html(text);
			popupDivHeight = popupDiv.height();
			popupDiv.stop().css({
					'top': -(popupDivHeight)
			});
		}

		popupDiv.css('display','block');

		if(b >= 1){
			popupShowTimeout = window.setTimeout('animatePopup('+s+','+a+','+h+')',b);
		}else{
			animatePopup(s,a,h)
		}
	}

}
