function show(object) {
if (document.getElementById) { 
document.getElementById(object).style.display = 'inline';
document.getElementById(object).style.visibility = 'visible';}
else {if (document.layers) { document.object.display = 'inline';document.object.visibility = 'visible';}
else {document.all.object.style.display = 'inline';document.all.object.style.visibility = 'visible';}
}
}
//----------------------------------------------------------------
function hide(object) {
if (document.getElementById) {
document.getElementById(object).style.display = 'none';}
else {if (document.layers) {document.object.display = 'none';}
else {document.all.object.style.display = 'none';}
}
}
//----------------------------------------------------------------
function getElem(id) { if (window.parent.document.getElementById) { return window.parent.document.getElementById(id); } else if (window.parent.document.all) { return window.parent.document.all(id); } else if (window.parent.document.layers) { return window.parent.document.layers(id); } }
//----------------------------------------------------------------
function Left(str, n) { if(n <= 0) { return ""; } else if(n > String(str).length) { return str; } else { return String(str).substring(0,n); } }
function Right(str, n) { if(n <= 0) { return ""; } else if(n > String(str).length) { return str; } else { var iLen = String(str).length; return String(str).substring(iLen, iLen - n); } }
//----------------------------------------------------------------
function changeSource(s) {
if(s.indexOf("*")>1) {var c=s.split("*"); top.cc.location.href=c[0]; document.getElementById("cpro").innerHTML="Provincia > " + c[1]; return true;}
top.location.href=s; return true;}
//----------------------------------------------------------------
function validaEmail(emails) {
trimJS(emails);emails.value = emails.value.toLowerCase();email = new String(emails.value);
if(email == "" || email.indexOf("@", 0) == -1 || email.indexOf(".", 0) == -1 || email.length <= 9) {
alert("La dirección de eMail proporcionada no es válida");
emails.focus();return false;
} else {var ok = 1;var validos = "abcdefghijklmnopqrstuvwxyz0123456789-_@.";
for (i=0;i<email.length;i++) {if (validos.indexOf(email.charAt(i)) == "-1") { ok = 0; }}
if (ok == 0) {alert("La dirección de eMail proporcionada no es válida");emails.focus();return false;}}
return true;
}
//----------------------------------------------------------------
function estaVacio(s,texto){
var len = s.value.length;
for (i=0;i<len;++i){if (s.value.charAt(i)!=" ") {return false;}}
alert(texto); s.focus();return true;
}
//----------------------------------------------------------------
function popUp(page,name,width,height,doFocus,properties) {
var posTop = screen.availHeight / 2 - (height / 2) - 30;
var posLeft = screen.availWidth / 2 - (width / 2);
properties = "status=no, width=" + width + ", height=" + height + ", top=" + posTop + ", left=" + posLeft + ", " + properties;
var ventana = window.open(page,name,properties);
if(doFocus){ ventana.focus(); }
}
//----------------------------------------------------------------

//-PONER ARRIBA LAS FUNCIONES QUE SE USEN


function blink(c){if (c!=''){eval(c+".innerHTML='<img src=/media/img/orange_arrow_blink.gif width=6 height=9 border=0 vspace=2>'")}} function blinkOff(c){if (c!=''){eval(c+".innerHTML='<img src=/media/img/nada.gif width=6 height=9 border=0 vspace=2>'")}}

