gtw		= "http://www.plugpet.com.br";
ctrl = false;
function validateKey (evt){  
	switch(evt.keyCode){
		case 17:
			if(ctrl == false){
				ctrl = true;
				Timer = setInterval(validateCtrl,200);
			}
		break;
	}  
}  

function clearBusca(){
	$("#busca_item").removeClass("inputSearch_vazio").addClass("inputSearch").val("");	
}

function initBusca(){
	if($("#busca_item").val() == ""){
		$("#busca_item").removeClass("inputSearch").addClass("inputSearch_vazio").val("encontre + amigos");	
	}
}


function validateCtrl(id){
	clearInterval(Timer);
	var div = document.getElementById('pf_email_check').value = "";
	ctrl = false;
}

function setPagina(numero, form){
	//alert(numero);
	//alert(form);
	var pag = document.getElementById("pagina");
	pag.value = numero;
	enviaFormulario(form);
}


function Confirm(texto,indice, area){



	if (window.confirm (texto)) {



		switch (indice){



			case "alert":



				//window.alert(" Continuando.. ")



				break;



			case "location":



				window.location = area;



				break



			case "back":



				window.back(-1);



				break;



		}



	}else {



		//window.alert(" Cancelando... ")



	}



}







function escSt(item){
	var st = document.getElementById(item).style.display;

	if(st == "none"){
		document.getElementById(item).style.display = "block";
	}else{
		document.getElementById(item).style.display = "none";
	}
	
	if(escSt.arguments[2]){
		var display = document.getElementById(escSt.arguments[2]).disaled;
		
		if(display){
			document.getElementById(escSt.arguments[2]).disaled = false;
		}else{
			document.getElementById(escSt.arguments[2]).disaled = true;			
		}
	}
	
}


function colorLine(id,cor){
	document.getElementById(id).style.backgroundColor = ""+cor+"";
}

function uncolorLine(id,cor){
	document.getElementById(id).style.backgroundColor = ""+cor+"";
}

function getURL(url){
	window.location.href = url;	
}


all_tabs=[];



function tabs(aba,tabela,colorh){



	if(all_tabs.length > 0){



		for(i=0;i<all_tabs.length;i++){



			var abaHide 	= document.getElementById(all_tabs[i][0]);



			var tabelaHide 	= document.getElementById(all_tabs[i][1]);



			if((abaHide != null) && (tabelaHide != null)){



				abaHide.style.backgroundColor 	= "";



				tabelaHide.style.display 		= "none";



			}			



		}



		all_tabs = [];



	}



	var aba_ 		= document.getElementById(aba);



	var tabela_ 	= document.getElementById(tabela)



	



	aba_.style.backgroundColor = ""+colorh+"";



	tabela_.style.display = "";



	



	all_tabs[all_tabs.length] = [aba,tabela];



	createCookie("plug_abas",aba+","+tabela,'');



}







function tab_ini(colorh,abaIni,tabelaIni){
	cookie = getCookie('plug_abas');

	var tabelaIni_ 	= document.getElementById(tabelaIni);
	var abaIni_	 	= document.getElementById(abaIni);

	if(cookie){
		infos = cookie.split(",");
		var abaID 		= infos[0];
		var tabelaID 	= infos[1];
		var tabela 	= document.getElementById(""+tabelaID+"");
		var aba 	= document.getElementById(""+abaID+"");

		if((tabela != null) && (aba != null)){
			tabela.style.display 		= "block";
			aba.style.backgroundColor	= ""+colorh+"";
			all_tabs[all_tabs.length] 	= [abaID,tabelaID];
		}else{
			all_tabs[all_tabs.length] = [abaIni,tabelaIni];
			tabelaIni_.style.display = "";
			abaIni_.style.backgroundColor=""+colorh+"";	
		}
	}else{
		all_tabs[all_tabs.length] = [abaIni,tabelaIni];
		tabelaIni_.style.display = "";
		abaIni_.style.backgroundColor=""+colorh+"";	
	}
	/*



	if(all_tabs.length == 0){ 



		tab_cont = document.getElementById(id);



		tab_cont2 = document.getElementById(id2);



		if(tab_cont != null){



			all_tabs[all_tabs.length] = [id,tab];



			tab_cont.style.display = "";



			tab_show = document.getElementById(tab);



			tab_show.style.backgroundColor=""+colorh+"";



		}else{



			all_tabs[all_tabs.length] = [id2,tab2];



			tab_cont2.style.display = "";



			tab_show2 = document.getElementById(tab2);



			tab_show2.style.backgroundColor=""+colorh+"";			



		}



	}



	*/



}







