﻿function setFocus(e, botaoId) {
    var tecla = window.event ? e.keyCode : e.which;

    if (tecla == 13) {
        document.getElementById(botaoId).focus();
        document.getElementById(botaoId).click();
    }
}
/***************************************
*** campos de busca
****************************************/
function limpaBox(Campo, mensagem) {
    if (document.getElementById(Campo).value == mensagem) {
        document.getElementById(Campo).value = "";
    }
}

function verBox(Campo, mensagem) {
    if (document.getElementById(Campo).value == "") {
        document.getElementById(Campo).value = mensagem;
    }
}

//
function SWFDelegate(url,width,height,caption) {
	var objLink = document.createElement('a');
	objLink.setAttribute('href',url);
	objLink.setAttribute('rel','lightbox');
	objLink.setAttribute('title',caption);
	
	if(typeof width != 'undefined') {
		objLink.setAttribute('width',width);
	}
	
	if(typeof height != 'undefined') {
		objLink.setAttribute('height',height);
	}
	
	Lightbox.prototype.start(objLink);
}

function callRegulamento(){
    if(box!=undefined)
        document.getElementById("content").removeChild(box);
            
    box = document.createElement("div");
    
    box.id = "pnl_indique";
    box.style.width = "735px";
    box.style.height = "420px";
    box.style.backgroundColor = "#000";
    box.style.position = "absolute";
    box.style.border = "solid 10px #ccc";
    box.style.zIndex = "3"
    box.innerHTML = "<div style='width:735px;float:left;overflow:hidden;padding-bottom:15px;'><img style='float:right;cursor:pointer;' onclick='javascript:fechar_modal();' alt='fechar' src='/master/imagem/indique_fechar.gif' /></div>"
    box.innerHTML += "<iframe style='width:735px;height:385px;float:left;overflow-x:hidden !important;' src='/Poty/Regulamento.aspx' frameborder='0' horizontalscrolling='n' verticalscrolling='yes'></iframe>"

    document.getElementById("content").appendChild(box);
    
    //alinhar
    setPosition(box,[735,420]);
}

///////////////////////////////////
// exibe o formulario de cadastro
///////////////////////////////////
var box = undefined;

function callLogin(){

     if(box!=undefined)
        document.getElementById("content").removeChild(box);
            
    box = document.createElement("div");
    
    box.id = "pnl_indique";
    box.style.width = "735px";
    box.style.height = "420px";
    box.style.backgroundColor = "#000";
    box.style.position = "absolute";
    box.style.border = "solid 10px #ccc";
    box.style.zIndex = "3"
    box.innerHTML = "<div style='width:735px;float:left;overflow:hidden;padding-bottom:15px;'><img style='float:right;cursor:pointer;' onclick='javascript:fechar_modal();' alt='fechar' src='/master/imagem/indique_fechar.gif' /></div>"
    box.innerHTML += "<iframe style='width:735px;height:385px;float:left;overflow-x:hidden !important;' src='/Poty/Avatar.aspx' frameborder='0' horizontalscrolling='n' verticalscrolling='yes'></iframe>"

    document.getElementById("content").appendChild(box);
    
    //alinhar
    setPosition(box,[735,420]);
}

function callCadastro(ConfirmID){

     if(box!=undefined)
        document.getElementById("content").removeChild(box);
            
    box = document.createElement("div");
    
    box.id = "pnl_indique";
    box.style.width = "735px";
    box.style.height = "420px";
    box.style.backgroundColor = "#000";
    box.style.position = "absolute";
    box.style.border = "solid 10px #ccc";
    box.style.zIndex = "3"
    box.innerHTML = "<div style='width:735px;float:left;overflow:hidden;padding-bottom:15px;'><img style='float:right;cursor:pointer;' onclick='javascript:fechar_modal();' alt='fechar' src='/master/imagem/indique_fechar.gif' /></div>"
    box.innerHTML += "<iframe style='width:715px;height:370px;float:left;overflow:auto;' src='/Poty/Cadastro.aspx?idConfirm=" + ConfirmID + "' frameborder='0' scrolling='auto'></iframe>"

    document.getElementById("content").appendChild(box);
    
    //alinhar
    setPosition(box,[735,420]);
}

function callVoto(nota,idItem,tipo)
{

    if(box!=undefined)
        document.getElementById("content").removeChild(box);
            
    box = document.createElement("div");
    
    box.id = "pnl_indique";
    box.style.width = "450px";
    box.style.height = "250px";
    box.style.backgroundColor = "#000";
    box.style.position = "absolute";
    box.style.border = "solid 10px #ccc";
    box.style.zIndex = "3"
    box.innerHTML = "<div style='width:450px;float:left;overflow:hidden;'><img style='float:right;cursor:pointer;' onclick='javascript:fechar_modal();' alt='fechar' src='/master/imagem/indique_fechar.gif' /></div>"
    box.innerHTML += "<iframe style='width:440px;height:180px;float:left;overflow:hidden;' src='/Poty/Avaliar.aspx?item_id=" + idItem + "&nota=" + nota + "&tipo=" + tipo + "' frameborder='0' scrolling='no'></iframe>"

    document.getElementById("content").appendChild(box);
   
    //alinhar
    setPosition(box,[450,250]) 
}

function fechar_modal() {
    document.getElementById("content").removeChild(box);
    box = undefined;
}

function setPosition(target,arrWH){
    var wh = ((screen.availHeight - parseFloat(arrWH[1])) / 2);
    var ww = ((screen.availWidth - parseFloat(arrWH[0])) / 2);

    with (target) { 
        style.top = ((wh + getScroll())-75) + "px";
        style.left = ww + "px";
    }
}

function getScroll() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY ;
}

function InsereFlash(Arquivo, Largura, Altura, FlashVars) {
    document.write('<object codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"');
    document.write('height="' + Altura + '" width="' + Largura + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>');
    document.write('<param name="_cx" value="15425">');
    document.write('<param name="_cy" value="741">');
    document.write('<param name="FlashVars" value="' + FlashVars + '">');
    document.write('<param name="Movie" value="' + Arquivo + '">');
    document.write('<param name="Src" value="' + Arquivo + '">');
    document.write('<param name="WMode" value="Transparent">');
    document.write('<param name="Play" value="-1">');
    document.write('<param name="Loop" value="-1">');
    document.write('<param name="Quality" value="High">');
    document.write('<param name="SAlign" value="">');
    document.write('<param name="Menu" value="-1">');
    document.write('<param name="Base" value="">');
    document.write('<param name="AllowScriptAccess" value="">');
    document.write('<param name="Scale" value="noscale">');
    document.write('<param name="DeviceFont" value="0">');
    document.write('<param name="EmbedMovie" value="0">');
    document.write('<param name="BGColor" value="">');
    document.write('<param name="SWRemote" value="">');
    document.write('<param name="MovieData" value="">');
    document.write('<param name="SeamlessTabbing" value="1">');
    document.write('<param name="Profile" value="0">');
    document.write('<param name="ProfileAddress" value="">');
    document.write('<param name="ProfilePort" value="0">');
    document.write('<embed src="' + Arquivo + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" ');
    document.write('type="application/x-shockwave-flash" width="' + Largura + '" height="' + Altura + '" FlashVars="' + FlashVars + '" ');
    document.write('_cx="15425" _cy="741" WMode="Transparent" Menu="-1" Scale="noscale" DeviceFont="0" EmbedMovie="0" SeamlessTabbing="1" Profile="0" ProfilePort="0"></embed>');
    document.write('</object>');
}