////////////////////////////////////////////////////////////////////
// Não esquecer de alterar a variável se caso o site mude de nome //
////////////////////////////////////////////////////////////////////
//
var siteNome = "http://portal.hidracor.com.br/";

function retornaID (src) { 
	if (typeof(src) == "object") {
		return src.id; 
	} else { 
		return src;
	}
}
function abrejanTmp(src) {
	var vls = "";
	var vlv = new Array();
	vls = retornaID(src);
	vlv = vls.split(",");
	for (var i=0;i<vlv.length;i++) {
		abrejan_amp(null, vlv[i]);
	}
}

function retornaInnerText (src) { return src.InnerText; }
function focoJanela (src) { src.focus(); }
function abrejanHnews() {
	var jan = window.open("img.aspx?img=img/Hnews_Selo_Cultural.jpg&width=780","news","width=780,height=500,resizable,scrollbars=1,location=0,menubar=0,toolbar=0,directories=0,status=1");
	jan.focus();
}
function abrejan_amp(oEvento,oIMG) {
	var height = 0;
	var width = 0; 
	var vFator = 0.0;
	var vIMG = new Image();
	var vStr = "";
	if (typeof(oIMG) == "object") {
		vIMG.src = oIMG.src;
	} else {
		vIMG.src = oIMG;
	}
	//Se nao conseguiu pegar as larguras
	if (vIMG.height == 0) {	vIMG.height = screen.availHeight * 0.7; }
	if (vIMG.width == 0) {	vIMG.width = screen.availWidth * 0.7; }
	//Width em relacao a 800x600
	if (vIMG.width > (screen.availWidth-100)) {
		width = vIMG.width;
		vIMG.width = screen.availWidth - 300;
		vFator = vIMG.width / width;
		vIMG.height = vIMG.height * vFator;
	}
	//Height em relacao a 800x600
	if (vIMG.height > (screen.availHeight-100)) {
		height = vIMG.height;
		vIMG.height = screen.availHeight - 300;
		vFator = vIMG.height / height;
		vIMG.width = vIMG.width * vFator;
	}
    var src = siteNome + "img_amp.aspx?foto="+vIMG.src+"&height="+vIMG.height;
	if (oEvento!=null) { src += "&evento="+oEvento.innerText; }
	var nameJan = vIMG.id;
	var features = "height="+(vIMG.height+17)+",width="+(vIMG.width+17)+",top="+((screen.availHeight-(vIMG.height+17))/2)+",left="+((screen.availWidth-(vIMG.width+17))/2)+",status=0,toolbar=0,directories=0,menubar=0,resizable=0,scrollbars=1,resizable=1";
	var jan = window.open(src,nameJan,features);
	jan.focus();
}
function abrejan(src,texto) {
	var width = 380;
	var height = 523;
	var jan = window.open("projetos/projetos_index.aspx?link="+src+"&texto="+texto,"news","width="+width+",height="+height+",top="+(((screen.availHeight-height)/2)-15)+",left="+((screen.availWidth-width)/2)+"resizable,scrollbars=1,location=0,menubar=0,toolbar=0,directories=0,status=1");
	jan.focus();
}
function abrejan2(src) {
	var width = 380;
	var height = 523;
	var jan = window.open(src,"eventos","width="+width+",height="+height+",top="+(((screen.availHeight-height)/2)-15)+",left="+((screen.availWidth-width)/2)+",status=1,toolbar=0,directories=0,menubar=0");
	jan.focus();
}
function abrejan_SW(src) {
	var width = 733;
	var height = 549;
	var jan = window.open(src,"eventos","width="+width+",height="+height+",top="+(((screen.availHeight-height)/2)-15)+",left="+((screen.availWidth-width)/2)+",status=1,toolbar=0,directories=0,menubar=0");
	jan.focus();
}
function MM_openBrWindow(src,nome,ft) {
	var jan = window.open(src,nome,ft);
	jan.focus();
}
function changeSelW(obj) {
	divRegiao.innerHTML = obj.options[obj.options.selectedIndex].text;
	divIRegiao.innerHTML = '<iframe src="http://www.tempoagora.com.br/selos/'+obj.options[obj.options.selectedIndex].value+'/selo.htm" name="selotempoagora" width="120" height="125" frameborder="0" marginheight="0" marginwidth="0" scrolling="no"></iframe>';
}
function desenhaJanela(arq,titulo,width,height,isSOM,som) {
	var top = 0; var left = 0; var jan; var vTJan = ""; var vSom = "";
	top = (screen.availHeight - height) / 2; 
	left = (screen.availWidth - width) / 2;
	var vHTML = "";
	vTJan = arq.substring(arq.length-10,arq.length).replace(".","");
	if (som.length > 0) { vSom = "<BGSOUND src='"+som+"' balance=0 volume='-600' loop='infinite'>"; }
	jan = window.open("",vTJan,"width="+width+",height="+height+",top="+top+",left="+left+",toolbars=0,location=0,menubars=0,scrollbars=0,status=1");
	vHTML = "<html><head><title>"+titulo+"</title></head><body topmargin=0 leftmargin=0 bottommargin=0 rightmargin=0><img src='"+arq+"'>";
	vHTML += (isSOM)?vSom:"";
	vHTML += "</body></html>";
	jan.document.open();
	jan.document.write(vHTML);
	jan.document.close();
}
function trocacor(obj,cor1,cor2) {
	obj.onmouseover = function() {
		this.style.cursor = "pointer";
		this.style.backgroundColor = cor1;
	}
	obj.onmouseout = function() {
		this.style.cursor = "pointer";
		this.style.backgroundColor = cor2;
	}
	obj.onclick = function() {
		window.open(this.link,"_self");
	}
}

///////////////////////////
//    Script do Menu     //
///////////////////////////
function gerarMenu(total) {
	for (var i=1;i<=total;i++) {
		//
		var obj = document.getElementById("TM"+i);
		if (obj != null && obj != undefined) {
		    obj.onmouseover = function() {
			    var obj3;
			    this.style.backgroundColor = "#0780b5";
			    obj3 = document.getElementById("TD"+this.id.replace("TM",""));
			    obj3.style.color = "#ffffff";
			    obj3 = document.getElementById("S"+this.id.replace("TM",""));
			    obj3.style.backgroundColor = "#ffffff";
		    }
		    obj.onmouseout = function() {
			    var obj3;
			    this.style.backgroundColor = "#ececec";
			    obj3 = document.getElementById("TD"+this.id.replace("TM",""));
			    obj3.style.color = "#000000";
			    obj3 = document.getElementById("S"+this.id.replace("TM",""));
			    obj3.style.backgroundColor = "#d45a5c";
		    }
		    //
		    obj.style.cursor = "pointer";
		    obj.style.backgroundColor = "#ececec";
		    obj.style.color = "#000000";
		    //
		    var obj2 = document.getElementById("S"+i);
		    obj2.style.backgroundColor = "#d45a5c";
		}
	}
}

function handleEvent(aEvent){
	// if aEvent is null, means the IE event model, so get window.event.
	var myEvent = aEvent ? aEvent : window.event;
}  
      
function onPageLoad(){
	document.getElementById("myDiv").onclick = handleEvent;
}