//Funções que criam e destroem banner, e função do combobox da página de Afixação
var rec;
var userAgentStr = navigator.userAgent.toLowerCase();
var isIE = ((userAgentStr.indexOf("msie") != -1) && (userAgentStr.indexOf("opera") == -1) && (userAgentStr.indexOf("webtv") == -1))? true:false;

var win= null;
function NewWindow(mypage,myname,w,h,scroll){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings ='height='+h+',';
  settings +='width='+w+',';
  settings +='top='+wint+',';
  settings +='left='+winl+',';
  settings +='scrollbars='+scroll+',';
  settings +='resizable=yes';
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
} 

function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}




// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + 
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}


function enviarform(ordem)
{
   window.document.forms[ordem].submit();
}


function mostraAguarde(){
	
	var oBgDiv = document.getElementById("appDlgBgSep");
	//oBgDiv.className = "dlgBgSep";
	oBgDiv.style.display = "block";
	oBgDiv.style.visibility='visible';
	
	//SetSize(oBgDiv, parseInt(document.body.clientWidth), parseInt(document.body.clientHeight), "px");
	//if (!isIE)	SetSize(oBgDiv, parseInt(document.body.clientWidth), parseInt(document.body.clientHeight), "px");
	var oDiv = document.getElementById("appLoadingDlgDiv");
	//setLocation(oDiv, (document.body.offsetWidth - oDiv.offsetWidth) / 2, 150, 'px');
	oDiv.style.display = "block";
	oDiv.style.visibility='visible';
}

function escondeAguarde(){

 	var oBgDiv = document.getElementById("appDlgBgSep");
	//oBgDiv.className = "dlgHidden";
	oBgDiv.style.visibility='hidden';
	oBgDiv.style.display = "none"
	//SetSize(oBgDiv, parseInt(document.body.clientWidth), parseInt(document.body.clientHeight), "px");
	//if (!isIE)	SetSize(oBgDiv, parseInt(document.body.clientWidth), parseInt(document.body.clientHeight), "px");
	var oDiv = document.getElementById("appLoadingDlgDiv");
	//SetLocation(oDiv, -1000, -1000, 'px');
	oDiv.style.visibility='hidden';
	oDiv.style.display = "none"
}

function SetSize(element, dx, dy, unit){
	if (element.style) element = element.style;
	if (dx >= 0) element.width = dx + unit;
	if (dy >= 0) element.height = dy + unit;
}

function SetLocation(element, x, y, unit){
	if (element.style) element = element.style;
	element.position = "absolute";
	element.zIndex = 1000;
	element.left = x + unit;
	element.top = y + unit;
}

function formSubmit(form, action)
{
	var f = getForm();
	f.action=action;
	f.submit();
}

function getForm()
{
	var b = new Browser();

	if (b.isNetscape())
	{
		return document.form;
	}
	else
	{
		return document.form;
	}
}

function abreLink(url)
{
	window.open(url,"novaJanela","status=yes,scrollbars=yes,toolbar=yes,location=1,directories=0,menubar=yes,resizable=yes");
}


/*
showProps(parent.cabecalho);
*/

function showProps(obj)
{
	var result= "", janela;
	janela=window.open("",janela,"status=no,scrollbars=yes,toolbar=yes,location=0,directories=0,menubar=yes,resizable=1,width=450,height=400");
	janela.document.writeln("<PRE>");
	janela.document.writeln("<b>PROPRIEDADES DO OBJETO</B>\n\n");
	for( var i in obj)
		result += i + " = " + obj[i] + "\n"
	janela.document.writeln(result)
	janela.document.writeln("</PRE>");
	return result
}

function submeter(order)
{
	mostraAguarde();
	window.document.forms(order).submit();
//	if( form.query.value == '') {
//		escondeAguarde();
//		alert('Você deve preencher a pesquisa!');
//	}
//	else {
//		form.submit();
//	}
}	


function MarcarTodos(form,name)
{
   for(var i = 0; i < form.length; i++)  
   {
       if(form[i].name==name)
       {
	  form[i].checked = true;  
        }
    }
}

function DesMarcarTodos(form,name)
{
   for(var i = 0; i < form.length; i++)  
   {
       if(form[i].name==name)
       {
	  form[i].checked = false;  
        }
    }
}