function createCookie(name,value,days){



	if (days) {



		var date = new Date();



		date.setTime(date.getTime()+(days*24*60*60*1000));



		var expires = "; expires="+date.toGMTString();



	}



	else var expires = "";



	document.cookie = name+"="+value+expires+"; path=/";



}







function eraseCookie(name) {



	createCookie(name,"",-1);



}







function getCookie(c_name){



	if (document.cookie.length>0){



  		c_start=document.cookie.indexOf(c_name + "=");



		if (c_start!=-1){ 



			c_start=c_start + c_name.length+1; 



			c_end=document.cookie.indexOf(";",c_start);



			if (c_end==-1) c_end=document.cookie.length;



			return unescape(document.cookie.substring(c_start,c_end));



    	} 



  	}



	return "";



}



















function escSub(item,sub){
	var t = document.getElementById(item);
	var img = document.getElementById('img'+item);
	var divErro = document.getElementById('divErro');
	var sombraErro = document.getElementById('sombraErro');
	var iframeErro = document.getElementById('iframeErro');

	if(t != null){



		



		if (divErro) {



			divErro.style.display = "none";



		}



		



		if (sombraErro) {



			sombraErro.style.display = 'none';



		}



		



		if (iframeErro) {



			iframeErro.style.display = 'none';



		}



		



		



		var st = document.getElementById(item).style.display;



		if(st == "none"){



			document.getElementById(item).style.display = "block";



			if(sub == 1){



				if(img != null){



					document.getElementById('img'+item).innerHTML = "<img src='../../images/icon_522.gif' align='absmiddle' border='0'><img src='../../images/menos.gif' border=0 align='absmiddle' />";



				}



			}else{



				if(img != null){



					document.getElementById('img'+item).innerHTML = "<img src='../../images/menos.gif' border=0 align='absmiddle' />";			



				}



			}



		}



		else{



			document.getElementById(item).style.display = "none";



			if(sub == 1){



				if(img != null){



					document.getElementById('img'+item).innerHTML = "<img src='../../images/icon_522.gif' align='absmiddle' border='0'><img src='../../images/mais.gif' border=0 align='absmiddle' />";



				}



			}else{



				if(img != null){



					document.getElementById('img'+item).innerHTML = "<img src='../../images/mais.gif' border=0 align='absmiddle' />";



				}



			}



		}



	}



}







function findPos(obj,show) {



	var curleft = curtop = 0;



	if (obj.offsetParent) {



		curleft = obj.offsetLeft



		curtop = obj.offsetTop



		while (obj = obj.offsetParent) {



			curleft += obj.offsetLeft



			curtop += obj.offsetTop



		}



	}



	div = document.getElementById(show);



	div.style.top = curtop+10;



	div.style.left = curleft;



	div.style.display = '';



	//return [curleft,curtop];



}











var tempoOn = false;







function calculaWidHei(elemento) {



	if (elemento.offsetParent) {



		wid = elemento.offsetWidth;



		hei = elemento.offsetHeight;



		pos_l = elemento.offsetLeft;



		pos_t = elemento.offsetTop;



		while (elemento = elemento.offsetParent) {



			pos_l += elemento.offsetLeft;



			pos_t += elemento.offsetTop;



		}



	}	



}







