$(function() {    
	$('tr.even').mouseover(function() {  
       $(this).addClass("overrow").show("slow");  
  } )  
  $('tr.even').mouseout(function() {  
      $(this).removeClass("overrow").show("slow");  
  } ) 	
}) 

function OFlash (file, width, height, bgcolor, mode) { document.write ("<object codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0 height=" + height + " width=" + width + " classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000><PARAM NAME='FlashVars' VALUE=''><PARAM NAME='Movie' VALUE='" + file + "'><PARAM NAME='Src' VALUE='" + file + "'><PARAM NAME='WMode' VALUE='" + mode + "'><PARAM NAME='Play' VALUE='-1'><PARAM NAME='Loop' VALUE='-1'><PARAM NAME='Quality' VALUE='High'><PARAM NAME='SAlign' VALUE=''><PARAM NAME='Menu' VALUE='0'><PARAM NAME='Base' VALUE=''><PARAM NAME='AllowScriptAccess' VALUE='0'><PARAM NAME='Scale' VALUE='ShowAll'><PARAM NAME='DeviceFont' VALUE='0'><PARAM NAME='EmbedMovie' VALUE='0'><PARAM NAME='BGColor' VALUE='" + bgcolor +"'><PARAM NAME='SWRemote' VALUE=''><PARAM NAME='MovieData' VALUE=''><PARAM NAME='SeamlessTabbing' VALUE='1'><PARAM NAME='Profile' VALUE='0'><PARAM NAME='ProfileAddress' VALUE=''><PARAM NAME='ProfilePort' VALUE='0'><embed src='" + file + "' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='" + width + "' height='" + height +"'  wmode= '"+mode+"'></embed></object>"); }

function popup(page, title) {	
	window.open(page, title, "width=590,height=478,menubar=no,scrollbars=yes");
}

function initValidation (id_form)
{
		
	var correcto = true;	
	// campos requeridos
	  $("#"+id_form).find(".required:visible").each(function(i) {
		id = $(this).attr("id");
	   valor=$(this).val();
	   
	   if (valor==''){
	   	   mark_field(id,'required');
		   correcto = false;		
	   }else 
	   		unmark_field(id,'required');
     
	   });
	  
	// Aceptar condiciones	
	if($("#accept_cond").val() != undefined && $("#accept_cond:checked").val() == null){		
		mark_field('accept_cond','required');
	   correcto = false;
	}else{
		unmark_field('accept_cond','required');
	}
	  
	// campos password iguales	  
	pasw = $("#password").attr("value");		
	repasw = $("#repassword").attr("value");		
	if(pasw != undefined && pasw != ''){
		if (pasw == repasw){
   			unmark_field('password','match_password');  		
	   }else{ 
   		   mark_field('password','match_password');
		   correcto = false;
	   }  	
	}
	   
	  
	 
	// campos email
	$("#"+id_form).find(".valid_email:visible").each(function(i) {	
		id = $(this).attr("id");
	   valor=$(this).attr("value");
	  
	   if (valor!=undefined) {
	  if (!valor.match(/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i)){
	  	mark_field(id,'valid_email');
		correcto = false;
	  }else unmark_field(id,'valid_email');
	   }
	   });
	   
	 // min length
	 $("#"+id_form).find(".min_length:visible").each(function(i) {		
		id = $(this).attr("id");
	   valor=$(this).attr("value");
	  if (valor!=undefined) {
	  if (valor.length<6){
	  	mark_field(id,'min_length');
		correcto = false;
	  }
	   else unmark_field(id,'min_length');
	  }
	   });

	 $("#"+id_form).find(".minimum:visible").each(function(i) {			 
		id = $(this).attr("id");
	   valor=$(this).attr("value");
	  if (valor!=undefined) {
	  	id = $(this).attr("id");
	  	fieldcomp = id.substring(0, id.indexOf('_') );
	  	
	  	valor2=$("#"+fieldcomp).attr("value");
	  
	  	if (parseInt(valor)>parseInt(valor2)){
	  	correcto = false;
	  	mark_field(id,'minimum');
		}
	   else unmark_field(id,'minimum');
	  }
	   }); 
	 
	 // campos numerico
	$("#"+id_form).find(".numeric:visible").each(function(i) {	
		id = $(this).attr("id");
	    valor=$(this).val();
	  
	   if (valor!='') {
	  if (!valor.match(/^\d+$/)){
	  	mark_field(id,'numeric');
		correcto = false;
	  }else unmark_field(id,'numeric');
	   }
	   });

	 
	 return correcto;
}

function doSubmit(id_form, action){
	$("#"+id_form).attr('action', action);
	$("#"+id_form).submit();
}


function doValid(id_form, action){
	
	if(initValidation(id_form)){
	
		$("#img_enviar").hide();
		doSubmit(id_form, action);		
	}
}


function mark_field (id, type)
{	
	$("#"+id).css("background-color", "#ffffcc");	
	$("#error_"+ id + "_" + type).show();	
}

function unmark_field (id, type)
{	
	$("#"+id).css("background-color", "#FFFFFF");
	$("#error_"+ id + "_" + type).hide();
	//$("../",id).remove("span");
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(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+' must contain an e-mail address.\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+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

// JavaScript Document

function activa_menu(id_menu){
	$(".submenu").hide();
	$("#submenu_equip"+id_menu).show();
}

function menuPCIMAGINE(){
	
	// Recordatori: Si es modifica algo del menú també s'haurà de modificar
	// al "template.php"
	
	document.getElementById('submenutxt').innerHTML = 'FS PC IMAGINE | <a href="plantilla.php?equip=1">Plantilla</a> | <a href="classificacio.php?equip=1">Classificació</a> | <a href="calendari.php?equip=1">Calendari</a> | <a href="quiniela.php?equip=1">Quiniela</a> | <a href="croniques.php?equip=1">Cròniques</a> | <a href="situacio.php?equip=1">Situació jornada</a>';
	
}

function menuTRANSCASSERRES(){

	// Recordatori: Si es modifica algo del menú també s'haurà de modificar
	// al "template.php"
	
	document.getElementById('submenutxt').innerHTML = 'FS TRANSCASSERRES | <a href="plantilla.php?equip=2">Plantilla</a> | <a href="classificacio.php?equip=2">Classificació</a> | <a href="calendari.php?equip=2">Calendari</a> | <a href="quiniela.php?equip=2">Quiniela</a> | <a href="croniques.php?equip=2">Cròniques</a> | <a href="situacio.php?equip=2">Situació jornada</a>';
	
}

function menuCURRIU(){

	// Recordatori: Si es modifica algo del menú també s'haurà de modificar
	// al "template.php"
	
	document.getElementById('submenutxt').innerHTML = 'FS JARDINERIA CURRIU | <a href="plantilla.php?equip=3">Plantilla</a> | <a href="classificacio.php?equip=3">Classificació</a> | <a href="calendari.php?equip=3">Calendari</a> | <a href="quiniela.php?equip=3">Quiniela</a> | <a href="croniques.php?equip=3">Cròniques</a> | <a href="situacio.php?equip=3">Situació jornada</a>';
	
}

function menuNULL(){
	$(".submenu").hide();
	
}
