function isValidEmail(str) {
   return (str.indexOf("@") > 0);
}
function rollOut(str) {
  dd = document.getElementById(str);
   if(dd.style.display == 'none') 
    	dd.style.display= '';
  else
  	   dd.style.display= 'none';
}
function strReplace(str1, str2, str3) { 
  while(str1.indexOf(str2) != -1) {
   str1 = str1.replace(str2, str3);
 } 
  return str1;     
} 

function getCalendarDate()
{
   var months = new Array(13);
   months[0]  = "January";
   months[1]  = "February";
   months[2]  = "March";
   months[3]  = "April";
   months[4]  = "May";
   months[5]  = "June";
   months[6]  = "July";
   months[7]  = "August";
   months[8]  = "September";
   months[9]  = "October";
   months[10] = "November";
   months[11] = "December";
   var now         = new Date();
   var monthnumber = now.getMonth();
   var monthname   = months[monthnumber];
   var monthday    = now.getDate();
   var year        = now.getYear();
   if(year < 2000) { year = year + 1900; }
   var dateString = monthname + 
                    ' ' + 
                    monthday + 
                    ', ' + 
                    year;
   //return dateString;
   DateSpan.innerText = dateString;
   setTimeout('getCalendarDate()',1000);
} // function getCalendarDate()


function getClockTime()
{
   var now    = new Date();
   var hour   = now.getHours();
   var minute = now.getMinutes();
   var second = now.getSeconds();
   var ap = "AM";
   if (hour   > 11) { ap = "PM";             }
   if (hour   > 12) { hour = hour - 12;      }
   if (hour   == 0) { hour = 12;             }
   if (hour   < 10) { hour   = "0" + hour;   }
   if (minute < 10) { minute = "0" + minute; }
   if (second < 10) { second = "0" + second; }
   var timeString = hour + 
                    ':' + 
                    minute + 
                    ':' + 
                    second + 
                    " " + 
                    ap;
   //return timeString;
   ClockSpan.innerText = timeString;
   setTimeout('getClockTime()',1000);
} 

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function CellColOn(id, col) {
        if (!id.contains(event.fromElement)) {
            id.bgColor = col;
        }
    }
function CellColOff(id,col) {
        if (!id.contains(event.toElement)) {
            id.bgColor = col;
        }
    }
		
function toggle(e){
	if (e.style.display == "none"){
		e.style.display = "";
		}
	else{
		e.style.display = "none";
	}
}


function validateNum(txt,elName)
				  {
				  	var re = /[^0-9]/
					if (txt.search(re) != -1)
					{
						alert('Invalid Characters detected\n-  ' + elName + ' can only contain Numeric Characters [0-9]');
						event.returnValue=false;
					}
				  }


function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function clearALLRows(RowName,RowCount)
{
	for (i=1;i<=RowCount;i++) 
		{	
		RowNam = RowName + i
		document.getElementById(RowNam).className= 'Tahofont';
  		}

}

function getRadioValue(radioName) 
{
  var coll;
  coll = document.all(radioName); // document.AllTransFrm.TransID; //[radioName];
  //alert (coll[0].value)
  //alert ('first' + coll[0].value)
  if (coll.length != undefined)// if the radio button coll is an array (remember Gerald, one button is not an array)
  	{
		//alert (coll.length)
  		for (i=0;i<coll.length;i++) 
		{
    		if (coll[i].checked)
    			return(coll[i].value);
  		}
	}
	else
		{
		//alert ('none ' + coll.value)
		return coll.value;
		}
}

