$(document).ready(function(){
	 $("#phone").mask("(99) 9999-9999");
	 if ($.browser.webkit) {
    $('#wrap').css('margin-top','-14px');
	 }
	$("#institucional #sobre img").parent().addClass('boxcolor');
	$("#banner").cycle({ 
    fx:     'fade', 
    speed:   1000, 
    timeout: 8000, 
    next:   '#next', 
    prev:  '#prev',
		cleartype: true, 
		cleartypeNoBg: true  
	});
	
	$("#cycle_masc").cycle({ 
    fx:     'fade',
    speed:   300,  
    timeout: 0, 
    next:   '.nextm', 
    prev:  '.prevm'
	});
	$("#cycle_fem").cycle({ 
    fx:     'fade',
    speed:   300,  
    timeout: 0,  
    next:   '.nextf', 
    prev:  '.prevf'
	});
	
	$(window).resize(function() {
		var w = document.body.scrollWidth;
		$('#bg').css('width',w+'px !important');
		var h = document.body.scrollHeight;
		$('#bg').css('height',h+'px !important');
		var widthwin = $(window).width();
		if(widthwin <1024){
			$('#menu').css('margin','0');
		} else if(widthwin <1300){
			$('#menu').css('margin','0 0 0 50px');
		}	else {
			$('#menu').css('margin','0 0 0 165px');
		}
	});
	
	var w = document.body.scrollWidth;
	$('#bg').css('width',w+'px !important');
	var h = document.body.scrollHeight;
	$('#bg').css('height',h+'px !important');
	
	$("#list_tabs a.tab").click(function () {
		$("#list_tabs a.active").removeClass("active");
		$(this).addClass("active");
		$(".tabs").show();
		var content_show = $(this).attr("alt");
		$("#"+content_show).hide();
	});	
	
	var widthwin = $(window).width();
	if(widthwin <1024){
		$('#menu').css('margin','0');
	} else if(widthwin <1300){
		$('#menu').css('margin','0 0 0 50px');
	}	else {
		$('#menu').css('margin','0 0 0 165px');
	}


	var opened = $("#box_left ul li a.active");
	$("#box_left ul li a").click(function(){
		$(opened).removeClass("active");
		$($(opened).attr("href")).hide();
		opened = this;
		$(opened).addClass("active");
		$($(this).attr("href")).show();
		var t = ($(this).attr("rel"));
		$(".shuffle_institucional").attr("src", 'images/bg-' + t + '.jpg');
	});
  $('#formConosco').validate({
		rules: {
			mail: {
				required: true,
				email: true
			}
		}
	});
  $('#formFale').validate({
		rules: {
			mail: {
				required: true,
				email: true
			}
		}
	});
  $('#formComercial').validate({
		rules: {
			mail: {
				required: true,
				email: true
			}
		}
	});	
	$('input#curriculo').change(function(){
	  $('span#legenda').text($('input#curriculo').val());
		$('input#curriculo').attr('value', $('span#legenda').text );
	});
	$(".select").selectbox();
	
	$(".group1").colorbox();
	$(".iframe").colorbox({iframe:true, width:"610px", height:"80%"});
	$(".boxcolor").colorbox()
        
$("#uf .jquery-selectbox-list span").click(function(){
    var value = $('#estado').val();
    var city_select = $('#box_city #city');

    if (value == null || value == "") {
        city_select.html('<option value="">Estado...</option>');
        city_select.parents('.jquery-selectbox').unselectbox();
        city_select.selectbox();
    } else {
        $.get('city.ajax.php?search=' + value, function(data){
            city_select.html(data);
            city_select.parents('.jquery-selectbox').unselectbox();
            city_select.selectbox();
        }, "html");
    }
});  
});