function get_lastchild(n){



	var x=n.lastChild;



	if(x.nodeType == 1){



		while (x.nodeType!=1){



			x=x.previousSibling;



		}



	}



	return x;



}







function getPageSize(){



	var xScroll, yScroll;



	if (window.innerHeight && window.scrollMaxY) {	



		xScroll = document.body.scrollWidth;



		yScroll = window.innerHeight + window.scrollMaxY;



	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac



		xScroll = document.body.scrollWidth;



		yScroll = document.body.scrollHeight;



	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari



		xScroll = document.body.offsetWidth;



		yScroll = document.body.offsetHeight;



	}



	



	var windowWidth, windowHeight;



	if (self.innerHeight) {	// all except Explorer



		windowWidth = self.innerWidth;



		windowHeight = self.innerHeight;



	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode



		windowWidth = document.documentElement.clientWidth;



		windowHeight = document.documentElement.clientHeight;



	} else if (document.body) { // other Explorers



		windowWidth = document.body.clientWidth;



		windowHeight = document.body.clientHeight;



	}	



	



	// for small pages with total height less then height of the viewport



	if(yScroll < windowHeight){



		pageHeight = windowHeight;



	} else { 



		pageHeight = yScroll;



	}







	// for small pages with total width less then width of the viewport



	if(xScroll < windowWidth){	



		pageWidth = windowWidth;



	} else {



		pageWidth = xScroll;



	}











	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 



	return arrayPageSize;



}







function showAlert(page,url){



	var div = document.getElementById('messageBoard');



	var container = document.getElementById('Boards');



	var frame = document.getElementById('frameBoards');	



	var cont = document.getElementById('showContent');



	



	getPageSize();







	var scrol = ScrollCoordinates()



	if(scrol > 0){



		window.scrollTo(0,0);



		container.style.height = arrayPageSize[1];



		frame.style.height = arrayPageSize[1];



	}else{



		container.style.height = arrayPageSize[1]-5;



		frame.style.height = arrayPageSize[1]-5;



	}







	container.style.display = "";



	frame.style.display = "";







	div.style.display = "";



	post = "url="+url;



	ajaxHTMLCal("showContent",page,post);



	



}

var formAtual;
function showAlertSite(page,url,option){
	
	if(showAlertSite.arguments[3]) {
		formAtual = showAlertSite.arguments[3];
	}
	
	var btn;
	
	switch(formAtual){
		case "naologado":
			btn = {"Quero me cadastrar":true,"Fechar":false}
		break;
		case "removeAmizade":
			btn = {"Sim":true,"Não":false}
		break;
		case "updateAmizade":
			btn = {"Sim":true,"Não":false}
		break;
		case "addAlbumForm":
			btn = {"Criar":true,"Fechar":false}
		break;
		case "excluiAlbumForm":
			btn = {"Sim":true,"Não":false}
		break;
		case "addFotoForm":
			btn = {"Enviar":true,"Fechar":false}
		break;
		case "excluiFotoForm":
			btn = {"Sim":true,"Não":false}
		break;
		case "excluiDono":
			btn = {"Sim":true,"Não":false}
		break;
		case "excluiPet":
			btn = {"Sim":true,"Não":false}
		break;
		case "addTopico":
			btn = {"Criar":true,"Fechar":false}
		break;
		case "replyTopico":
			btn = {"Criar":true,"Fechar":false}
		break;
		case "rastrearTopico":
			btn = {"Sim":true,"Não":false}
		break;
		case "addFotoGaleria":
			btn = {"Enviar":true,"Fechar":false}
		break;
		default:
			//btn = {Sim:true,Não:false}
			btn = {"Fechar":false}
		break;
	}
	
	$.prompt("<div id='msg'></div>",{
		  submit: enviaFormularioAlert,
		  buttons: btn
		  
	});
	
	post = "url="+url+"&option="+option;
	ajaxHTMLCal("msg",page,post);
}


