function enq(id,tipo){
	switch(tipo){
		case 1:
			opcaoS = null;
			opcaoL = document.enqueteForm.opcao.length;
			for(var i=0; i<opcaoL;i++){
				if(document.enqueteForm.opcao[i].checked) opcaoS = i + 1;
			}
			if(opcaoS==null||opcaoS=="") {
				alert("É necessário a escolha de uma opção!");
				return;
			} else {
				document.enqueteForm.id_enq.value = id;
				document.enqueteForm.enquete.value = "voto";
				document.enqueteForm.submit();
			}
		break;
		case 2:
			document.enqueteForm.id_enq.value = id;
			document.enqueteForm.enquete.value = "resultado";
			document.enqueteForm.submit();
		break;
	}
}
function abreMural(){
	var w = 468, h = 400;
	muralWin = window.open("ng.mural.php","bw","top=25,left=25,scrollbars=yes,width="+w+",height="+h);
	if(muralWin==null) {alert("Talvez o seu bloqueador de Pop-Ups esteja ativado, para visualizar o mural será necessário desativa-lo.")                        ; return}
	muralWin.moveTo((screen.width-w)/2,(screen.height-h)/2);
	muralWin.focus();
//--><br>
}
//Function to create an XMLHttp Object.
	function getxmlhttp (){
		//Create a boolean variable to check for a valid microsoft active X instance.
		var xmlhttp = false;
		
		//Check if we are using internet explorer.
		try {
			//If the javascript version is greater than 5.
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			//If not, then use the older active x object.
			try {
				//If we are using internet explorer.
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				//Else we must be using a non-internet explorer browser.
				xmlhttp = false;
			}
		}
		
		//If we are using a non-internet explorer browser, create a javascript instance of the object.
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		
		return xmlhttp;
	}
	
	//Function to process an XMLHttpRequest.
	function processajax (serverPage, obj, getOrPost, str){
		
	//	obj.innerHTML = '<center><img src="images/loading.gif"></center>';
		//Get an XMLHttpRequest object for use.		
		xmlhttp = getxmlhttp ();
		if (getOrPost == "get"){
			xmlhttp.open("GET", serverPage);
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					obj.innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(null);
		} else {
			xmlhttp.open("POST", serverPage, true);
			xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					obj.innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(str);
		}
	}


//Functions to submit a form.
	function getformvalues (fobj){
		
		var str="";
		
		
		//Run through a list of all objects contained within the form.
		for(var i = 0; i < fobj.elements.length; i++){
			if (fobj.elements[i].type == "checkbox")
			{
				str += fobj.elements[i].name + "=" + escape(fobj.elements[i].checked) + "&";	
				
			}else{
			str += fobj.elements[i].name + "=" + escape(fobj.elements[i].value) + "&";
			}
		}
		//Then return the string values.
		return str;
	}
	
	function submitform (theform, serverPage, objID){
		var file = serverPage;
		var str = getformvalues(theform);
		
		obj = document.getElementById(objID);
	
		processajax (serverPage, obj, "post", str);
	
	}
	
function setTabClasses(id,numtabs)
{
	 switch(id){
		 case 1:  document.getElementById('1').className='tab-active';
		          for( i=1; i<=numtabs ; i++){
					 if (i!=id) 
				     document.getElementById(i).className='tab';
				  
				  }
				  break;
		 case 2:  document.getElementById('2').className='tab-active';
				   for( i=1; i<=numtabs ; i++){
					 if (i!=id) 
				     document.getElementById(i).className='tab';
				  
				  }
				  break;
		 case 3:  document.getElementById('3').className='tab-active';
				   for( i=1; i<=numtabs ; i++){
					 if (i!=id) 
				     document.getElementById(i).className='tab';
				  
				  }
				  break;
				  
	 }
}	


var refreshrate = 5000; // Delay im miliseconds before refreching the gallery


// fucntion to show a "loading" message
function updateStatus()
{

	document.getElementById("tabmain").innerHTML = "<b>Carregando...</b>";
}


function refreshView(page,elem)
{
	// reload the full-size image.	
    var _function = 'processajax ("'+page+'", document.getElementById("'+elem+'"), "get")';
	
	setTimeout ( _function , refreshrate);
	

	
}

function mainflashplayer(vidname){
	var fo = new SWFObject("/flowplayer/FlowPlayer.swf", "FlowPlayer", "400", "300","9", "#ffffff", true);
  									fo.addParam("AllowScriptAccess", "always");
	  								fo.addParam("allowFullScreen", "true");
	  								fo.addVariable("config", "{playList: [ { url: '/vids_data/main_vid/"+vidname+"'} ], showPlayListButtons: false,autoPlay:true, showMenu: false,showFullScreenButton: false, initialScale: 'fit', loop: false, startingBufferLength: 1, initialScale: 'orig',useNativeFullScreen: true }");  
	 								fo.write("video");	
}


