var formulario2 =''



function  sinAccesoW(){
	alert("You are not authorized to modify data.");
}

function sincambios()
{
//top.cabecera.cambios="no";
top.cabecera.sincambios_cabecera();
}

function cambiorealizado()
{
//top.cabecera.cambios="si";
top.cabecera.concambios_cabecera();
}


function salvarDatos()

{
//formulario = formulario +' </form>';

document.datos.submit();

}

function saveData(formular)
{
//formulario = formulario +' </form>';
//alert(document.getElementById(formular));
document.getElementById(formular).submit();
}


function generaCampo( nombreCampo , valorCampo )
{
	if( document.getElementById(nombreCampo))
	{
	document.getElementById(nombreCampo).value = valorCampo;
	}
	else
	{
	formulario2 += "<input id='"+nombreCampo+"' type='hidden' name='"+nombreCampo+"'	value='"+valorCampo+"'>";
	document.getElementById('capaoculta').innerHTML=formulario2;
	}
}

function generaCampo_c( nombreCampo , valorCampo )
{

var textoformulario
	if( document.getElementById(nombreCampo))
	{
	document.getElementById(nombreCampo).value = valorCampo;
	}
	else
	{
	
		if(brw!="NN")
		{
		textoformulario = "<input id='"+nombreCampo+"' type='hidden' name='"+nombreCampo+"'	value='"+valorCampo+"'>";	
		document.getElementById('capaoculta').insertAdjacentHTML("AfterBegin",textoformulario);
		}
		else
		{		
	formulario2 += "<input id='"+nombreCampo+"' type='hidden' name='"+nombreCampo+"'	value='"+valorCampo+"'>";
	document.getElementById('capaoculta').innerHTML=formulario2;
		
		}
		
	}


/*
var aux=document.createElement("input");
	aux.type="hidden";
	aux.getAttribute('name',nombreCampo);
//	aux.getAttribute('id',nombreCampo);
	aux.id		=	nombreCampo;
	aux.value	=	valorCampo;
	
alert(aux.id);
document.getElementById('formname').appendChild=aux;
//alert(document.getElementById(aux.id).value);
*/


}


// números aleatorios
function aleatorio(inferior,superior){
    numPosibilidades = superior - inferior
    aleat = Math.random() * numPosibilidades
    aleat = Math.round(aleat)
    return parseInt(inferior) + aleat
} 
function LTrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}

function RTrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }

   return s;
}
function Trim(str)
{
   return RTrim(LTrim(str));
}
 


function redondeo(number,X)		{	
X = (!X ? 0 : X);
return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}