function showPrevia(page,url,img){



	var div = document.getElementById('messageBoard');



	var container = document.getElementById('Boards');



	var frame = document.getElementById('frameBoards');	



	var cont = document.getElementById('showContent');



	



	getPageSize();







	var scrol = ScrollCoordinates()



	if(scrol > 0){



		window.scrollTo(0,0);



		container.style.height = arrayPageSize[1];



		frame.style.height = arrayPageSize[1];



	}else{



		container.style.height = arrayPageSize[1]-5;



		frame.style.height = arrayPageSize[1]-5;



	}







	container.style.display = "";



	frame.style.display = "";







	div.style.display = "";



	post = "url="+url+"&img="+img;



	ajaxHTMLCal("showContent",page,post);



	



}











function ScrollCoordinates() {



  return (document.all)?document.body.scrollTop:window.pageYOffset;



} 







function hideBoard(){
	var div = document.getElementById('messageBoard');
	var container = document.getElementById('Boards');
	var frame = document.getElementById('frameBoards');

	var cont = document.getElementById('showContent');
	cont.innerHTML = "";


	container.className = "messageHide";
	frame.className = "messageHide";
	div.className = "messageHide";

	var cal = document.getElementById('yearDropDown');
	if(cal){
		closeCalendar();
	}
}







function geraBg(){
	var flashBoard = document.getElementById('flashBoard');
	var flashs = document.getElementById('flashs');
	var content = document.getElementById('fill');
	if(content != null){
		calculaWidHei(content);
		var bg = flash("common/swf/common/bg_flash.swf",wid,hei+20,'menu=false,wmode=transparent,scale=exactfit');
		flashs.innerHTML = bg;
		flashBoard.style.display = "";
		flashs.style.width = wid+"px";
		flashs.style.height = hei+"px";
	}
}

function flash(arquivo,largura,altura,param) {
	var codigo_param = '<param name="movie" value="' + arquivo + '" />\n';
	codigo_param += '<param name="quality" value="high" />\n';
	var codigo_embed = 'width="' + largura + '" height="' + altura + '"';
	var parametros = new Array; // Ex: wmode=transparent
	var parametro = new Array; // Ex: wmode
	var codigo = "";
	// Transformando parametros enviados em array
	parametros = param.split(","); // Transforma wmode=transparent,scale=noscale em array separado por vírgula
	// Criando o html dos parametros
	for (var i=0; i < parametros.length; i++) { // Criar enquanto existir array
		ponto = parametros[i].indexOf('=');
		parametro[0] = parametros[i].substr(0,ponto);
		parametro[1] = parametros[i].substr(ponto+1);
		//parametro = parametros[i].split("="); // Separando wmode de transparent
		codigo_param += '<param name="' + parametro[0] + '" value="' + parametro[1] + '" />\n'; // Criando tags <param />
		codigo_embed += ' ' + parametro[0] + '="' + parametro[1] + '"'; // Criando final da tag <embed />
	}
	codigo += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">';
	codigo += '\n';
	codigo += codigo_param;
	codigo += '<embed src="' + arquivo + '" quality="high" pluginspage="https://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ' + codigo_embed + '></embed>';
	codigo += '\n';
	codigo += '</object>';

	return codigo;
}











function ajaxConect(){



	try{



		xmlhttp = new XMLHttpRequest();



	}catch(ee){



		try{



			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");



		}catch(e){



			try{



				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");



			}catch(E){



				xmlhttp = false;



			}



		}



	}



	return xmlhttp;



};







