var browserName = window.navigator.appName;
var browserVersion = window.navigator.appVersion;
var enableEvent = (browserName=='Netscape')?0:((parseInt(browserVersion.substring(0,1))<4)?0:1);

var maxLen = 300;
var oldMessage = ''; 
var InAction = 0;

function textarea_onkeydown(paObject){	
  if(paObject.value.length + InAction < maxLen ){
	oldMessage = paObject.value;
	if(enableEvent==1){
	  InAction = ((window.event.keyCode>15) && (window.event.keyCode<19))?0:1;
	  window.event.cancelBubble = true;
	} 
	else 
	  ++InAction;
  } 
  else{
	if(enableEvent==1){
	  if(window.event.keyCode >=65 ){
		window.event.returnValue = false;
		window.event.cancelBubble = true;
	  }
	} 
	else 
	  return false;
  }
}
		
function textarea_onkeyup(paObject){
  var newMessage = paObject.value;
		  
  if(newMessage.length > maxLen ){
	paObject.value = oldMessage;
	if(enableEvent==1){
	  window.event.returnValue = false;
	  window.event.cancelBubble = true;
	}
  }  
  InAction = 0;
}

function isValidEmail(paEmail){
 return new RegExp("^([_a-z0-9]+([\\._a-z0-9-]+)*)@([a-z0-9-]{2,}(\\.[a-z0-9-]{2,})*\\.[a-z]{2,4})$", "i").test(paEmail)
}	

function isValidPasswd(paPasswd){
  return new RegExp("^([a-z0-9]{6,})$", "i").test(paPasswd);
}

function isValidLink(paLink){
  return new RegExp("http:|ftp:|news:[a-z0-9.]+", "ig");
}	

function isJpeg(paFileName){

 if(paFileName.substring(paFileName.lastIndexOf(".")+1,paFileName.length).toLowerCase()=="jpg" 
    || paFileName.substring(paFileName.lastIndexOf(".")+1,paFileName.length).toLowerCase()=="jpeg")
   return true;
 else
   return false;
}


function windowOpen(url,name,features,replace){
   var win=window.open(url,name,features,replace);
   win.focus();
}

function Image(file,width,height){
/*
   var win=window.open('/image.php?file='+file,'','directories=no,fullscreen=no,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,width='+width+',height='+height+',resizable=yes',true);
   win.focus();
*/
}

function URLOpen(url){
  var win=window.open(url);
  win.focus();
}     
     
function viewHelp(file){
   var win=window.open('/help/'+file,'','directories=no,fullscreen=no,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,width=800,height=600,resizable=no',true);
   win.focus();
}
