function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function fillLayer(objName,newText) { 
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function newComent () {
	var selected = comentarios[Math.floor(Math.random()*comentarios.length)];
	 /*COMPLETO*/ fillLayer("comentarios","<p class='comentarios'><span class='comentarios_texto'>«"+selected[0]+"»</span><br>"+selected[1]+"<br><span class='comentarios_id'>in "+selected[2]+"</span></p>");
	///*ABREVIADO*/ fillLayer("comentarios","<p class='comentarios'><span class='comentarios_texto'>«"+selected[0]+"»</span><br>"+selected[1]+"</p>");
}

function flash_DoFSCommand(command, args) {
	if (args) {
		eval(command+"('"+args+"')");
	} else {
		eval(command+"()");
	}
}

function getDepth(obj){
	var param = self.location.href.indexOf("?");
	if (param){
//		obj.SetVariable("innerpage", 1);
	}
}

function whatVideo() {
	var videoName = self.location.href.substr(self.location.href.indexOf("?")+1);
	obj = MM_findObj('tv');
 	obj.SetVariable("videoPath", "/videos/"+videoName+".flv");
}

function newPage(args) {
	var nextFile = args.split(",")[0];
	var lang = args.split(",")[1];
	if (!lang) lang = "pt";
	var thisFile = findThisFileName ();
	if ((nextFile == thisFile) && (self.location.href.indexOf(lang)>0)) return;
	//if (nextFile.indexOf(".pdf") >0) window.open(nextFile);
	else self.location.href="/htmls/"+nextFile+"?inpg";
}

if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
  document.write('<SCRIPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('Sub menu_FSCommand(ByVal command, ByVal args)\n');
  document.write(' call flash_DoFSCommand(command, args)\n');
  document.write('end sub\n');
  document.write('Sub tv_FSCommand(ByVal command, ByVal args)\n');
  document.write(' call flash_DoFSCommand(command, args)\n');
  document.write('end sub\n');
  document.write('</SCRIPT\> \n');
} 

function findThisFileName () {
	var thisFile = self.location.href.substr(self.location.href.lastIndexOf("/")+1);
	if (thisFile.indexOf("?") >= 0){
		thisFile = thisFile.substr(0,thisFile.indexOf("?"));
	}
	return thisFile;
}

////////////////////////////////////////////////////////////

var fotoWindow;
function popImg(filename) {
	if (fotoWindow){
		fotoWindow.close();
	}
	fotoWindow=window.open("", "fotoWindow", "height=150,width=150,resize=yes,scrollbars=yes,status=yes");
	fotoWindow.document.write("<HTML>");
	fotoWindow.document.write("<HEAD>");
	fotoWindow.document.write("<SCRIPT LANGUAGE=\"JavaScript\">function resizeMe(picRef) {	MM_showHideLayers('tempLayer','','hide'); 		if (window.screen){ 		var Wlimit = screen.width-70; 		var Hlimit = screen.height-80; 	} 	var picW = picRef.width+45; 	var picH = picRef.height+110; 	var targetW = (Wlimit) ? (picW > Wlimit) ? Wlimit : picW : picW; 	var targetH = (Hlimit) ? (picH > Hlimit) ? Hlimit : picH : picH; 	window.resizeTo(targetW,targetH); 	var window_left = (window.screen.width/2) - ((targetW/2) + 5); 	var window_top = (window.screen.height/2) - ((targetH/2) + 22); 	window.moveTo(window_left,window_top);}</SCRIPT>");
	fotoWindow.document.write('<script language="JavaScript" type="text/JavaScript">function MM_reloadPage(init) {  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();}MM_reloadPage(true);function MM_findObj(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=MM_findObj(n,d.layers[i].document);if(!x && d.getElementById) x=d.getElementById(n); return x;}function MM_showHideLayers() { var i,p,v,obj,args=MM_showHideLayers.arguments;for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];if (obj.style) { obj=obj.style; v=(v==\'show\')?\'visible\':(v==\'hide\')?\'hidden\':v; }obj.visibility=v; }}</script>');
	fotoWindow.document.write("<TITLE>Imagem</TITLE>");
	fotoWindow.document.write("<HEAD>");
	fotoWindow.document.write("<BO"+"DY bgcolor=#ffffff leftmargin=10 topmargin=10 marginwidth=10 marginheight=10>");
	fotoWindow.document.write('<div id="tempLayer" style="position:absolute; left:0; top:0; width:130; height:130; z-index:10; background-color: #ffffff; layer-background-color: #ffffff; border: 1px none #000000; visibility: visible; overflow: visible;"><table width="130" height="130"  border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle"><b><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Por favor aguarde.</font></b></td></tr></table></div>');
	fotoWindow.document.write("<A href=javascript:self.close()>");
	fotoWindow.document.write("<IMG name=foto id=foto src="+filename+" onLoad=resizeMe(this) border=0 alt=\"clique para fechar esta imagem\"></a>");
	fotoWindow.document.write("</HTML>");
}

var infoWindow;
function popinfo(file,w,h) {
	if (infoWindow){
		infoWindow.close();
	}
	infoWindow=window.open(file, "infoWindow", "height="+h+",width="+w+",resize=yes,scrollbars=yes,status=yes");
}

/////////////////////////////////////////////////////////////

function closeVideo () {
	MM_showHideLayers('handicaps','','show','tv','','show','slideshow','','show','overallVideo','','hide');
}
function openVideo () {
	MM_showHideLayers('handicaps','','hide','tv','','hide','slideshow','','hide','overallVideo','','show');
}
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

	function MM_validateForm() { //v4.0
	  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
		if (val) { nm=val.name; if ((val=val.value)!="") {
		  if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
			if (p<1 || p==(val.length-1)) errors+='. '+nm+': Tem que conter um endereço de e-mail válido.\n';
		  } else if (test!='R') { num = parseFloat(val);
			if (isNaN(val)) errors+='. '+nm+': O número não é valido.\n';
			if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
			  min=test.substring(8,p); max=test.substring(p+1);
			  if (num<min || max<num) errors+='. '+nm+' Tem que ser um número entre '+min+' e '+max+'.\n';
		} } } else if (test.charAt(0) == 'R') errors += '. '+nm+': É necessário.\n'; }
	  } 
	//  updateValue();
	  if (errors) alert('Os seguintes campos têm erros:\n'+errors);
	  document.MM_returnValue = (errors == '');
	}
