top.location.target="_top"
if(window.location.target != "_top") {
  top.location.href=window.location.href
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function popWord(URL) {
	day = new Date();
	ide = day.getTime();
	leftVal = (screen.width - 500)/2;
	topVal  = (screen.height - 650)/2;
	eval("page" + ide + " = window.open(URL, '" + ide+ "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=600,left="+leftVal+",top="+topVal+"');");
}

function goHome(){
		window.location = "index.php"
}

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	leftVal = (screen.width - 500)/2;
	topVal  = (screen.height - 650)/2;
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=600,left="+leftVal+",top="+topVal+"');");
}

function popHelp(URL) {
	day = new Date();
	id = day.getTime();
	leftVal = (screen.width - 650)/2;
	topVal  = (screen.height - 650)/2;
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=650,height=600,left="+leftVal+",top="+topVal+"');");
}

function confEsborrar(url) {
	var entrar = true;
	entrar = confirm("Realment vol eliminar aquest registre?")
	if (entrar) this.location.href = url;
}

function rSelectFormOp(SelectName, Value) {
  eval('SelectObject = document.' + SelectName + ';');
  for(index = 0; index < SelectObject.length; index++) {
   if(SelectObject[index].value == Value)
     SelectObject.selectedIndex = index;
   }
}


function validate_required(field,alerttxt){
	with (field){
		if (value==null||value==""){
			alert(alerttxt);return false;
		}else{
			return true;
		}
	}
}

function validate_form_email(thisform){
	with (thisform){
	  if (validate_required(email,"E-mail no vàlid!")==false){
		  {email.focus();return false;}
	  }
	}
}

function validate_form(thisform){
	with (thisform){
	  if (validate_required(titol,"El Nom es obligatòri!")==false){
		  {titol.focus();return false;}
	  }
	  if (validate_required(client,"El Client es obligatòri!")==false){
		  {client.focus();return false;}
	  }
	  if (validate_required(imatge4,"La Miniatura es obligatòria!")==false){
		  {imatge4.focus();return false;}
	  }
	  if (validate_required(imatge,"Una imateg es obligatòria, com a mínim!")==false){
		  {imatge.focus();return false;}
	  }
	}
}
