startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace
					(" over", "");
				}
			}
		}
	}
}
window.onload=startList;

function setDisable( type ){

	if( type == 1 ){
	
		document.getElementById("image_str").disabled = "disabled";
		document.getElementById("title_str").disabled = false;
		document.getElementById("message_str").disabled = false;
		document.getElementById("author_str").disabled = false;
	
	}else{
	
		document.getElementById("title_str").disabled = "disabled";
		document.getElementById("message_str").disabled = "disabled";
		document.getElementById("author_str").disabled = "disabled";
		document.getElementById("image_str").disabled = false;
	
	}

}

function deleteFavorite( code ){
	if(confirm("Você deseja confirmar esta ação?"))			
		trator_removeFavorite( code );
}


function showImage( src ){

	document.getElementById('bigImage').src = src;

}

function getKey( e , index , page ){
	
	var pagina = index.toString() + page.toString();
	
	var tecla=(window.event)?event.keyCode:e.which;
	
	if( tecla == 13 ){

		document.location.href = pagina;		
	
	}

}

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
	else 
		countfield.value = maxlimit - field.value.length;
}

function eNum(e){
    var tecla=(window.event)?event.keyCode:e.which;
    if((tecla > 47 && tecla < 58)) return true;
    else{
    if (tecla != 8) return false;
    else return true;
    }
}

/**
	* Confirma a exclusão de determinado objeto
	* @Event OnSubmit
	* @since 04/10/2006
	* @author Jonathan Pereira <jonathan@5clicks.com.br>
	* @access public
	*/

function createConfirm( codType , cod ){
		
		switch (codType) {
			case 0:
				type = "um usuário";
				destiny = "index.php?session=listUsers"
				break
			case 1:
				type = "um artigo";
				destiny = "index.php?session=listArticles"
				break
			case 2:
				type = "uma notícia";
				destiny = "index.php?session=listNews"
				break
			case 3:
				type = "uma novidade";
				destiny = "index.php?session=listHighlights"
				break
			case 4:
				type = "uma enquete";
				destiny = "index.php?session=listPolls"
				break
			case 5:
				type = "uma gazeta";
				destiny = "index.php?session=listGazettes"
				break
		}
		
		if( confirm( "Você está prestes a excluir "+type+". Deseja confirmar esta ação?" ) ){
		
			location.href= destiny+"&drop=1&code="+cod ;
		
		}
		
	}	
		
	var lastObject;

	function changeColor() {
		if ( this.type == "text" || this.type == "textarea" || this.type == "password" || this.type == "file" || this.type == "select" ) {
			this.style.borderColor = '#999';			
			if ( ( lastObject.name != undefined ) && ( lastObject.name != this.name ) ) {
				lastObject.style.borderColor = '#D9D9D9';
			}
			lastObject = this;
		}
	}
	
	function callElementsInForm() {
		if ( document.forms.length != 0 )
			lastObject = document.forms[ 0 ].elements[ 0 ];
		f = document.forms;
		
		for ( var i = 0; i < f.length; i++ ) {
			for ( var j = 0; j < f[ i ].elements.length; j++ ) {
				f[ i ].elements[ j ].onfocus = changeColor;
			}
		}
	}
	
	function enableButton(id){
		
		obj = document.getElementById(id);
		
		obj.disabled = !(obj.disabled);
		
	}
	
	/**
	* Mascara para Data
	* @Event OnKeyUp
	* @since 06/10/2006
	* @access public
	*/

	function mask(str,textbox,loc,delim){
		
		var locs = loc.split(',');

		for (var i = 0; i <= locs.length; i++){
			for (var k = 0; k <= str.length; k++){
				if (k == locs[i]){
					if (str.substring(k, k+1) != delim){
						if (event.keyCode != 8)
						str = str.substring(0,k) + delim + str.substring(k,str.length);
					}
				}
			}
		}
		
		document.getElementById(textbox.name).value = str;
	
	}
	
	/**
	* Controle de produtos alterados
	* @since 06/10/2006
	* @access public
	*/
	
	function addCheckBoxChanged( code ){

		exist = 0;
		
		arrCheckBox = document.getElementById("checkBoxChanged").value.split(",");
		
		for( x = 0 ; x < arrCheckBox.length ; x++ ){
			
			if( arrCheckBox[x] == code )
				exist = 1;
				
		}
		
		if( exist == 0 )
			document.getElementById("checkBoxChanged").value += code + ",";
		else{
		
			teste = "";
			
			arrCheckBox = document.getElementById("checkBoxChanged").value.split(",");
			
			for( x = 0 ; x < arrCheckBox.length - 1 ; x++ ){
				
				if( arrCheckBox[x] != code )
					teste += arrCheckBox[x] + ",";
					
			}
			
			document.getElementById("checkBoxChanged").value = teste;
		
		}
			

	}
	
	/**
	* Verifica se todos produtos selecionados estão com seus valores
	* @Event OnKeyUp
	* @since 06/10/2006
	* @access public
	*/
	
	function verifyProductsPrices(){
	
		error = 0;
		
		if( required('',document.offer,0) == true ){
	
		arrCheckBox = document.getElementById("checkBoxChanged").value.split(",");
		
		if( arrCheckBox.length > 1 ){
		
			for( x = 0 ; x < arrCheckBox.length - 1 ; x++ ){
				
				if( document.getElementById("priceProduct_"+arrCheckBox[x]).value == "" ){
					error = 1;
					x = arrCheckBox.length;
				}
			
			}
			
			if( error == 0 ){
			
				document.offer.submit();
				
			}else{
			
				alert("Coloque o valor de todos produtos selecionados para a oferta.");
				
			}
		
		}else{
		
			alert("Selecione ao menos um produto para inserir na oferta.");
			
		}
		
		}
		
	}
	
	
