//
// Browser Detection
//
isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
NS4 = (document.layers) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IE4plus = (document.all) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
IE6 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? true : false;
ver4 = (NS4 || IE4plus) ? true : false;
NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;

IE5plus = IE5 || IE6;
IEMajor = 0;

if (IE4plus)
{
	var start = navigator.appVersion.indexOf("MSIE");
	var end = navigator.appVersion.indexOf(".",start);
	IEMajor = parseInt(navigator.appVersion.substring(start+5,end));
	IE5plus = (IEMajor>=5) ? true : false;
}

function menuOver(o)
{
 o.style.backgroundColor = '#DAA6A9';
 o.style.color = '#BA0000';
 o.style.cursor = 'hand';
 if (NS4 || NS6) o.style.cursor = 'pointer';
}

function menuOut(o)
{
 o.style.backgroundColor = '#BA0000';
 o.style.color = 'white';
 o.style.cursor = 'default';
}

function menuOverH(o)
{
 o.style.backgroundColor = '#BA0000';
 o.style.color = 'white';
 o.style.cursor = 'hand';
 if (NS4 || NS6)  o.style.cursor = 'pointer';
}

function menuOutH(o)
{
 o.style.backgroundColor = '#DAA6A9';
 o.style.color = 'white';
 o.style.cursor = 'default';
}

function menuClick(d)
{
 document.location.href = d;
}


function PopUpPage(p) 
{
var t = window.open(p,'_blank','');
}

function SetClassO(obj, cn)
{
	obj.className=cn;
}

function GoToPage(p)
{
 document.location.href = p;
}

function openAWindow( pageToLoad, winName, width, height, center) {
/* Opens a new window on the users desktop.   Arguments:
    pageToLoad - The URL of a page to load in the browser window.
                 This can be a relative URL or fully qualified.
    winName - 	 Name of the new window.
    width - 	 The horizontal size of the new window.
    height - 	 The vertical size of the new window.
    center -     toggle centering on 4.0 browsers.
                  1=centered window 0=no centering
    Values in the "args" section below can all be toggled in the
    same fashion as the center toggle.  Just modify the appropriate
    value in the args section to be either 0 or 1.
    A call to this function might look like this:
    <a href="javascript:openAWindow('ice.html','ice',375,250,1)">Ice</a>
   Created by Glenn Davis of Project Cool, Inc. for general use.  If
   you use this routine please leave all comments in place so that
   others may benefit as well.*/	
    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;    }
    args = "width=" + width + ","     + "height=" + height + "," 
    + "location=0,"     + "menubar=0,"    + "resizable=0,"    + "scrollbars=0,"
    + "status=0,"     + "titlebar=0,"    + "toolbar=0,"    + "hotkeys=0,"
    + "screenx=20" + xposition + ","  //NN Only
    + "screeny=15" + yposition + ","  //NN Only
    + "left=20" + xposition + ","     //IE Only
    + "top=15" + yposition;           //IE Only
    window.open( pageToLoad,winName,args );}
	
t_ie4 = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ));
	
function toggle( targetId ){
  if (t_ie4){
  		target = document.all( targetId );
  			if (target.style.display == "none"){
  				target.style.display = "";
  			} else {
  				target.style.display = "none";
  			}
  	}
}

function stripSpaces(s) 
{
    while (s.substring(0,1) == ' ') s = s.substring(1);
    while (s.substring(s.length-1,s.length) == ' ') s = s.substring(0,s.length-1);
	return s;
}


function validateEmailContent(s)
{
 // list of valid characters to be excluded
 var iChars = "*¬`|,\":<>[]{}\\\';()&^%$£!#~?+=";
 
 for (var i=0; i < s.length; i++)
 {
  var x = iChars.indexOf(s.charAt(i));
   // if found a non-valid character, exit
   if (x != -1)
   	  return false;
 }
 
 return true;
}

function isValidPassword(pwd)
{
 // list of valid characters to be included
 var iChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
 
 for (var i=0; i < pwd.length; i++)
 {
  var x = iChars.indexOf(pwd.charAt(i));
   // if found a non-valid character, exit
   if (x == -1)
   	  return false;
 }
 
 return true;
}


function isValidUserID(pwd)
{
 // list of valid characters to be included
 var iChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
 
 for (var i=0; i < pwd.length; i++)
 {
  var x = iChars.indexOf(pwd.charAt(i));
   // if found a non-valid character, exit
   if (x == -1)
   	  return false;
 }
 
 return true;
}

function validateEmailFormat(s)
{
  var result = false;
 
  if (s == '')
  	 return false;
	 
  var theStr = new String(s);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
  }
  return result;
}
