/*
function click() {
if (event.button==2) {
alert('For security reasons the right button function is disabled!');
}
}
function keypresed() {
alert('Proibido a Cópia');
}
//document.onkeydown=keypresed;
document.onmousedown=click;
*/

function b( bb )
{
  alert( bb );
}


//
// getO()
//
function getO( field_expr )
{
   var elem, endOfElem = field_expr.indexOf( '.' );

   endOfElem = ( endOfElem == -1 ? field_expr.indexOf( '[' ) : endOfElem );

   if ( endOfElem == -1 )
      elem = field_expr;
   else
      elem = field_expr.substr( 0, endOfElem );

   for ( var i = 0 ; i < document.forms.length ; i++ )
      if ( document.forms[ i ][ elem ] )
      {
         var v = document.forms[ i ][ elem ];
         break;
      } // if

//   alert( 'var v = ( typeof( ' + elem + ' ) == "undefined" ? null : ' + elem ' );' );
//   eval( 'var v = ' + elem + ';' );

   if ( v.length == 2 )
      eval( 'v = ' + elem + '[1]' + ( endOfElem == -1 ? '' : field_expr.substr( endOfElem ) ) + ';' );

   return v;
} // getO()



//
// bwChangePreviewImage()
//
function bwChangePreviewImage( img, target_img, max_width, max_height, doc )
{
   var i = new Image();

   i.src = img;

//   alert( i.size );

   if ( i && i.src )
   {
      orig_width = i.width;
      orig_height = i.height; 

//alert( orig_width + '.' + orig_height );
   
      if ( i.width > max_width )
      {
         i.height = max_width*i.height/i.width;
         i.width = max_width;
      } // if

      if ( i.height > max_height )
      {
         i.width = max_height*i.width/i.height;
         i.height = max_height;
      } // if
      
//    OLD CODE!!!!      
//      doc.bw_preview_image.src = img;
//      doc.bw_preview_image.width  = i.width;
//      doc.bw_preview_image.height = i.height;

//      doc.target_img.src = img;
//      doc.target_img.width  = i.width;
//      doc.target_img.height = i.height;



      eval( 'doc' + '.' + target_img + '_img' + '.src = img;' );
      eval( 'doc' + '.' + target_img + '_img' + '.width  = i.width;' );
      eval( 'doc' + '.' + target_img + '_img' + '.height = i.height;' );

      eval( 'doc' + '.' + target_img + '_width.value = orig_width;' );
      eval( 'doc' + '.' + target_img + '_height.value = orig_height;' );

//      doc.bwUploadForm.actionButton.value = 'Upload Image!';
//      bwCurrent_state = 1;
   } // if
   
} // bwChangePreviewImage()



function preview(thisImg,thisObj, max_width, max_height)
{
   var filenam = "";
   var nothing = "";
   filenam = "file:\/\/"+thisObj.value;


//   var i = new Image();
//   i.src = thisImg.src;

   
//   alert("a" + filenam);
    
   var fileExtension = filenam.substring(filenam.lastIndexOf(".")+1);
   
   if(fileExtension == "jpg" || fileExtension == "jpeg" || fileExtension == "gif" || fileExtension == "png" || 
      fileExtension == "JPG" || fileExtension == "JPEG" || fileExtension == "GIF" || fileExtension == "PNG")
   {   
      thisImg.src="file:\/\/"+thisObj.value; 
   }
   else
   { 
      alert ("Only jpg, jpeg, gif and png files are allowed."); 
   }
}



function preview2(Img,button,max_width, max_height)
{
   var filenam = "";
   var nothing = "";
   filenam = "file:\/\/"+ document.getElementById(button).value;

//   alert("a" + filenam);
    
   var fileExtension = filenam.substring(filenam.lastIndexOf(".")+1);
   
   if(fileExtension == "jpg" || fileExtension == "jpeg" | fileExtension == "gif" | fileExtension == "png")
   {   
      document.getElementById(Img).src = "file:\/\/"+ document.getElementById(button).value
//      thisImg.src="file:\/\/"+thisObj.value; 
   }
   else
   { 
      alert ("Only jpg, jpeg, gif and png files are allowed."); 
   }
}


function getRadioId(obj,value)
{
	for (i=0;i<obj.length;i++)
   {
		if (obj[i].value == value)
      {
			return i;
		}
	}
}


function ListCheckBoxClick()
{
alert(this.parentNode.parentNode.parentNode);

	var oTR = this.parentNode;


	if(this.checked)
	{
//alert(this.id);

		oTR.className = ' selected';
	}
	else
	{
alert(this.nodeName);
		oTR.className = 'ListRowEven';
	}

}


function vl_selectRow(widget, isOdd)
{
  var isSelected = widget.checked;    // is the row currently selected?
  var parentRow = widget.parentNode.parentNode;   // this is the TR element
  var childNodes = parentRow.childNodes;    // the list of all TD elements in this row
  var className = "ListRowOdd";

  // figure out which class to use
  if (isSelected) {
    className = "ListRowSelected";
  }else{
    if (isOdd) {
      className = "ListRowEven";
    }else{
      className = "ListRowOdd";
    }
  }
 // apply the style class to all TDs in this row
  for (var i=0; i<childNodes.length; i++) {
    childNodes[i].className = className;
  }
}   // end selectRow()



function confirm_action(form_name,message,action_ok,action_cancel) 
{
   if (confirm(message)) 
   {
		eval("document." + form_name + ".action='" + action_ok + "';");
		eval("document." + form_name + ".submit();");
   }
/*
   else      
   {   
		eval("document." + form_name + ".action='" + action_cancel + "';");
		eval("document." + form_name + ".submit();");
   }      
*/   
   return false;         
}   



function CheckBoxAll(form_name, field_name, value) 
{
	if(!document.forms[form_name])
		return;
	var objCheckBoxes = document.forms[form_name].elements[field_name];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = value;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
		{
         // Selecionar/desseleccionar...
			objCheckBoxes[i].checked = value;
			// Chamar para mudar a côr...
         vl_selectRow(objCheckBoxes[i], true);			
      }			


//   var TRs = document.getElementsByClassName(className);


/*
   if (value == true)    
      document.getElementById(id).checked = false;   
   else
      document.getElementById(id).checked = true;   
*/         
   
/*      
   var boxes = document.getElementsByClassName(className);
alert('1');      
   var cur_value = false;

   
   for (var i=0, boxes_len=boxes.length; i<boxes_len; i++) 
   {
      if (value == 'toggle') 
      {
         cur_value = boxes[i].checked;
         if (cur_value == true) 
         {
            boxes[i].checked = '';
         }
         else 
         {
            boxes[i].checked = 'checked';
         }
      } 
      else 
      {
         boxes[i].checked = value;
      }
   }
*/   
}


function hlight(imgOrg,imgSwap) {
 document.images[imgOrg].src = eval(imgSwap + ".src");
}

