function openWin(image,title)
{
	aWindow=window.open("img_large.php?img="+image+"&title="+title,"","toolbar=no,width=400,height=400,status=no,scrollbars=no,resize=no,menubars=no");
	aWindow.focus();
}

function openWin2(url,w,h)
{
	aWindow=window.open(url,"","toolbar=no,width="+w+",height="+h+",status=no,scrollbars=no,resize=no,menubars=no");
	aWindow.focus();
}
function openWin3(url,w,h,title)
{
	aWindow=window.open(url,title,"toolbar=no,width="+w+",height="+h+",status=no,scrollbars=yes,resize=no,menubars=no");
	aWindow.focus();
}


function openLargeImage(url)
{
	aWindow=window.open(url,"","toolbar=no,width=400,height=400,status=no,scrollbars=no,resize=no,menubars=no");
	aWindow.focus();
}

function openBookmark(aURL)
{
	aWindow=window.open(aURL,"","toolbar=no,width=400,height=100,status=no,scrollbars=no,resize=no,menubars=no");
	aWindow.focus();
}
function openVideo(aURL)
{
	aWindow=window.open(aURL,"","toolbar=no,width=400,height=400,status=no,scrollbars=no,resize=no,menubars=no");
	aWindow.focus();
}
function openMatchUs(aURL)
{
	aWindow=window.open(aURL,"","toolbar=no,width=400,height=200,status=no,scrollbars=no,resize=no,menubars=no");
	aWindow.focus();
}
function submitFormTA() 
{
	updateRTE('ta');
	return true;
}
function setImage(string) 
{
	document.getElementById('previewImage').src = 'File:\/\/' + string;
}

function checkSelectedOption(value,form,warning)
{
	if( value != -1 )
	{
		form.catid.value = value;
		form.submit();
	}
	else
	{
		alert(warning);
	}
}
function previewImage(string)
{		
	document.getElementById('previewImage').src = 'File:\/\/' + string;	
}
function previewImageServer(string)
{		
	if (string=="")
		document.getElementById('previewImage').src = "../catimages/blank.gif";	
	else
		document.getElementById('previewImage').src = "../catimages/" + string;	
}
isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

function switchDiv(strDivName,bolVisible){

 //identify the element based on browser type
 if (isNS4) {
   objElement = document.layers[strDivName];
 } else if (isIE4) {
   objElement = document.all[strDivName];
 } else if (isIE5 || isNS6) {
   objElement = document.getElementById(strDivName);
 }
 
 if(isNS4){
     if(!bolVisible) {
       objElement.visibility ="hidden"
     } else {
       objElement.visibility ="visible"
     }     
 }else{
     if(!bolVisible) {
       objElement.style.visibility = "hidden";
     } else {
       objElement.style.visibility = "visible";
     }
 }
}


function removeall(checkboxId)
{
  
	var the_box = eval("window.document.itemForm." + checkboxId);
	for (var i=0;i<the_box.length;i++) 
	{
		the_box[i].checked=false;
  	}
  	the_box[0].checked=true;
}

function resetfirst(checkboxId)
{
  	var the_box = eval("window.document.itemForm." + checkboxId);
  	the_box[0].checked=false;
}

function collapse_all (n_index, n_depth) {
	var o_tree = TREES[n_index ? n_index : 0];
	if (!n_depth) n_depth = 1;
	if (!o_tree)
		alert("Tree is not initialized yet");
	var a_nodes = o_tree.a_nodes;
	for (var i = a_nodes.length - 1; i >= 0; i--)
		if (a_nodes[i].n_depth >= n_depth && a_nodes[i].open)
			a_nodes[i].open(1, 1);
	o_tree.ndom_refresh();
}
function expand_all (n_index, n_depth) {
	var o_tree = TREES[n_index ? n_index : 0];
	if (!o_tree)
		alert("Tree is not initialized yet");
	var a_nodes = o_tree.a_nodes;
	for (var i = 0; i< a_nodes.length; i++)
		if (n_depth == null || a_nodes[i].n_depth <= n_depth)
			a_nodes[i].open(0, 1);
	o_tree.ndom_refresh();
}

