(function($){if($.browser.mozilla){$.fn.disableTextSelect=function(){return this.each(function(){$(this).css({"MozUserSelect":"none"})})};$.fn.enableTextSelect=function(){return this.each(function(){$(this).css({"MozUserSelect":""})})}}else{if($.browser.msie){$.fn.disableTextSelect=function(){return this.each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})})};$.fn.enableTextSelect=function(){return this.each(function(){$(this).unbind("selectstart.disableTextSelect")})}}else{$.fn.disableTextSelect=function(){return this.each(function(){$(this).bind("mousedown.disableTextSelect",function(){return false})})};$.fn.enableTextSelect=function(){return this.each(function(){$(this).unbind("mousedown.disableTextSelect")})}}}})(jQuery)
var myHtml = "<div><p><strong>Eventia</strong></p><p>Gran Vía, 81 - 5a planta. Dpto. 6 48011 Bilbao - Vizcaya</p></div>";
$(document).ready(function() {
	
	$(".javascripted").each(function(){
		
		$(this).attr("href",$(this).attr("href")+"?javascript=true");
		
	});
	$('.otype').each(function(){
		var self = $(this);
		
		if (self.hasClass('EMAIL')){
			self.attr("otype",'EMAIL');
		}
		if (self.hasClass('DNI')){
			self.attr("otype",'DNI');
		}
		if (self.hasClass('SS')){
			self.attr("otype",'SS');
		}
		if (self.hasClass('CC')){
			self.attr("otype",'CC');
		}
		if (self.hasClass('CP')){
			self.attr("otype",'CP');
		}
		
		
	});
	
	$('.cellaux4 .formline .errorspan').css('opacity','0');
	
	$('.cell1 .effect').bind('mouseenter',function(){
		var pic = $(this).find('img');
		var p = $(this).find('p');
		pic.stop();
		pic.animate({opacity:0.4},1100);
		p.stop();
		p.css('opacity','0').css('visibility','visible').animate({opacity:1},1600);
	}).bind('mouseleave',function(){
		var pic = $(this).find('img');
		var p = $(this).find('p');
		p.stop();
		p.animate({opacity:0},1100);
		pic.stop();
		pic.animate({opacity:1},1100);
	});


	$('.homesection, .section, .subsection').mouseover(function(){
		if ($.browser.msie){
			$(this).stop().animate({backgroundPosition:"0 -480px"}, {duration:400});
		}else	$(this).stop().animate({backgroundPosition:"(0 -480px)"}, {duration:400});
	}).mouseout(function(){
		if ($.browser.msie){
			$(this).stop().animate({backgroundPosition:"0 0"}, {duration:400});
		}else	$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:400});
	});

	var contactform = $("#contactForm");
	
	if (contactform.length>0){
		options = { url:contactform.attr('action')+"?ajax=true",
					dataType:  'json',
					success : function(responseText, statusText){
						$("#contactForm span.errorSpan").remove();
						if (responseText.error){
							
							for (var a in responseText.error){
								
								$("#"+a).after('<span class="errorSpan">'+responseText.error[a]+'</span>');
							}
						}else{
							contactform.before('<p>'+responseText.success+'</p>');
							contactform.resetForm();
							contactform.find('input,textarea').attr('disabled','disabled');
						}
					}
		    };
		contactform.ajaxForm(options); 
	}
	
	
	$("#searchB").bind('click',function(){
		$("#searchForm").trigger("submit");
		
		return false;
	});
	
	
	$('#olvido_contrasena').bind('click',function(){
		var txt = '<input name="email" value="tu email" id="email_pass" />';
		var dialog = '<div id="dialog">'+txt+'</div>';
		$(dialog).dialog({ 	resizable: false ,
							buttons: 
									{ "Ok": function() {
												var dia = $(this); 
												$.getJSON("",{ajax:true,email_pass:$('#email_pass').val()},function(data){
													if (data.ok){
														dia.dialog("close");
														var dialog = '<div id="dialog">'+data.ok+'</div>';
														$(dialog).dialog({	resizable: false ,
															buttons: 
																	{ "Ok": function() {$(this).dialog("close");}}
															});
													}
													if (data.error){
														$('#email_pass').before('<span class="errorSpan">'+data.error+'</span>');
														window.setTimeout(function(){$('.errorSpan').fadeOut('slow',function(){$(this).remove();});},1500);
													}
													
												});
			
												 
											} 
									},
							open:	function(){
										$('#email_pass').one('click',function(){
											$(this).val("");
											return false;
										});
									
									}
		});
		
		
		return false;
	});
	
	$('.focus:eq(0)').focus();
	
	/*$('img, .bgpic7, .pic').bind("contextmenu" ,function(event){ return false; });*/
	//$('#page').disableTextSelect();
	
});