function flashplayer(div,path,id,vidname,place){
	if (place == "section")
			obj = document.getElementById("comment"+id);		
	if (place == "user")
			obj = document.getElementById("comment");		
	var serverpage = "php/get_vidcoment.php?"+place+"&id="+id+"&vidname="+vidname;
	processajax (serverpage , obj , "get" , "");	
 	var fo = new SWFObject("/flowplayer/FlowPlayer.swf", "FlowPlayer", "320", "262","9", "#ffffff", true);
 	fo.addParam("AllowScriptAccess", "always");
	fo.addParam("allowFullScreen", "true");
	fo.addVariable("config", "{playList: [ { url: '"+path+"'} ], showPlayListButtons: false,autoPlay:true, menuItems: [ true, true, false, false, false, true ], initialScale: 'fit', loop: false, startingBufferLength: 1, initialScale: 'orig',useNativeFullScreen: true }");  
	fo.write(div);
							// ]]>
}
function carregavideo(id,filename,placeID, secao){
	
	var obj = document.getElementById(placeID);
	
	var serverPage;
	
	obj.innerHTML = '<img src="/images/loading.gif">';
	
	if (secao == "atletas")
	 	serverPage = 'video_loader.php?atletas&id='+id+'&filename='+filename;
	if (secao == "videos")
	 	serverPage = 'video_loader.php?videos&id='+id+'&filename='+filename;	
		
		
    processajax (serverPage, obj, 'get', '');
}


function generateComentBox(elemId)
{
	var html;
	
	html = '<textarea name="coment" cols="30" rows="3" scroll="no"></textarea><br/><div align="center">';
	
	html += '<a href="javascript: closeDiv(' + "'" + elemId + "'" + ');"><font size="1">fechar[x]</font></a></div>';
	return html;
		
	
}

function openDiv(elem)
{
    html = generateComentBox(elem);
	document.getElementById(elem).innerHTML = html;	
}

function closeDiv(elem)
{
	document.getElementById(elem).innerHTML = ' ';

}



	function AbrePaginah(Foto)   {window.open(Foto,"","resizable=no,toolbar=no,status=no,menubar=no,scrollbars=no,width=630,height=600,top=20,left=20")}

	function AbrePaginaV(Foto,width,height)   {window.open(Foto,"","resizable=no,toolbar=no,status=no,menubar=no,scrollbars=no,width="+width+",height="+height+",top=20,left=20")}
	

	
	function openLoginDiv(){
		
		var html =   '<form action="login.php" method="POST">Email:<input name="email" type="text" tabindex="1" value="" maxlength="40" size="24">Senha:<input name="pass" type="password" tabindex="2" maxlength="40" size="24"><input type="submit" name="submit" tabindex="3" value="Login"><a href="javascript: closeLoginDiv()"><font size="1" color="#FFFFFF">fechar[X]</font></a></form>';


		document.getElementById('logindiv').innerHTML = html;

		}
		
	function closeLoginDiv(){
		document.getElementById('logindiv').innerHTML = '';
		}
		
		
		
function add_update_link(page,place,id){

var onclick = "atualizaView('"+page+"','"+id+"')";
document.getElementById(place).innerHTML= '<a href="javascript:' + onclick + '">Atualiza View</a>';


}

function atualizaView(page,id){
	processajax(page,document.getElementById(id),"get", "");
}

var indice_masc = 0;
var indice_fem = 0;
var indice_aces = 0;

function add_item(tipo){
	
var id;

if (tipo == 'masc'){
	id = 'new_item_'+tipo+indice_masc;
	indice_masc++;
	document.getElementById(id).innerHTML = 'nome: <input type="text" name="item_masc'+indice_masc+'" /><br/><div id="new_item_'+tipo+indice_masc+'"></div>';
	
	}

if (tipo == 'fem'){
	id = 'new_item_'+tipo+indice_fem;
	indice_fem++;
	document.getElementById(id).innerHTML = 'nome: <input type="text" name="item_fem'+indice_fem+'" /><br/><div id="new_item_'+tipo+indice_fem+'"></div>';

	}

if (tipo == 'aces'){
	id = 'new_item_'+tipo+indice_aces;
	indice_aces++;
	document.getElementById(id).innerHTML = 'nome: <input type="text" name="item_aces'+indice_aces+'" /><br/><div id="new_item_'+tipo+indice_aces+'"></div>';
	}



	
}