// JavaScript Document
//paramIN:	src:string - source do movie;
//			width:int - comprimento;
//			heigth:int - altura;
//			menu:string - permite ver menu (mousse right click)
//			wmode:string - permite transparent
//			version:string - versao do flash player
//			id:string - identificador do objecto do flash
//			protocolo:string - http ou https
//paramOUT: void
//summary: faz o render do objecto flash
function printFlash(src, width, height, menu, wmode, version, id, protocolo){
	document.write('<object id=\"'+id+'\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"' + protocolo + '://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + version + '\" width=\"' + width + '\" height=\"' + height + '\">');
	document.write('<param name=\"movie\" value=\"' + src + '\">');
	document.write('<param name=\"quality\" value=\"high\">');
	document.write('<param name=\"menu\" value=\"' + menu + '\">');
	document.write('<param name=\"scale\" value=\"noscale\">');
	document.write('<param name=\"salign\" value=\"t\">');	
	document.write('<param name=\"wmode\" value=\"' + wmode + '\">');
	document.write('<embed id=\"'+id+'\" src=\"' + src + '\" quality=\"high\" wmode=\"' + wmode + '\" menu=\"' + menu + '" pluginspage=\"' + protocolo + '://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"' + width + '\" height=\"' + height + '\" scale="noscale" salign="t" ></embed>');
	document.write('</object>');
}

var req;

function loadXMLDoc(url) {
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
        }
    }
}

function processReqChange() {
    // only if req shows "complete"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            // ...processing statements go here...
		  response = req.responseXML.documentElement;
		  //alert(req.responseText);
		  method = response.getElementsByTagName('method')[0].firstChild.data;
		  result = response.getElementsByTagName('result')[0];
		  eval(method + '(\'\', result)');
        } else {
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
        }
    }
}


function converteStringParaNumero(nr){
	
	var numeroPartido = nr.split(",");
	var inteiro = numeroPartido[0];
	var decimal = numeroPartido[1];
	var numeroFinal = 0;
	
	if(inteiro.length < 4){
		numeroFinal = inteiro+'.'+decimal;
	}else if(inteiro.length > 3){
		numeroPartido = inteiro.split(".");

		numeroFinal = (numeroPartido[0])+numeroPartido[1]+'.'+decimal;
	}
	
	return numeroFinal;
	//return parseInt(numeroFinal);

}


function converteNumeroParaString(nr){
	
	var numeroPartido = nr.split(".");
	var inteiro = numeroPartido[0];
	var decimal = numeroPartido[1];
	var numeroFinal = 0;

	if(inteiro.length < 4){
		if(decimal.length == 1){
			decimal = decimal+'0';
		}
	}else if(inteiro.length > 3){
		inteiro /= 1000;
		//inteiro = inteiro.toDecimals(3);
		inteiro = inteiro.toFixed(3);
		
		if(decimal.length == 1){
			decimal = decimal+'0';
		}
	}
	
	return inteiro+','+decimal;
}


function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}

/*
Number.prototype.toDecimals=function(n){
    n=(isNaN(n))?
        2:
        n;
    var
        nT=Math.pow(10,n);
    function pad(s){
            s=s||'.';
            return (s.length>n)?
                s:
                pad(s+'0');
    }
    return (isNaN(this))?
        this:
        (new String(
            Math.round(this*nT)/nT
        )).replace(/(\.\d*)?$/,pad);
}
*/