// JavaScript Document
// exibe o erro na página em um alert
function error(msg, url, line){
	//return true;
	alert(
		"Erro na página \n\n"	+
		"Error:	" + msg + "\n"	+
		"URL:	" + url + "\n"	+
		"Line:	" + line
	);
}
window.onerror = error;


jQuery(document).ready(function($){

$('input[type=text]').bind('focus', function(){
    valor_ = $(this).val();            
    if(valor_ == "Busca:" ){
        this.ref = valor_;        
      $(this).attr('value','');
    }
});
$('input[type=text]').bind('blur', function() {
    if($(this).val() == '')  
        $(this).attr('value', this.ref);
});

});

// ########################################################################################
		function show(field){
			if (field.nodeName == "#text") field = field.nextSibling;
			
			if (field.nodeType != 1) var target = document.getElementById(field);
			else target = field;
			if (target){
				target.style.display = "block";
			}
		}
// ########################################################################################
		function hide(field){
			if (field.nodeName == "#text") field = field.nextSibling;
			
			if (field.nodeType != 1) var target = document.getElementById(field);
			else target = field;
			if (target){
				target.style.display = "none";
			}
		}
// ########################################################################################
		function show_mn(bt, mn){
			var target_bt = document.getElementById(bt).childNodes[0].firstChild;
			var target_mn = document.getElementById(mn);
			if(target_bt)	target_bt.style.backgroundPosition = "0 -14px";
			if(target_mn)	target_mn.style.display = "block";
		}
// ########################################################################################
		function hide_mn(bt, mn){
			var target_bt = document.getElementById(bt).childNodes[0].firstChild;
			var target_mn = document.getElementById(mn);
			if(target_bt)	target_bt.style.backgroundPosition = "0 0";
			if(target_mn)	target_mn.style.display = "none";
		}
// ########################################################################################
function showHide(field, modeIni){
	if (field.nodeName == "#text") field = field.nextSibling;
	
	if (field.nodeType != 1) var target = document.getElementById(field);
	else target = field;
	if (target){
		if (!target.style.display) target.style.display = modeIni;
		else if (target.style.display == "none") target.style.display = "block";
		else									 target.style.display = "none";
	}
}
// ########################################################################################
//atacha o flash em uma div
//                   1obr 2obr   3obr    4opc	 5opc	6opc   7opc   	8opc
function attachFlash(url, width, height, target, wmode, scale, quality, vars){
	var content; identity = url.split("."); identity = identity[0]; 
	if(!target) { document.write("<div id=\"id_"+ identity +"\"></div>"); target = "id_"+ identity;}
	if(!quality)quality	= "best";
	target = document.getElementById(target);
	content =  "<object id=\"" + identity + "\" width=\"" + width + "\" height=\"" + height + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\">";
    content += "<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
	content +=  "<param name=\"movie\" value=\"" + url + "?" + vars +"\">";
    content +=  "<param name=\"quality\" value=\"" + quality + "\">";
	content +=  "<param name=\"wmode\" value=\"" + wmode + "\" /> ";
	content +=  "<param name=\"bgcolor\" value=\"#F2B775\" /> ";
    content +=  "<embed name=\"" + identity + "\" src=\"" + url + "?" + vars +"\"  width=\"" + width + "\" height=\"" + height + "\" wmode=\"" + wmode + "\" scale=\"" + scale + "\" quality=\"" + quality + "\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed>";
	content +=  "</object>";
	target.innerHTML = content;
}
// ########################################################################################
//manda uma variavel no flash
function talkFlash(fla, func, arguments){
	if(window[fla])		window.document[fla].SetVariable("_root.func", func);
	if(document[fla])	document[fla].SetVariable("_root.func", func);
	
	if(window[fla]) 	window.document[fla].SetVariable(arguments, arguments);
	if(document[fla])	document[fla].SetVariable(arguments, arguments);
	
	if(window[fla])		window.document[fla].SetVariable("_root.flag", arguments);
	if(document[fla])	document[fla].SetVariable("_root.flag", arguments);
}
// ########################################################################################
	function formatField(e, field, format){
		var keyCode = e.charCode? e.charCode : e.keyCode;
		var keyChar = String.fromCharCode(keyCode);
		var noKey = [8, 9, 13, 37, 38, 39, 40, 46, 116];
		
		var string 	= field.value + keyChar;
		var char	= format.substring(string.length-1, string.length);
		var simb 	= format.substring(string.length, string.length+1);

		if( char && !searchInArray(noKey, keyCode) ){
			if(char == "n" && nNumbers(keyChar, 1, 0)) field.value += keyChar;
			if(char == "t" && nLetters(keyChar, 1, 0)) field.value += keyChar;
			if(char == "f") field.value += keyChar;
			
			if(field.value==string && simb != "n" && simb != "t" && simb != "f"){
				field.value += simb;
			}
		}
	}
/*
_root.watch("flag", function() { 
    eval(this.func)(); 
}); 
*/