// este JS contiene todos los metodos que son comunes a la mayoria de las plantillas
// coloque metodos aqui, solo si esta seguro que esto es de utilidad para todos, de los
// contrario, arme rancho en otro lado
// author Oliver ACE
// since  27 dec 2002
//////////////////////////////////////////////////////////////////////////////////////
var win = null;

var isIE=document.all?true:false;
// options: [para showmodal]

// *dialogHeight: 100px ancho 
// *dialogWidth : 100px alto
// center:{ yes | no | 1 | 0 | on | off }
// help:{ yes | no | 1 | 0 | on | off }
// *resizable:{ yes | no | 1 | 0 | on | off }
// scroll:{ yes | no | 1 | 0 | on | off }
// *status:{ yes | no | 1 | 0 | on | off }

// para window.open
// *height = number
// *left = number
// menubar = { yes | no | 1 | 0 }
// *resizable = { yes | no | 1 | 0 }
// scrollbars = { yes | no | 1 | 0 }
// *status = { yes | no | 1 | 0 }
// titlebar = { yes | no | 1 | 0 }
// toolbar = { yes | no | 1 | 0 }

// para aplicacion
// options es un string, los valores que alli aparezcan se toman como true
// CENTER    : ventana centrada
// SCROLL    : tiene scroll
// STATUS    : tiene barra status
// NOTITLEBAR: no tiene barra de título
// MENUBAR   : tiene barra de menu
// HELP      : tiene boton de ayudas
// RESIZABLE : se puede mod tanano
// MODAL     : es ventana modal
// TOOLBAR   : barra herramientas
// LOCATION  : info de ubicacion [http:// blablabla.com]
// <!-- link nombre ancho alto opciones -->
var dialogWin = new Object();
function openWindow(mypage,myname,w,h,options){
  //--hallamos los parametros
if ((!options)||(options==null)) alert('no hay opciones definidas en ventana emergente!! ['+mypage+']');
  var help     = (options.toUpperCase().indexOf("HELP")      != -1)?'1':'0';
  var modal    = (options.toUpperCase().indexOf("MODAL")     != -1)?'1':'0';
  var modeLess = (options.toUpperCase().indexOf("MODELESS")  != -1)?'1':'0';
  var maxim    = (options.toUpperCase().indexOf("MAXIM")     != -1)?'1':'0';
  var center   = (options.toUpperCase().indexOf("CENTER")    != -1)?'1':'0';
  var scroll   = (options.toUpperCase().indexOf("SCROLL")    != -1)?'1':'0';
  var toolbar  = (options.toUpperCase().indexOf("TOOLBAR")   != -1)?'1':'0';
  var location = (options.toUpperCase().indexOf("LOCATION")  != -1)?'1':'0';
  var status   = (options.toUpperCase().indexOf("TOOLBAR")   != -1)?'1':'0';
  var menubar  = (options.toUpperCase().indexOf("MENUBAR")   != -1)?'1':'0';
  var resizable= (options.toUpperCase().indexOf("RESIZABLE") != -1)?'1':'0';
  var notitlebar=(options.toUpperCase().indexOf("NOTITLEBAR")!= -1)?'1':'0';//? no aplica a todos los browwsers, ie es <titlebar>
  var semiModal= (options.toUpperCase().indexOf("SEMIMODAL") != -1)?'1':'0';
  var borde    = (options.toUpperCase().indexOf("BORDE")     != -1)?'Raised':'Sunken';
  var left     = 20;
  var top      = 20;
  var day      = new Date();
  var now      = day.getTime();
  
  if  (maxim=='yes'){ // si es maximizada 
      left= 0;
      top = 0;
      if (modal=='yes'){
        w   = (screen.width)?screen.width:640;
        h   = (screen.height)?(screen.height-9):480;
        
      }else{
        w   = (screen.width)?screen.width-12:640;
        h   = (screen.height)?(screen.height-73):480;
      }
  }else{
    left = (screen.width) ? (screen.width-w)/2 : 0;
    top  = (screen.height) ? (screen.height-h)/2 : 0;
  }
  if ((modal=='yes')&&(isIE)){
    datosObj = loadObj();
    window.name=''+myname;
    if (center=='yes') win = window.showModalDialog(""+mypage,datosObj,"dialogHeight: "+h+"px; dialogWidth: "+w+"px; dialogTop:       px; dialogLeft:        px; edge:"+borde+"; center:Yes;help:"+help+"; resizable:"+resizable+"; status:"+status+"; scroll"+scroll+";");
    else               win = window.showModalDialog(""+mypage,datosObj,"dialogHeight: "+h+"px; dialogWidth: "+w+"px; dialogTop:"+top+"px; dialogLeft:"+left+"px; edge:"+borde+"; center: No;help:"+help+"; resizable:"+resizable+"; status:"+status+"; scroll"+scroll+";");
    if (win) openWindow(mypage,myname,w,h,options);
  }else if((modeLess=='yes')&&(isIE)){
   alert(1);
    datosObj = new Object();
    datosObj.name = ''+myname;
    window.name=''+myname;
    if (center=='yes') win = window.showModelessDialog(""+mypage,datosObj,"dialogHeight: "+h+"px; dialogWidth: "+w+"px; dialogTop:       px; dialogLeft:        px; edge:"+borde+"; center:Yes;help:"+help+"; resizable:"+resizable+"; status:"+status+"; scroll"+scroll+";");
    else               win = window.showModelessDialog(""+mypage,datosObj,"dialogHeight: "+h+"px; dialogWidth: "+w+"px; dialogTop:"+top+"px; dialogLeft:"+left+"px; edge:"+borde+"; center: No;help:"+help+"; resizable:"+resizable+"; status:"+status+"; scroll"+scroll+";");
  }else if((semiModal=='yes')&&(isIE)){
   alert(2);
    if (center=='yes') settings = 'height='+h+',width='+w+',top='+top+',left='+left+',scrollbars='+scroll+', status='+status+',resizable='+resizable+',menubar='+menubar;
    else               settings = 'height='+h+',width='+w+',top='+top+',left='+left+',scrollbars='+scroll+', status='+status+',resizable='+resizable+',menubar='+menubar;
    dialogWin.win = window.open(mypage,myname,settings);
    dialogWin.win.focus();
    //checkModal();
  }else{ 
    //alert('screen.width='+screen.width+'-- screen.height='+screen.height);
    if (center=='yes') settings = 'width='+w+',height='+h+',left='+left+',top='+top+',scrollbars='+scroll+', status='+status+',resizable='+resizable+',menubar='+menubar+',toolbar='+toolbar+',location='+location;
    else               settings = 'width='+w+',height='+h+',left='+left+',top='+top+',scrollbars='+scroll+', status='+status+',resizable='+resizable+',menubar='+menubar+',toolbar='+toolbar+',location='+location;
    eval("page" + now + " = window.open(mypage,'"+myname+"','"+settings+"');"); // tiene que ser con eval!
  }
}

function showlayer(whichLayer){
  if (document.getElementById) document.getElementById(whichLayer).style.display = "block";
  if (document.all)            document.all[whichLayer].style.display            = "block";
  if (document.layers)         document.layers[whichLayer].style.display         = "block";
	return;
}

function hidelayer(whichLayer){
  if (document.getElementById) document.getElementById(whichLayer).style.display = "none";
  if (document.all)            document.all[whichLayer].style.display            = "none";
  if (document.layers)         document.layers[whichLayer].style.display         = "none";
	return;
}

function switchlayer(whichLayer){
  if (document.getElementById) document.getElementById(whichLayer).style.display = (document.getElementById(whichLayer).style.display=="none")?"block":"none";
  if (document.all)            document.all[whichLayer].style.display            = (document.all[whichLayer].style.display=="none")?"block":"none";
  if (document.layers)         document.layers[whichLayer].style.display         = (document.layers[whichLayer].style.display=="none")?"block":"none";
	return;
}

 
