// JavaScript Document
/**
*
* Funções para pesquisa, validação e ajax
* @autor Michael Mafort <mm@michaelmafort.com>
* @since 10/10/2007
*/
function validate(form){
		
	elem = form.elements;

	for( i = 0 ; i < elem.length ; i++ ){
		
		if( ( !elem[i].disabled ) && ( elem[i].type != "checkbox" ) ){

			if( validateForm( form ) ){
		
				xajax_search( xajax.getFormValues("search_form") );
				
				return false;
				
			}
			
			return false
			
		}
				
	}
	
	return false;
	
}

function getDates( team2 ){
	team1 = document.search_form.team1_int.value;
	xajax_getDates( team1, team2 );
}

function checkInput(id){
	elem = document.getElementById('search_form').elements;
	
	for( i = 0 ; i < elem.length ; i++ ){
		
		if( elem[i].type == "checkbox" ){
			
			elem[i].style.volume = i;
			elem[i].onclick = function(){

				if( this.checked ){

					for( x = 0 ; x < elem.length ; x++ ){
						
						if( elem[x].name.substring( 0, elem[x].id.length-4) == this.id.substr( 0 , this.id.length-4 ) ){
						
							elem[x].disabled = false;
							elem[x].focus();
							document.getElementById('submit').disabled = false;
							
						}
						
					}
					
				}else{

					for( x = 0 ; x < elem.length ; x++ ){
						
						if( elem[x].name.substring( 0, elem[x].id.length-4) == this.id.substr( 0 , this.id.length-4 ) ){
						
							elem[x].disabled = true;
							
							if( this.id.substr( 0 , this.id.length-4 ) == "team" ){
								
								document.getElementById('dates').innerHTML = "";
								
								var date_dat = document.createElement('input');
								date_dat.setAttribute('name','date_dat');
								date_dat.setAttribute('id','date_dat');
								date_dat.setAttribute('title','Data');
								date_dat.disabled = !document.getElementById('date_cbx').checked;

								document.getElementById('dates').appendChild( date_dat );// = '<input type="text" name="date_dat" id="date_dat" title="date" '+( !document.getElementById('date_cbx').checked ? 'disabled="disabled"' : '' )+' />';

							}
							
						}
						
					}
					
				}
			}
		}
	}
}


function dateOpen(){
	
	  document.getElementById('date_dat').disabled = !document.getElementById('date_cbx').checked;
	
}

function order( status ){
	
	if( status == 1 ){	
		document.getElementById('order').style.display = 'none';
		document.getElementById('paragraph').style.display = '';
	}else{
		document.getElementById('order').style.display = '';
		document.getElementById('paragraph').style.display = 'none';
	}

}

function searchPage( page ){
	
	xajax_search( 'pagination',null, page );
	
}