$(window).resize(topMenuPosition);
$(window).load(Window_OnLoad);
			   
function Window_OnLoad()
{

	// Carrega a função para posicionar o menu de soluções
	topMenuPosition();
							   
}

function topMenuPosition()
{
	padding		= 10;
	posicaoLeft	= $("#liAlesteGroup").offset().left + padding;
	posicaoTop	= $("#liAlesteGroup").offset().top;
	$('#menuAlesteGroup').css("left",posicaoLeft + "px");
	$('#menuAlesteGroup').css("top",posicaoTop);
	$('#menuAlesteGroup').show();
}

function switchTabs(PsTabId)
{
	for (i = 0; i < 3; i++)
	{
		$("#aba_" + i).removeClass("on");
		$("#aba_" + i).addClass("off");
		
		if(i != PsTabId)
			$("#content_" + i).hide();
		else
			$("#content_" + i).show();
	}
	
	$("#aba_" + PsTabId).addClass("on");
}

function showLang()
{
	$("#lang_div_off").toggle();
}

function changePicture(PsItem,PiType)
{
	if(PiType == 0)
	{
		$("#" + PsItem).removeClass("PsItem");
		$("#" + PsItem).addClass(PsItem + "Over");
	}
	
	else
	{
		$("#" + PsItem).removeClass(PsItem + "Over");
		$("#" + PsItem).addClass("PsItem");
	}
}

function abrirprint(pagina,largura,altura)
{
	var esquerda = 2000;
	var topo = 2000;
	window.open(pagina,'','status=yes,height=' + altura + ', width=' + largura + ', top='+topo+', left='+esquerda+'');
}

function abrirpopup(pagina,largura,altura)
{	
	var esquerda = (screen.width - largura)/2;
	var topo = (screen.height - altura)/2;
	window.open(pagina,'','status=yes,height=' + altura + ', width=' + largura + ', top='+topo+', left='+esquerda+'');
}

function abrirrelatorio(pagina)
{
	var largura = (screen.width - 10);
	var altura = (screen.height - 90);
	window.open(pagina, '', "resizable=1,scrollbars=1,status=yes,height=" + altura + ", width=" + largura + ", top=0, left=0");
}

function PopupPic(caminho)
{
	var w = window.open('imagem.php?img='+caminho, "_blank", "width=100,height=100,toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no");
	w.screenX = 20;
	w.screenY = 20;
}

function limpainput(obj)
{
	obj.value = "";
}

function MM_swapImgRestore()
{
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d)
{
	var p,i,x;
	if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length)
	{
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
		for(i=0;!x&&i<d.forms.length;i++)
			x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=MM_findObj(n,d.layers[i].document);
		
	if(!x && d.getElementById)
		x=d.getElementById(n); return x;
}