function CheckProfile() {
	   var joinfrm = document.EditFrm
	   var ErrMsg = ''
	  
		if (trim(joinfrm.FName.value) ==  '' ) {
			ErrMsg = ErrMsg + '\n - Your First Name is required'
		}
		if (trim(joinfrm.IsOldBoy.value) ==  'Yes' && trim(joinfrm.EntryYear.value =='') ) {
			ErrMsg = ErrMsg + '\n - If you are a Sasse Old Boy, then a Valid Year of Entry is required'
		}
		if (trim(joinfrm.LName.value) ==  '' ) {
			ErrMsg = ErrMsg + '\n - Your Last Name is required'
		}
		var EmailAdd = trim(joinfrm.Email.value)
		 if (EmailAdd ==  '') {
			ErrMsg = ErrMsg + '\n - A valid Email Address is required'
		}
		 if (trim(joinfrm.City.value) ==  '' ) {
			ErrMsg = ErrMsg + '\n - Your City of Residence is Required'
		}  
		var user = trim(joinfrm.UserName.value)
		if ( user ==  '' ) {
			ErrMsg = ErrMsg + '\n - A valid User Name is required'
		}
		else
			{
			//chk if username contains any spaces		
			if ( user.indexOf(' ',0) != -1 || user.indexOf('xxx',0) != -1 || user.indexOf('yyy',0) != -1 || user.indexOf('hhh',0) != -1) {
				ErrMsg = ErrMsg + '\n - User Name cannot contain spaces! or the ff. charaters:\nxxx\nhhh\nyyy\n\n Please use another name'
			}
		}
		if (trim(joinfrm.DobDay.value) <= 0 || trim(joinfrm.DobDay.value) > 31 ) {
			ErrMsg = ErrMsg + '\n - A valid Day of Birth is required and must be between 1st and 31st'
		}
		passwd = trim(joinfrm.Pass.value)
       if ( passwd ==  '' || passwd.length < 5) {
			ErrMsg = ErrMsg + '\n - A valid Password is required and must be at least 5 letters long'
		} 
		if  (passwd  != trim(joinfrm.VPass.value) ){
			ErrMsg = ErrMsg + '\n - Passwords do not Match'
			//alert(trim(joinfrm.Pass.value))//alert('You must accept the terms of membership before joining SOBAN.net')
	  	}
		
		if  (ErrMsg != ''){
			alert(':::SOBAN.net Sign - up Errors Encountered \n ========================' +ErrMsg)//alert('You must accept the terms of membership before joining SOBAN.net')
			
	  	}
		else
		{
			toggle(SaveAlertPersonal);
			joinfrm.submit();
		}
			//alert('submit form now')
}
function CheckPassMatch() {
	   var joinfrm = document.editPassFrm
	   var ErrMsg = ''
	  
	  var passwd = trim(joinfrm.OldPass.value)
       if ( passwd ==  '' ) {
			ErrMsg = ErrMsg + '\n - Invalid Old Password.'
		} 
		if ( trim(joinfrm.NewPass.value).length < 5) {
			ErrMsg = ErrMsg + '\n - Invalid New Password. It must be at least 5 letters long'
		} 
		if  (trim(joinfrm.NewPass.value) != trim(joinfrm.VNewPass.value) ){
			ErrMsg = ErrMsg + '\n - Your New Passwords do not Match'
		}
		if  (ErrMsg != ''){
			alert('Password Update: Errors Encountered \n ========================' +ErrMsg)//alert('You must accept the terms of membership before joining SOBAN.net')
	  	}
		else
			joinfrm.submit()
			//alert('submit form now')
}

function CheckRefForm() {
	   var refFrm = document.referSobanFrm;
	   var ErrMsg = '';
	  
	  var em = trim(refFrm.VEmailAddress.value)
       if ( !isValidEmail(em)  ) {
			ErrMsg = ErrMsg + '\n - Invalid Email Address';
		} 
		if  (trim(refFrm.VFirstName.value) == '' ){
			ErrMsg = ErrMsg + '\n - First Name Required';
		}
		if  (trim(refFrm.VLastName.value) == '' ){
			ErrMsg = ErrMsg + '\n - Last Name Required';
		}
		if  ( isNaN(refFrm.VClassOf.value) ){
			ErrMsg = ErrMsg + '\n - Please check the SOBA Class';
		}
		if  (ErrMsg != ''){
			alert('Referring Soban: Errors Encountered \n ========================' +ErrMsg);//alert('You must accept the terms of membership before joining SOBAN.net')
	  	}
		else
			refFrm.submit();
			//alert('submit form now')
}

