var widthScreen = $(window).width();
var heightScreen = $(window).height();

function login(code,login,zone){
	
	if(login){
		if(zone==1)	location.href='../emprego/index.php';
		else if(zone==2)	location.href='../historico/index.php';
		else if(zone==3)	location.href='../biblioteca/index.php';
	}else	postitWindow(""+code+"",400,280,true,"#f5fcc7",40,1);

}


function centerDiv(obj,width_div,height_div,less_height){

	var pos = 2 + less_height;
	
	var top_position = Math.ceil((heightScreen/pos) - (height_div/2));
	var left_position = Math.ceil((widthScreen /2) - (width_div/2));
	
	
	//$k(obj).style.display 	= "block";
	$k(obj).style.top 		= top_position+"px";
	$k(obj).style.left 		= left_position+"px";
	$k(obj).style.width 	= width_div+"px";
	$k(obj).style.height 	= height_div+"px";
	
}

function heightMAX(obj){
	$k(obj).style.height = Math.ceil(heightScreen)+"px";
}

/************************************

code: cod html
px_width: width postit
px_height: height postit
back: true/false: if the field is the true value is Disables the page, if the field is set to false, the page is enabled
color: background color of the page. Work if it is true back.
opacity: opacity of the bottom of the page. Work if it is true back
less_height: Position is taken as the center window of the page if less_height is zero. less_height takes positive values if the vertical position becomes smaller.

**************************************/

function postitWindow(code,px_width,px_height,back,color,opacity,less_height){
	var contentHTML	;
	
	var postitHTML = 	"<div id='postit' style='position:absolute; background:white; z-index:6002; display:none;' onMouseOver=\"$('#postit_close_icon').css('display','block');\" onMouseOut=\"$('#postit_close_icon').css('display','none');\">"+
						"<div style='margin:20px 20px 20px 20px;'>"+code+"</div>"+
						"<div id='postit_close_icon' style='position:absolute; top:5px; right:5px; cursor:pointer; display:none;' onClick='postitWindowClose();'><img src='../images-web/postit_close.gif' alt='' title='' ></div>"+
						"<div style='position:absolute; bottom:10px; right:10px; cursor:pointer; display:block;' onClick='postitWindowClose();'>cerrar</div></div>";
	if(back == true){
		if(color == "")
			color = "black";
			contentHTML = "<div id='opacityHtml' style='position:absolute; width:100%; top:0px; left:0px; background-color:"+color+"; z-index:6000; display:none;'>&nbsp;</div>";
	}

	var borderPostitHTML = "<div id='postitBorder' style='position:absolute; background:#556102; z-index:6001; display:none;'>&nbsp;</div>";
	document.body.innerHTML = contentHTML + borderPostitHTML + postitHTML + document.body.innerHTML;
	centerDiv('postit',px_width,px_height,less_height);
	//$("#postit").corner();
	$("#postit").fadeTo("slow",1);
	
	centerDiv('postitBorder',px_width+20,px_height+20,less_height);
	$("#postitBorder").corner();
	$("#postitBorder").fadeTo("slow",0.4);
	
	
	if(opacity){
		heightMAX('opacityHtml');
		$("#opacityHtml").fadeTo("slow",opacity/100);
	}
}

function postitWindowClose(){
	/*
	$("#postit").hide();
	$("#opacityHtml").hide();
	$("#postitBorder").hide();
	*/
	
	$("#postit").fadeOut("slow");
	$("#opacityHtml").fadeOut("slow");
	$("#postitBorder").fadeOut("slow");
}
function showDiv(id){
	$k(id).style.display="block";
}
function hideDiv(id){
	$k(id).style.display="none";
}

function $k(id) {
	return (document.getElementById(id));
}
