
function writeFlash( nameFlash, targetFlash, widthFlash, heightFlash, optionsFlash ) {
	var paramFlash = "?_u=\/swf\/";
	
    if ( optionsFlash )
		paramFlash += optionsFlash;

	document.write( "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"" + widthFlash + "\" height=\"" + heightFlash + "\" id=\"" + nameFlash + "\" name=\"" + + nameFlash + "\" >" );
	document.write( "<param name=\"allowScriptAccess\" value=\"sameDomain\" />" );
	document.write( "<param name=\"movie\" value=\"" + targetFlash + paramFlash + "\" />" );
	document.write( "<param name=\"quality\" value=\"high\" />" );
	document.write( "<param name=\"menu\" value=false />" );
	document.write( "<param name=\"wmode\" value=\"transparent\" />" );
	document.write( "<embed wmode=\"transparent\" src=\"" + targetFlash + paramFlash + "\" quality=\"high\" menu=false pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + widthFlash + "\" height=\"" + heightFlash + "\" swLiveConnect=\"true\" id=\"" + nameFlash + "\" name=\"" + nameFlash + "\" ></embed>" );
	document.write( "</object>" );
}


function ClickCenario( qualCenario ) {
	var wo = window.open( "cenario.asp?c=" + qualCenario, "CENARIO", "top=0,left=0,width=1000,height=400,scrollbars=no,resizable=no,toolbar=0,location=0,directories=0,status=no,menubar=0" );
	
	if ( wo )
		wo.focus();
	else {
		window.alert( "O bloqueador de Popups do seu navegador está impedindo a abertura dos cenários./n/nPara visualizar os cenários é necessário liberar a abertura de Popups." );
	}
}


function clickValeVerde( novoLocal ) {
	document.location.href = novoLocal;
}


function pageSize() {
	var here_w = 0, here_h = 0;

	if ( document.body.scrollWidth )
		here_w = Math.max( here_w, document.body.scrollWidth );
		
	if ( document.body.scrollHeight )
		here_h = Math.max( here_h, document.body.scrollHeight );
		
	if ( document.documentElement ) {
		here_w = Math.max( here_w, document.documentElement.scrollWidth );
		here_h = Math.max( here_h, document.documentElement.scrollHeight );
		
	} else {
			
		if ( self.innerWidth )
			here_w = Math.max( here_w, self.innerWidth );
			
		if ( self.innerHeight )
			here_h = Math.max( here_h, self.innerHeight );
	
		if ( document.body ) {
			here_w = Math.max( here_w, document.body.clientWidth );
			here_h = Math.max( here_h, document.body.clientHeight );
		}		
	} 
	
	sizes = { w:here_w, h:here_h };
	return sizes;
}
    

function detailContent( obj, url, title ) {
	var limitsScreen = pageSize();
	var containerDiv = document.getElementById( "container" );
	
	var painelDiv = document.createElement( "div" );
	painelDiv.className 	= "painel";
	painelDiv.id 			= obj.id + "_painel";
	painelDiv.style.width  	= ( limitsScreen.w + "px" );
	painelDiv.style.height 	= ( limitsScreen.h + "px" );
	painelDiv.style.display	= "block";
	painelDiv.style.opacity	= "0.8";
	painelDiv.style.filter	= "alpha(opacity=80)";
	document.body.appendChild( painelDiv );
	
	var detalheDiv = document.createElement( "div" );
	detalheDiv.className 		= "detalhe";
	detalheDiv.id 				= obj.id + "_detalhe";
	detalheDiv.style.display	= "block";
	
	var detalheTituloDiv = document.createElement( "div" );
	detalheTituloDiv.className = "detalhe_titulo";
	
	var detalheTituloA = document.createElement( "a" );
	detalheTituloA.className 		= "direita";
	detalheTituloA.display	 		= "block";
	detalheTituloA.href 			= "javascript:void(0);";
	detalheTituloA.title			= "Clique para fechar";
	detalheTituloA.onclick			= new Function( "return( fecharDetalhe( '" + obj.id + "' ) );" );
	detalheTituloA.style.padding	= "6px 8px";
	detalheTituloA.style.height		= "13px";
	detalheTituloA.style.width		= "13px";

	var detalheTituloIMG = document.createElement( "img" );
	detalheTituloIMG.alt			= "Clique para fechar";
	detalheTituloIMG.src 			= "/img/botao_fechar.gif";
	detalheTituloIMG.style.height	= "13px";
	detalheTituloIMG.style.width	= "13px";
	detalheTituloIMG.onmouseover	= new Function( "this.src = \"/img/botao_fechar_on.gif\";" );
	detalheTituloIMG.onmouseout		= new Function( "this.src = \"/img/botao_fechar.gif\";" );
	
	detalheTituloA.appendChild( detalheTituloIMG );
	detalheTituloDiv.appendChild( detalheTituloA );

	var detalheTituloH1 = document.createElement( "h1" );
	detalheTituloH1.innerHTML = title;
	detalheTituloDiv.appendChild( detalheTituloH1 );
	detalheDiv.appendChild( detalheTituloDiv );
	
	var detalheFrame = document.createElement( "iframe" );
	detalheFrame.id				= obj.id + "_iframe";
	detalheFrame.name			= detalheFrame.id;
	detalheFrame.className		= "detalhe_area";
	detalheFrame.frameBorder 	= "0";
	detalheFrame.scrolling		= "auto";
	detalheFrame.src			= escape( url );
	
	detalheDiv.appendChild( detalheFrame );
	
	document.body.appendChild( detalheDiv );
	
	detailCenter( detalheDiv );
	
	return false;
}

