﻿$(document).ready(function(){

    // ajusta fundo branco e bottom
    var alt = $('.main').height();
    $('.bg_white').height(alt + 3);
    $('#bottom').css('top',alt + 95);


    // MASCARA INPUTS
    var txt = null;
    var txt2 = null;
    $(".mascara").focus(function(){
        txt = $(this).attr("value");
        txt2 = $(this).attr("title"); // Title no componente .net é o paramento ToolTip
        if (txt == txt2){
            $(this).attr("value","");
        }
    });
    $(".mascara").blur(function(){       
        if ($(this).attr("value") == ""){
            $(this).attr("value",txt2);
        }
    });
    // //MASCARA INPUTS
    
    // FUNCAO DROP LIST
       $('.ct_drop span').click(function(){
        $(this).parent().find('.lk_drop_list').slideDown();
    })
    $('.lk_drop_list li a , .variavel_drop li a').live('click', function(){
        var val = $(this).html();
        $(this).parent().parent().parent().find('span').html(val);
        $(this).parent().parent().parent().find('input').attr('value',val);
        $(this).parent().parent().slideUp();
    });  
    $('.ct_drop').hover(
        function(){
            
        },
        function(){
            $(this).find('.lk_drop_list , .variavel_drop').slideUp();
        }
    );
    var valor_drop = null;
    // pega o valor da drop list
    $('.variavel_drop_select li a').click(function(){
        valor_drop = $(this).attr('value');
    })
    // exibe o valo do valor_drop se nulo exibe o primeiro item ul
    $('.variavel_drop_click').click(function(){
        if (valor_drop == null){
            $(this).find('ul:first').slideDown();
        }else{
            $(this).find('#'+ valor_drop +'').slideDown();
        }    
    });
    // //DROP LIST
    
    // Z-INDEX RECURSIVO
   var z_qtd = $('.ct_drop').size();
   $('.ct_drop').each(function(){
    $(this).css('z-index',z_qtd);
    z_qtd--;
   })
   
   // botao adiciona em cotacao
   var item_cotacao = 0;
   $('.bt_add').live('click' , function(){
       $('.addItem:last').after('<li class=\"row after addItem\"><div class=\"col2 fl\"><label>Nº de participantes:</label><input type="text" ID=\"n_participantes_'+ item_cotacao++ +' \" name=\"n_participantes_'+ (item_cotacao-1) +'\" runat=\"server\" style=\"width:132px;\" /></div><div class=\"col2 fr\"><label>* Tipo de montagem:</label><input type=\"text\" ID=\"tipo'+ (item_cotacao-1) +'\" name=\"tipo'+ (item_cotacao-1) +'\" runat=\"server\" style=\"width:100px;\" CssClass=\"fl ie\" style=\"float:left!important\" /><a href=\"javascript:;\" class=\"bt_add\">adicionar</a></div></li>');       
      
        var alt = $('.main').height();
        $('.bg_white').height(alt -60);
        $('#bottom').css('top',alt + 47);
   });

    // lista comparacao tamanho 
    var tul = 0
    $('.line_h_210 li').each(function(){
        var tv = $(this).height();
        
        if (tul <= tv){
            tul = tv;
        }
    });
    $('.line_h_210 li').css('height',tul);
    // lista comparacao tamanho 
    
    // corrige borda subtitulo
	if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
	    $('h3').css('overflow','hidden');
	}
	
	// LINK CARROSEL 
	$('#carrosel li a').click(function(){
	    var vlr = '<img src="' + $(this).attr('rel') +'" alt="" />';
	    $('.image_conceitual').html(vlr);
	});

// fim do loading
});

// ABRE O 1 ITEM DO CARROSEL
function abre1 (){
    $('.image_conceitual').html('<img src="' + $('#carrosel li a').attr('rel') +'" alt="" />');
}

// marca menu topo
function top_nav(obj){
    $('.nav_top li:eq('+obj+') a').addClass('atv');
}
// marca nav
function nav(obj){
    $('.nav li:eq('+obj+') a').addClass('atv');
    $('.nav_bottom li:eq('+obj+') a').addClass('atv');
}

// marca sub nav
function subnav(obj){
    $('.subnavC li:eq('+obj+') a').addClass('atv');
}

function aumenta(){
    var alt = $('.main').height();
    $('.main').height(alt + 50);
    $('.bg_white').height(alt + 30);
    $('#bottom').css('top',alt + 95);
}