$(document).ready(function() {
	$('div.wrapper a').each(function(){
		var name = $(this).text();
		$(this).attr('name', name);
	});
});

$(document).ready(function(){
	$('.request_call').click(function(e){
		e.preventDefault();
		$(this).colorbox({
			innerWidth:"426px", 
			innerHeight:"237px", 
			inline:true, 
			href:"#request_a_call"
		});
	});

	$('#call_calc').click(function(e){
		e.preventDefault();
		$(this).colorbox({
			innerWidth:"426px",  
			inline:true, 
			href:"#form_cost_top"
		});
	});

	$('#banner')
		.hover(
			function(){
				$(this).stop().animate({width: 536, height: 167}, 200);
				$(this).find('.img_1').stop().animate({width: 156, height:63}, 200);
				$(this).find('.img_2').stop().animate({width: 220, height:63}, 200);
			},
			function(){
				$(this).stop().animate({width: 505, height: 61}, 200);
				$(this).find('.img_1').stop().animate({width: 147, height: 61}, 200);
				$(this).find('.img_2').stop().animate({width: 207, height: 61}, 200);
			}
		);
    $('.select .arrow').live('click', arrow);
           $('.list a').live('click', select_val);
             $('.plus').live('click', plus);

    $.each($('.bg.ol'), function(){
        $(this).css('z-index', z).find('.select').css('z-index', z).find('list').css('z-index', z);
        $(this).parents('.ol_wrapper').css('z-index', z);
        z--;
    })
})
function plus(){
    var html = $('.ol_wrapper').first().html();
    $('.ol_wrapper:last').after('<div class="ol_wrapper">'+html+'</div>');
    $('.ol_wrapper:last .arrow').click(arrow)
    $('.ol_wrapper:last .plus').click(plus);
    $('.ol_wrapper:last .list a').click(select_val);
    $.each($('.bg.ol'), function(){
        $(this).css('z-index', z).find('.select').css('z-index', z).find('list').css('z-index', z);
        $(this).parents('.ol_wrapper').css('z-index', z);
        z--;
    })
    $.colorbox.resize();
    return false;
}
function select_val(){
    var val = $(this).attr('href');
    var name = $(this).html();
    val = val.substr(1)
    $(this).parents('ul').siblings('.hidden').val(name);
    $(this).parents('.list').hide().siblings('.value').html(name);
    return false;
}
function arrow(){
    if($(this).siblings('.list:visible').size()==0){
        $('.list').hide();
        $(this).siblings('.list').show();
        
    }else{
        $(this).siblings('.list').hide();
    }
    return false;
}
var z = 999;
