function show_submenu(element)
{       
		if (document.layers)
		{		 
			document.layers[element].display = 'block';			
		}
		else if (document.all)
		{	
			document.all[element].style.display = 'block';			
		}
		else if (document.getElementById)
		{
			document.getElementById(element).style.display = 'block';			
		}
}

function ieFix() {
		window.focus();
}

function toggleDisplay(dest)
{
	var obj = null;

	if ( document.getElementById )
	{
		// If a string, get the object and set its display
		if ( typeof(dest) == "string" ) dest = document.getElementById(dest);

		if ( dest )
		{
			if ( dest.style.display == "none" ) setDisplay(dest, "block");
			else setDisplay(dest, "none");
		}
		else alert("dest does not exist");		// DEBUG
	}
}

function hide_submenu(element)
{       
		if (document.layers)
			document.layers[element].display = 'none';
		else if (document.all)
			document.all[element].style.display = 'none';
		else if (document.getElementById)
			document.getElementById(element).style.display = 'none';
}

function validateEmail(addr,man,db) {
if (addr == '' && man) {
   if (db) alert('email address is mandatory');
   return false;
}
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
      if (db) alert('email address contains invalid characters');
      return false;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {
      if (db) alert("email address contains non ascii characters.");
      return false;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
   if (db) alert('email address must contain an @');
   return false;
}
if (atPos == 0) {
   if (db) alert('email address must not start with @');
   return false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
   if (db) alert('email address must contain only one @');
   return false;
}
if (addr.indexOf('.', atPos) == -1) {
   if (db) alert('email address must contain a period in the domain name');
   return false;
}
if (addr.indexOf('@.',0) != -1) {
   if (db) alert('period must not immediately follow @ in email address');
   return false;
}
if (addr.indexOf('.@',0) != -1){
   if (db) alert('period must not immediately precede @ in email address');
   return false;
}
if (addr.indexOf('..',0) != -1) {
   if (db) alert('two periods must not be adjacent in email address');
   return false;
}
var suffix = addr.substring(addr.lastIndexOf('.')+1);
if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
   if (db) alert('invalid primary domain in email address');
   return false;
}
return true;
}

function validateInput() {
   if  (validateEmail(document.SignIn.UserName.value,1,0))
       document.SignIn.submit();
   else
      alert("pleasae input valid email address.");

}

function radPop(){
	window.open('/rad/applet.php','FTP_Uploader','width=330,height=425,status=yes,scrollbars=no,resizable=no').focus();
}

function popup(url,name,height,width) {
  window.open(url,null,"width="+width+",height="+height+",left=20,top=20,scrollbars=no,menubar=no,resizable=yes,location=no,toolbar=no");
}

function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}


function IsNumeric(obj) //  check for valid numeric strings    
{
    var regEx = /^[-+]?\d*\.?\d*$/;
    var strString = obj.value;

    if (obj.value.search(regEx)==-1)
    {        
        var myNumber = obj.value.substring(0, (obj.length) - 1);
        obj.value = myNumber; 
    }              
}


   
function IsFileInputEmpty(obj)
{
    for(i=0; i< obj.elements.length; i++)
    {
        if(obj.elements[i].type == 'text' && obj.elements[i].id.substring(0,5) == 'file_')
            if(obj.elements[i].value.length == 0)
            {
                alert("Please Select a File");
                obj.elements[i].style.backgroundColor = 'red';
                return false;
            }

    }

}