//---------------------------------------------- [FLASH]----------------------------------//
if(Browser == undefined){
   var Browser = {
      isIE: function(){ return (window.ActiveXObject && document.all && navigator.userAgent.toLowerCase().indexOf("msie") > -1  && navigator.userAgent.toLowerCase().indexOf("opera") == -1) ? true : false; }
   }
}
var Flash = function(movie, id, width, height, initParams){
   this.html = "";
   this.attributes = this.params = this.variables = null;
   this.variables = new Array();
   this.attributes = {
      "classid": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
      "codebase": "http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=8,0,22,0",
      "type": "application/x-shockwave-flash"
   }
   this.params = { "pluginurl": "http://www.macromedia.com/go/getflashplayer_br" };
   if(movie) {
      this.addAttribute("data", movie);
      this.addParameter("movie", movie);
   }
   if(id && id != null) this.addAttribute("id", id);
   if(width) this.addAttribute("width", width);
   if(height) this.addAttribute("height", height);
   if(initParams != undefined){
      for(var i in initParams){
         this.addParameter(i.toString(), initParams[i]);
      }
   }
}
Flash.version = "1.2b";
Flash.getObjectByExceptions = function(obj, excep){
   var tempObj = {};
   for(var i in obj){
      var inclui = true;
      for(var j=0; j<excep.length; j++)
         if(excep[j] == i.toString()) { inclui = false; break; };
      if(inclui) tempObj[i] = obj[i];
   }
   return tempObj;
}
Flash.prototype.addAttribute = function(prop, val){ this.attributes[prop] = val; }
Flash.prototype.addParameter = function(prop, val){ this.params[prop] = val; }
Flash.prototype.addVariable = function(prop, val){ this.variables.push([prop, val]); }
Flash.prototype.getFlashVars = function(){
   var tempString = new Array();
   for(var i=0; i<this.variables.length; i++)
      tempString.push(this.variables[i].join("="));
   return tempString.join("&");
}
Flash.prototype.toString = function(){
   this.params.flashVars = this.getFlashVars();
   if(Browser.isIE()){
      //IE
      this.html = "<object";
      var attr = Flash.getObjectByExceptions(this.attributes, ["type", "data"]);
      for(var i in attr) if(i.toString() != "extend") this.html += " " + i.toString() + " = \"" + attr[i] + "\"";
      this.html += "> ";
      var params = Flash.getObjectByExceptions(this.params, ["pluginurl", "extend"]);
      for(var i in params) if(i.toString() != "extend") this.html += "<param name=\"" + i.toString() + "\" value=\"" + params[i] + "\" /> ";
      this.html += " </object>";
   }
   else{
      //non-IE
      this.html = "<object";
      var attr = Flash.getObjectByExceptions(this.attributes, ["classid", "codebase"]);
      for(var i in attr) if(i.toString() != "extend") this.html += " " + i.toString() + " = \"" + attr[i] + "\"";
      this.html += "> ";
      var params = Flash.getObjectByExceptions(this.params, ["extend"]);
      for(var i in params) if(i.toString() != "extend") this.html += "<param name=\"" + i.toString() + "\" value=\"" + params[i] + "\" /> ";
      this.html += " </object>";
   }
   return this.html;
}
Flash.prototype.write = Flash.prototype.outIn = Flash.prototype.writeIn = function(w){
   if(typeof w == "string" && document.getElementById) var w = document.getElementById(w);
   if( w != undefined && w ) w.innerHTML = this.toString();
   else document.write( this.toString() );
}
//------------------------------------------------------------[/FLASH]------------------------------------------------------------------------------------//
function criaXMLHttp() {
	if (typeof XMLHttpRequest != "undefined") 
		return new XMLHttpRequest();
	else if (typeof ActiveXObject != "undefined") { // suporte ao IE 7
		var aVersoes = ["MSXML2.XMLHttp.6.0", "MSXML2.XMLHttp.5.0",
		"MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0",
		"MSXML2.XMLHttp", "Microsoft.XMLHttp"
		];
		for (var i = 0; i < aVersoes.length; i++){
			try{
				return new ActiveXObject(aVersoes[i]);
			}catch (e) {}
		}
	}
	// se nenhum objeto xmlhttp for suportado
	throw new Error("Seu browser nao suporta AJAX");
}
function extraiScript(texto){
    var ini = 0;
    while (ini!=-1){         
		ini = texto.indexOf('<script', ini);        
		if (ini >=0){             
			ini = texto.indexOf('>', ini) + 1;            
			var fim = texto.indexOf('</script>', ini);            
			codigo = texto.substring(ini,fim);             
            novo = document.createElement("script")
            novo.text = codigo;
            document.body.appendChild(novo);			
            //document.write(codigo);			
        }
    }	
}
//--------------------------------------------------------------------------------------
function enviaReqAtt(forumlario, exibe){
	var oForm = forumlario;
	var sBody = criaReqStrAtt(oForm);

	var oXMLHttp = criaXMLHttp();
	oXMLHttp.open("post", oForm.action, true);	
	oXMLHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	oXMLHttp.onreadystatechange = function (){		
		if(oXMLHttp.readyState != 4){
			exibeResultAtt("<p align=\"center\"><img src=\"images/preloader.gif\" align=\"absmiddle\"></p>", exibe);	
			bloqueia('envia');
		}
		if(oXMLHttp.readyState == 4){
			if (oXMLHttp.status == 200){
				exibeResultAtt(oXMLHttp.responseText, exibe);
				extraiScript(oXMLHttp.responseText);
				desbloqueia('envia');
			}
			if (oXMLHttp.status == 404){
					alert("404");
					desbloqueia('envia');
			}
		}
		/*else
			exibeResult("Ocorreu um erro: " + oXMLHttp.statusText);*/
	};	
	oXMLHttp.send(sBody);
}
function exibeResultAtt(sTxt, exibe){	
	document.getElementById(exibe).innerHTML = sTxt;
}
function criaReqStrAtt(oForm){
	var aPostStr = new Array();

	for(var i = 0; i < oForm.elements.length; i++){
		if (oForm.elements[i].type == "checkbox"){
			if(oForm.elements[i].checked == 1){
				var sValor = encodeURIComponent(oForm.elements[i].name);
				sValor += "=";
				sValor += encodeURIComponent(oForm.elements[i].value);
				aPostStr.push(sValor);
			}
			if(oForm.elements[i].checked == 0){
				var sValor = encodeURIComponent(oForm.elements[i].name);
				sValor += "=";
				sValor += encodeURIComponent("");
				aPostStr.push(sValor);
			}
		}
		else if (oForm.elements[i].type == "radio"){
			if(oForm.elements[i].checked == 1){
				var sValor = encodeURIComponent(oForm.elements[i].name);
				sValor += "=";
				sValor += encodeURIComponent(oForm.elements[i].value);
				aPostStr.push(sValor);
			}
		}
		else {
			var sValor = encodeURIComponent(oForm.elements[i].name);
			sValor += "=";
			sValor += encodeURIComponent(oForm.elements[i].value);
			aPostStr.push(sValor);
		}
	}	
	return aPostStr.join("&");
}
//
function bloqueia(obj){
	try{
		document.getElementById(obj).disabled = true;
	}
	catch(e){}
}
function desbloqueia(obj){
	try{
		document.getElementById(obj).disabled = false;
	}
	catch(e){}
}