function mOvr(src,color) {
	if (!src.contains(event.fromElement)) {
		src.style.cursor = 'hand';
		src.bgColor = color
	}
}
function mOut(src,color) {
	if (!src.contains(event.toElement)) {
		src.style.cursor = 'default';
		src.bgColor = color
	}
}
function mClk(src) {
	if(event.srcElement.tagName=='TD'){
		src.children.tags('A')[0].click()
	}
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  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); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_validateForm() { //v3.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+' debe ser una direccion de email.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' debe ser un numero.\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+' debe ser un numero entre '+min+' y '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' debe ser ingresado.\n'; }
  } if (errors) alert('Tiene los siguientes errores:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_validateFormEn() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormEn.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 == '');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function trim(cadena)
{
	for(i=0; i<cadena.length; )
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(i+1, cadena.length);
		else
			break;
	}

	for(i=cadena.length-1; i>=0; i=cadena.length-1)
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(0,i);
		else
			break;
	}
	
	return cadena;
}

var menuids=["suckertree1"] //Enter id(s) of SuckerTree UL menus, separated by commas

function buildsubmenus(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
    ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle"
		if (ultags[t].parentNode.parentNode.id==menuids[i]) //if this is a first level submenu
			ultags[t].style.left=ultags[t].parentNode.offsetWidth+"px" //dynamically position first level submenus to be width of main menu item
		else //else if this is a sub level submenu (ul)
		  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.display="block"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.display="none"
    }
    }
		for (var t=ultags.length-1; t>-1; t--){ //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars
		ultags[t].style.visibility="visible"
		ultags[t].style.display="none"
		}
  }
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus)
	
// C.V.

idcvActivo=0;
function vercv(idcv) {
	document.getElementById('cv').style.display = 'block';
	id='cv'+idcv;
	idapaga='cv'+idcvActivo;
	document.getElementById(idapaga).style.display = 'none';
	document.getElementById(id).style.display = 'block';
	idcvActivo=idcv;
}

idGerenciaActivo=0;
function verGR(idGR) {
	document.getElementById('GR').style.display = 'block';
	id='GR'+idGR;
	document.getElementById(id).style.display = 'block';
	idGerenciaActivo=idGR;
}

function ocuGR() {
	idapaga='GR'+idGerenciaActivo;
	document.getElementById('GR').style.display = 'none';
	document.getElementById(idapaga).style.display = 'none';
}


/**************** rutinas formulario de reclamos **********************/
function hide(id) {
  	document.getElementById(id).style.visibility="hidden";
  	document.getElementById(id).style.display="none";
}

function show(id,mensaje) {
    document.getElementById(id).style.visibility="visible";
  	document.getElementById(id).style.display="block";
	document.getElementById('txt_reclamo').innerHTML=mensaje;
    
}

function cambiar(){
	var valor = document.getElementById('prestador').value;
	if (valor==2) {
		hide('nrocliente');
		document.getElementById('nis').value = '';
		show('nis','<strong>N.I.S.</strong>');
	}else{
		hide('nis');	
		show('nrocliente','<strong>N&ordm; Cliente</strong>');
		document.getElementById('nrocliente').value = '';
	}
}

function validar(form){
	valor = document.getElementById('prestador').value;
	var msjErr = ''
	
	error=0;
	if (form.idreclamo.value == "reclamo") 
	{
		if ((form.nrocliente.value == '') && (form.nis.value == '')){
			if (valor==2) {
				msjErr += 'El campo N.I.S. no puede quedar vacío\n\r';
				error=1;
				form.nis.focus();
			}else{
				msjErr += 'El campo Nº Cliente no puede quedar vacío\n\r';
				error=1;
				form.nrocliente.focus();		
			}
		}
	}
	if (form.telefono1.value == ''){
		msjErr +='EL campo Teléfono 1 no puede quedar vacío\n\r';
		if(!error){
			form.telefono1.focus();
		}
		error=1;
	}
/*	if (form.telefono2.value == ''){
		msjErr +='EL campo Teléfono 2 no puede quedar vacío\n\r';
		if(!error){
			form.telefono2.focus();
		}
		error=1;		
	}
*/
	if (form.referencia.value == ''){
		msjErr +='El campo Referencia no puede quedar vacío\n\r';
		if(!error){
			form.referencia.focus();
		}
		error=1;
	}
	if(error){alert(msjErr);}else{form.submit();}

}
