$(function(){
	$('#nav>li').hover(
		function(){
			$('.submenu',this).stop(true,true).slideDown('fast');
		},
		function(){
			$('.submenu',this).slideUp('fast');
		}
	);
	$('.submenu li a').css( {backgroundPosition: "0px 0px"} ).hover(
		function(){
			$(this).stop().animate({backgroundPosition: "(0px -95px)"}, 250);
		},
		function(){
			$(this).stop().animate({backgroundPosition: "(0px 0px)"}, 250);
		}
	);			
});

$(function(){

	var base_url = $("meta[name='DC.url']").attr('content');
	
	$("#item_type").change(function(){
		var type = $(this).val();
		$("#buscar-cursos-form").attr("action", base_url + type);
	});
})
		
$(function() {
	
	$("#accordion").tabs("#accordion div.pane", {tabs: 'h2', effect: 'slide', initialIndex: 0});
	
	 $("div.scrollable").scrollable({
		circular: true,
		speed:500
	}).autoscroll({autoplay:true, interval:6000});
	
});
			

$(document).ready(function(){
	 
	 var base_url = $("meta[name='DC.url']").attr('content');
	
	 $.preloadCssImages();
	 $("a[rel^='prettyPopin']").prettyPopin({
			modal : true, /* true/false */
			width : false, /* false/integer */
			height: false, /* false/integer */
			opacity: 0.7, /* value from 0 to 1 */
			animationSpeed: 'fast', /* slow/medium/fast/integer */
			followScroll: true, /* true/false */
			loader_path: base_url + '../assets/laguiadel/images/prettyPopin/loader.gif', /* path to your loading image */
			callback: function(){}, /* callback called when closing the popin */
			onResultContent: function(){
				jQuery.validator.messages.required = "";
				jQuery.validator.messages.email = "";
				jQuery.validator.messages.dateISO ="";
				jQuery.validator.messages.samemail = "";
				jQuery.validator.messages.digits = "";
				jQuery.validator.messages.maxlength = "";
				jQuery.validator.messages.minlength = "";
			  
			  var validator = $("#center-form").validate({
					errorElement: "span",  
				  rules: {
						nombre: {
							required:true,
							lettersonly:true
						},
						provincia: {
							required:true,
							lettersonly:true
						},  
						nif: {
							required:true
						},   
						website: {
							required:true
						},       
						email: {
							required:true,
							email:true         
						},
						contacto: {
							required:true
						},
						cargo: {
							required:true
						},
						horario: {
							required:true
						},
						telefono: {
							required:true,
							digits: true,
							maxlength: 9
						},
						observaciones: {
							required:true
						}
					},
					
					invalidHandler: function(e, validator) {
							var errors = validator.numberOfInvalids();
							validator.hideErrors();
					}

			  });
			  
			  /*jQuery.validator.addMethod(
			  'condiciones', 
			  function (a, element, param) {
				  if($('#condiciones:checked').length > 0){
					  var cssObj = {
					  'color' : '#7d7d7d',
					  'font-weight' : 'normal'
					  }
						  
					  $("#informacion-label").css(cssObj);
					  return true;
					  
				  }else{
						var cssObj2 = {
						'color' : '#f00',
						'font-weight' : 'bold'
						 }            
					  $("#informacion-label").css(cssObj2);
					  return false;
					  
				  }                  
			  }, '');*/
			  
			  jQuery.validator.addMethod("lettersonly", function(value, element) {
			  return this.optional(element) || /^[\á\é\í\ó\ú\ñ\Ñ\s a-z A-Z]+$/i.test(value);
			  }, '');
		   }
		});
	 

	$.fn.hoverClass = function(c) {
		return this.each(function(){
			$(this).hover( 
				function() { $(this).addClass(c);  },
				function() { $(this).removeClass(c); }
			);
		});
	};

});

$.tools.tabs.addEffect("slide", function(i, done) {

	this.getPanes().slideUp().css({backgroundColor: "#fff"});
	this.getPanes().eq(i).slideDown(function()  {
		$(this).css({backgroundColor: 'transparent'});
		done.call();
	});
});	
	 

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};

				   
function abrir(a,e,b,c,d){
	if(document.all){var ventanaW=document.body.clientWidth;}
	else{var ventanaW=window.innerWidth}
	if(document.all){var ventanaH=document.body.clientHeight+150;}
	else{var ventanaH=window.innerHeight}
	var w = ventanaW/2;
	w = w-(b/2);
	var h = ventanaH/2;
	h = h-(c/2);
	window.open(a, e, 'width='+b+', height='+c+', top='+h+',left='+w+', scrollbars='+d+', location=0');
}





		

