var alt=1, nilai=4;
var tinggi;
var currentpos=0 ;


function ScrollMoveDown() {
	if (currentpos<=(parent.content.document.body.scrollHeight-200)) { 
		currentpos = currentpos + nilai 
	}; 
	window.parent.content.scroll(0,currentpos)
}


function FastScroll() {
	nilai = 14 ;
}
	
function NormalScroll() {
	nilai = 4 ;
}


function ScrollMoveUp(){
	if (currentpos >= nilai) { 
		currentpos = currentpos - nilai 
	};
	window.parent.content.scroll(0,currentpos)
}


function ScrollUp() {
	detik = setInterval("ScrollMoveUp()",alt)
}


function ScrollDown() {
	detik = setInterval("ScrollMoveDown()",alt)
}


function StopScroll() {
	clearInterval(detik) 
}


function validate_search()
{
   var form = document.search_form;
   if(trim(form.search_field.value) == "")
   {
		alert("Please enter some keywords to search.");
		form.search_field.focus();
		return false
   }	
   return true
}
// End -->

<!-- Begin
function trim(inputString) 
{
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   return retValue; // Return the trimmed string back to the user
}
// End -->

<!-- Begin
function swapSource(selected_source) {
   var new_source = selected_source.value;
   //document.write (new_source);
   document.audiopanel.fileName = new_source;
}
// End -->
<!-- Begin
function validateDelete(chk){

    var flag = false;
	
	if (chk.checked)
	  flag = true;
	    
	for (var counter = 0; counter < chk.length && flag == false; counter++)
    {
	  if (chk[counter].checked)
	  {
		 flag = true;
	  }
	}
	 
	if (flag == false)
	  alert("Please tick at least one checkbox to delete.");
    else	
	  flag = confirm ("Are you sure you want to delete this entry?");
	  	
    return flag;
}
// End -->
function CheckAllBox() {
  for (var i = 0; i < document.Main.elements.length; i++) {
    if(document.Main.elements[i].type == 'checkbox'){
      document.Main.elements[i].checked = true;
    }
  }
}

<!-- Begin
function isNotEmpty() {
   var form = document.register_form;
   
   if(trim(form.firstName_field.value) == "")
   {
		alert("Please enter the first name.");
		form.firstName_field.focus();
		return false
   }
   if(trim(form.nricNo_field.value) == "")
   {
		alert("Please enter the NRIC/ Passport No.");
		form.nricNo_field.focus();
		return false
   }
   if(trim(form.address_field.value) == "")
   {
		alert("Please enter the address.");
		form.address_field.focus();
		return false
   }
   if(trim(form.postalCode_field.value) == "")
   {
		alert("Please enter the postal code.");
		form.postalCode_field.focus();
		return false
   }
   if(trim(form.city_field.value) == "")
   {
		alert("Please enter the city.");
		form.city_field.focus();
		return false
   }
   
   if(trim(form.country_field.value) == "")
   {
		alert("Please enter the country.");
		form.country_field.focus();
		return false
   }
   
   if(trim(form.phoneNo_field.value) == "")
   {
		alert("Please enter the phone number.");
		form.phoneNo_field.focus();
		return false
   }
   if(trim(form.email_field.value) == "")
   {
		alert("Please enter the email address.");
		form.email_field.focus();
		return false
   }
   if(trim(form.userid_field.value) == "")
   {
		alert("Please enter the userid.");
		form.userid_field.focus();
		return false
   }
   if(trim(form.password_field.value) == "")
   {
		alert("Please enter the password.");
		form.password_field.focus();
		return false
   }
   if(trim(form.password1_field.value) == "")
   {
		alert("Please re-enter the password.");
		form.password1_field.focus();
		return false
   }
   if(trim(form.question_field.value) == "")
   {
		alert("Please enter the question for password reminder.");
		form.question_field.focus();
		return false
   }
  
   if(trim(form.answer_field.value) == "")
   {
		alert("Please enter the answer for password reminder.");
		form.answer_field.focus();
		return false
   }
    if(trim(form.cardNo_field.value) == "")
   {
		alert("Please enter the credit card number.");
		form.cardNo_field.focus();
		return false
   }
   if(trim(form.cardHolder_field.value) == "")
   {
		alert("Please enter the credit card holder name.");
		form.cardHolder_field.focus();
		return false
   }
   
   return true
}
// End -->

