function popup(name,w,h){
            myWindow = window.open(name, "popup",'toolbar=no,width='+w+',height='+h+',status=no,scrollbars=no,resize=no,menubars=no');
            myWindow.focus();
			return false;
}

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

function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}

function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + 30 + "px";
  }
}

function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;   
    return false;
  }
  else return true;
}

function hidden(tipus) {
	document.getElementById(tipus).style.visibility = "hidden";
}

function visible(tipus) {
	var obj = document.getElementById(tipus);
	obj.style.visibility = "visible";
}

function display(tipus,prop) {
	var obj = document.getElementById(tipus);
	obj.style.display = prop;
}

function change(tipus) {
    var obj = document.getElementById(tipus);
	if (obj.style.display == 'block') {
		obj.style.display = 'none';
	} else {
		obj.style.display = 'block';
	}
}

function ch_img(id,img) {
	var obj = document.getElementById(id);
	obj.src = img;
}

function validar(ar) {
	i = 0;
	while ((ar.length-1)>=i) { 
		if (ar[i].value == "") {
			alert("No puede haber campos vacios");
			return false;	
		}
		i++;
	}
	return true;
}

function checkMail(mail) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(mail.value)) {
		return true;
	} else {
		alert("Email, no es correcto");
		return false;
	}
	return true;
}


function avisoLegal(obj) {
	if (!obj.checked) {
			alert("Tiene que validar el Aviso Legal");
			return false;	
	}
	return true;
}
