﻿// JavaScript Document

$(document).ready(function(){
	
	
	
	
	if($("#destaqrepresentantes #CEP").length > 0){
		$("#destaqrepresentantes #CEP").placeHolder({
			"text"		 : "CEP",
			"placeholder": "#333333", /* Placeholder Text Color */
			"active"	 : "#000000" /* Normal Text Color */
		});
		
		$("#consultaRep").submit(function(evt){			
			obj = $(this);			
			if ($("#CEP").val().length < 8 || $("#CEP").val() == "CEP" ){
				alert("O campo CEP é requerido.");
				$("#CEP").focus();
				return false;
			}
			
			if ($("#codcanal").val() == "" ){
				alert("Selecione um canal.");
				$("#codcanal").focus();
				return false;
			}			
		});		
	}		
	
	// Input Placeholder
	if($("#homeSearchBox #proc").length > 0){
		$("#homeSearchBox #proc").placeHolder({
			"text"		 : "Busca de produtos",
			"placeholder": "#333333", /* Placeholder Text Color */
			"active"	 : "#000000" /* Normal Text Color */
		});
		
		
		$("#form1").submit(function(evt){			
			obj = $(this);			
			if ($("#proc").val().length < 2 || $("#proc").val() == "Busca de produtos" ){
				//obj.submit;
				alert("Por favor, digite o termo a ser pesquisado.");
				$("#proc").focus();
				return false;
			}
		})
	}
	
	
	
	
	
	/* Comportamento Menus */	
	$('.navigateMenu ul li > ul').each(function(index) {
   	 	//$(this).prev().append("<span>&nbsp;</span>");
		$(this).prev().addClass("marc");
		
		minwidth = parseFloat($(this).prev().width());
		//paddingLef = $(this).prev().css("padding-left");
		
		$(this).css({minWidth: minwidth + 32 });
		
	});

	$('.navigateMenu ul ul').css({opacity: 0});
	$('.navigateMenu ul li').hover(
		function(index) {
			$(this).find("ul:first").show().stop().animate({opacity: 1},300);
		},		
		function(index) {
		$(this).find("ul:first").stop().animate({opacity: 0},300,function(){$(this).hide()});
	});
		
		
		
		
		
		
	//Assign the ColorBox event to elements	
	if($("#cadastroNews").length > 0){
		$("#cadastroNews").colorbox({transition:'elastic', initialWidth:"200", width:"300", initialHeight:"100", height:"246", iframe:true, scrolling:false, title:"&nbsp;"});
	}	
});
