// JavaScript Document
String.prototype.trim = function(){ return this.replace(/^s+|s+$/g,'') }

function ajustarTextarea(src,max){
  if(src.value.length > max){
    src.value = src.value.substr(0,max);
  }
}

function submitForm(form,action) {
	validator = new AjaxFormValidator(form,action);
	return validator.validate();
}

function submitSearchForm(form,action) {
	validator = new AjaxFormValidator(form,action);
	validator.errorDisplay = 'div';
	return validator.validate();
}

function toggleChecks(name){
  var objs = document.getElementsByName(name);
  for(var i=0; i<objs.length; i++){
    objs[i].checked = !(objs[i].checked);
  }
}

function abrirPagina(strUrl, strWindowName)
{
  var windowNewPage = window.open(strUrl, strWindowName, "resizable=yes,scrollbars=yes,toolbar=yes,location=yes,status=yes,directories=no,status=yes,menubar=yes");
  windowNewPage.focus();
}

/*function abrirPopUp(url,nom,width,height){
  window.open(url,nom,"width:"+width+",height:"+height+",toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no");  
}*/

/*window.onload = function() {
  //toggleChecks('ids[]');
}*/

function currencyFormat(num){
  num = num.toString().replace(/\'/g,'');
  if(isNaN(num)){ num="0"; }
  var sign = (num==(num=Math.abs(num)));
  num = Math.floor(num*100+0.50000000001);
  var cents = num%100;
  num = Math.floor(num/100).toString();
  if(cents < 10){ cents="0"+cents; }
  for(var i=0;i<Math.floor((num.length-(1+i))/3);i++){
    num=num.substring(0,num.length-(4*i+3))+","+num.substring(num.length-(4*i+3));
  }
  return((sign?'':'-')+num+'.'+cents);
};
