
function repos(id,tp,lf,h,w) {

	document.getElementById(id).style.top = tp + "px";
	document.getElementById(id).style.left = lf + "px";
	document.getElementById(id).style.position = "absolute";
	document.getElementById(id).style.display = "block";
	
	if (h && h > 0) {
		document.getElementById(id).style.height = h;
	}
	if (w && w > 0) {
		document.getElementById(id).style.width = w;
	}

}

function addEvent(obj, evType, fn){
 if (obj.addEventListener){
    obj.addEventListener(evType, fn, true);
    return true;
 } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
 } else {
    return false;
 }
} 


function checkMail(x){
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return 1;
	else return 0;
}
function ocultarparte(id) {
	$(id).style.display='none';
}
function mostrarparte(id) {
	$(id).style.display='block';
}
function deshabilitar(id) {
	$(id).disabled=true;
}
function habilitar(id) {
	$(id).disabled=false;
}

function hideparte (id) {
	document.getElementById(id).style.display='none';
}
function showparte (id) {
	document.getElementById(id).style.display='block';
}

function gotoSite(obj) {
	var s;
	s=obj.options[obj.selectedIndex].value
	if (s!="") {
		location.href=s;
	}
}

function validatenum(field) {

	var valid = "0123456789"
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
		}
	if (ok == "no") {
		alert("El numero ingresado no es correcto");
		field.focus();
		field.select();
		return false;
   }
   
}

function validateimporte(field) {

	var valid = "0123456789."
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
		}
	if (ok == "no") {
		alert("El importe no es correcto, el separador decimal es el punto");
		field.focus();
		field.select();
   }
   
}

function borrardelagrilla(url) {
	
	var cant = document.grilla.grilla_formulario.length;
	var elegidos = "";

	for (var i=0;i<document.grilla.grilla_formulario.length;i++) {
	
		var valor = document.grilla.grilla_formulario[i].name;
		
		if (document.grilla.grilla_formulario[i].checked) {
			elegidos = elegidos + '|' + valor;
		}

	}
	if (elegidos == "") {
			alert("Elija los que quiere eliminar");
	}
	else {
		if (window.confirm("Confirma eliminar los elegidos")) {
			window.location.href = url + "?proc=1&q=borrar&borrar=" + elegidos + "&r=$RANDOM";
		}
	}

}

function trim(s){

	while((s.charAt(0)==" ")||(s.charAt(0)=="\t")){
		s=s.substring(1,s.length)
	}
	while((s.charAt(s.length-1)==" "||s.charAt(s.length-1)=="\t")){
		s=s.substring(0,s.length-1)
	}

	return s

}

function AbrirVentana (url, name, rs, w, h, s) {
  var resize = "";
  if (rs) {
    resize = "resizable,";
  }
  popupWin = window.open(url, name, 'status=1,menubar=0,' + resize + 'width=' + w + ',height=' + h + ',scrollbars=' + s);
}