function CheckJoin() 
{
		var joinfrm = document.JoinFrm
	   	var ErrMsg = ''
	  
		if (trim(joinfrm.FName.value) ==  '' ) {
			ErrMsg = ErrMsg + '\n - Your First Name is required'
		}
		if (trim(joinfrm.LName.value) ==  '' ) {
			ErrMsg = ErrMsg + '\n - Your Last Name is required'
		}
		var EmailAdd = trim(joinfrm.Email.value)
		 if (EmailAdd ==  '') {
			ErrMsg = ErrMsg + '\n - A valid Email Address is required'
		 }
		 
		passwd = trim(joinfrm.Pass.value)
       	if ( passwd ==  '' || passwd.length < 5) {
			ErrMsg = ErrMsg + '\n - A valid Password is required and must be at least 5 letters long'
		} 
		if  (passwd  != trim(joinfrm.VPass.value) ){
			ErrMsg = ErrMsg + '\n - Passwords do not Match'
			//alert(trim(joinfrm.Pass.value))//alert('You must accept the terms of membership before joining SOBAN.net')
	  	}
		
		if  (ErrMsg != ''){
			alert('SOBA UK Join Errors\n =====================' +ErrMsg)//alert('You must accept the terms of membership before joining SOBAN.net')
			
	  	}
		else
		{
			//toggle(SaveAlertPersonal);
			joinfrm.submit();
		}
		 
}
	
	function chkmess(curUser) 
	{
		var postee = document.FrmPostMess.postee.value
		var mess = trim(document.FrmPostMess.TxtMessage.value)
		var visname = document.FrmPostMess.visited.value
		
		if (visname== postee)
		{
			alert('You cannot Post a Message in your GuestBook')
		}
		else
		{
			if (mess.length==0) 
			{
				alert('My.SOBAN.net Guest Book -- ' + unescape(curUser) + '\n=========================\nYou must enter a Message');
			}
			else
			{
				document.FrmPostMess.submit()
			}
		}
	}


function OpaceLayer(strLayerID,ShowHide)
{
		//if ShowHide is True, then show Target, else hide obj...
	//window.focus();
	TargetObj = document.getElementById(strLayerID);
	var ftnName ='OpaceLayer("' + TargetObj.id + '",' + ShowHide + ')'
	//alert (ftnName)
	if (ShowHide==1)
	{
		TargetObj.style.display = '';
		if(TargetObj.filters.item("DXImageTransform.Microsoft.Alpha").opacity <80)
		{
			TargetObj.filters.item("DXImageTransform.Microsoft.Alpha").opacity += 20;
			setTimeout(ftnName,20)
		}
		
	}
	else
	{
		if(TargetObj.filters.item("DXImageTransform.Microsoft.Alpha").opacity >0)
		{
			TargetObj.filters.item("DXImageTransform.Microsoft.Alpha").opacity -= 20;
			setTimeout(ftnName,20)
			
		}
		else
			TargetObj.style.display = 'none';
	}
	
}

function viewEvent(EvType,EvName,EvLocation,EvStartDate,EvEndDate,EvContact,EvDesc)
{
	//set the value of the span tags to the passed values
	//alert(EvType)
	OpaceLayer('ViewEventLayer',1)
	var eType = document.getElementById("EvType")
	eType.innerText = EvType 
	document.getElementById("EvName").innerText = EvName
	document.getElementById("EvLocation").innerText = EvLocation 
	document.getElementById("EvStartDate").innerText =EvStartDate
	document.getElementById("EvEndDate").innerText = EvEndDate
	document.getElementById("EvContact").innerText = EvContact
	document.getElementById("EvDesc").innerText = EvDesc
	
}



















