<!-- Validacion de suscripcion del club del vino
function MM_validateForm_clubdelvino() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm_clubdelvino.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.id; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe ser una direccion de email valida.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' debe contener un numero.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es requerido.\n'; }
    } if (errors) alert('Han ocurrido los siguientes errores:\n'+errors);
    document.MM_returnValue = (errors == '');
} }
//-->

function MM_validateForm_contacto() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm_contacto.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe ser una direccion de email valida.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es requerido.\n'; }
    } if (errors) alert('Han ocurrido los siguientes errores:\n'+errors);
    document.MM_returnValue = (errors == '');
} }
//-->

function MM_validateForm_ecommerce() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm_ecommerce.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.id; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe ser una direccion de email.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es requerido.\n'; }
    } if (errors) alert('Han ocuriddo los siguientes errores:\n'+errors);
    document.MM_returnValue = (errors == '');
} }


$(document).ready(function(e){
						   
	$("a").click(function(e){
		e.preventDefault();
	})
	
	$(document).bind("contextmenu",function(e){
        return false;
    });


	// Bloqueo del ctrl+V para copiar contenidos
	var jun=0;
	$(document).keydown(function(e){
		if(e.keyCode==17 ){ // el code 17 es el ctrl
			jun++;
			if(jun==2){
				return false;
			jun=0;
			}
		}
		
		if(e.keyCode==67 ){//el code 67 es la letra V
			jun++;
			if(jun==2){
				return false;
			jun=0;
			}
		}

		}).keyup(function(e){
			if(jun>0){
				jun=jun-1;
			}
	});


	$("a").bind('mouseover',function(e){
		window.status='';return true;
	});

	$("#upbanner").click(function(){
		window.location="./index.php";
	  });

	$("#vocabulariodelvino").click(function(){
		window.location="./vocabulario.php";
	  });

	$("#oliva2").click(function(){
		window.location="./aceite_de_oliva2.php";
	  });

	$(".wa").click(function(){
		window.open("http://www.wasistemas.com","_blank");
	  });

	$("#vocabulariodeoliva").click(function(){
		window.location="./vocabulario_de_oliva.php";
	  });

	$("a[link]").click(function(){
		window.location=$(this).attr("href");
	  });


	$("#atras").click(function(){
		history.go(-1);
	  });

	$(".suscribirme").click(function(){
		$(".club_del_vino").slideToggle();								 
									 
	})

	$(".tituloreportaje").click(function(){
		$(this).next().slideToggle();

	});

	$(".programasdetv").click(function(){
		window.location="./tv.php";
	  });


	$("#promoindex").slideToggle();

	$(".botoneravertical ul div").click(function(e){
		if ($(e.target).is("li"))
		{
			if ($(e.target).parent().next().hasClass("subsecciones"))
				$(e.target).parent().next().slideToggle();
			else
				window.location=$(e.target).children().attr("href");
		}
			
		if ($(e.target).is("a"))
		{
			if ($(e.target).parent().parent().next().hasClass("subsecciones"))
				$(e.target).parent().parent().next().slideToggle();
			else
				window.location=$(e.target).attr("href");
		}
	});


	$(".bannerauspiciantes").click(function(e){
		if ($(e.target).parent().attr("href")!= "#")
			window.open($(e.target).parent().attr("href"),"_blank");
	});


	$(".botoneraservicios").after('<div class="bannerauspicio2"><iframe src="http://www.facebook.com/plugins/likebox.php?href=http://www.facebook.com/pages/Hoteles-y-Gastronomia/161044987251103&amp;width=180&amp;colorscheme=light&amp;connections=0&amp;stream=false&amp;header=false&amp;height=100" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:180px; height:100px;" allowTransparency="true"></iframe></div>');

	$(".subsecciones").click(function(e){
		if ($(e.target).is("li"))
			window.location=$(e.target).children().attr("href");

		if ($(e.target).is("a"))
			window.location=$(e.target).attr("href");
	});


	$("head").append("<LINK REL='SHORTCUT ICON' HREF='images/icono.ico'>");

	$("head").append("<script type='text/javascript'>var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-19307741-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script>");


	$(".facebook").bind({
		mouseover:function(){
			$(this).children().children().attr({'src':'images/facebookOver.png'});
		},
		mouseout:function(){
			$(this).children().children().attr({'src':'images/facebookGris.png'});
		},
		click:function(){
			window.open('http://www.facebook.com/group.php?gid=36226117939',"_blank");
		}		
	});

	$(".facebook[club]").bind({
		mouseover:function(){
			$(this).children().children().attr({'src':'../images/facebookOver.png'});
		},
		mouseout:function(){
			$(this).children().children().attr({'src':'../images/facebookGris.png'});
		},
		click:function(){
			window.open('http://www.facebook.com/group.php?gid=36226117939',"_blank");
		}		
	});

	$(".twitter").bind({
		mouseover:function(){
				$(this).children().children().attr({'src':'images/twitterOver.png'});
		},
		mouseout:function(){
			$(this).children().children().attr({'src':'images/twitterGris.png'});
		},
		click:function(){
			window.open('http://twitter.com/#!/WehrliWines',"_blank");
		}
	});

	$(".twitter[club]").bind({
		mouseover:function(){
				$(this).children().children().attr({'src':'../images/twitterOver.png'});
		},
		mouseout:function(){
			$(this).children().children().attr({'src':'../images/twitterGris.png'});
		},
		click:function(){
			window.open('http://twitter.com/#!/WehrliWines',"_blank");
		}
	});


	$(".contbot").bind({
		mouseover:function(){
			$(this).css("background","#ffb");	
		},
		mouseout:function(){
			if ($(this).attr("id") != 'activarseccion')
				$(this).css("background-image","url(images/fdobotonppal.jpg)");
		}			   
	});

	$(".subsecciones li").bind({
		mouseover:function(){
			$(this).css("background","#ffc");	
		},
		mouseout:function(){
			if ($(this).attr("id")!='activarsubseccion')
				$(this).css("background","#f9f9f9");
		}			   
	});



	$(".contbotonerahorizontal ul li").bind({
		mouseover:function(){
			$(this).css("color","#fff");	
		},
		mouseout:function(){
			$(this).css("color","#edd");
		},		
		click:function(){
			if ($(this).children().attr("target")=='_blank')
				window.open($(this).children().attr("href"),"_blank");				
			else
				window.location=$(this).children().attr("href");			
		}
	});
	
	
	
	$(".botoneraservicios ul div li").bind({
		mouseover:function(){			 
			$(this).children().css("color","#e85");
			$(this).parent().css("background","#ffd");				
		},
		mouseout:function(){			 
			$(this).children().css("color","#977");
			$(this).parent().css("background-image","url(images/fdobotonserv.jpg)");
		},
		click:function(){	
			if ($(this).children().attr("class")== "")
				window.open($(this).children().attr("href"),$(this).children().attr("target"));
			else
				if ($(this).children().attr("class")== "clubdelvino")
					$(".club_del_vino").slideToggle();
		}
	});


	$(".activar_link").click(function(){ 
		window.open($(this).attr("href"),$(this).attr("target"));
	});

	$(".ampliar").click(function(){ 
		$(this).parent().next().next().slideToggle();
	});


});
