// JavaScript Document

$(document).ready(function(){
	if($('#banner_slider').is('#banner_slider')){
    $('#banner_slider').nivoSlider({
        effect:'random', //Specify sets like: 'fold,fade,sliceDown'
        animSpeed:500, //Slide transition speed
        pauseTime:4000,
        directionNav:false,
        controlNav:true
    });
	}
    $('.opc').hover(
	function(){	
				//$(this).children('.btn_main').addClass('active');
				$(this).children('[class^="sub_m_h"]').fadeIn('normal'); 
				$(this).find('[class^="btn_main"]').not('btn_main_active').addClass(function(){return $(this).attr('class')+'_active'});
	},
	function(){	$(this).children('[class^="sub_m_h"]').fadeOut('fast');
				$(this).find('[class^="btn_main"]').not('btn_main_active').removeClass(function(){c=$(this).attr('class').split(' '); return c[1];});
	})
	
	if($('#form_holder').is('#form_holder')){
		
		$('.step_item').click(function(){		
		if($(this).children('#step_1').is('#step_1')){
			$('#paso2').hide();$('#paso1').fadeIn('fast');
			$('.step_item').removeClass('step_on')
			$(this).first().addClass('step_on')
		}else{
			$('#paso1').hide();$('#paso2').fadeIn('fast');
			$('.step_item').removeClass('step_on')
			$(this).first().addClass('step_on')
		}
		
		});
		$('#plazo').keyup(function(){
			var cuota=$(this).val()
			if(cuota.length>=1&&cuota>=2){
				var monto=$('#montor').val();
				
				$.ajax({
  					type: "POST",
   					url: "bridge.php",
   					data: "call=1&monto="+monto+"&cuota="+cuota,
   					success: function(msg){
     					$('#car_items_holder').html(msg)
     					pinta()
   					}
 				});	
			}
		})
	}
	$('#send_feed').click(function(){
	if($('#mail').val()!=''&&$('#name').val()!=''){
		var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/; 
		var s=$('#mail').val();
		   if (filter.test(s)) 
		   var save=true;
		   else 
			 alert("Entre una direccion de corre valida"); 
		$('#mail').focus(); 
		
		if(save){
		var datos=$('#feed_form').serialize();
		$.ajax({
		   type: "POST",
		   url: "bridge.php",
		   data: "call=9&"+datos,
		   success: function(msg){
			 $('#feedback_text').html(msg);
		   }
		 });
		}
	}else{
	 alert("Debe llenar los campos vacios"); 
	}
	})
function pinta(){
	cual=document.getElementById("tablei").rows;

	for(a=0;a<cual.length;a++){
		color(a);
	}

}

function color(b){
	if(b%2==0)
		cual[b].style.backgroundColor="#e4e4e4";
	else
		cual[b].style.backgroundColor="#cccccc";
}
	
	
})
