/*
script desenvolvido por Luis Carlos de Brito - luis@pevermelho.art.br - e Anderson Julio de Souza - anderson.julio@ibest.com.br - 45 8814-7761 | 45 3037-3004 - Cascavel - PR

caso venha adquirir este script por outro meio senao atraves dos autores, favor manter os creditos dos criadores
este script pode ser utilizado, modificado, publicado, utilizado sem restricoes desde que mantido os credidos dos criadores

##########------- tivemos muito trabalho para fazer este funcionar, respeite nosso trabalho e conhecimento -------##########

*/
var conexoes = new Array();
var naoPermitidas='alert null undefined none';
var idx = 0;

function openAjax() {
	try	{
		xmlhttp= new ActiveXObject("Msxml2.XMLHTTP");
	}catch (e) {
		try 		{
			xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
		}catch (Ex) {
			xmlhttp= false;
		}
	}
	if(!xmlhttp && typeof XMLHttpRequest!='undefined') {
	   xmlhttp= new XMLHttpRequest();
	}
	return xmlhttp;
}

function ReqHeader(method, index){
	conexoes[index].open(method, URL, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 
    xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate"); 
    xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0"); 
    xmlhttp.setRequestHeader("Pragma", "no-cache"); 
}

function Response(dv,index){
   conexoes[index].onreadystatechange=function() {
      if(conexoes[index].readyState==4) {
	     if(conexoes[index].status==200) {
		    resp=conexoes[index].responseText;
		    switch(dv) {
		    	case 'alert':
		    		showDvAlert(resp);
		    		break;
		    	case 'none': break;
		    	default:
		    		 getElmt(dv).innerHTML=resp;
		    }
		   // setCorner();
	     }
      }
   }
}

function getElmt(id) {
	return document.getElementById(id);
}

function buscarConteudo(dv,dst,param1,param2) {
	idx = conexoes.push(openAjax());
	idx-=1;
	URL='conteudo.php';
	ReqHeader('post', idx); 

	if(naoPermitidas.indexOf(dv)==-1)
		getElmt(dv).innerHTML='<b>Aguarde, carregando...<img src="imagens/carregando.gif" border="0"></b>'; 
	conexoes[idx].send("acao=" + escape(dst)+"&param1="+escape(param1)+"&param2="+escape(param2));
	Response(dv,idx);
}

function buscarURL(dv,dst,param) {
	idx = conexoes.push(openAjax());
	idx-=1;
	URL=dst;
	if(dst=='')
		URL='conteudo.php';
	ReqHeader('post', idx);
	
	if(naoPermitidas.indexOf(dv)==-1)
		getElmt(dv).innerHTML='<b>Aguarde, carregando...<img src="imagens/carregando.gif" border="0"></b>'; 
	conexoes[idx].send(param);
	Response(dv,idx);
}

function showHide(id,param) {
	getElmt(id).style.display=param;
}

function insertSWF(file, w, h, params) {
	insert = new Flash(file, '', w, h);
	insert.addParameter('wmode', 'transparent'); 
	insert.addParameter('showMenu', 'false'); 
	
	if(params.lenght>2) {
		data = params.split(',');
		for(i in data) {
			param_value = data[i].split('=');
			insert.addParameter(''+param_value[0]+'', ''+param_value[1]+'');
		}
	}
	return insert.toString();
}


function init() {
	getElmt('site').innerHTML=insertSWF('index.swf', 1000, 1000, '');
	$('.publicidade').cycle({fx:'fade'});
	/*if(document.referrer.indexOf('sonhachnek.com.br')==-1) {
		getElmt('popup').style.left=(window.screen.width-600)/2+'px';
		$('#popup').slideToggle();
	}*/
}


function tocar() {
	str='<embed src="upload/musica.mp3" width="1" height="1"></embed>';
	window.setTimeout(function(){ getElmt('musica').innerHTML=str;},500);
	
}

function parar() {
	getElmt('musica').innerHTML='';
}

var cache = (new Image()).src='upload/fundo_inicial.jpg';

if(window.navigator.appName=="Microsoft Internet Explorer") {
	window.attachEvent('onload', init);
} else {
	window.addEventListener("load", init, false);
}

