/**
 * Single Drop Down Menu
 * March 24, 2008
 * Corey Hart @ http://www.codenothing.com
 *
 * @timer: milliseconds to keep dropped menus open
 * @parentMO: CSS class to add/remove to parent list on mouseover/mouseout's
 * @childMO: CSS class to add/remove to child list on mouseover/mouseout's
 */
(function(A){A.fn.singleDropMenu=function(C){var F;var E;var D=A.extend({timer:500,parentMO:null,childMO:null},C||{});this.each(function(){A("li",this).mouseover(function(){B();A("a",this).addClass(D.parentMO).siblings("ul").show()}).mouseout(function(){E=this;F=setTimeout(function(){B()},D.timer)});A("li ul li",this).mouseover(function(){A("a",this).addClass(D.childMO)}).mouseout(function(){A("a",this).removeClass(D.childMO)})});A(document).click(function(){B()});var B=function(){if(E&&F){A("a",E).removeClass(D.parentMO).siblings("ul").hide();clearTimeout(F);E=""}}}})(jQuery);
/*Single Drop Down Menu*/

//checkform
var msgNumber='debe ser un número';var msgEMail='debe ser una dirección de correo';var msgURL='debe ser una dirección de internet';var msgDate='debe ser una fecha';var msgFillOut='Por favor introduzca';var msgNoForm='Formulario no existe';var msgNoField='Campo no existe';function _trim(str){if(str)str=str.replace(/^\s+/,'').replace(/\s+$/,'');return str}function _isDate(yy,mm,dd){mm--;var d=new Date(yy,mm,dd);return((dd==d.getDate())&&(mm==d.getMonth())&&(yy==d.getFullYear()))}function checkForm(){var args=checkForm.arguments;var f=args[0];var msg='';var arr,field,title,type,minLength,elem,val,cnt,nr,i,j,focus;var format,d,dd,mm,yy;var valid_url=/^(https?|ftp):\/\/([a-z0-9._-]+:[a-z0-9._-]+@)?[a-z0-9äöüÄÖÜ#._\/~% -]+(\?([a-z0-9_-]+(=[a-zA-Z0-99äöüÄÖÜß+%?_-]+&?)?)*)?$/i;var valid_mail=/^[a-z0-9._-]+@[a-z0-9äöüÄÖÜ.-]+\.[a-z]{2,4}$/i;for(i=1;i<args.length;i++){arr=args[i].split(':');field=_trim(arr[0]);title=_trim(arr[1]);if(!title)title=field;type=_trim(arr[2].toLowerCase());minLength=_trim(arr[3]);elem=f.elements[field];if(elem){val=_trim(elem.value);if(val!=''){if(type=='number'){if(isNaN(val)){msg+='"'+title+'" '+msgNumber+'\n';if(!focus)focus=elem}}else if(type=='mail'&&val.search(valid_mail)==-1){msg+='"'+title+'" '+msgEMail+'\n';if(!focus)focus=elem}else if(type=='url'&&val.search(valid_url)==-1){msg+='"'+title+'" '+msgURL+'\n';if(!focus)focus=elem}else if(type.indexOf('date')!=-1){if(type.indexOf('(')!=-1)format=type.substr(type.indexOf('('));else format='(dmy)';d=val;for(j=1;j<format.length-1;j++){cnt=d.search(/[^0-9]/);if(cnt==-1)cnt=d.length;nr=d.substr(0,cnt);nr=parseInt(nr.replace(/^0/,''));switch(format.charAt(j)){case'd':dd=nr;d=d.substr(cnt+1);break;case'm':mm=nr;d=d.substr(cnt+1);break;case'y':yy=nr;d=d.substr(cnt+1);break}}if(!_isDate(yy,mm,dd)){msg+='"'+title+'" '+msgDate+"\n";if(!focus)focus=elem}}}if(minLength){if(elem.length){if(elem.options){for(j=cnt=0;j<elem.options.length;j++){if(elem.options[j].selected&&elem.options[j].value!="")cnt++}}else for(j=cnt=0;j<elem.length;j++){if(elem[j].checked)cnt++}}else if(elem.type=="checkbox")cnt=elem.checked?1:0;else cnt=val.length;if(cnt<minLength){msg+=msgFillOut+' "'+title+'"\n';if(!focus)focus=elem}}}else msg+=msgNoField+': "'+field+'"\n'}if(msg){alert(msg);focus.focus();return false}return true}

function focus_form(i){if(i)try{i.focus(); if(i.type=='text')i.select()}catch(e){}};
$(document).ready(function(){
	$('.ddmenu').singleDropMenu({parentMO:'ddmenu-hover', childMO:'ddchildhover'});
  focus_form($(':input:visible:enabled:first')[0]);
  switch (document.body.id){
    case 'index':
	  	$('#fotos').s3Slider({timeOut:5000});
	  	$('#logos').s3Slider({timeOut:2000});
    	swfobject.embedSWF("swfs/personajes.swf","bg2","246","442","9.0.0","","",{wmode:"transparent"});
      break;
    case 'directorio':
    	function removeSpaces(string){return string.split(' ').join('');}
			$('#form2').submit(function(){
				b=document.form2.b;
				e=true;
				bb=b.value.split(' ');
				for (var i=0; i< bb.length; i++) if (bb[i].length>3) {e=false; break;}
				//if ($.trim(b.value).length<4) {
				//if (b.value.replace(/\s/gi,"").length<4) {
				if (e) {
					alert('La búsqueda debe contener una palabra de al menos 4 caracteres.');
					b.focus();
					return false
				}
			});
     	break;
    case 'noticias2':
			$('.tree1 ul').hide();
			$('.tree1 a.t1').addClass('ul_a');
			$('.tree1 a.t1').click(function(){
				$(this).next().slideToggle('slow');
    		$(this).toggleClass('ul_b');
			});
      break;
    case 'public':
			$('.aa').hide();
			$('.prodia1 a').mouseover(function(){$('#a'+$(this).attr('id')).show();});
		  $('.prodia1 a').mouseout( function(){$('#a'+$(this).attr('id')).hide();});
      break;
    case 'rse2':
			$('.tree1 div').hide();
			$('.tree1 a.t1').addClass('ul_a');
			$('.tree1 a.t1').click(function(){
				$(this).next().slideToggle('slow');
    		$(this).toggleClass('ul_b');
			});
      break;
    case 'rse3':
			$('.tree1 ul').hide();
			$('.tree1 a.t1').addClass('ul_a');
			$('.tree1 a.t1').click(function(){
				$(this).next().slideToggle('slow');
    		$(this).toggleClass('ul_b');
			});
      break;
    case 'rse4':
			$('#all').click(function(){
				$('.tree1 div').show('slow');
				$('.tree1 a.t1').addClass('ul_b');
				$('.tree1 a.t2').addClass('ul_b');
				$('.tree1 a.t3').addClass('ul_b');
			});
			$('.tree1 a').next().hide();
			$('.tree1 a.t1').addClass('ul_a');
			$('.tree1 a.t1').click(function(){
				$(this).next().slideToggle('slow');
				$(this).toggleClass('ul_b');
			});
			$('.tree1 a.t2').addClass('ul_a');
			$('.tree1 a.t2').click(function(){
				$(this).next().slideToggle('slow');
				$(this).toggleClass('ul_b');
			});
			$('.tree1 a.t3').addClass('ul_a');
			$('.tree1 a.t3').click(function(){
				$(this).next().slideToggle('slow');
				$(this).toggleClass('ul_b');
			});
      break;
    case 'transp2':
			$('.tree1 ul').hide();
			$('.tree1 a.t1').addClass('ul_a');
			$('.tree1 a.t1').click(function(){
				$(this).next().slideToggle('slow');
    		$(this).toggleClass('ul_b');
			});
      break;
    case 'fideicomiso8':
			$('.tree1 ul').hide();
			$('.tree1 a.t1').addClass('ul_a');
			$('.tree1 a.t1').click(function(){
				$(this).next().slideToggle('slow');
    		$(this).toggleClass('ul_b');
			});
      break;
    case 'eosc':
			$('.tree1 div').hide();
			$('.tree1 a.t1').addClass('ul_a');
			$('.tree1 a.t1').click(function(){
				$(this).next().slideToggle('fast');
    		$(this).toggleClass('ul_b');
			});
      break;
    case 'eosc10contacto':
			swfobject.embedSWF("swfs/eosc.swf","banner","250","60","9.0.0","","",{bgcolor:"#9C9500"});
    	$('#form1').submit(function(){return checkForm(this,'s_nombre:Nombre::1','s_email:Correo electrónico:mail:1')});
			break;
	}
});