function isContact(quem,contato,resp)
{
	obj = document.getElementById('HELP');
	obj.src = 'functions/php/help.php?acao=new_con&resp='+resp+'&q='+quem+'&c='+contato;
}

function blockContact(quem,contato,resp)
{
	obj = document.getElementById('HELP');
	obj.src = 'functions/php/help.php?acao=block_con&resp='+resp+'&q='+quem+'&c='+contato;
}
function commUser(quem,com,resp)
{
	obj = document.getElementById('HELP');
	obj.src = 'functions/php/help.php?acao=comm_user&resp='+resp+'&q='+quem+'&c='+com;
}

function addContact(quem,contato)
{
	obj = document.getElementById('HELP');
	obj.src = 'functions/php/help.php?acao=add_con&q='+quem+'&c='+contato;
}

function findContact()
{
	obj = document.getElementById('HELP');
	obj.src = 'functions/php/help.php?acao=find_contact&nome='+document.getElementById('nomeC').value;
}

function addTo(username)
{
	obj = document.getElementById('to');
	obj.value = obj.value + username + ';';
	closeObj('search_contact','display');
}

function addSmile(smile)
{
	obj = document.getElementById('mensagem');
	obj.value = obj.value + smile;
	closeObj('smiles','display');
}

function readed(msg)
{
	obj = document.getElementById('HELP');
	obj.src = 'functions/php/help.php?acao=readmsg&id='+msg;
}

function readed_m(msg)
{
	obj = document.getElementById('HELP');
	obj.src = 'functions/php/help.php?acao=readmsg&l=1&id='+msg;
}

function del_msg(msg)
{
	obj = document.getElementById('HELP');
	obj.src = 'functions/php/help.php?acao=delmsg&id='+msg;
}

function del_post(post)
{
	obj = document.getElementById('HELP');
	obj.src = 'functions/php/help.php?acao=delpost&id='+post;
}



function mascara_data(data,campo){ 
  var mydata = ''; 
  mydata = mydata + data; 
  if (mydata.length == 2){ 
	  mydata = mydata + '/'; 
	  document.getElementById(campo).value = mydata; 
  } 
  if (mydata.length == 5){ 
	  mydata = mydata + '/'; 
	  document.getElementById(campo).value = mydata; 
  } 
  if (mydata.length == 10){ 
	  verifica_data(campo); 
  } 
} 

function verifica_data (campo) 
{ 

	dia = (document.getElementById(campo).value.substring(0,2)); 
	mes = (document.getElementById(campo).value.substring(3,5)); 
	ano = (document.getElementById(campo).value.substring(6,10)); 
	
	situacao = ""; 
	// verifica o dia valido para cada mes 
	if ((dia < 01) || (dia < 01 || dia > 30) && (  mes == 04 || mes == 06 || mes == 9 || mes == 11 ) || dia > 31) { 
		situacao = "falsa"; 
	} 
	
	// verifica se o mes e valido 
	if (mes < 01 || mes > 12 ) { 
		situacao = "falsa"; 
	} 
	
	// verifica se e ano bissexto 
	if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) { 
		situacao = "falsa"; 
	} 
	
	if (document.getElementById(campo).value == "") { 
		situacao = "falsa"; 
	} 
	
	if (situacao == "falsa") 
	{ 
		alert("Data inválida!"); 
		document.getElementById(campo).value = '';
		document.getElementById(campo).focus(); 
	} 
} 


function IEHoverPseudo(total) 
{

	var navItems = document.getElementById("primary-nav").getElementsByTagName("li");
	
	for (var i=0; i < navItems.length; i++) 
	{
		if(navItems[i].className == "menuparent") 
		{
			navItems[i].onmouseover=function() { this.className = "over"; }
			navItems[i].onmouseout=function() { this.className = "menuparent"; }
		}
	}

}
function fonte(id, size)
{
	obj = document.getElementById(id);
	obj.style.fontSize = size +'px';
}

function preenche(num, id)
{
	obj = document.getElementById(id);
	val = obj.value;
	fim = val + num;
	obj.value = "";
	obj.value = fim;
}

function testaSenha(senha,confirmacao,formulario)
{
	if (erro == true) 
		return true;
	obj1 = eval("document."+formulario+"."+senha);
	obj2 = eval("document."+formulario+"."+confirmacao);
	if (obj1.value != obj2.value)
	{
		alert ('Sua senha não foi confirmada!');
		document.formulario.senha.focus();
		return true;
	}
	else 
		return false;
}

function testaVazio(campo,comparacao,formulario,mensagem,erro) 
{
	if (erro == true)
		return true;
	obj1 = eval("document."+formulario+"."+campo);
	if (obj1.value == comparacao)
	{
		alert (mensagem);
		obj1.focus();
		return true;
	}
	else 
		return false;
}

function testaNumero(campo,formulario,mensagem,erro)
{
	if (erro == true)
		return true;
	obj1 = eval("document."+formulario+"."+campo);
	if (isNaN(obj1.value)) 
	{
		obj1.value = "";
		alert (mensagem);
		obj1.focus();
		return true;
	}
	else 
		return false;
}

function mostraConteudo(id_cont,  id_local)
{
	obj_cont = document.getElementById(id_cont);
	obj_local = document.getElementById(id_local);
	
	obj_local.innerHTML = obj_cont.innerHTML;
}

function verDados(valor, option)
{
	if(valor == "")
	{
		alert("Você deve escolher um valor válido!");
	}
	else if(valor == 0)
	{
		alert("Você deve escolher um valor, não uma categoria!");
	}
	else
	{
		document.location = "index.php?acao=admin&action=" + option + "&act=ver&valor=" + valor	;
	}
}