//----------------------------------------------------------------
function validaNumeros(valor,texto,minimo, minimotexto){
numero = new String(valor.value)
var ok = 1;var validos = "0123456789";for (i=0;i<numero.length;i++){if (validos.indexOf(numero.charAt(i)) == "-1") ok = 0;}
if (ok == 0) {alert(texto);valor.focus(); return false}
if (numero.length<minimo){alert(minimotexto);valor.focus(); return false}
return true;
}
//----------------------------------------------------------------
function validaNumerosGuion(valor,texto,minimo, minimotexto){
numero = new String(valor.value);var ok = 1;var validos = "0123456789-";
for (i=0;i<numero.length;i++){if (validos.indexOf(numero.charAt(i)) == "-1") ok = 0;}
if (ok == 0) {alert(texto);valor.focus(); return false}
if (numero.length<minimo){alert(minimotexto);valor.focus(); return false}
return true;
}
//----------------------------------------------------------------
var activeDialog = 0;
function OpenDialog(strURL, properties) {
window.onfocus = WindowFocus;
activeDialog = window.open(strURL, "dialog", properties);
return true;
}
function WindowFocus(event) {
if (activeDialog) { try {activeDialog.focus(); }
catch (e) { activeDialog = 0; }
}
}
//----------------------------------------------------------------
function trimJS(cadena) { cadena.value = cadena.value.replace(/^\s*|\s*$/g,""); }
//----------------------------------------------------------------
function isDate(p_Expression){
return !isNaN(new Date(p_Expression));}
//----------------------------------------------------------------
function dateAdd(p_Interval, p_Number, p_Date){
if(!isDate(p_Date)){return "fecha inválida: '" + p_Date + "'";}
if(isNaN(p_Number)){return "número inválido: '" + p_Number + "'";}

p_Number = new Number(p_Number);
var dt = new Date(p_Date);
switch(p_Interval.toLowerCase()){
case "yyyy": {// year
dt.setFullYear(dt.getFullYear() + p_Number);break;}
case "q": {// quarter
dt.setMonth(dt.getMonth() + (p_Number*3));break;}
case "m": {// month
dt.setMonth(dt.getMonth() + p_Number);break;}
case "y":// day of year
case "d":// day
case "w": {// weekday
dt.setDate(dt.getDate() + p_Number);break;}
case "ww": {// week of year
dt.setDate(dt.getDate() + (p_Number*7));break;}
case "h": {// hour
dt.setHours(dt.getHours() + p_Number);break;}
case "n": {// minute
dt.setMinutes(dt.getMinutes() + p_Number);break;}
case "s": {// second
dt.setSeconds(dt.getSeconds() + p_Number);break;}
case "ms": {// second
dt.setMilliseconds(dt.getMilliseconds() + p_Number);break;}
default: {
return "intervalo inválido: '" + p_Interval + "'";}
}
return dt;
}
//----------------------------------------------------------------
function weekdayName(p_Date, p_abbreviate){
if(!isDate(p_Date)){return "fecha inválida: '" + p_Date + "'";}
var dt = new Date(p_Date);
var retVal = dt.toString().split(' ')[0];
var retVal = Array('Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado')[dt.getDay()];
if(p_abbreviate==true){retVal = retVal.substring(0, 3)}// abbr to 1st 3 chars
return retVal;
}
//----------------------------------------------------------------
function monthName(p_Date, p_abbreviate){
if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
var dt = new Date(p_Date);
var retVal = Array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agost','Septiembre','Octubre','Noviembre','Diciembre')[dt.getMonth()];
if(p_abbreviate==true){retVal = retVal.substring(0, 3)}// abbr to 1st 3 chars
return retVal;
}
//----------------------------------------------------------------
function datePart(p_Interval, p_Date, p_firstdayofweek, p_firstweekofyear){
if(!isDate(p_Date)){return "fecha inválida: '" + p_Date + "'";}

var dtPart = new Date(p_Date);
switch(p_Interval.toLowerCase()){
case "yyyy": return dtPart.getFullYear();
case "q": return parseInt(dtPart.getMonth()/3)+1;
case "m": return dtPart.getMonth()+1;
case "y": return dateDiff("y", "1/1/" + dtPart.getFullYear(), dtPart);// day of year
case "d": return dtPart.getDate();
case "w": return dtPart.getDay();// weekday
case "ww":return dateDiff("ww", "1/1/" + dtPart.getFullYear(), dtPart);// week of year
case "h": return dtPart.getHours();
case "n": return dtPart.getMinutes();
case "s": return dtPart.getSeconds();
case "ms":return dtPart.getMilliseconds();// millisecond// 
default: return "intervalo inválido: '" + p_Interval + "'";
}
}
//----------------------------------------------------------------
function dateDiff(p_Interval, p_Date1, p_Date2, p_firstdayofweek, p_firstweekofyear){
if(!isDate(p_Date1)){return "fecha inválida: '" + p_Date1 + "'";}
if(!isDate(p_Date2)){return "fecha inválida: '" + p_Date2 + "'";}
var dt1 = new Date(p_Date1);
var dt2 = new Date(p_Date2);

var iDiffMS = dt2.valueOf() - dt1.valueOf();
var dtDiff = new Date(iDiffMS);
var nYears  = dt2.getUTCFullYear() - dt1.getUTCFullYear();
var nMonths = dt2.getUTCMonth() - dt1.getUTCMonth() + (nYears!=0 ? nYears*12 : 0);
var nQuarters = parseInt(nMonths/3);
var nMilliseconds = iDiffMS;
var nSeconds = parseInt(iDiffMS/1000);
var nMinutes = parseInt(nSeconds/60);
var nHours = parseInt(nMinutes/60);
var nDays  = parseInt(nHours/24);
var nWeeks = parseInt(nDays/7);

// return requested difference
var iDiff = 0;
switch(p_Interval.toLowerCase()){
case "yyyy": return nYears;
case "q": return nQuarters;
case "m": return nMonths;
case "y": // day of year
case "d": return nDays;
case "w": return nDays;
case "ww":return nWeeks;// week of year// 
case "h": return nHours;
case "n": return nMinutes;
case "s": return nSeconds;
case "ms":return nMilliseconds;// millisecond
default: return "intervalo inválido: '" + p_Interval + "'";
}
}