<!-- Begin
function isValidInfo()
{
  var form = document.register_form;
  
  if (!isAlphabeticStrWithSpace(trim(form.firstName_field.value)))
  {
    	alert("Invalid first name. Please enter a valid first name.");
		form.firstName_field.focus();
		return false
  }
  if (!isAlphabeticStrWithSpace(trim(form.lastName_field.value)))
  {
    	alert("Invalid last name. Please enter a valid last name.");
		form.lastName_field.focus();
		return false
  }
  if (!isValidDate (form.dateDOB_field.value, form.monthDOB_field.value, form.yearDOB_field.value))
  {
	  alert("Invalid date of birth. Please select a valid date of birth");
	  form.dateDOB_field.focus();
	  return false
  }
  if (!isAlphabeticStrWithSpace(trim(form.city_field.value)))
  {
    	alert("Invalid city. Please enter a valid city.");
		form.city_field.focus();
		return false
  }
  if (!isAlphabeticStrWithSpace(trim(form.state_field.value)))
  {
    	alert("Invalid state. Please enter a valid state.");
		form.state_field.focus();
		return false
  }
  if (!isAlphabeticStrWithSpace(trim(form.country_field.value)))
  {
    	alert("Invalid country. Please enter a valid country.");
		form.country_field.focus();
		return false
  }
  if (!isNumberString(trim(form.postalCode_field.value)))
  {
    	alert("Invalid postal code. Please enter a valid postal code.");
		form.postalCode_field.focus();
		return false
  }
  if(trim(form.postalCode_field.value).length < 5){
		alert("You have to enter at least 5 digits of postal code.");
		form.postalCode_field.focus();
		return false
  }
  if (!isNumberString(trim(form.phoneNo_field.value)))
  {
    	alert("Invalid phone number.Please enter a valid phone number.");
		form.phoneNo_field.focus();
		return false
  }
  if (!isNumberString(trim(form.officeNo_field.value)))
  {
    	alert("Invalid office number. Please enter a valid office number.");
		form.officeNo_field.focus();
		return false
  }
  if (!isNumberString(trim(form.faxNo_field.value)))
  {
    	alert("Invalid fax number. Please enter a valid fax number.");
		form.faxNo_field.focus();
		return false
  }
  if (!isNumberString(trim(form.mobileNo_field.value)))
  {
    	alert("Invalid mobile number. Please enter a valid mobile number.");
		form.mobileNo_field.focus();
		return false
  }
  if (!isValidEmail(trim(form.email_field.value)))
  {
    	alert("Invalid email address. Please enter a valid email address.");
		form.email_field.focus();
		return false
  }
  if(trim(form.userid_field.value).length < 5){
		alert("You have to enter at least 5 characters of userid.");
		form.userid_field.focus();
		return false
  }
  if(trim(form.password_field.value).length < 5){
		alert("You have to enter at least 5 characters of password.");
		form.password_field.focus();
		return false
  }
  if(trim(form.password_field.value) != trim(form.password1_field.value))
   {
		alert("You have to enter the same password again.");
		form.password1_field.focus();
		return false
   }
   if (!isNumberString(trim(form.cardNo_field.value)))
  {
    	alert("Invalid credit card number. Please enter a valid credit card number.");
		form.cardNo_field.focus();
		return false
  }
  if(trim(form.cardNo_field.value).length != 16){
		alert("You have to enter 16 digits of credit card number.");
		form.cardNo_field.focus();
		return false
  }
  if (!isAlphabeticStrWithSpace(trim(form.cardHolder_field.value)))
  {
    	alert("Invalid credit card holder name. Please enter a valid credit card holder name.");
		form.cardHolder_field.focus();
		return false
  }
  if (!isValidDate (form.dateExpiry_field.value, form.monthExpiry_field.value, form.yearExpiry_field.value))
  {
	  alert("Invalid credit card expiry date. Please select a valid expiry date.");
	  form.dateExpiry_field.focus();
	  return false
  }
  if (!isValidRangeDate (form.dateExpiry_field.value, form.monthExpiry_field.value, form.yearExpiry_field.value))
  {
	  alert("Credit card expiry date must be at least 30 days later than current date.");
	  form.dateExpiry_field.focus();
	  return false
  }
    
  return true;
}
  
