
function trim(strText) { 
	// this will get rid of leading spaces 
	while (strText.substring(0,1) == ' ') 
		strText = strText.substring(1, strText.length);
	
	// this will get rid of trailing spaces 
	while (strText.substring(strText.length-1,strText.length) == ' ')
		strText = strText.substring(0, strText.length-1);
	
	return strText;
}


function ValidateNumber(textbox){
	if(textbox.value != ""){
		if(isNaN(textbox.value)){
			alert("Please enter a number.");
			textbox.focus();
		}
	}
}


function ConfirmDelete(sName, sAdditionalText){
	var strConfirm = "Are you sure you want to delete '" + sName + "'?";
	if(sAdditionalText != ""){
		strConfirm += "\n" + sAdditionalText;
	}
	return confirm(strConfirm);
}


function IsValidEmail(str) {
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if(str.indexOf(at)==-1){ return false; }
	if(str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return false; }
	if(str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false; }
	if(str.indexOf(at,(lat+1))!=-1){ return false; }
	if(str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false; }
	if(str.indexOf(dot,(lat+2))==-1){ return false; }
	if(str.indexOf(" ")!=-1){ return false; }
	return true;
}



/*-----------------------------------------------------------------------------------*/
/* SCROLLING FUNCTIONS */
/*-----------------------------------------------------------------------------------*/

  var maxPixel = 65;
  var currentDownPixel = 0;
  var currentUpPixel = 65;
  var currentDoc = 1;

  function scrollDown() {   
    if (currentDoc < maxDoc) {
      var div = document.getElementById('divDocumentList');
      if (currentDownPixel < maxPixel) {
        div.scrollTop = div.scrollTop + 1; //scroll 1 pixel down
        currentDownPixel++;
        scrollTimer = setTimeout('scrollDown()', 5);
      }
      else {
        currentDownPixel = 0;
        clearTimeout(scrollTimer);
        currentDoc++;
      }
    }
  }


  function scrollUp() {
    var div = document.getElementById('divDocumentList');
    if (currentUpPixel > 0) {
      div.scrollTop = div.scrollTop - 1; //scroll 1 pixel up
      currentUpPixel--;
      scrollTimer = setTimeout('scrollUp()', 5);
    }
    else {
      currentUpPixel = 65;
      clearTimeout(scrollTimer);
      currentDoc--;
    }
  }



function openGreenThumb() {
  document.getElementById('divGreenThumbPopup').style.left = (document.body.offsetWidth - 183) / 2 + "px";
  //document.getElementById('divGreenThumbPopup').style.top = (document.body.offsetHeight - 743) / 2 + "px";
  blockAccess('visible');
}


function blockAccess(newState){
	changeObjectVisibility('showModal',newState);
	changeObjectVisibility('divGreenThumbPopup',newState);
}