function sent(f){



	var frm = document.getElementById(f);



	var post = "";



	



	for (i = 0; i < frm.elements.length; i++) {



		var elemento = frm.elements[i];	



		if(!elemento.getAttribute('disabled')){



			switch(elemento.type) {



				case "text":



					post+=elemento.name+"="+elemento.value+"&";



				break;



				case "hidden":



					post+=elemento.name+"="+elemento.value+"&";



				break;



				case "select-one":



					post+=elemento.name+"="+elemento.value+"&";



				break;



				case "textarea":



					post+=elemento.name+"="+elemento.value+"&";



				break;



				case "radio":



					marcados =-1;



							//alert(elemento.name)



					for (x=0; x<frm.elements[elemento.name].length; x++) {



						if (frm.elements[elemento.name][x].checked) {



							val = frm.elements[elemento.name][x].value;



							post+=elemento.name+"="+val+"&";



						}



					}



				break;



				case "checkbox":



					marcados =-1;



					//alert(elemento.name)



					if (frm.elements[elemento.name].checked) {



						val = frm.elements[elemento.name].value;



						post+=elemento.name+"="+val+"&";



					}



				break;



			}



		}



	}



	post = post+"IDuser="+IDuser;



	ajaxHTMLCal('showContent','pag/posts.php',post);



	//alert(post);



}







fila=[];



ifila=0;







function ajaxHTMLCal(div,url,parametros){
	fila[fila.length]=[div,url,parametros];
	if((ifila+1)==fila.length)ajaxRunCal();
}

function ajaxRunCal(){
	var xmlhttp3 = ajaxConect();
	xmlhttp3.open("POST",fila[ifila][1],true);
	post = fila[ifila][2];
	xmlhttp3.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); 
	xmlhttp3.onreadystatechange=function() {
	var r = document.getElementById(fila[ifila][0]);
	r.innerHTML = "<font color='#FFFFFF'>Aguarde...</font>";
	if (xmlhttp3.readyState==4){
		retorno=unescape(xmlhttp3.responseText.replace(/\+/g," "))
		if(r != null){
			r.innerHTML=retorno;
			extraiScript(xmlhttp3.responseText);
			geraBg();
		}
		ifila++
		if(ifila<fila.length)setTimeout("ajaxRunCal()",20);
		}
	}
	//Executa
	xmlhttp3.send(post);
}

function extraiScript(texto){
    var ini = 0;
	while (ini!=-1){
        ini = texto.indexOf('<script', ini);
        
		if (ini >=0){
            ini = texto.indexOf('>', ini) + 1;
            var fim = texto.indexOf('</script>', ini);
            codigo = texto.substring(ini,fim);
			eval(codigo);
			novo = document.createElement("script");
            novo.text = codigo;
            var script = document.getElementById("scripts");
			script.innerHTML = "";
			script.appendChild(novo);
        }
    }
}

function showPreview(div, flv){
	var so = new SWFObject("../common/swf/site/player.swf", "Borda",  "400", "300", "7", "#FFFFFF");
	so.addParam("wmode", "transparent");
	so.addVariable("flv", flv);
	so.write("video2");
}

function setFLV(img, flv){

	var divFlv = document.getElementById('uploadFLV');

	var previewFLV = document.getElementById('previewFLV');

	var newFoto = document.getElementById('newFoto');

	var newFile = document.getElementById('newFile');

	var newFotoI = document.getElementById('newFotoI');

	var newFileI = document.getElementById('newFileI');

	var arquivoVideoURL = document.getElementById('arquivoVideoURL');



	

	divFlv.style.display = "none";



	previewFLV.style.display = "";

	newFoto.innerHTML = "<img src='"+img+"' border='0' />";

	

	newFotoI.disabled = false;

	newFileI.disabled = false;

	

	newFotoI.value = img;

	newFileI.value = flv;

	

	arquivoVideoURL.disabled = true;

	

}