function checkNumeric(objName,minval, maxval,comma,period,hyphen)
{
	var numberfield = objName;
	if (chkNumeric(objName,minval,maxval,comma,period,hyphen) == false)
	{
		numberfield.select();
		numberfield.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function chkNumeric(objName,minval,maxval,comma,period,hyphen)
{
// only allow 0-9 be entered, plus any values passed
// (can be in any order, and don't have to be comma, period, or hyphen)
// if all numbers allow commas, periods, hyphens or whatever,
// just hard code it here and take out the passed parameters
var checkOK = "0123456789" + comma + period + hyphen;
var checkStr = objName;
var allValid = true;
var decPoints = 0;
var allNum = "";

for (i = 0;  i < checkStr.value.length;  i++)
{
ch = checkStr.value.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid)
{	
alertsay = "Please enter only these values \""
alertsay = alertsay + checkOK + "\" in the \"" + checkStr.name + "\" field."
alert(alertsay);
return (false);
}

// set the minimum and maximum
var chkVal = allNum;
var prsVal = parseInt(allNum);
if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
{
alertsay = "Please enter a value greater than or "
alertsay = alertsay + "equal to \"" + minval + "\" and less than or "
alertsay = alertsay + "equal to \"" + maxval + "\" in the \"" + checkStr.name + "\" field."
alert(alertsay);
return (false);
}
}



function IsNumeric(strString,tipo)
    	
   {
//real y positivo
if(tipo=="0"){   var strValidChars = "0123456789.";}
// entero y positivo
if(tipo=="1"){   var strValidChars = "0123456789";}
// real y negativo
if(tipo=="2"){   var strValidChars = "0123456789.-";}


   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

    
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function addcomentario(ide_1,ide_2, cambiar)
{
//alert(document.getElementById(ide_1).value);
texto1=document.getElementById(ide_1).value;
texto2=document.getElementById(ide_2).value;
if (brw=='NN'){

//comentario=window.open('comentario.html','loewe','toolbar=yes,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,left=0,top=0,width=573,height=200');
}
else
{

var myObject = new Object();
myObject.firstName = texto1;
myObject.lastName  = texto2;

comentario=showModalDialog('comentario.html'  ,  myObject  ,  "dialogWidth:500px;dialogHeight:360px;center:1;scroll:0;help:0;status:0");

	if (comentario.cambio==1)
	{

	document.getElementById(ide_1).value 	= comentario.asunto	;
	document.getElementById(ide_2).value	= comentario.comentario	;

		if(cambiar="add")
		{
		var ide_b 		= ide_1.substring(0,2);
		ide_b=ide_b+"boton";
		
		document.getElementById(ide_b).style.color="#333333";
		document.getElementById(ide_b).style.background="#DCC1A6";		
//		document.getElementById(ide_b).innerHtml="VIEW COMMENT";
//		document.getElementById(ide_b).outerHTML="VIEW COMMENT";
		}
	}
 
}
}


function addcomentarioS(ide_1,ide_2)
{
var cambio = 0;
texto1=document.getElementById(ide_1).value;
texto2=document.getElementById(ide_2).value;
if (brw=='NN'){
//comentario=window.open('comentario.html','loewe','toolbar=yes,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,left=0,top=0,width=573,height=200');
}
else
{

var myObject = new Object();
myObject.firstName = texto1;
myObject.lastName  = texto2;

comentario=showModalDialog('comentario.html'  ,  myObject  ,  "dialogWidth:500px;dialogHeight:360px;center:1;scroll:0;help:0;status:0");

//if(!comentario.cambio){alert("no existe");}else{cambio=1;};


if(comentario.cambio==0){}
else{
	document.getElementById(ide_1).value 	= comentario.asunto	;
	document.getElementById(ide_2).value	= comentario.comentario	;
	cambiorealizado();
	}
}
}
/*

function addcomentarioS(ide_1,ide_2)
{
 
var cambio =0;
texto1=document.getElementById(ide_1).value;
texto2=document.getElementById(ide_2).value;
if (brw=='NN'){
//comentario=window.open('comentario.html','loewe','toolbar=yes,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,left=0,top=0,width=573,height=200');
}
else
{

var myObject = new Object();
myObject.firstName = texto1;
myObject.lastName  = texto2;

comentario=showModalDialog('comentario.html'  ,  myObject  ,  "dialogWidth:500px;dialogHeight:300px;center:1;scroll:0;help:0;status:0");

//if(!comentario.cambio){alert("no existe");}else{cambio=1;};


if(comentario.cambio==0){}
else{
	document.getElementById(ide_1).value 	= comentario.asunto	;
	document.getElementById(ide_2).value	= comentario.comentario	;
	}
}
}

*/







var inputActual="";
function actual(id)
{
inputActual=document.getElementById(id).value;

}
function comprobar(id)
{
	if(document.getElementById(id).value==inputActual)	{	}
	else
	{
	document.getElementById(id).style.background="#E6E6A6";
	inputActual="";
	}
}



function sumar1(id)
{
a=document.getElementById(id).value;

}


function doTooltip(e, msg) {
//alert(Tooltip.ready );
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) {/*alert();*/return;}
  Tooltip.show(e, msg);
}
function hideTip() {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.hide();
}

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_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_findObj(n, d) { //v4.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);
  if(!x && document.getElementById) x=document.getElementById(n); 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 validarBrowser(){
  if(document.getElementById){
	
	if(navigator.appName == "Netscape")
		brw='NN';
	else if(navigator.appName == "Microsoft Internet Explorer"){
		if(navigator.appVersion.indexOf("MSIE 5.0"))
			brw='IE5.0';
		else
			brw='IE';
	}
	return true;
  }
  else	
	return false;
}
