// A Collection of classic javascript Checks
//Author Melt

function hasAnyValue(anObject){
	anObject.value=trim(anObject.value);
	if(anObject.value.length==0){
		anObject.focus();
		return false;
	}
	return true;
}

function isValidURL(your_url){
	var is_protocol_ok=your_url.indexOf('http://');
	var is_dot_ok=your_url.indexOf('.');
	if ((is_protocol_ok==-1) || (is_dot_ok==-1)){
	  return false;
	}
	return true;
}

//--------------trim()-------------------------
function trim(mltstr) {
  while (mltstr.charAt(0) == ' '){//remove white spaces from start
    mltstr=mltstr.substring(1);
  }//remove white spaces from start
  while (mltstr.charAt(mltstr.length - 1) == ' '){//remove white spaces from end
    mltstr = mltstr.substring(0, mltstr.length - 1);
  }//remove white spaces from end
  return mltstr;
}

//--------------isValidNumber()-------------------------

function isValidNumber(anObject){
	if(!hasAnyValue(anObject)){
    anObject.focus();
		return false;
	}  
  if (isNaN(parseInt(anObject.value))) {
    anObject.value='';
    anObject.focus();
    return false;
  }
  return true;
}

//--------------getNumber()-------------------------
function getNumber(anObject){	
  anObject.value = parseInt(anObject.value);
  if (anObject.value=="NaN") {    
    return -1;
  }else{
  	return parseInt(anObject.value);
  }
  return true;
}