// JavaScript Document
		function clearsearch() 
		{
			if (document.searchform.f.value == "Site Search")
				document.searchform.f.value = "";
		}	
		
		function submitSearch( form )
		{
			var f = form.f.value;
			if( f.length > 0 )
			{
				return true;
			}
			return false;
		}

		function ChatPopup()
		{
			props=window.open('modules/chatroom', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width=540, height=400, left=50, top=40');
		}
		
		function ForumPopup()
		{
			props=window.open('modules/forum', 'Forumpoppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, left=50, top=40');
		}
		
		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) { //v4.01
		  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);
		  if(!x && d.getElementById) x=d.getElementById(n); 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 ValidateNlSubscriber( frm, checkGroup )
{
    var errMsg = "";
    var nlSelected = false;
    var emailAddress = frm.userEmail.value;
    var firstname = frm.UserFName.value;
    var lastname = frm.UserLName.value;
    var subscriptionid = frm.subscriptionid;
    
    if( firstname.length == 0 ){ errMsg = errMsg + "Please fill in your First Name.\n"; }
    if( lastname.length == 0 ){ errMsg = errMsg + "Your Last Name is required.\n"; }
    if( emailAddress.length > 0 ){
        if( !isValidEmail( emailAddress ) ){ errMsg = errMsg + "Invalid Email Address.\n"; }
    }else{
        errMsg = errMsg + "Email address is required.\n";
    }
    if( checkGroup ){
    	for( i=1; i<=subscriptionid.length; i++ ){
        	if( document.getElementById( "subscriptionid" + i ).checked ){ nlSelected = true; i=(subscriptionid.length + 5 ); }   
    	}
	if( !nlSelected ){ errMsg = errMsg + "Please select at least one newsletter to subscribe to.\n"; }
    }
    
    if( errMsg.length > 0 ){ errMsg = "Please amend the followings:\n\n" + errMsg + "\nThank You."; alert( errMsg ); return false;}    
    return true;
}		

function isValidEmail(email){
	invalidChars=" /:,;!#$%^&*()+=~|<>?][}{\\"					
	for (i=0;i<invalidChars.length;i++){
		badChar=invalidChars.charAt(i);
		if (email.indexOf(badChar,0)>-1) return false;
	}
	if(email.charAt(0)=="_" || (email.charAt(0)=="@" && email.charAt(1)=="@")) return false;
	atPos=email.indexOf("@",1)
	if (atPos==-1) return false;
	if(email.charAt(atPos+1)=="." || email.charAt(atPos+1)=="_") return false;
	if(email.indexOf("@",atPos+1)>-1) return false;
	periodPos=email.indexOf(".",atPos);
	if (periodPos==-1 || email.charAt(0)==".") return false;
	return true;
}

	
/* Flash Activation Script */		
		
function commitFlashObject(_obj, _container){
	_output=""
	_paramoutput=""
	_src=""
	_ver=""
	for(_cO in _obj){
		_output+=_cO+"=\""+_obj[_cO]+"\" "
		_paramoutput+="<param name="+_cO+" value=\""+_obj[_cO]+"\">";
		if(_cO=="movie")_src="src=\""+_obj[_cO]+"\"";
		if(_cO=="version")_ver=_obj[_cO];
	}
	if(_ver=="")_ver="6,0,0,0"
	ihtm="<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+_ver+" "+_output+">\n"
	ihtm+=_paramoutput+"\n"
	ihtm+="<embed "+_src+" pluginspage=https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash "+_output+">\n";
	ihtm+="</embed>\n";
	ihtm+="</object>\n";
	document.getElementById(_container).innerHTML=ihtm	
}







function SetCookie() {
if(arguments.length < 2) { return; }
var n = arguments[0];
var v = arguments[1];
var d = 0;
if(arguments.length > 2) { d = parseInt(arguments[2]); }
var exp = '';
if(d > 0) {
	var now = new Date();
	then = now.getTime() + (d * 24 * 60 * 60 * 1000);
	now.setTime(then);
	exp = '; expires=' + now.toGMTString();
	}
document.cookie = n + "=" + escape(String(v)) + '; path=/' + exp;
}

function ReadCookie(n) {
var cookiecontent = new String();
if(document.cookie.length > 0) {
	var cookiename = n+ '=';
	var cookiebegin = document.cookie.indexOf(cookiename);
	var cookieend = 0;
	if(cookiebegin > -1) {
		cookiebegin += cookiename.length;
		cookieend = document.cookie.indexOf(";",cookiebegin);
		if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
		cookiecontent = document.cookie.substring(cookiebegin,cookieend);
		}
	}
return unescape(cookiecontent);
}
