function link(str, width, height, scroll)
      {
      var str = str;
      var W = width;
      var H = height;
      var S = scroll;

      tipWin1 = window.open( str, 'tipWin1', 'width='+W+',height='+H+',toolbar=no,location=no,status=no,menubar=no,screenx=0,screeny=0,left=0,top=0,scrollbars='+S+',resizable=no' );
      tipWin1.location.href=str
      tipWin1.focus();
      }
function x_link(str, width, height, scroll)
      {
      var str = str;
      var W = width;
      var H = height;
      var S = scroll;

      tipWin1_x = window.open( str, 'tipWin1_x', 'width='+W+',height='+H+',toolbar=no,location=no,status=no,menubar=no,screenx=0,screeny=0,left=0,top=0,scrollbars='+S+',resizable=no' );
      tipWin1_x.location.href=str
      tipWin1_x.focus();
      }


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



function XMLHTTPRequest() {
	var tXHR=0;
	if (window.XMLHttpRequest) {
		tXHR=new XMLHttpRequest();
	} else {
		try{ tXHR=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(e){
			try { tXHR=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch(e){ tXHR=false; }
		}
	}
	return tXHR;
}
var tXHR=XMLHTTPRequest();
function carrega(lk,div){
	var conteudo = "";
	if(tXHR){
		conteudo=document.getElementById(""+div+"");
		lk = lk + "&ajax=1";
		tXHR.open("GET", lk, true);
		tXHR.onreadystatechange=function(){
			if (tXHR.readyState==4){
				if(tXHR.status == 200) {
					repl = /\+/g;
					conteudo.innerHTML = unescape(tXHR.responseText.replace(repl," "));
				}
			}
		}
		tXHR.send(null);
		setTimeout("hideRecadoBD('')",2000);
	} else {
		alert("Ative as funções de Javascript em seu computador.");
		return false;
	}
}

function hideRecadoBD(cod_solucaoS){
	if(cod_solucaoS != ""){ cod_solucaoP = cod_solucaoS; } else { cod_solucaoP = cod_solucao; }
	if(document.getElementById("recadoBD_"+cod_solucaoP+"")){
		document.getElementById("recadoBD_"+cod_solucaoP+"").style.display="none";
	}
}

function getCheckedValue(radioObj, numRadio) {
	if(radioObj.checked){ return radioObj.value; }
	for(var i = 0; i < numRadio; i++) {
		if(radioObj[i].checked) { return radioObj[i].value; }
	}
	return "aa";
}

// submitForm(div, form, php, arg1, arg2...)
function submitForm(){
	div = arguments[0];
	form = arguments[1];
	php = arguments[2];
	var poststr = "";
	var vvalue = "";
	for(var j=3; j<arguments.length;j++){
		var vfield = arguments[j];
		if(vfield == "fa_ch" || vfield == "fa_com"){
			if(eval("document."+form+"." + vfield + ".checked") == true){ vvalue = "1"; } else { vvalue = "0"; }
		} else if(vfield.indexOf("rd_") >= 0){
			vvalue = getCheckedValue(eval("document."+form+"." + vfield),10);
		} else {
			vvalue = eval("document."+form+"." + vfield).value;
		}
		if(vfield == "cod_solucao"){ var cod_solucao = vvalue; }
		if(vvalue != "" && vvalue != undefined){
			vvalue = vvalue.replace(/&/g,"*am*");
			vvalue = vvalue.replace(/=/g,"*eq*");
			vvalue = vvalue.replace(/\+/g,"*pl*");
		}
		//poststr += vfield + "=" + encodeURI(vvalue) + "&";
		poststr += vfield + "=" + escape(vvalue) + "&";
	}
	//alert(php+"?"+poststr+" , para "+div+" -- vindo de: "+form);
	carrega(php+"?"+poststr, div);
}

function redBt(BA){
	document.getElementById(""+BA+"").style.backgroundColor="#FF3333";
}


function checkConvida(){
	var erro = "";
	if(document.convideF.r_nomelist.value.length<2){ erro += "SEU NOME\n"; }
	if(document.convideF.r_maillist.value.length<2){ erro += "SEU E-MAIL\n"; }
	if(document.convideF.d_nomelist.value.length<2){ erro += "NOME DO AMIGO\n"; }
	if(document.convideF.d_maillist.value.length<2){ erro += "E-MAIL DO AMIGO\n"; }
	if(erro != ""){
		alert("Preencha todos os campos para enviar o convite\n\n"+erro);
	} else {
		submitForm('divConvide', 'convideF', 'o_access.php', 'r_nomelist', 'r_maillist', 'd_nomelist', 'd_maillist', 'id_conc','assuntoMail','id_cartaz_show','id_curso_show','id_olhaisso_show');
	}	
}


function showDiv(dv){
	if(dv != ""){
		document.getElementById("baseFormLogin").style.display="block";
	} else {
		document.getElementById("baseFormLogin").style.display="none";	
	}
	document.getElementById("divCliente").style.display="none";
	document.getElementById("divCriativo").style.display="none";
	document.getElementById("divSenha").style.display="none";
	if(document.getElementById("divRecado")) document.getElementById("divRecado").innerHTML="";
	if(dv == "criativo"){
		document.getElementById("divCriativo").style.display="block";
	} else if(dv == "cliente"){
		document.getElementById("divCliente").style.display="block";
	} else if(dv == "senha"){
		document.getElementById("divSenha").style.display="block";
	}
}


over = function(tdiv, vd){
	var sfEls = "";
	var sfEls = tdiv;
	//alert(sfEls);
	//showFlut(vd);
	if(!sfEls.ok){
		sfEls.ok=1;
		sfEls.onmouseover=function(){
			this.className = this.className + " over";
			//showFlut(vd);
		}
		sfEls.onmouseout=function(){
			this.className = this.className.replace(new RegExp("\\s?over\\b"), "");
			//showFlut(0);
		}
		sfEls.className += " over";
	}
}

window.defaultStatus = "";
function janela(param,nome,w,h) {
	ns = document.layers;
	ie = document.all;
	rs = "yes";
	sc = "yes";
	if(w == "100%" && h == "100%"){
		w = screen.width - 20;
		h = screen.height - 70;
		larg = 10;
		alt = 10;
	} else {
		if(!w) w=500;
		larg = ((screen.width - w)/2) - 12;
		if(!h) h=500;
		if(h == "h") {
			h=(screen.height-70);
			if(navigator.userAgent.indexOf("OS") > 0){ alt = 30; } else { alt = 5; }
			rs = "yes";
			sc = "yes";
		} else {
			alt = ((screen.height - h)/2) - 50;
		}
	}
	winvar = window.open(param,nome,"scrollbars="+sc+",location=no,directories=no,status=no,menubar=no,resizable="+rs+",toolbar=no,top="+alt+",left="+larg+",width="+w+",height="+h);
	winvar.focus();
}

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function fixPNG(myImage){
    if ((version >= 5.5) && (version < 7) && (document.body.filters)){
		var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
		var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
		var imgTitle = (myImage.title) ? "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
		var imgStyle = "display:inline-block;" + myImage.style.cssText
		var strNewHTML = "<span " + imgID + imgClass + imgTitle
		+ " style=\"" + "width:" + myImage.width 
		+ "px; height:" + myImage.height 
		+ "px;" + imgStyle + ";"
		+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		+ "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
		myImage.outerHTML = strNewHTML	  
    }
}


function sizeimg(img, v, s){
	iw = Math.floor(eval(img).width);
	ih = Math.floor(eval(img).height);
	//alert("altura 1: "+ih+" = "+eval(img).height + " .");
	if(v == "h" && ih > s){  document.getElementById(img).style.width = ((s/ih) * iw) + "px"; document.getElementById(img).style.height = s+"px"; }
	if(v == "w" && iw > s){ document.getElementById(img).style.height = ((s/iw) * ih) + "px"; document.getElementById(img).style.width = s+"px"; }
	//setTimeout("sizeimg('"+img+"','"+v+"',"+s+")",1000);
}




function showFoto(file){
	document.getElementById("divFoto").style.display = "block";
	document.getElementById("imgAmplia").src = file;
}


function checkOS(){
	if(navigator.userAgent.indexOf('Linux') != -1){
		var OpSys = "Linux";
	} else { 
		if((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('95') != -1)){
			var OpSys = "Win";
		} else{
			if((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('98') != -1)){
				var OpSys = "Win";
			} else {
				if(navigator.userAgent.indexOf('Win') != -1){
					var OpSys = "Win";
				} else {
					if(navigator.userAgent.indexOf('Mac') != -1){
						var OpSys = "Macintosh";
					} else {
						var OpSys = "Other";
					}
				}
			}
		}
	}
	return OpSys;
}
var OpSys = checkOS();

function restaura(){
	var myWidth = 0, myHeight = 0;
	if(typeof(window.innerWidth) == 'number'){
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		if(myWidth < 801){ myWidth=788; }
	} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)){
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if(document.body && (document.body.clientWidth || document.body.clientHeight)){
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	if(document.getElementById("divFoto")){
		//wf = myWidth - 30;
		//hf = myHeight - 20;
		wf = myWidth;
		hf = myHeight;
		document.getElementById("divFoto").style.width = wf + "px";
		document.getElementById("divFoto").style.height = hf + "px";
		document.getElementById("divFoto").style.top = "0px";
		document.getElementById("divFoto").style.left = "0px";
	}
}

function topBanner(){
	if(typeof(window.scrollTop) == 'number'){
		positionY = window.scrollTop;
	} else if(document.documentElement && (document.documentElement.scrollTop)){
		positionY = document.documentElement.scrollTop;
	} else if(document.body && (document.body.scrollTop)){
		positionY = document.body.scrollTop;
	} else {
		var positionY = document.body.scrollTop;
	}
	if(document.getElementById("divBanner")){
		if(positionY > 185){
			document.getElementById("divBanner").style.top = (positionY + 5) + "px";
		} else {
			document.getElementById("divBanner").style.top = (185) + "px";
		}
	}
	if(document.getElementById("divFoto")){
		document.getElementById("divFoto").style.top = (positionY) + "px";
	}
}

var intervalo = window.setInterval("topBanner()",20);