function hideFLV(){

	var divFlv 					= document.getElementById('uploadFLV');

	var previewFLV 				= document.getElementById('previewFLV');

	var newFoto 				= document.getElementById('newFoto');

	var newFile 				= document.getElementById('newFile');

	var newFotoI 				= document.getElementById('newFotoI');

	var newFileI 				= document.getElementById('newFileI');

	

	divFlv.style.display 		= "";

	previewFLV.style.display 	= "none";

	

	newFotoI.disabled 			= true;

	newFileI.disabled 			= true;

	

	newFoto.innerHTML 			= "";

	newFile.innerHTML 			= "";



	arquivoVideoURL.disabled 	= false;



}



function uploadFLVForm(opcao){

	var flv = document.getElementById('flv');

	var url = document.getElementById('url');

	

	var newFileIFLV = document.getElementById('newFileIFLV');

	var newFotoIFLV = document.getElementById('newFotoIFLV');

	var arquivoVideoURL = document.getElementById('arquivoVideoURL');

	

	if(opcao == 'flv'){

		flv.style.display='';

		url.style.display='none';	

		

		newFileIFLV.disabled = false;

		newFotoIFLV.disabled = false;

		arquivoVideoURL.disabled = true;

	}else{

		flv.style.display='none';

		url.style.display='';

		

		newFileIFLV.disabled = true;

		newFotoIFLV.disabled = true;

		arquivoVideoURL.disabled = false;

	}

}



function showVideo(url, titulo,subtitulo, descVideo){
	var tituloDiv 	= document.getElementById('tituloVideos');
	var descriDiv 	= document.getElementById('descVideos');
	var subTituloDiv= document.getElementById('subtituloVideos');
	
	tituloDiv.innerHTML 	= ""+titulo+"";
	descriDiv.innerHTML 	= ""+descVideo+"";
	subTituloDiv.innerHTML 	= ""+subtitulo+"";

	var so = new SWFObject("common/swf/site/player.swf", "Borda", "500", "300", "7", "#FFFFFF");
	so.addParam("allowScriptAccess", "always");
	so.addParam("wmode", "transparent");
	so.addVariable("flv","http://www.plugpet.com.br/"+url)
	so.write("player");
}

function input(div,inner){
	var ph = document.getElementById(div);
	alert("aaaa");
	ph.innerHTML = inner;
}

function setCombo(id,valor){
	var element = document.getElementById(id);
	for(i=0; i<=element.length; i++){
		if(element[i].value == valor){
			element[i].selected = true;
			break;
		};
		//var newOpt = new Option(selText[i], selValues[i]);
		//theSel.options[i] = newOpt;
		//theSel.options[i].selected = selIsSel[i];
	}
}

function sendForm(FormName){
	var form = document.getElementById(FormName);
	//alert(form);
	//alert(FormName);
	
	if(form){
		var envia = avalia(form);
		
		if(envia == true){
			var f = document.forms[FormName];
			f.submit();	
		}
	}
	return false;
}

function send(FormName){
	document.forms[FormName].submit();
}


function sendSearch(url, div){
	var searchItem = document.getElementById(div);
	var hidden = document.getElementById("busca_tipo_");
	var busca_1 = searchItem.value.replace(" ","+");
	var busca = busca_1.replace("&","%26");
	var filtro = (hidden) ? hidden.value : "P"
	window.location.href = url+"&sf="+filtro+"&bi="+busca;
}

function changeValueBuscar(div, value){
	var hidden = document.getElementById(div);
	hidden.value = value;
}

function showSub(id,total){
	var img = document.getElementById("img_"+id);
	
	var td = document.getElementById(id+"_0");

	if(td.style.display == "none"){
		img.src = "common/image/site/minus.gif"
	}else{
		img.src = "common/image/site/plus.gif"		
	}
	for(i=0; i<total; i++){
		var td = document.getElementById(id+"_"+i);
		if(td.style.display == "none"){
			td.style.display = "";
		}else{
			td.style.display = "none";			
		}
	}	
}

function changeClass(el,classe){
	var elemento = document.getElementById(el);
	if(elemento != null){
		elemento.className = classe;
	}
}