function limitTextarea( txtArea , limit )
{

    limite = limit;
    myTextArea = txtArea;
    myTextField = document.getElementById('cont_aux');

    if (myTextArea.value.length > limite) {
        myTextArea.value = myTextArea.value.substr(0, (myTextArea.value.length - 1));
    } else {
        myTextField.value=(limite - myTextArea.value.length);
    }
}

<!-- This script and many more are available free online at -->

<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Original:  Fred P -->

<!-- Begin

// Compare two options within a list by VALUES

function compareOptionValues(a, b) 

{ 

  // Radix 10: for numeric values

  // Radix 36: for alphanumeric values

  var sA = parseInt( a.value, 36 );  

  var sB = parseInt( b.value, 36 );  

  return sA - sB;

}



// Compare two options within a list by TEXT

function compareOptionText(a, b) 

{ 

  // Radix 10: for numeric values

  // Radix 36: for alphanumeric values

  var sA = parseInt( a.text, 36 );  

  var sB = parseInt( b.text, 36 );  

  return sA - sB;

}



// Dual list move function

function moveDualList( srcList, destList, moveAll ) 

{
  // Do nothing if nothing is selected

  if (  ( srcList.selectedIndex == -1 ) && ( moveAll == false )   )

  {

    return;

  }



  newDestList = new Array( destList.options.length );



  var len = 0;



  for( len = 0; len < destList.options.length; len++ ) 

  {

    if ( destList.options[ len ] != null )

    {

      newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected, destList.options[ len ].selected );

    }

  }



  for( var i = 0; i < srcList.options.length; i++ ) 

  { 

    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )

    {

       // Statements to perform if option is selected



       // Incorporate into new list

       newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );

       len++;

    }

  }



  // Sort out the new destination list

  newDestList.sort( compareOptionValues );   // BY VALUES

  //newDestList.sort( compareOptionText );   // BY TEXT



  // Populate the destination with the items from the new array

  for ( var j = 0; j < newDestList.length; j++ ) 

  {

    if ( newDestList[ j ] != null )

    {

      destList.options[ j ] = newDestList[ j ];

    }

  }



  // Erase source list selected elements

  for( var i = srcList.options.length - 1; i >= 0; i-- ) 

  { 

    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )

    {

       // Erase Source

       //srcList.options[i].value = "";

       //srcList.options[i].text  = "";

       srcList.options[i]       = null;

    }

  }



} // End of moveDualList()

//  End -->


function getSelectedMails( ){
	
	obj = document.getElementById("selectedMails");
	nameSelected = "e-mail";

	arrValues = "";

	for(var i=0;i<obj.options.length;i++){
		if(obj.options[i]){
			arrValues += "," + obj.options[i].value;
		}
	}
	
	if( arrValues == "" ){
		alert("Selecione ao menos um e-mail para enviar a newsletter.");
	}else{
		arrValues = arrValues.substr(1,arrValues.strlen)+",";
		document.getElementById("arrSelecteds").value = arrValues;
		document.newsLetter.submit();
	}
	
}

/**
* Gera um confirm para alteração de status
* @Event onClick
* @since 06/10/2006
* @access public
*/

function setStatusVehicle( action , codeMachine , admin ){

	if( confirm("Você deseja confirmar esta ação?") ){
		
		if( admin == 1 )
			location.href="index.php?session=listMachines&action="+action+"&codeMachine="+codeMachine;
		else
			location.href="listMachinesUsers.php?action="+action+"&codeMachine="+codeMachine;
	
	}
	
}

/**
*
* Verifica se um radio button de um radiogroup está selecionado
* 
* @since 13/06/2008
* @author Lucas Araujo Mezencio <lucas.mezencio@gmail.com>
*
* @event onclick
* 
**/

function valForm( AForm ){
  Inputs = document.getElementsByTagName( "input" );
  
  for( i = 0 ; i < Inputs.length ; i++ )
    if( Inputs[i].name == "option" )
      if( Inputs[i].checked ) 
        return true;
  alert( 'Selecione uma opção.' );
  return false;
}

/**
* Idiot function that create a simple pop-up
*
* @since 13/06/2008
* @author Lucas Araújo Mezêncio <lucas.mezencio@gmail.com
* 
* @event onclick 
*
**/

function popUp(num, width, height){
  window.open('resultPollSite.php?codePoll='+num, '_blank', "width="+width+", height="+height)
}

function getValue(opt){
  document.getElementById('opt').value = opt;
}

/**
*
* @since 09/06/2008
* @author Lucas Araújo Mezêncio <lucas.mezencio@gmail.com>
* @access public
*
**/

function teste(sel){
  if(sel.value == 3){
    document.getElementById("photo").disabled = true;
  }else{
    document.getElementById("photo").disabled = false;
  }
  
  /*if(sel.value == 2){
    document.getElementById("title_str").setAttribute('maxlength', 50)
    document.getElementById("tam").value = 50;
  }else{
    document.getElementById("title_str").setAttribute('maxlength', 40)
    document.getElementById("tam").value = 40;
  }*/
}