<!--

var ajaxRequest;

// Browser Support Code
function ajaxFunction() {
  try {
    // Opera 8.0+, Firefox, Safari
    ajaxRequest = new XMLHttpRequest();
    ajaxRequest.overrideMimeType('text/html');
    return true;
  } catch (e) {
    // Internet Explorer Browsers
    try {
      ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
      return true;
    } catch (e) {
      try {
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
        return true;
      } catch (e) {
        alert("Seu progama navegador Internet não suporta AJAX (Asynchronous Javascript And XML). Atualize sua versão!");
        return false;
      }
    }
  }
}

function ReloadPage(init) {
  if ( init == true ) with ( navigator ) {
    if ( ( appName == "Netscape" ) || ( appName == "Firefox" ) ) {
      document.pgW = innerWidth; document.pgH = innerHeight;
      onresize = ReloadPage;
    }
  }
  else if ( innerWidth != document.pgW || innerHeight != document.pgH ) location.reload();
}
ReloadPage(true);

function QueryString(qn) {
  qs = window.location.search.substring(1);
  rq = qs.split("&");
  for ( i = 0; i < rq.length; i++ ) {
    qe = rq[i].split("=");
    if ( qe[0] == qn ) return qe[1];
	else return "";
  }
}

function FindObject(n, d) {
  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 = FindObject(n, d.layers[i].document);
  if ( !x && d.getElementById ) x = d.getElementById(n);
  return x;
}

function ValidateForm() {
  var k = 0, i, p, q, nm, test, num, vmin, vmax, errs = "", args = ValidateForm.arguments;
  for ( i = 0; i < ( args.length - 2 ); i += 3 ) {
    test = args[i+2]; val = FindObject(args[i]);
    if ( val ) {
      nm = ( args[i+1] != "" )?args[i+1]:val.name; nm = "- campo " + nm;
      if ( val.options && val.selectedIndex <= 0 ) errs += "" + nm + " deve ser selecionado\n";
      else if ( (val=val.value) != "" ) {
        if ( test.indexOf("isEmail") != -1 ) {
          p = val.indexOf("@"); if ( p < 1 || p == ( val.length - 1 ) ) errs += "" + nm + " deve conter um endereço de e-mail válido\n";
        } else if ( test != "R" ) {
          p = val.indexOf(","); if ( p != -1 ) val = val.substring(0, p) + "." + val.substring(p + 1);
          num = parseFloat(val); if ( val != ""+num && val.indexOf(".") == -1 ) errs += "" + nm + " deve conter um número\n";
          if ( test.indexOf("inRange") != -1 ) {
            p = test.indexOf(":"); vmin = parseFloat(test.substring(8, p)); vmax = parseFloat(test.substring(p + 1));
            if ( num < vmin || vmax < num ) errs += "" + nm + " deve conter um número entre " + vmin + " e " + vmax + "\n";
          }
        }
      } else if ( test.charAt(0) == "R" ) errs += "" + nm + " é requerido\n";
    }
  }
  return errs;
}

function CharsLeft(f, h, m) {
  val = FindObject(f);
  hlp = FindObject(h);
  if ( val && hlp ) {
    l = m - val.value.length;
    if ( l > 0 ) hlp.innerHTML = "Restam " + l + " caracteres até o limite!";
    else if ( l == 0 ) hlp.innerHTML = "Limite de caracteres esgotado!";
    else val.value = val.value.substring(0, m);
  }
}

function CheckAll(f) {
  var df;
  if ( !f ) df = document.forms[0];
  else if ( typeof(f) == "object" ) df = f;
  else if ( isNaN(f) ) df = document.forms(f);
  else df = document.forms[f];
  new_value = (!df.elements[0].checked);
  for ( var i = 0; i < df.elements.length; i++ ) {
    df.elements[i].checked = new_value;
  }
}

var sTitle = "";

function ViewImage(i, t) {
  window.open("view.asp?img=" + i + "&title=" + t, "DETAIL", "left=10, top=10, width=160, height=120, scrollbars=no");
}

function ShowSlide() {
  var i, f = "", args = ShowSlide.arguments;
  for ( i = 0; i < args.length; i++ ) f += "&img" + eval( i + 1 ) + "=" + args[i];
  window.open("slide.asp?qty=" + args.length + f + "&title=" + sTitle, "DETAIL", "left=10, top=10, width=160, height=120, scrollbars=yes");
}

function PreviewVideo(v, t, w, h) {
  window.open("player.asp?video=" + v + "&title=" + t, "PLAYER", "width=" + w + ", height=" + h + ", toolbar=no, location=no, status=no, menubar=no, scrollbars=no, resizable=no");
}

function Redimension() {
  var args = Redimension.arguments;
  
  if ( args.length == 0 ) {
    x = self.document.body.scrollWidth + self.document.body.offsetWidth - self.document.body.clientWidth + 7;
    y = self.document.body.scrollHeight + self.document.body.offsetHeight - self.document.body.clientHeight + 15 + 58;
  } else if ( args.length >= 2 ) { x = args[0]; y = args[1]; }
  
  self.resizeTo(x, y);
  
  x = ( screen.availWidth - x ) / 2;
  y = ( screen.availHeight - y ) / 2;
  if ( x > 0 && y > 0 ) window.moveTo(x, y);
  
  self.focus();
}

function CloseWindow() {
  window.opener.focus();
  window.close();
}

function SwapImage(i, s) {
  var objI = FindObject(i), objS = FindObject(s);
  if ( objI && objS ) objI.src = objS.src;
}

function SwapText(i, s) {
  var objI = FindObject(i);
  if ( objI ) objI.innerHTML = s;
}

function Expand() {
  var args = Expand.arguments;
  var iplus = FindObject("Plus_" + args[0]);
  var tplus = FindObject("Table_" + args[0]);
  if ( tplus ) {
    if ( tplus.style.display != "" ) {
      if ( iplus ) iplus.src = "images/minus.gif";
      tplus.style.display = "";
    } else {
      tplus.style.display = "none";
      if ( iplus ) iplus.src = "images/plus.gif";
    }
  }
}

function ReloadImage(n) {
  var img = FindObject(n);
  if ( img ) {
    var src = img.src;
    var i = src.indexOf("?");
    if ( i >= 0 ) src = src.substring(0, i);
    img.src = src + "?" + Math.random();
  }
}

//-->

