

var _chat_support_window;

function start_chat_support_window8688(operator, dept) {

 var querystring = "";

 var _chat_support_variables = parent._chat_support_variables;
 //alert(_chat_support_variables);
 if (dept)
 querystring += "&DEPT_STATUS["+dept+"]=1&DEPT=" + dept;

 if (operator)
 querystring += "&info[invited_by_operator]="+operator;

 var show_dept_list = "";
 if (show_dept_list)
 querystring += "&SHOW_DEPT_LIST=" + show_dept_list;

 try {
 if (typeof(_chat_support_variables)!='object') {
 var _chat_support_variables = new Array();
 }

 var _WTK_appName;

 if (navigator.userAgent.indexOf("Opera") != -1)
 _WTK_appName = "Opera";
 else if (navigator.userAgent.indexOf("Firefox") != -1)
 _WTK_appName = "Firefox";
 else if (navigator.userAgent.indexOf("Netscape") != -1)
 _WTK_appName = "Netscape";
 else if (navigator.userAgent.indexOf("MSIE") != -1)
 _WTK_appName = "Microsoft Internet Explorer";
 else if (navigator.userAgent.indexOf("Chrome") != -1)
 _WTK_appName = "Google Chrome";
 else
 _WTK_appName = navigator.appName;

 _chat_support_variables['appName'] = _WTK_appName;
 _chat_support_variables['appVersion'] = navigator.appVersion;
 // _chat_support_variables['appUserAgent'] = navigator.userAgent;

 if (navigator.platform)
 _chat_support_variables['platform'] = navigator.platform;

 for (var infoname in _chat_support_variables) {
 var value_type = typeof(_chat_support_variables[infoname]);
 if ((value_type != 'object') && (value_type != 'function')) {
 querystring += "&info[" + escape(infoname) + "]=" + escape(_chat_support_variables[infoname]);
 }
 }
 } catch(e) { /*alert(e.description);*/ }


 var uid = _webtrack_getCookie("WEBTRACK_USER_ID");
 var supp_window = window.open("http://www.chatcomercial07.com.br/livehelp/www/visitor/?userId=" + uid + "&COMPANY_ID=7722&SITE_ID=8688" + querystring, "_chat_support_window", "width=450,height=400,resizable=yes,status=no");
 try {supp_window.focus();} catch(e) {}
}

function _webtrack_getCookie(WTKNameOfCookie){
 if (document.cookie.length > 0){
 var WTKbegin = document.cookie.indexOf(WTKNameOfCookie+"=");
 if (WTKbegin != -1) {
 WTKbegin += WTKNameOfCookie.length+1;
 WTKend = document.cookie.indexOf(";", WTKbegin);
 if (WTKend == -1) WTKend = document.cookie.length;
 return unescape(document.cookie.substring(WTKbegin, WTKend));
 }
 return "";
 }
 return "";
}

//document.write("<a href='javascript:void(0)' target='_self' onclick='start_chat_support_window8688()'><img src='http://www.chatcomercial07.com.br/livehelp/lib/system/icon_status/off_icon_status8.gif' border=0></a>"); 



//	Funcao para carregar flash
function carregaFlash(caminho,largura,altura) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+largura+'" height="'+altura+'">');
	document.write('<param name="movie" value="'+caminho+'">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<param name="menu" value="false">');
	document.write('<embed wmode="transparent" src="'+caminho+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+largura+'" height="'+altura+'"></embed>');
	document.write('</object>');
}

function mudaFoto(id, imgaddress){
	$("div.imagem img.img-box").hide();
	$(".ampliar-imagem").attr('href', imgaddress);
	$("#foto_"+id).show();
}

function mudaVideo(id){
	$("div.right").hide();
	$("#vid_"+id).show();
}

function enviaFrmFiltros(){
	$("#frm_filtros").submit();
}

function mostraFiltro(){
	
	//1 - marcas
	if($("#selfiltrapor").val() == 1){
		
		$("div.filtra-por").show();
		
	}else{
		
		$("div.filtra-por").hide();
	}
	
	//salva na sessao qual filtro sera exibido
	$.get("_ajax-muda-filtro.php", { filtro: $("#selfiltrapor").val() } );
	
}

//tipo 1 - tabela
//tipo 2 - lista
function trocaExibicao(tipo){
	
	if(tipo == 1){
		
		$("li.li_lista").hide();
		
		$("#ul_gal_produtos").removeClass("galeria-lista-produtos");
		$("#ul_gal_produtos").addClass("lista-produtos");
		
		$("li.li_tabela").show();
		
		//salva na sessao que a exibição é tabela
		$.get("_ajax-muda-exibicao.php", { tipo: 1 } );
		
	}else if(tipo == 2){
		
		$("li.li_lista").show();
		
		$("#ul_gal_produtos").removeClass("lista-produtos");
		$("#ul_gal_produtos").addClass("galeria-lista-produtos");
		
		$("li.li_tabela").hide();
		
		//salva na sessao que a exibição é lista
		$.get("_ajax-muda-exibicao.php", { tipo: 2 } );
	}
	
}
	
	
	
	
	
function checkM(mail){
	
	var er= new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    
	if(typeof(mail) == "string"){
        
		if(er.test(mail)){ return true; }
    
	}else if(typeof(mail) == "object"){
    	
		if(er.test(mail.value)){
        	return true;
        }
		
    }else{
		return false;
    }
	
}

function Trim2(str){return str.replace(/^\s+|\s+$/g,"");}	
	
