function notEmpty(obj,msg){   
   var mystr = ""
   len = obj.value.length
   if (len > 0)
   {  for (i=0;i<len; i++) 
		{ if(obj.value.substring(i,i+1)!=" ")
			{ mystr = mystr + obj.value.substring(i,i+1)}}	
	}
	if(mystr=="")
	{alert(msg);if(obj.name !='rte1')
	{
		if(obj.name!='txt_total')
			{obj.focus();}
		}
		return false;}
 return true;	
}

// check NUMBER only
function isNumber(obj,msg){
  var strTmp = obj.value;
  var ValidChars = "0123456789";

  //Check Validity
  for (i=0; i<=strTmp.length-1; i++) 
    if (ValidChars.indexOf(strTmp.charAt(i)) == -1) 
    {
	  alert(msg)
      obj.focus()
      return false;
	}
  return true;
}	

// check Price 
function isPrice(obj,msg){
  var strTmp = obj.value;
  var ValidChars = "0123456789.";

  //Check Validity
  for (i=0; i<=strTmp.length-1; i++) 
    if (ValidChars.indexOf(strTmp.charAt(i)) == -1) 
    {
	  alert(msg)
      obj.focus()
      return false;
	}
  return true;
}	

// check email 
function CheckEmail(obj,msg){
	var Mymail=obj.value;
	if (Mymail != "")
	{
	var filter=/^.+@.+\..{2,3}$/;
	var listchar = " ~!#$%^&*()+=|\\?<>:;'{}[]`/,‘";
	var foundchar, status;
    // check email if valid...
	for (i=0; i<listchar.length; i++) 
	{	
		xchar = listchar.substr(i,1);
		foundchar = Mymail.indexOf(xchar);
		
		if (foundchar>=0)// seach invalid character. 
		{	
			status = "Your email address contains an invalid character "+'"'+xchar+'".'; // popup message 
			alert(status);
			obj.focus();
			return false;
		}
	}
	if (!filter.test(Mymail))
	{
		alert(msg); // popup message if invalid
		obj.focus();
		return false;
	}
	return true;
	}
}
// check phone format
function checknumberformat(obj,msg){
  var strTmp = obj.value;
  var ValidChars = "0123456789()-+. ";
  //Check Validity
  for (i=0; i<=strTmp.length-1; i++) 
    if (ValidChars.indexOf(strTmp.charAt(i)) == -1) 
    {
	  alert(msg)
      obj.focus()
      return false;
	}
  return true;
}	

//check empty selectbox
function checkSelect(obj,msg){
	if(obj.selectedIndex == "-1")
	{	alert(msg);	obj.focus();return false;}
 return true;	
}

//verify if 2 fields have the same value
function verify(obj,obj2,msg){
	if(obj.value != obj2.value){	
		alert(msg);	
		obj2.focus();
		return false;
	}
 return true;	
}

//check min length
function minLength(obj,len,msg){
	if(obj.value.length < len){	
		alert(msg);	
		obj.focus();
		return false;
	}
 return true;	
}
//maximum length
function maxLength(obj,len,msg){
	if(obj.value.length > len){	
		alert(msg);	
		obj.focus();
		return false;
	}
 return true;	
}

//popup
function popwin(url,ttl,w,h){	
	vjtop = (screen.height - h)/2;
   	vjleft = (screen.width - w)/2;
	window.open(url,ttl,'width='+w+',height='+h+',scrollbars=1,top='+vjtop+',left='+vjleft);
}

function application_form(){
	popwin("dsp_application_form.php", "hangar", 450, 800);	
}

function check_form_add_article(){
	obj = document.form_add_article;
	if(notEmpty(obj.news_title,"Please enter the entry title.") == false ||
		notEmpty(obj.news_date,"Please enter the display date.") == false ||
		notEmpty(obj.news_body_text,"Please enter the body content.") == false
		){
		return false;
	}else{
		return true;
	}		
}