﻿function popup(url, title, w, h) {
	h = (h == '0') ? '315' : h;
	w = (w =='0') ? '415' : w;
	window.open(url,title,'height=' + h + ',width=' + w + ',resizable=yes,toolbars=no,scrollbars=yes');
}

function getRef(obj){
  	return(typeof obj == "string") ? document.getElementById(obj) : obj;
}

function getObject(obj) {
  var theObj;
  
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function clearText(box) {
     if(box.value==box.defaultValue) {
 	     box.value = "";
     }
 }

function Contar(entrada,salida,texto,caracteres) {
  var entradaObj=getObject(entrada);
  var salidaObj=getObject(salida);
  var longitud=caracteres - entradaObj.value.length;
  if(longitud <= 0) {
    longitud=0;
    texto='<span class="disable"> '+texto+' </span>';
    entradaObj.value=entradaObj.value.substr(0,caracteres);
  }
  salidaObj.innerHTML = texto.replace("{CHAR}",longitud);
}

var newWindow;

function showOriginalImage(imageUrl, windowStyle)
{
  if (windowStyle == "Self")
  {
    location.href = imageUrl;
    return;
  }
  
  var targetName;
  targetName = windowStyle == "Shared" ? "thumbnailWindow" : "_blank";
  newWindow = window.open(imageUrl, targetName, 
      "location=no,status=no,toolbar=no,resizable=yes,titlebar=no");
  newWindow.width = 640;
  newWindow.height = 480;
  newWindow.title = "Thumbnail Window";
  fitWindowToImage();
  newWindow.focus();
}

function fitWindowToImage()
{
  if (document.images)
  {
    if (newWindow.document.images.length == 1)
    {
      if (document.layers)
      {
        newWindow.resizeTo(newWindow.document.images[0].width+20,
            newWindow.document.images[0].height+20)
      }
      else if (document.all)
      { 
        newWindow.resizeTo(newWindow.document.images[0].width+50,
            newWindow.document.images[0].height+61)
      }
    }
    else 
    {
      setTimeout('fitWindowToImage()',500);
    }
  }
}