function esqueciSenhaCorp()
{
	var email = Trim2(document.getElementById("txtUsuarioCorp").value);
	var erro= false;
	var msg= "";
	
	if(email == ""){
	
		erro= true;
		msg+= "Preencha com seu usuário.\n";
	
	}else if(!checkM(email)){
	
		erro= true;
		msg+= "O usuário preenchido é inválido.\n";
	
	}
	
	
	
	if(erro){
		alert(msg);
		//return false;
	
	}else{
	
		
		//$("#statusCorp").html("carregando...");
	
		$.get("_ajax-senha.php", { e: email }, function(retorno){
		  	
			if(retorno == '1'){
			
			  //$("#statusCorp").html("");
			  alert("Senha enviada com sucesso para "+email+".");
			
			}else if(retorno == '2'){
			
			   //$("#statusCorp").html("Informação de login inexistente.");
			   alert("Informação de login inexistente.");
			   			
			}else if(retorno == '3'){
			
			   //$("#statusCorp").html("E-mail inválido.");
			   alert("E-mail inválido.");
			   
			}else if(retorno == '4'){
			
			   //$("#statusCorp").html("Verificação inválida.");
			   alert("Verificação inválida.");
			   
			}else if(retorno == '5'){
			
			   //$("#statusCorp").html("Falha no envio da mensagem.");
			   alert("Falha no envio da mensagem.");
			   
			}else{
			   //$("#statusCorp").html("");
			   
			}
			
		});
		
		
	}
	
	
}
	
	
function verificaCorp()
{
	//return true;
	var email = Trim2(document.getElementById("txtUsuarioCorp").value);
	var senha = Trim2(document.getElementById("txtSenhaCorp").value);
		
	var erro= false;
	var msg= "";
	
	if(email == ""){
	
		erro= true;
		msg+= "Preencha com seu usuário.\n";
	
	}else if(!checkM(email)){
	
		erro= true;
		msg+= "O usuário preenchido é inválido.\n";
	
	}
	
	if(senha == ""){
		erro= true;
		msg+= "Preencha o campo senha.\n";
	}
	
	
	if(erro){
		alert(msg);
		//return false;
	
	}else{
	
		//$("#statusCorp").html("carregando...");
	
		$.get("_ajax-login.php", { e: email, s: senha }, function(retorno){
		  	
			if(retorno == '1'){
				  
			  //$("#statusCorp").html("");
			  alert("Login efetuado com sucesso!");
			  window.location= 'index.php';
			  
			}else if(retorno == '2'){
			   
			   //$("#statusCorp").html("O e-mail e senha não conferem.");
			   alert("O e-mail e senha não conferem.");
			
			}else if(retorno == '3'){
			   
			   //$("#statusCorp").html("O e-mail é inválido.");
			   alert("O e-mail é inválido.");
			
			}else if(retorno == '4'){
			
			   //$("#statusCorp").html("A senha deve ter entre 6 e 10 caracteres.");
			   alert("A senha deve ter entre 6 e 10 caracteres.");
			
			}else if(retorno == '5'){
			
			   //$("#statusCorp").html("O cliente não está ativo.");
			   alert("O cliente não está ativo.");
			
			}else{
			
			   //$("#statusCorp").html("");
			}
			
		});
		
		
	}
	
}


	
	
// Função para iniciar as demais
$(document).ready(function() {

	
  	$( '#txtUsuarioCorp' ).each( function(){
	
		$(this).attr( 'title', $(this).val() )
		  .focus( function(){
			if ( $(this).val() == $(this).attr('title') ) {
			  $(this).val( '' );
			}
		  } ).blur( function(){
			if ( $(this).val() == '' || $(this).val() == ' ' ) {
			  $(this).val( $(this).attr('title') );
			}
		  } );

	} );
	
	$( '#txtSenhaCorp' ).each( function(){
	
		$(this).attr( 'title', $(this).val() )
		  .focus( function(){
			if ( $(this).val() == $(this).attr('title') ) {
			  $(this).val( '' );
			}
		  } ).blur( function(){
			if ( $(this).val() == '' || $(this).val() == ' ' ) {
			  $(this).val( $(this).attr('title') );
			}
		  } );

	} );


				   
						   
						   
	$('#menu-local ul li a.link-menu').click(function() {
													  
		if(!$(this).parent().hasClass("ativo")){
			
			$("#menu-local ul li.ativo ul.submenu").slideUp("slow");
			$("#menu-local ul li").removeClass("ativo");
				
		}
		
		$(this).parent().toggleClass("ativo");
		$(this).next().slideToggle("slow");
		
	});
	
	
	$('.meus-pedidos a.link-menu').click(function() {
		if($(this).next()[0] != $(".meus-pedidos tr.ativo")[0])
			{
				//alert('teste');
				$(".meus-pedidos tr.ativo").slideUp("slow");
				$(".meus-pedidos tr.ativo").addClass("hidden");
			}
		$(this).next()[1].toggleClass("ativo");
		$(".meus-pedidos tr").slideToggle("slow");
	});
	
	
	$("#txtPesquisar").focus(function(){
									  
		if($("#txtPesquisar").val() == "Busca de Produtos"){
			$("#txtPesquisar").val("");
		}
		  
	});
	
	$("#txtPesquisar").blur(function(){
									  
		if($("#txtPesquisar").val().length == 0){
			$("#txtPesquisar").val("Busca de Produtos");
		}
		  
	});
	
	
	
});


