$(document).ready(function(){
   var nav = navigator.userAgent.toLowerCase();
	a =  /(chrome)(?:.*chrome)?[ \/]([\w.]+)/.exec(nav) || /(safari)(?:.*version)?[ \/]([\w.]+)/.exec(nav) || /(opera)(?:.*version)?[ \/]([\w.]+)/.exec(nav) || /(ie) ([\w.]+)/.exec(nav) || !/compatible/.test(nav) && /(firefox)(?:.*firefox)?[ \/]([\w.]+)/.exec(nav) || [];
	if ( nav.indexOf('macintosh') != -1 ){ os = 'macintosh';}  else if ( nav.indexOf('windows') != -1 ){ os = 'windows'; } else if ( nav.indexOf('linux') != -1 ){ os = 'linux'; }
	var	browser = { name: a[1] || "", version: a[2] || "0", os: os }
	$("body").addClass( browser.name + ' ' + browser.name+parseInt(browser.version) + ' ' + browser.os );
	/*START PARA ZOOM DAS IMAGENS*/
    $(".jqzoom").jqzoom();
	
	$('#slider-code').tinycarousel({ pager: true, controls: false });
	/*ESTILO PARA O ALERT DE CAMPO OBRIGATORIO*/
	var aux = setInterval( function(){
	$(".ajax__validatorcallout_icon_cell img").attr('src','/img/alert.png');
	}, 500 );
	


	var aux2 = setInterval( function(){
		$(".ajax__validatorcallout_close_button_cell img").attr('src','/img/close.jpg');
	}, 500 );
	
						   
	$(".menuDropInside:first").css('display','table');
	$(".menuDropClick").click(function(){
			//fecha
			$(".menuDropInside:visible").css('display','table').slideUp('slow');
			//abre
			$(this).parent().find(".menuDropInside").not(':visible').slideDown("slow");
	});
	
	
	/*DUVIDAS FREQUENTES*/
	$(".question").click(function(){
			//fecha
			$(".answers:visible").css('display','table').slideUp('0.1');
			//abre
			$(this).parent().next().slideDown("fast");
	});
	
	var tamanhoEntrada = 0;
	var tamanhoSaida = 0;
	var largura = 0;
	var posicaoX = 0;	
	var pos = 0 ;
 		
	/*MENU PRINCIPAL*/
	$("#menu li a").not("#menu li li a").hover( function(e){
        $('.submenu:visible').fadeOut( 120 );
		$(this).parent().find(".submenu").slideDown('fast', function(){ 
																tamanhoSaida = $(this).parent().find(".submenu").height() + e.clientY;  
																tamanhoEntrada  =  e.clientY;
																largura = $(this).parent().find(".submenu").width();
																posicaoX = e.clientX;  
																pos = $(this).parent().find(".submenu").offset(); 
																//alert( pos.left);
															} 
		);

		
		
    });
	//alert($.browser.msie);
    /*if ($.browser.msie===false){
		$("#content").mousemove( function(){ $('.submenu:visible').css('display','none') });
	}*/
	$("#contejkgjnt").mouseenter( function(){ $('.submenu').css('display','none') });
	
	$("body").mousemove( function(e){ 
	
	
		if(e.clientY > tamanhoSaida || e.clientY < (tamanhoEntrada - 20) ) {
			
			$('.submenu:visible').css('display','none') 
		}
		
		if(e.clientX <  pos.left - 50 || e.clientX >  pos.left + largura  + 50   ){
			
			$('.submenu:visible').css('display','none') 
		}
		
		

	}); 
	
	/*ACCORDION LINHAS WORKWEAR*/
    /*$("#horizoltalAccordion").msAccordion({defaultid:0});*/

	$("#horizoltalAccordion").msAccordion({defaultid:$(".startaccordion").text()});
    
	$(".content").mouseout(function(){
			$(this).find(".family").css("display","none");
		});
	
	$(".content").mouseover(function(){
			$(this).find(".family").css("display","block");
		});
	
	
	/*MODAL CADASTRO REALIZADO COM SUCESSO*/	
	$('a[name=modal]').click(function(e) {
		e.preventDefault();
		alert('clicou');
		
		var id = $(this).attr('href');
	
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		$('#mask').css({'width':maskWidth,'height':maskHeight});

		$('#mask').fadeIn(500);	
		$('#mask').fadeTo("fast",0.5);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		$(id).fadeIn(500); 
	
	});
	
	$('.window .bg-ok').click(function (e) {
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});	
	
	
	$('.imgAcabEsp a').lightBox();	
	
	
	
});

	/*JAVASCRIPT SIMPLES*/
		
        function TrocarCor(nome, cod)
        {
      			$(".sampleColor").html('<img src="/img/cores/'+cod+'.jpg" width="132px"  height="90" />');
				$(".textColor").html(cod+" <br> "+ nome );
        }
		
        function TrocarFoto(foto, idProduto, fotoGrande )
        {
			var ftPrincipal = document.getElementById('ctl00_ContentPlaceHolder1_imgPrincipal');
			var imgZoom = document.getElementById('ctl00_ContentPlaceHolder1_lnkImgZoom');
						 
			$("#ctl00_ContentPlaceHolder1_imgPrincipal").attr('src', "../arquivos/produtos/" + idProduto + "/" + foto);

			$("#ctl00_ContentPlaceHolder1_lnkImgZoom").attr('href', "../arquivos/produtos/" + idProduto + "/" + fotoGrande);

			$(".jqZoomWindow").remove();

			$(".jqZoomWindow img").attr('src', "../arquivos/produtos/" + idProduto + "/" + fotoGrande);
			
			
			
			
        }
		
		function MessageAlert(message){
		
			
			var id = "#dialog";//$(this).attr('href');
		
			var maskHeight = $(document).height();
			var maskWidth = $(window).width();
		
			$('#mask').css({'width':maskWidth,'height':maskHeight});

			$('#mask').fadeIn(500);	
			$('#dialogMessage').text(message);
			$('#mask').fadeTo("fast",0.5);	
		
			//Get the window height and width
			var winH = $(window).height();
			var winW = $(window).width();
				  
			$(id).css('top',  winH/2-$(id).height()/2);
			$(id).css('left', winW/2-$(id).width()/2);
		
			$(id).fadeIn(500); 
			
		}