function detailCenter( obj ) {
	obj.style.top	= Math.max( document.documentElement.scrollTop, document.documentElement.scrollTop + document.documentElement.clientHeight - obj.offsetHeight - ( ( document.documentElement.clientHeight - ( obj.offsetHeight / 2 ) ) / 2 ) ) + "px";
	obj.style.left	= ( document.documentElement.scrollLeft + ( ( document.documentElement.clientWidth / 2 ) - ( obj.offsetWidth / 2 ) ) ) + "px";
}

function fecharDetalhe( objID ) {
	document.body.removeChild( document.getElementById( objID + "_detalhe" ) );
	document.body.removeChild( document.getElementById( objID + "_painel" ) );
	return false;
}


function AnalisaPromocao( objForm ) {
	if ( objForm ) {
	
		// Dados do contato
		if ( ( !CheckNome( objForm.nome_contato ) || !CheckEMail( objForm.email_contato ) ) ) {
			return( false );
		}
		
		// Dados do primeiro amigo
		if ( ( !CheckNome( objForm.amigo1_nome_contato ) || !CheckEMail( objForm.amigo1_email_contato ) ) ) {
			return( false );
		}
		
		// Dados do segundo amigo
		if ( ( !CheckNome( objForm.amigo2_nome_contato ) || !CheckEMail( objForm.amigo2_email_contato ) ) ) {
			return( false );
		}
		
		// Dados do terceiro amigo
		if ( ( !CheckNome( objForm.amigo3_nome_contato ) || !CheckEMail( objForm.amigo3_email_contato ) ) ) {
			return( false );
		}
		
		// Nomes e e-mails repetidos.
		if ( ( objForm.nome_contato.value == objForm.amigo1_nome_contato.value ) || ( objForm.nome_contato.value == objForm.amigo2_nome_contato.value ) ||
		     ( objForm.nome_contato.value == objForm.amigo3_nome_contato.value ) || ( objForm.amigo1_nome_contato.value == objForm.amigo2_nome_contato.value ) ||
		     ( objForm.amigo1_nome_contato.value == objForm.amigo3_nome_contato.value ) || ( objForm.amigo2_nome_contato.value == objForm.amigo3_nome_contato.value ) ||
		     ( objForm.email_contato.value == objForm.amigo1_email_contato.value ) || ( objForm.email_contato.value == objForm.amigo2_email_contato.value ) ||
		     ( objForm.email_contato.value == objForm.amigo3_email_contato.value ) || ( objForm.amigo1_email_contato.value == objForm.amigo2_email_contato.value ) ||
		     ( objForm.amigo1_email_contato.value == objForm.amigo3_email_contato.value ) || ( objForm.amigo2_email_contato.value == objForm.amigo3_email_contato.value ) ) {
			ExibeMensagem( "Não é possível cadastrar nomes ou contas de e-mail repetidas." );
			return( false );
		}
		
		return( true );
	} else
		return( false );
}


