/*
Strip whitespace from the beginning and end of a string
Input : a string
*/
function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}

/*
Make sure that textBox only contain number
*/
function checkNumber(textBox)
{
	while (textBox.value.length > 0 && isNaN(textBox.value)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}
	
	textBox.value = trim(textBox.value);
/*	if (textBox.value.length == 0) {
		textBox.value = 0;		
	} else {
		textBox.value = parseInt(textBox.value);
	}*/
}

/*
	Check if a form element is empty.
	If it is display an alert box and focus
	on the element
*/
function isEmpty(formElement, message) {
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '') {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	
	return _isEmpty;
}

/*
	Set one value in combo box as the selected value
*/
function setSelect(listElement, listValue)
{
	for (i=0; i < listElement.options.length; i++) {
		if (listElement.options[i].value == listValue)	{
			listElement.selectedIndex = i;
		}
	}	
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function newWindow(varURL,varWidth,varHeight)
{
	varTop = (screen.height - varHeight)/2;
	varLeft = (screen.width - varWidth)/2;
	window.open(varURL, "myWindow","scrollbars=0,resizable=0,location=0,status=0,toolbar=0,top=" + varTop + ",left=" + varLeft +  ",width="+ varWidth + ",height=" + varHeight);
}

function submitPaging(pageNbr)
{
	document.formPage.action = document.formPage.action + '?curPage=' + pageNbr;
	document.formPage.submit();
}

function PlayIt(anObj){
		// check if method if available 
		if (anObj.controls.isAvailable('Play'))
        // start playback
        anObj.controls.play();
}

function StopIt(anObj) {
		// check if method if available 
		if (anObj.controls.isAvailable('Stop'))
		// stop playback
		anObj.controls.stop();
		}
		
function PauseIt(anObj) {
		// check if method is available
		if (anObj.controls.isAvailable('Pause'))
		// pause the movie
		anObj.controls.pause();
}

function ForwardIt() {
		//check if the method is available
if (movie3.controls.isAvailable('FastForward'))
        movie3.controls.fastForward();
}

function ReverseIt() {
		//check if the method is available
if (movie3.controls.isAvailable('FastReverse'))
        movie3.controls.fastReverse();
}

function muteClick(anObj) {
anObj.settings.mute=(anObj.settings.mute ? false : true);
}

// function to increase volume
function upVol(anObj){
	anObj.settings.volume = anObj.settings.volume +20;
}
// function to decrease volume
function downVol(anObj){
	anObj.settings.volume = anObj.settings.volume -20;
}


function hidify_showify(e_table, e_img, alt_less, alt_more) {
   if(document.getElementById) {
      var id_table = document.getElementById(e_table).style;
      var id_img = document.getElementById(e_img);

      //Set the object to table-cell if the browser is
      //Firefox and block if it's anything else.
      if(navigator.userAgent.indexOf("Firefox") != -1){
         if(id_table.display == "table-cell") {
            id_table.display = "none";
            id_img.src = "images/arrow_down.gif";
            id_img.alt = alt_more;
         }
         else {
            id_table.display = "table-cell";
            id_img.src = "images/arrow_up.gif";
            id_img.alt = alt_less;
         }
      }
      else {
         if(id_table.display == "block") {
            id_table.display = "none";
            id_img.src = "images/arrow_down.gif";
            id_img.alt = alt_more;
         }
         else {
            id_table.display = "block";
            id_img.src = "images/arrow_up.gif";
            id_img.alt = alt_less;
         }
      }
      return false;
   }
   else {
      return true;
   }
}