function MM_swapImage()
{
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null)
	{
		document.MM_sr[j++]=x;
		if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


//FAZ O MOUSEOVER NA TR E COLOCA O LINK NELA
function over_tr(src,clrOver)
{
	if (!src.contains(event.fromElement))
	{
		src.style.cursor = 'hand';
		src.bgColor = clrOver;
	}
}
function out_tr(src,clrIn)
{
	if (!src.contains(event.toElement))
	{
		src.style.cursor = 'default';
		src.bgColor = clrIn;
	}
}
function go(loc)
{
	window.location.href = loc;
}


//FUNÇÕES DE PAGINAÇÃO
function decrementa(nameForm, nameField)
{
	var form = eval("document." + nameForm);
	if(form == null)
	{
		alert("Função decrementa não encontrou o formulário");
	} else {
		var field = eval("document." + nameForm + "." + nameField);
		if(field == null)
		{
			alert("Função decrementa não encontrou o campo que contém a página atual");
		} else {
			if(verificaIsNum(field.value))
			{
				if(parseInt(field.value) > 1)
				{
					field.value = parseInt(field.value) - 1;
					form.submit();
				} else {
					return false;
				}
			} else {
				return false;
			}
		}
	}
}
	
function incrementa(nameForm, nameField, totalPaginas)
{
	var form = eval("document." + nameForm);
	if(form == null)
	{
		alert("Função incrementa não encontrou o formulário");
	} else {
		var field = eval("document." + nameForm + "." + nameField);
		if(field == null)
		{
			alert("Função incrementa não encontrou o campo que contém a página atual");
		} else {
			if( (verificaIsNum(field.value)) && (verificaIsNum(totalPaginas)) )
			{
				if(parseInt(field.value) < totalPaginas)
				{
					field.value = parseInt(field.value) + 1;
					form.submit();
				} else {
					return false;
				}
			} else {
				return false;
			}
		}
	}
}

//FORMATA MONETÁRIOS
function FmascTempoReal(ConteudoCampo)
{
	if(((event.keyCode) > 47) && ((event.keyCode) < 58))
	{
		NumDig = ConteudoCampo.value;
		TamDig = NumDig.length;
		Contador = 0;
		if(TamDig > 1)
		{
			numer = "";
			for(i = TamDig; (i >= 0); i--)
			{
				if((parseInt(NumDig.substr(i,1))>=0) && (parseInt(NumDig.substr(i, 1))<=9))
				{
					Contador++;
					if((Contador == 2) && ((TamDig -i) < 4))
					{
						numer = "," + numer;
						Contador = 0;
					}
					else if (Contador == 3)
					{
						numer = "." + numer;
						Contador = 0;
					}
					numer = NumDig.substr(i, 1) + numer;
				}
			}
			ConteudoCampo.value = numer;
		};
		return(true)
	}
   else return(false)
}

/* Função para formatar o valor */
function FtrataBackSpace(dado)
{
	NumDig = dado.value;
	TamDig = NumDig.length;
	TamDig--;
	Contador = 0;
	if((TamDig >= 0) && (event.keyCode == 8))
	{
		numer = "";
		for (i = TamDig; (i >= 0); i--)
		{
			if((parseInt(NumDig.substr(i,1))>=0) && (parseInt(NumDig.substr(i, 1))<=9))
			{
				Contador++;
				if((Contador == 4) && ((TamDig -i) < 5))
				{
					numer = "," + numer;
					Contador = 0;
				}
				else if ((Contador == 3) && ((numer.length) > 4))
				{
					numer = "." + numer;
					Contador = 0;
				}
				numer = NumDig.substr(i, 1) + numer;
			}
		}
		dado.value = numer;
	};
}

function FormatNumber(dado)
{
	if (dado.length > 0)
	{
		dado.value = ValorFloatToFmt(FloatToSrt(ValorFmtToFloat(dado.value)))
	}		
}

function ValorFmtToFloat(input)
{
	var inputlength = input.length;
	input = input.toLowerCase();
	var number = "";
	for (i = 0; i < inputlength; i++)
	{
		var character = input.charAt(i);   
		switch(character)
		{
			case '0': number += "0"; break;
			case '1': number += "1"; break;
			case '2': number += "2"; break;
			case '3': number += "3"; break;
			case '4': number += "4"; break;
			case '5': number += "5"; break;
			case '6': number += "6"; break;
			case '7': number += "7"; break;
			case '8': number += "8"; break;
			case '9': number += "9"; break;
		}
	}
	var numberAux = number.substring(0, number.length - 2);
	if(numberAux == "")
	{
		numberAux += "0";
	}	
	numberAux += ".";	
	numberAux += number.substring(number.length - 2, number.length);	
	number = numberAux;
	var valor;
	//var valor =0;
	valor = parseFloat(number);
	//valor = eval(number);
	return valor;
}

function FloatToSrt(Num)
{
	var valorStr = "";
	var pospt = 0;
	valorStr += Num;	
	if(Num <= .99)
	{
		valorStr = valorStr.replace("0", "");
		valorStr = "0" + valorStr;		
	}	
	for (var n = 1 ; n <= valorStr.length ; n++) 
	{
		if (valorStr.substring(n-1, n) == ".") 
		{
			pospt = n;
			break;
		}
	}

	if (pospt == 0)		
	{
		valorStr += ".00";		
	}
	else if(pospt > 0)
	{
		var fracao = valorStr.substring(pospt, valorStr.length);
		if(fracao.length == 1)
		{
			valorStr += "0";			
		}
	}
	return valorStr;
}

function ValorFloatToFmt(Num)
{
	var numer;
	var i;	
	var TamDig = Num.length;
	var Contador = 0;
	if (TamDig > 1)
	{
 		numer = "";
   		for (i = TamDig; (i >= 0); i--)
   		{
			if ((parseInt(Num.substr(i,1))>=0) && (parseInt(Num.substr(i, 1))<=9))
			{
				Contador++;
				if ((Contador == 3) && ((TamDig -i) < 5))
				{
					numer = "," + numer;
					Contador = 0;
				}
				else if (Contador == 3)
				{
					numer = "." + numer;
					Contador = 0;					
				}
				numer = Num.substr(i, 1) + numer;
			}
		}       
	}    
	return numer;   
}

//FIM FORMATA MONETÁRIOS

//Marca ou desmarca os checkboxes
function checkUncheck(form, nameCheck)
{	
	if(eval('document.' + form + '.' + nameCheck + '.length') != undefined)		
	{	
		for(i = 0; i < eval("document." + form + "." + nameCheck + ".length"); i++)
		{
			eval("document." + form + "." + nameCheck + "[" + i + "].checked = !document." + form + "." + nameCheck + "[" + i + "].checked");
		}
	} else {
		eval('document.' + form + '.' + nameCheck + '.checked = !document.' + form + '.' + nameCheck + '.checked;');
	}	
}
//Função que valida os checkboxes para deleção
function checkDelete(form, nameCheck)
{
	var marcado = false;
	if(eval('document.' + form + '.' + nameCheck + '.length') != undefined)
	{
		for(i = 0; i < eval("document." + form + "." + nameCheck + ".length"); i++)
		{
			if(eval("document." + form + "." + nameCheck + "[" + i + "].checked") == true)
			{
				marcado = true;
				break;
			}
		}
	}	
	else
	{	
		if(eval('document.' + form + '.' + nameCheck + '.checked') == true)
		{
			marcado = true;
		}
	}	
	
	if(marcado)
	{
		if(confirm("Você deseja realmente apagar este(s) ítem(ns)?") == true)
		{
			return true;
		} else {
			return false;
		}
	} else {
		alert("Você deve selecionar pelo menos um ítem para ser deletado!");
		return false;
	}
}

//Função que valida os checkboxes para deleção
function checkDeletePHP(form, nameCheck)
{
	var marcado = false;
	if(eval("document." + form + ".cods") != null) {
		eval("document." + form + ".cods.value = '';");
	}
	
	if(eval('document.' + form + '.' + nameCheck + '.length') != undefined)
	{
		for(i = 0; i < eval("document." + form + "." + nameCheck + ".length"); i++)
		{
			if(eval("document." + form + "." + nameCheck + "[" + i + "].checked") == true)
			{
				if(eval("document." + form + ".cods") != null) {
					if(eval("document." + form + ".cods.value == ''")) {
						eval("document." + form + ".cods.value = document." + form + "." + nameCheck + "[" + i + "].value;");
					} else {
						eval("document." + form + ".cods.value = document." + form + ".cods.value + ', ' + document." + form + "." + nameCheck + "[" + i + "].value;");
					}
				}
				marcado = true;
			}
		}
	}
	else	
	{
		if(eval('document.' + form + '.' + nameCheck + '.checked'))
		{
			eval("document." + form + ".cods.value = document." + form + "." + nameCheck + ".value;");
			marcado = true;			
		}
	}	
	if(marcado)
	{
		if(confirm("Você deseja realmente apagar este(s) ítem(ns)?") == true)
		{
			return true;
		} else {
			return false;
		}
	} else {
		alert("Você deve selecionar pelo menos um ítem para ser deletado!");
		return false;
	}
}


//Compara duas datas
function comparaData(form, data1, data2)
{
	DataInicial = eval('document.' + form + '.' + data1 + '.value' );
	DataFinal = eval('document.' + form + '.' + data2 + '.value' );
	DataInicial = DataInicial.split("/");
	DataFinal = DataFinal.split("/");
	DataInicial = new Date(DataInicial[2],DataInicial[1],DataInicial[0]);
	DataFinal = new Date(DataFinal[2],DataFinal[1],DataFinal[0]);
	
	if(DataInicial > DataFinal)
	{	
		return false;
	}	
	else
	{	
		return true;
	}
}

function addOption(selectId, txt, val) {
	var objOption = new Option(txt, val);

	document.getElementById(selectId).options.add(objOption);
}

function checkRadioMarcado(objCheck)
{
	var marcado = false;
	if(objCheck == null) {
		alert("A função checkRadioMarcado não encontrou o campo");
	} else {
		if(typeof(objCheck.length) != 'undefined') {
			for(i = 0; i < objCheck.length; i++) {
				if(objCheck[i].checked == true) {
					marcado = true;
					break;
				}
			}
		} else {
			if(objCheck.checked == true) {
				marcado = true;
			}
		}
	}
	return marcado;	
}

function check_email(e) {
  ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
  for(i=0; i < e.length ;i++){
    if(ok.indexOf(e.charAt(i))<0){ 
    return (false);
  }	
} 
  if (document.images) {
    re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
    re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
    if (!e.match(re) && e.match(re_two)) {
      return (-1);		
    } 
  }
}
function validaLogin(){
  var field = '';
  with (document.getElementById('frmLogin')){
  	if (tipologin.value == 'logar'){
  	  if (!usuario.value || usuario.value == 'Usuário') field = '\nUsuário';
      if (!senha.value || senha.value == 'xxxx') field += '\nSenha';       
  	}else if (tipologin.value == 'lembrar'){
  	  if (!nome.value || nome.value == 'Nome') field += '\nNome';
      if (!email.value || email.value == 'Email') field += '\nEmail';         		
  	}
  }
 
  if (!field) document.getElementById('frmLogin').submit();
  else alert('Necessário preencher os campos: \n'+field);   	
}

function validaLoginNew(){
  var field = '';
  with (document.getElementById('formLogin'))
  {
  	if (tipologin.value == 'logar'){
  	  if (!usuario.value || usuario.value == 'Usuário') field = '\nUsuário';
      if (!senha.value || senha.value == 'xxxx') field += '\nSenha';       
  	}else if (tipologin.value == 'lembrar'){
  	  if (!nome.value || nome.value == 'Nome') field += '\nNome';
      if (!email.value || email.value == 'Email') field += '\nEmail';         		
  	}
  }
 
  if (!field)
  {
  	document.getElementById('formLogin').submit();
  }
  else
  {
	alert('Necessário preencher os campos: \n'+field);
	return false;
  }
}

function sFormSenha(){
	if (document.getElementById('tipologin').value=='logar')
	{
		document.getElementById('divLoginSenha').style.display = 'none';
		document.getElementById('divNomeEmail').style.display = '';
		document.getElementById('tipologin').value = 'lembrar';  
		document.getElementById('lblEsqueci').innerHTML = '[login]';  
	}else if (document.getElementById('tipologin').value=='lembrar')
	{
		document.getElementById('divLoginSenha').style.display = '';
		document.getElementById('divNomeEmail').style.display = 'none';		
		document.getElementById('tipologin').value = 'logar'; 
		document.getElementById('lblEsqueci').innerHTML = "["+Resources.FORGOTPASSWORD+"]";  
	}
}

function validasenha(campo1, campo2)
{
	if((document.getElementById(campo1).value != "") || (document.getElementById(campo1).value != ""))
	{
		if(document.getElementById(campo1).value == document.getElementById(campo2).value)
		{
		return true;
		}
		else
		{
			alert("Nova senha e confirmação não conferem");
			return false;
		}
	}
	else
	{
		return false;
	}
}

function abrirlogin(elemento)
{
	if(document.getElementById(elemento).style.display == 'none')
		document.getElementById(elemento).style.display = '';
	else
		document.getElementById(elemento).style.display = 'none';
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function loadremotesite(site,user,key)
{
	document.getElementById('remotesiteframe').src = site+'?user='+user+'?key='+key;
}

function mostrardiv()
{
	if(document.getElementById('right-headerlista').style.display == 'none')
    {
		document.getElementById('right-headerlista').style.display = '';
	}
	else
	{
		document.getElementById('right-headerlista').style.display = 'none';
	}
}


function openCloseBox(p){
	
	if (document.getElementById('box_'+p).style.display=='none'){
	  document.getElementById('box_'+p).style.display = '';
	  document.getElementById('boxtitle_'+p).className = 'h5-solucoes-sel';
   }else{
	 document.getElementById('box_'+p).style.display = 'none';		  
	 document.getElementById('boxtitle_'+p).className = 'h5-solucoes';
   }
	
}

var solucaoBoxStatus = 0;

function openCloseAllBoxes(total){
	    
        for (i = 0; i < total; i++){
        	if (document.getElementById('box_'+i).style.display == ''){
        	   for (j = 0; j < total; j++){
        	   	   document.getElementById('box_'+j).style.display = 'none';   
        	   	   document.getElementById('boxtitle_'+j).className = 'h5-solucoes';    
        	   }
        	   document.getElementById('labelexpande').innerHTML = Resources.EXPANDINGALL;
        	   break;
        	}  
        	if (document.getElementById('box_'+i).style.display == 'none'){
        	   for (j = 0; j < total; j++){
        	   	   document.getElementById('box_'+j).style.display = '';
        	   	   document.getElementById('boxtitle_'+j).className = 'h5-solucoes-sel';    
        	   }
        	   document.getElementById('labelexpande').innerHTML = Resources.COLLECTEDALL;
        	   break;
        	}         	
        }    
        
}
	
	function querystring(variavel)
	{ 
	var url = window.location.href;
	 qs = url.split('&');
	  for(i=0;i<qs.length;i++){
		pg = qs[i].substr(qs[i].indexOf('?')+1,qs[i].length - qs[i].indexOf('?'));
		v = pg.substr(0,pg.indexOf('='));
		if(variavel == v){
		valor = pg.substr(pg.indexOf('=')+1,pg.length - pg.indexOf('='));
		return valor;  
		} 
	  }
	}
		
	function redirecionarhistory(id)
	{
		query = querystring('contentId');
		window.location.href = "contentLevel_3.php?contentId=" + query + "&history=" + id;
	}
	
	function validaFormTrabalhe()
	{
		doc = document.trabalheConosco;		
		// Validar nome
		if (doc.nome.value == "")
		{
			alert("Campo 'Nome' em branco!");
			doc.nome.focus();
			return false;
		}
		
		// Validar email
		if (doc.email.value == "")
		{
			alert("Campo 'E-mail' em branco!");
			doc.email.focus();
			return false;
		}
		
		// Validar email - dados
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(doc.email.value)))
		{
			alert("Campo 'E-mail' inválido!");
			doc.email.focus();
			return false;
		}
		
		// Validar area
		if (doc.area.value == "selecione")
		{
			alert("Campo 'Área' não selecionado!");
			doc.area.focus();
			return false;
		}
		
		// Validar cidade
		if (doc.cidade.value == "")
		{
			alert("Campo 'Cidade' em branco!");
			doc.cidade.focus();
			return false;
		}
		
		// Validar arquivo
		if (doc.anexocv.value == "")
		{
			alert("Campo 'Anexo' em branco!");
			doc.anexocv.focus();
			return false;
		}
		
		// Validar arquivo - conteudo invalido
		if (doc.anexocv.value != "")
		{		
			exts = ['doc','docx','zip','rar','pdf','txt'];
			bOk  = false;
			
			for (i = 0; i < exts.length; i++) 
			{
				if (doc.anexocv.value.lastIndexOf("." + exts[ i ]) != -1) bOk = true;
			}
			if (!bOk) 
			{     
				alert("Extensão de arquivo inválida!");
				doc.anexocv.focus();
				return false;
			}
		}
		return true;
	}
	
	function validaFormContato()
	{
		// Validar departamento
		if ($("#departamento").val() == "selecione")
		{
			alert("Campo 'Departamento' não selecionado!");
			$("#departamento").focus();
			return false;
		}
		
		// Validar nome
		if ($("#nome").val() == "")
		{
			alert("Campo 'Nome' em branco!");
			$("nome").focus();
			return false;
		}
		
		// Validar email
		if ($("#email").val() == "")
		{
			alert("Campo 'E-mail' em branco!");
			$("#email").focus();
			return false;
		}
		
		// Validar email - dados
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($("#email").val())))
		{
			alert("Campo 'E-mail' inválido!");
			$("#email").focus();
			return false;
		}
		
		// Validar fone
		if ($("#fone").val() == "")
		{
			alert("Campo 'Telefone' em branco!");
			$("#fone").focus();
			return false;
		}
		
		// Validar cidade
		if ($("#cidade").val() == "")
		{
			alert("Campo 'Cidade' em branco!");
			$("#cidade").focus();
			return false;
		}
		
		// Validar estado
		if ($("#estado").val() == "selecione")
		{
			alert("Campo 'Estado' não selecionado!");
			$("#estado").focus();
			return false;
		}
		
		// Validar duvida
		if ($("#duvida").val() == "")
		{
			alert("Campo 'Dúvida' em branco!");
			$("#duvida").focus();
			return false;
		}
		return true;
	}
	
	function validaFormSac()
	{
		// Validar nome
		if ($("#empresa").val() == "")
		{
			alert("Campo 'Nome da Empresa' em branco!");
			$("nome").focus();
			return false;
		}
		
		// Validar nome
		if ($("#nome").val() == "")
		{
			alert("Campo 'Nome do Contato' em branco!");
			$("nome").focus();
			return false;
		}
		
		//Validar tipo de sexo
		if($("input[name=sexo]:checked").length == 0 ) 
		{ 
			alert("'Sexo' não selecionado!"); 
			$("#sexo").focus();
			return false; 
		} 
		
		// Validar email
		if ($("#email").val() == "")
		{
			alert("Campo 'E-mail' em branco!");
			$("#email").focus();
			return false;
		}
		
		// Validar email - dados
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($("#email").val())))
		{
			alert("Campo 'E-mail' inválido!");
			$("#email").focus();
			return false;
		}
		
		// Validar cidade
		if ($("#cidade").val() == "")
		{
			alert("Campo 'Cidade' em branco!");
			$("#cidade").focus();
			return false;
		}
		
		// Validar estado
		if ($("#estado").val() == "selecione")
		{
			alert("Campo 'Estado' não selecionado!");
			$("#estado").focus();
			return false;
		}
		
		//Validar tipo de mensagem
		if($("input[name=tipomensagem]:checked").length == 0 )
		{
			alert("'Tipo de Mensagem' não selecionado!");
			$("#tipomensagem").focus();
			return false;
		}
		
		// Validar Mensagem
		if ($("#mensagem").val() == "")
		{
			alert("Campo 'Mensagem' em branco!");
			$("#mensagem").focus();
			return false;
		}
		return true;
	}
	
	function validaFormParceiro()
	{
		doc = document.parceiro;
		
		// Validar nome
		if (doc.nome.value == "")
		{
			alert("Campo 'Nome' em branco!");
			doc.nome.focus();
			return false;
		}
		
		// Validar empresa
		if (doc.empresa.value == "")
		{
			alert("Campo 'Empresa' em branco!");
			doc.empresa.focus();
			return false;
		}
		
		// Validar Telefone
		if (doc.fone.value == "")
		{
			alert("Campo 'Telefone' em branco!");
			doc.fone.focus();
			return false;
		}
		
		// Validar duvida
		if (doc.duvida.value == "")
		{
			alert("Campo 'Comentário' em branco!");
			doc.duvida.focus();
			return false;
		}
		
		// Validar email
		if (doc.email.value == "")
		{
			alert("Campo 'E-mail' em branco!");
			doc.email.focus();
			return false;
		}
		
		// Validar email - dados
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(doc.email.value)))
		{
			alert("Campo 'E-mail' inválido!");
			doc.email.focus();
			return false;
		}
		return true;
	}
	
	function validaFormComoComprar()
	{
		doc = document.comoComprar;
		// Validar nome
		if (doc.nome.value == "")
		{
			alert("Campo 'Nome' em branco!");
			doc.nome.focus();
			return false;
		}
		
		// Validar empresa
		if (doc.empresa.value == "")
		{
			alert("Campo 'Empresa' em branco!");
			doc.empresa.focus();
			return false;
		}
		
		// Validar email
		if (doc.email.value == "")
		{
			alert("Campo 'E-mail' em branco!");
			doc.email.focus();
			return false;
		}
		
		// Validar email - dados
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(doc.email.value)))
		{
			alert("Campo 'E-mail' inválido!");
			doc.email.focus();
			return false;
		}
		
		// Validar fone
		if (doc.fone.value == "")
		{
			alert("Campo 'Telefone' em branco!");
			doc.fone.focus();
			return false;
		}
		
		// Validar endereco
		if (doc.endereco.value == "")
		{
			alert("Campo 'Endereco' em branco!");
			doc.endereco.focus();
			return false;
		}
		
		// Validar cidade
		if (doc.cidade.value == "")
		{
			alert("Campo 'Cidade' em branco!");
			doc.cidade.focus();
			return false;
		}
		
		// Validar estado
		if (doc.estado.value == "selecione")
		{
			alert("Campo 'Estado' não selecionado!");
			doc.estado.focus();
			return false;
		}
		return true;
	}
	
	function validaRecom()
	{	
		// Validar Nome
		if ($("#nome").val() == "")
		{
			alert("Campo 'Nome' em branco!");
			$("#nome").focus();
			return false;
		}
		
		if ($("#email").val() == "")
		{
			alert("Campo 'E-mail' em branco!");
			$("#email").focus();
			return false;
		}
		
		// Validar email - dados
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($("#email").val())))
		{
			alert("Campo 'E-mail' inválido!");
			$("#email").focus();
			return false;
		}

			return true;
	}
		
	function openNewOffice()
	{
		window.open('http://www.ivirtua.com.br/newoffice.php','','height = 325, width = 500,left = 0, screenX = 0, top = 0, screenY = 0');
	}
	
	function changeEmailTab ()
	{
		document.getElementById('divLinkReportWeb').style.display = 'none';
		document.getElementById('divMailReportWeb').style.display = 'block';
	}
	
	function validaFormReportWeb()
	{
		doc = document.mailReportWeb;
		
		// Validar email
		if (doc.email.value == "")
		{
			alert("Campo 'E-mail' em branco!");
			doc.email.focus();
			return false;
		}
		
		// Validar email - dados
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(doc.email.value)))
		{
			alert("Campo 'E-mail' inválido!");
			doc.email.focus();
			return false;
		}
		return true;
	}
	
	function filterCustomers()
	{
		var cat	= document.getElementById("listCategories").value;		
		var query = querystring('contentId');
		
		window.location.href = "contentLevel_1.php?contentId=" + query + "&customerid=" + cat;
	}
	
	function filterPartner(PiFilter)
	{
		if (PiFilter == 0)
		{
			var cat	= "&region=" + document.getElementById("listRegion").value;
			var query = querystring('contentId');
		}
		else if (PiFilter == 1)
		{
			var cat	= "&continent=" + document.getElementById("listContinent").value;
			var query = querystring('contentId');
		}
		
		window.location.href = "contentLevel_1.php?contentId=" + query + cat;
	}
	
	function onlyNumber(field)
	{
		var iDigits = "0123456789"
		var fieldTemp;
		for (var i=0; i < field.value.length; i++)
		{
			fieldTemp = field.value.substring(i,i+1)    
			if (iDigits.indexOf(fieldTemp) == -1)
			{
				field.value = field.value.substring(0,i);
				break;
			}
		}
	}
	
	function verifyDemoNumber(field)
	{
		// Verifica se foram digitados somente números
		onlyNumber(field);
		
		// Pega o formulário
		doc = document.frmDemo;
		
		// Verifica o módulo Gestao de Ativos
		if (doc.gestaodeativos.value != "")
		{
			doc.tz0assetinventory.disabled = true;
			doc.tz0snifferrescue.disabled = true;
			doc.tz0productivityandsoftwaremeterig.disabled = true;
			doc.tz0performancemonitor.disabled = true;
			
		}
		else
		{
			doc.tz0assetinventory.disabled = false;
			doc.tz0snifferrescue.disabled = false;
			doc.tz0productivityandsoftwaremeterig.disabled = false;
			doc.tz0performancemonitor.disabled = false;
		}
		if ( (doc.tz0assetinventory.value != "") ||
			 (doc.tz0snifferrescue.value != "") ||
			 (doc.tz0productivityandsoftwaremeterig.value != "") ||
			 (doc.tz0performancemonitor.value != "") )
		{
			doc.gestaodeativos.disabled = true;
		}
		else
		{
			doc.gestaodeativos.disabled = false;
		}
		
		// Solução de Controle e Segurança da Informação (IPC)
		if (doc.solucaodecontroleesegurancadainformacao.value != "")
		{
			doc.tz0networksecurity.disabled = true;
			doc.tz0emailsondas.disabled = true;
			doc.tz0ontheflydiskencryption.disabled = true;
			doc.tz0phoenix.disabled = true;
			
		}
		else
		{
			doc.tz0networksecurity.disabled = false;
			doc.tz0emailsondas.disabled = false;
			doc.tz0ontheflydiskencryption.disabled = false;
			doc.tz0phoenix.disabled = false;
		}
		if ( (doc.tz0networksecurity.value != "") ||
			 (doc.tz0emailsondas.value != "") ||
			 (doc.tz0ontheflydiskencryption.value != "") ||
			 (doc.tz0phoenix.value != "") )
		{
			doc.solucaodecontroleesegurancadainformacao.disabled = true;
		}
		else
		{
			doc.solucaodecontroleesegurancadainformacao.disabled = false;
		}
		
		// Solução de Gerenciamento de Workplace
		if (doc.solucaodegerenciamentodeworkplace.value != "")
		{
			doc.tz0softwaredeliveryanddeploy.disabled = true;
			doc.tz0patchmanagement.disabled = true;
			doc.tz0remotecontrol.disabled = true;
			
		}
		else
		{
			doc.tz0softwaredeliveryanddeploy.disabled = false;
			doc.tz0patchmanagement.disabled = false;
			doc.tz0remotecontrol.disabled = false;
		}
		if ( (doc.tz0softwaredeliveryanddeploy.value != "") ||
			 (doc.tz0patchmanagement.value != "") ||
			 (doc.tz0remotecontrol.value != "") )
		{
			doc.solucaodegerenciamentodeworkplace.disabled = true;
		}
		else
		{
			doc.solucaodegerenciamentodeworkplace.disabled = false;
		}
		
		// Solução de Gerenciamento de Serviços
		if (doc.solucaodegerenciamentodeservicos.value != "")
		{
			doc.tz0cyclehelpdeskserver.disabled = true;
			doc.tz0cycleservicedeskserver.disabled = true;
			doc.tz0cycleworkflowserver.disabled = true;
			doc.tz0cyclehelpdeskclient.disabled = true;			
			doc.tz0cycleservicedeskclient.disabled = true;
			doc.tz0cycleworkflowserverclient.disabled = true;
			doc.tz0cycleclientweb.disabled = true;
			doc.tz0assetinventorycmdb.disabled = true;			
		}
		else
		{
			doc.tz0cyclehelpdeskserver.disabled = false;
			doc.tz0cycleservicedeskserver.disabled = false;
			doc.tz0cycleworkflowserver.disabled = false;
			doc.tz0cyclehelpdeskclient.disabled = false;			
			doc.tz0cycleservicedeskclient.disabled = false;
			doc.tz0cycleworkflowserverclient.disabled = false;
			doc.tz0cycleclientweb.disabled = false;
			doc.tz0assetinventorycmdb.disabled = false;
		}
		if ( (doc.tz0cyclehelpdeskserver.value != "") ||
			 (doc.tz0cycleservicedeskserver.value != "") ||
			 (doc.tz0cycleworkflowserver.value != "") ||
			 (doc.tz0cyclehelpdeskclient.value != "") ||
			 (doc.tz0cycleservicedeskclient.value != "") ||
			 (doc.tz0cycleworkflowserverclient.value != "") ||
			 (doc.tz0cycleclientweb.value != "") ||
			 (doc.tz0assetinventorycmdb.value != "") )
		{
			doc.solucaodegerenciamentodeservicos.disabled = true;
		}
		else
		{
			doc.solucaodegerenciamentodeservicos.disabled = false;
		}
		
		// Soluções iVirtua para gerenciamento de projetos
		if (doc.solucoesivirtuaparagerenciamentodeprojetos.value != "")
		{
			doc.tz0tnetx.disabled = true;
			doc.tz0eis.disabled = true;
			
		}
		else
		{
			doc.tz0tnetx.disabled = false;
			doc.tz0eis.disabled = false;
		}
		if ( (doc.tz0tnetx.value != "") ||
			 (doc.tz0eis.value != "") )
		{
			doc.solucoesivirtuaparagerenciamentodeprojetos.disabled = true;
		}
		else
		{
			doc.solucoesivirtuaparagerenciamentodeprojetos.disabled = false;
		}
	}
	
	function validaFormDemo()
	{
		doc = document.frmDemo;
		
		// Validar nome
		if (doc.nome.value == "")
		{
			alert("Campo 'Nome' em branco!");
			doc.nome.focus();
			return false;
		}
		
		// Validar empresa
		if (doc.empresa.value == "")
		{
			alert("Campo 'Empresa' em branco!");
			doc.empresa.focus();
			return false;
		}
		
		// Validar email
		if (doc.email.value == "")
		{
			alert("Campo 'E-mail' em branco!");
			doc.email.focus();
			return false;
		}
		
		// Validar email - dados
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(doc.email.value)))
		{
			alert("Campo 'E-mail' inválido!");
			doc.email.focus();
			return false;
		}
		
		// Validar fone
		if (doc.fone.value == "")
		{
			alert("Campo 'Telefone' em branco!");
			doc.fone.focus();
			return false;
		}
		
		// Verifica se o numero da quantidade é superior
		// a 30 licenças (demo)
		if ( (doc.gestaodeativos.value >= 31) ||
			 (doc.tz0assetinventory.value >= 31) ||
			 (doc.tz0snifferrescue.value >= 31) ||
			 (doc.tz0productivityandsoftwaremeterig.value >= 31) ||
			 (doc.tz0performancemonitor.value >= 31) ||
			 (doc.solucaodecontroleesegurancadainformacao.value >= 31) ||
			 (doc.tz0networksecurity.value >= 31) ||
			 (doc.tz0emailsondas.value >= 31) ||
			 (doc.tz0ontheflydiskencryption.value >= 31) ||
			 (doc.tz0phoenix.value >= 31) ||
			 (doc.solucaodegerenciamentodeworkplace.value >= 31) ||
			 (doc.tz0softwaredeliveryanddeploy.value >= 31) ||
			 (doc.tz0patchmanagement.value >= 31) ||
			 (doc.tz0remotecontrol.value >= 31) ||
			 (doc.solucaodegerenciamentodeservicos.value >= 31) ||
			 (doc.tz0cyclehelpdeskserver.value >= 31) ||
			 (doc.tz0cycleservicedeskserver.value >= 31) ||
			 (doc.tz0cycleworkflowserver.value >= 31) ||
			 (doc.tz0cyclehelpdeskclient.value >= 31) ||
			 (doc.tz0cycleservicedeskclient.value >= 31) ||
			 (doc.tz0cycleworkflowserverclient.value >= 31) ||
			 (doc.tz0cycleclientweb.value >= 31) ||
			 (doc.tz0assetinventorycmdb.value >= 31) ||
			 (doc.solucoesivirtuaparagerenciamentodeprojetos.value >= 31) ||
			 (doc.tz0tnetx.value >= 31) ||
			 (doc.tz0eis.value >= 31))
		{
			if(doc.solicitar.value == "")
			{
				alert("Informar o motivo para solicitações superiores a 30 licenças.");
				doc.solicitar.focus();
				return false;
			}
		}
		
		// Verifica se o numero da quantidade é superior
		// a 30 licenças (demos)
		if ( (doc.solucaodegerenciamentodeservicos.value != "") ||
			 (doc.tz0cyclehelpdeskserver.value != "") ||
			 (doc.tz0cycleservicedeskserver.value != "") ||
			 (doc.tz0cycleworkflowserver.value != "") ||
			 (doc.tz0cyclehelpdeskclient.value != "") ||
			 (doc.tz0cycleservicedeskclient.value != "") ||
			 (doc.tz0cycleworkflowserverclient.value != "") ||
			 (doc.tz0cycleclientweb.value != ""))
		{
			if(doc.justificar.value == "")
			{
				alert("Justificar motivo da necessidade de Demo do Tz0 Cycle.");
				doc.justificar.focus();
				return false;
			}
		}
		
		return true;
	}
	
function ShowDivCatalog(sDivID)
{
	$(".classDv").hide(); 
	$("#dv"+sDivID+"").toggle();	
}