function CheckNome( obj ) {
	if ( obj.value ) {
		if ( obj.value.length > 5 )
			return( true );
	}
	PreenchimentoInadequado( obj );
	return( false );
}


function CheckEMail( obj ) {
	if ( obj.value ) {
		if ( ( -1 == obj.value.search( /\s/ ) ) && ( -1 != obj.value.search( /^([\d\w\D]{2,})@([\d\w\D]{2,}).([\d\w]{2,})/ ) ) )
			return( true );
	}
	PreenchimentoInadequado( obj );
	return( false );
}


function PreenchimentoInadequado( obj ) {
	ExibeMensagem( obj.title + " deve ser preenchido corretamente." );
	obj.focus();
}


function ExibeMensagem( msg ) {
	window.alert( msg );
}






















function fotogrande(obj,url,txt) {
	var tamanhos = pageSize();
	var classe = 'maior';
	
	var div1 = document.createElement('div');
	div1.className = 'grande';
	div1.id = 'grande';
	div1.style.height = (tamanhos.y + 'px');
	
	var div2 = document.createElement('div');
	div2.className = 'fora';
	div2.id = 'fora';
	div2.style.height = (tamanhos.y + 'px');
	document.body.appendChild(div2);
	
	var div3 = document.createElement('div');
	div3.className = 'fotogrande';
	div3.id = 'foto_' +  classe;
	
	var img1 = document.createElement('img');
	img1.className = classe;
	img1.id = 'img_' +  classe;
	img1.src = url;
	img1.alt = 'Clique para fechar';
	img1.title = 'Clique para fechar';
	
	var div4 = document.createElement('div');
	div4.classname="retorna";
	
	var img2 = document.createElement('img');
	img2.src = 'http://css.vrum.com.br/img/fechar2.png';
	img2.onclick = function() { fechafoto(this); return false; }
	img2.alt = 'Clique para fechar';
	img2.title = 'Clique para fechar';
	
	div4.appendChild(img2);
	
	img1.onclick = function() { fechafoto(this); return false; }
	
	var divDescricao = document.createElement('div');
	divDescricao.id = 'desc_' +  classe;
	divDescricao.className = 'legenda';
	var p = document.createElement('p');
	
	if ( url != '' ) 
		if ( txt != '' )
			p.innerHTML = txt;
		
	divDescricao.appendChild(img1);
	divDescricao.appendChild(div4);
	divDescricao.appendChild(p);
	div3.appendChild(divDescricao);
	div1.appendChild(div3);      
	document.body.appendChild(div1);
	
	if ( img1.width && img1.width > 32 ) {
		resizefoto(img1);
	}
	
	img1.onload = function() {
		resizefoto(this);
	 	return false;
	}
}

                        
function fechafoto(obj) {
	document.body.removeChild( document.getElementById( 'grande' ) );
	document.body.removeChild( document.getElementById( 'fora' ) );
	
	obj.parentNode.parentNode.parentNode.removeChild( obj.parentNode.parentNode );
}

function rolagem(){
	var dy;

	if ( self.pageYOffset )
		dy = self.pageYOffset
		
	else if ( document.documentElement && document.documentElement.scrollTop ) 
		dy = document.documentElement.scrollTop
		
	else if ( document.body )
		dy = document.body.scrollTop;
		
	ret = { dy:dy };

	return ret;
}

function resizefoto(obj) {
	var largura 	= obj.width;
	var altura 		= obj.height;
	var over 		= obj.parentNode.parentNode;
	var tamanhos 	= pageSize();
	var desloc 		= rolagem();
	var topo 		= desloc.dy + ( ( tamanhos.altu - altura - 20 ) / 2 );
	var esq 		= ( ( tamanhos.x - largura - 20 ) / 2 );
	
	over.style.top	= ( topo < 0 ) ? "0px" : topo + "px";
	over.style.left = ( esq < 0 ) ? "0px" : esq + "px";
	over.style.visibility = 'visible';
	
	try {
		var div1 = document.getElementById(  'zoom_' + obj.className );
		var div2 = document.getElementById( 'desc_' + obj.className );
		
		if( div1 )
			div1.style.width = largura;
			
		if( div2 )
			div2.style.width = largura;
			
	} catch(erro) {}
}
