$(document).ready(function(){
	$("#print").bind('click',function(){
		
		print();
		return false;
	});
	$("#vs").bind('change',function() {
		$("#vistasemanal").submit();
	});
	
	$("#bbuscador").bind('change',function() {
		$("#buscador").submit();
	});

	$("#submit").bind('click',function() {
		//alert($("#link").val()); 
		document.location = $("#link").val().replace('%var%',$("#mcat").val());
		
		return false;
	});
	
	$(".isel").bind('change',function() {
		//alert($(this).val()); 
		document.location = $(this).val();
		
		return false;
	});
	
	a="";
	$("#submitF").bind('click',function() {
		first=1;
		$(".mcat").each(function(){
			
			
			if ( $(this).attr('checked')==true  ) {
				if (first==1) {
					a+= ""+$(this).val();
					first=2;
				}else{
					a+= ","+$(this).val();
				}
			}
			
			
		}); 
		if (a=="") a="general";
		document.location = $("#link").val().replace('%var%',a);
		
		return false;
	});
	
	
	
	$('.ibusca').bind('focus',function(){
		$(this).attr('value','');
	});
	var url = $("#base").attr('value');
	
		$("#datesubmit").bind('click',function(){
		    al = $("#v_dateinput").val();
		    bl = $("#v_dateinput2").val();
			document.location = $("#link2").val()+al+"::"+bl;
			
		});

	function bindear() {
		
		$(".dianondisabled").bind('click',function(){
		    //ll = $(this).parents('tr').attr('id').replace('VV','');
			//document.location = $("#link2").val()+l;
			l = $(this).attr('id').replace('V','');
			ll = eval((60*60*24));
			
			lll = eval(ll)+eval(l)-eval(1);
			y = l+"::"+lll;
			document.location = $("#link2").val()+y;
		});
	
		$('.ante').bind('click',function(){
			var opts = {id:$(this).attr('id').replace('S','')};
			$.getJSON(url+"calendario.html",opts,function(j) {
				if(j.ret){ return;} 
				if(j.data){
					$("#calendario").slideUp('slow',function(){
						$("#calendario div").html('');
						$("#calendario div").html(j.data);
						$("#calendario").slideDown('slow');
						bindear();
					});
								
				}
			
			});

			
		});
		$('.sig').bind('click',function(){
			
						var opts = {id:$(this).attr('id').replace('S','')};
			$.getJSON(url+"calendario.html",opts,function(j) {
				if(j.ret){ return;} 
				if(j.data){
					$("#calendario").slideUp('slow',function(){
						$("#calendario div").html('');
						$("#calendario div").html(j.data);
						$("#calendario").slideDown('slow');
						bindear();
					});
								
				}
			
			});
			
		});
	}
	bindear();
	
	
});	
	
	