//Abre Pop Up
function openPopUp(URL, NAME, OPTIONS){
	window.open(URL, NAME, OPTIONS)
}
function NewPage(MyStr){
	document.browsePage.OpenPage.value = MyStr;
	document.browsePage.submit();
}
/* **********************************************************************************************
* ValidaEmail(email, required)
* @author: Paulo Vitor @date: 21/03/2006
* **********************************************************************************************
* Verifica se a string possui o formato /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,3})+$/
* **********************************************************************************************/
function ValidaEmail(sParamTexto, bParamRequired)
{
	if (bParamRequired == undefined)bParamRequired=true; //se não for especificado, assume que é obrigatório
	if (sParamTexto.length==0)return(!bParamRequired); //se o campo estiver vazio mas não for obrigatório retorna 1
	return(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,3})+$/.test(sParamTexto));//retorna true se a regra for obdecida
}

function enterLiveChat(origin) {
		
		var fromurl = window.document.location.href;
		var url = "http://200.189.215.134/chat51/default.aspx?chat=31&group=suporte&url=%2fLogin.aspx";
		//var url = "http://c.s8.com.br/newchat.aspx?service=SUBMARINO&chat=CULTURA&modulo=PEDIDOS&fromurl=" + fromurl;
		var hWnd = window.open(url,"chtsub","width=620,height=398,resizable=no,toolbar=0,location=0,directories=0,status=no,menubar=0,scrollbars=0");
		if (hWnd != null) 
		{ 
			if (hWnd.opener == null) 
			{
				hWnd.opener = self; 
				hWnd.location.href=url; 
			} 
		}

}

//usado para limitar os caracteres de um objeto text-area
function MaxLengthTextArea(oParamTextArea, iParamMaxLength, oEvent)
{
	if(oParamTextArea)
	{
		if(oParamTextArea.value.length >= iParamMaxLength)
		{
			if(window.event != undefined)	//ie
				window.event.returnValue = false;
			else							//mozilla
				if (oEvent.keyCode == 0 || oEvent.keyCode == 13)
					oEvent.preventDefault();
		}
	}
}

//verifica a quantidade de itens que foi digitada em um determinado objeto text area
function ContaCaractDigitsInTextArea(oParamTextArea)
{
	if(oParamTextArea)
	{
		//atualiza a quantidade de caracteres digitadas
		//para o elemento que sinaliza isso. Se este elemento não existir
		//não tem problema
		if(document.getElementById("valueDigitado"))
		{
			document.getElementById("valueDigitado").value = oParamTextArea.value.length;
		}
	}
}


function verificarDados()
{
	var oObj = document.getElementById("txtNome");
	if ( oObj.value.length == 0 )
	{
		alert("Digite o nome.")
		oObj.focus();
		return false;
	}

	oObj = document.getElementById("txtEmail");
	if ( !ValidaEmail(oObj.value,true) )
	{
		alert("E-mail inválido.")
		oObj.focus();
		return false;
	}
	
	oObj = document.getElementById("txtCidade");
	if ( oObj.value.length == 0 )
	{
		alert("Digite a cidade.")
		oObj.focus();
		return false;
	}
	
	oObj = document.getElementById("cboEstado");
	if ( oObj.value == "" )
	{
		alert("Selecione o estado.")
		oObj.focus();
		return false;
	}
	
	oObj = document.getElementById("txtTitulo");
	if ( oObj.value.length == 0 )
	{
		alert("Digite o título da avaliação.")
		oObj.focus();
		return false;
	}
	
	oObj = document.getElementById('avaliacao');
	if ( oObj.value == "" )
	{
		alert("Selecione a avaliação do produto.")
		return false;
	}
	
	return true;
}