var bookmarkurl="http://www.oficinadanet.com.br"
var bookmarktitle="Oficina da Net"
function addbookmark()
{
	if (document.all)
	{
		window.external.AddFavorite(bookmarkurl,bookmarktitle)
	}
	else
	{
		alert("Pressione Ctrl + D para adicionar!");
	}
}


function clickParceiro(parc)
{
	window.open('add_click.php?tipo=parceiros&parceiros_id='+parc);
}

function relogio()
{
	
	dataNow = new Date;
	
	spanClock = document.getElementById('relogio');
	if(dataNow.getHours()<10) hora = "0"+dataNow.getHours();
	else hora = dataNow.getHours();
	
	if(dataNow.getMinutes()<10) minutos = "0"+dataNow.getMinutes();
	else minutos = dataNow.getMinutes();
	
	if(dataNow.getSeconds()<10) segundos = "0"+dataNow.getSeconds();
	else segundos = dataNow.getSeconds();
	
	spanClock.innerHTML = hora+":"+minutos+":"+segundos;
	setTimeout('relogio();',1000);
}

function htmlColChange(show,logado,bt)
{
	obj = document.getElementById(show);
	base = document.getElementById('baseCol');
	
	if(show == 'info')
	{
		base.innerHTML = obj.innerHTML;
	}
	else if(logado == 0)
	{
		base.innerHTML = document.getElementById('log').innerHTML;
	}
	else
	{
		base.innerHTML = obj.innerHTML;
	}
	//obj.focus();
	openObj('baseCol','display');
}


///////////////////////////////////////////////////////////////////////////////////////////
atual = 0;
numero = 0;
function destaque(pos,tot,view)
{
	para = document.getElementById('dest');
	if(pos == 'pro')
	{
		if(numero == tot)
		{
			atual = tot;
			numero = 1;
		}
		else
		{
			atual = numero;
			numero++;
		}
		document.getElementById('x_'+atual).className = "page";
		document.getElementById('x_'+numero).className = "page_is";
		para.innerHTML = document.getElementById('dest_' + numero).innerHTML;
		atual++;
		
	}
	else if(pos == 'atu')
	{
		para.innerHTML = document.getElementById('dest_1').innerHTML;
		img_pro = document.getElementById('x_1').className = "page_is";
		atual++;
		numero = 1;
	}
	else if(pos == 'view')
	{
		for( x = 1; x <= tot; x++ )
			document.getElementById('x_'+x).className = "page";
		
		document.getElementById('x_'+view).className = "page_is";
		para.innerHTML = document.getElementById('dest_' + view).innerHTML;
		atual = view;
		numero = view;
	}
	else
	{
		if(numero == 1)
		{
			atual = 1;
			numero = tot;
		}
		else
		{
			atual = numero;
			numero--;
		}
		document.getElementById('x_'+atual).className = "page";
		document.getElementById('x_'+numero).className = "page_is";
		para.innerHTML = document.getElementById('dest_' + numero).innerHTML;
		atual--;
	}
	//setTimeout("destaque('pro',"+tot+")",30000);
}
///////////////////////////////////////////////////////////////////////////////////////////
aux = 1;
function showCol(id, total)
{
	//alert(total);
	obj = document.getElementById('col_'+id);
	var x;
	var t = 0;
	for (x = 1; x <= total; x++)
	{
		document.getElementById('col_'+x).style.display = 'none';	
	}
	if(aux == 1)
	{
		//new Effect.BlindDown('col_'+id);
		obj.style.display = 'block';	
		aux = 0;
	}
	else
	{
		closeDiv('col_'+id);
		aux = 1;
	}

}

function fechaPromo()
{
	document.getElementById('promocao').style.display = 'none';
}
function closeDiv(ids)
{
	document.getElementById(ids).style.display = 'none';
	
}


function closeObj(id, method)
{
	obj = document.getElementById(id);
	
	if(method == 'display')
		obj.style.display = 'none';
	else
		obj.style.visibility = 'hidden';
	
}

function openObj(id, method)
{
	obj = document.getElementById(id);
	
	if(method == 'display')
		obj.style.display = 'block';
	else
		obj.style.visibility = 'visible';
	
}



function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

/*ANTIGOS*/

function geralOver(id)
{
	obj = document.getElementById(id);
	obj.style.backgroundColor = '#F7F7F7';
}

function geralOut(id)
{
	obj = document.getElementById(id);
	obj.style.backgroundColor = '';
}

function objOver(id)
{
	obj = document.getElementById(id);
	obj.style.border = '1px solid #2F4F00';
	obj.style.color = '#2F4F00';
}
function objOut(id)
{
	obj = document.getElementById(id);
	obj.style.border = '1px solid #CCCCCC';
	obj.style.color = '#000000';
}
function objOver1(id)
{
	obj = document.getElementById(id);
	obj.style.border = '1px solid #2F4F00';
	obj.style.color = '#2F4F00';
}
function objOut1(id)
{
	obj = document.getElementById(id);
	obj.style.border = '1px solid #CCCCCC';
	obj.style.color = '#000000';
}


function retornaValor() {

	//alert();
	/*
	if (http_request.readyState == 1) {
		document.getElementById('index').innerHTML = "<div style='padding-top:5px;' align='center'>Carregando...</div>";
	}
	
	if (http_request.readyState == 4) {
		document.getElementById('retCalendario').innerHTML = http_request.responseText;
	}*/

}

var http_request = false;

function makeRequest(url) {
	//alert(url);
	http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}

	http_request.onreadystatechange = retornaValor;
	//alert(http_request.onreadystatechange);
	http_request.open('GET', url, true);
	http_request.send(null);
	//alert();

}