// End -->

<!--
function isValidRangeDate(startDate,startMonth,startYear) {

	var month="";
	
	if (startMonth == "JAN") month ="00";
	else
		if (startMonth == "FEB") month ="01";
	else
		if (startMonth == "MAR") month ="02";
	else
		if (startMonth == "APR") month ="03";
	else
		if (startMonth == "MAY") month ="04";
	else
		if (startMonth == "JUN") month ="05";
	else
		if (startMonth == "JUL") month ="06";
	else
		if (startMonth == "AUG") month ="07";
	else
		if (startMonth == "SEP") month ="08";
	else
		if (startMonth == "OCT") month ="09";
	else
		if (startMonth == "NOV") month ="10";
	else
		month="11";
		
	var start = new Date(startYear,month,startDate);
    
	var now = new Date();
	var diff = start - now;

	if(diff < 2592000000) return false;
	// document.write (now + " - " + start + " = " + diff);
	return true;
}
function isNumberString(InString)
{
  var i = 0;
  var RefString = "1234567890";

  for (i=0; i<InString.length; i++)
  {
    TempChar = InString.substring(i, i+1);

    if (RefString.indexOf(TempChar, 0)==-1)
       return (false);
  }

  return(true);
}

function isAlphabeticStrWithSpace(InString)
{
  var i=0;
  var TempChar = '';
  var RefString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ- ";

  for (i=0; i<InString.length; i++)
  {
    TempChar = InString.substring(i, i+1);

    if (RefString.indexOf(TempChar, 0)==-1)
       return (false);
  }

  return (true);
}

function isValidEmail(InString)
{
  InString = InString.toLowerCase();

  if (InString.indexOf(" ")>0)
  {
    return(false);
  }

  if (InString.indexOf("@")<2)
  {
    return(false);
  }

  if ((InString.indexOf(".com")<5) &&
      (InString.indexOf(".gov")<5) &&
      (InString.indexOf(".net")<5) &&
      (InString.indexOf(".edu")<5) &&
      (InString.indexOf(".nus")<5) &&
      (InString.indexOf(".ntu")<5) &&
      (InString.indexOf(".ac")<5) &&
      (InString.indexOf(".org")<5) &&
      (InString.indexOf(".mil")<5) &&
      (InString.indexOf(".sg")<5))
  {
    return(false);
  }

  return(true);
}


function isValidDate(date, month, year)
{
  var invalidDate = new Array(6);
  var checkedDate = date + " " + month;
  var isValid = true;
  
  invalidDate [0] = "30 FEB";
  invalidDate [1] = "31 FEB";
  invalidDate [2] = "31 APR";
  invalidDate [3] = "31 JUN";
  invalidDate [4] = "31 SEP";
  invalidDate [5] = "31 NOV";
  
  for (var i = 0; i < invalidDate.length; i++)
  {
    if(checkedDate == invalidDate[i])
	  isValid = false; 
  }
  
  if (checkedDate == "29 FEB")
  {
    var yearInt = parseInt(year);
	
	if (yearInt%4==0)
	  if (yearInt%100==0) 
        if (yearInt%400==0) 
		  isValid = true;
        else 
		  isValid = false;
      else 
        isValid = true;
	else
	  isValid = false;
  }
 
  return isValid;
}
// End -->

