
//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var fallowStatus = 0;

//loading popup with jQuery magic!
function loadfallow(){
	//loads popup only if it is disabled
	if(fallowStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.9"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#contfallowme").fadeIn("slow");
		fallowStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disableFallowme(){
	//disables popup only if it is enabled
	if(fallowStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#contfallowme").fadeOut("slow");
		fallowStatus = 0;
		$('embed, object, select').css({ 'visibility' : 'visible' });
	}
}

//centering popup
function centerFallow(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var fallowHeight = $("#contfallowme").height();
	var fallowWidth = $("#contfallowme").width();
	
	if(window.ActiveXObject)
	{
		var fallowtop = document.documentElement.scrollTop+100;
	}

	else
	{
		var fallowtop = window.pageYOffset+100;
	}
	//centering
	$("#contfallowme").css({
		"position": "absolute",
		"top": fallowtop,
		"left": windowWidth/2-fallowWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$(".fallowme").click(function(){
		//centering with css
		centerFallow();
		//load popup
		loadfallow();
		$('embed, object, select').css({ 'visibility' : 'hidden' });
		xo=12;
		ObjetXHR("res_fallow","../fallowme/index.php?id="+this.id);
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#boxClose").click(function(){
		disableFallowme();
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disableFallowme();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && fallowStatus==1){
			disableFallowme();
		}
	});

});
