<!--

function no_undo(u){fno=confirm(u);if(fno){return true}else{return false}}

function storeCaret(textarea) {
	// is it worth storing?..
	if (typeof(textarea.createTextRange) != 'undefined') {
		textarea.caretPos = document.selection.createRange().duplicate();
	}
	StoredCaret = textarea.selectionStart;
}

function nodisabled(){
MM_findObj("Delete").disabled=false;
MM_findObj("Perm").disabled=false;
MM_findObj("Edit").disabled=false;
MM_findObj("Move").disabled=false;
MM_findObj("Rename").disabled=false;
}
function yesdisabled(){
MM_findObj("Delete").disabled=true;
MM_findObj("Perm").disabled=true;
MM_findObj("Edit").disabled=true;
MM_findObj("Move").disabled=true;
MM_findObj("Rename").disabled=true;
}

// surround the selected text with tStart and tEnd.
function SurroundText(e, tStart, tEnd) {

	// grab the textarea element from the current form..
	textarea = MM_findObj(e);
	StoredUndo = textarea.value;
	// can a valid text range be created?
	if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange) {
		var caretPos = textarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? tStart + caretPos.text + tEnd + ' ' : tStart + caretPos.text + tEnd;
		caretPos.select();
		StoredSelLength = caretPos.text.length;

	// moz wrap..
	} else if (typeof(textarea.selectionStart) != "undefined") {
		var begin = textarea.value.substr(0, textarea.selectionStart);
		var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart);
		var end = textarea.value.substr(textarea.selectionEnd);
		var newCursorPos = textarea.selectionStart;
		var scrollPos = textarea.scrollTop;
		StoredSelLength = selection.length;
		textarea.value = begin + tStart + selection + tEnd + end;

		if (textarea.setSelectionRange) {
			if (selection.length == 0)
				textarea.setSelectionRange(newCursorPos + tStart.length, newCursorPos + tStart.length);
			else
				textarea.setSelectionRange(newCursorPos, newCursorPos + tStart.length + selection.length + tEnd.length);
			textarea.focus();
		}
		textarea.scrollTop = scrollPos;

	// or else slam it on the end again..
	} else {
		textarea.value += tStart + tEnd;
		textarea.focus(textarea.value.length - 1);
	}
}


function selectic(ini){
var statusicselect=MM_findObj(ini).value;
var statusicclass=MM_findObj("statusicclass");
if(statusicselect=="PSL of "){
statusicclass.disabled=false;
statusicclass.value="1?";
}
else if(statusicselect!="PSL of "){
statusicclass.disabled=true;
statusicclass.value="";
}
}


function DisEnAbled(ini){ 
ini=MM_findObj(ini).disabled;
if(ini==false){ ini=true; }
else if(ini==true){ ini=false; }
}

function InsertText(e, text) {

	// grab the textarea element from the current form..
	textarea = MM_findObj(e);

	// IE...
	if (typeof(textarea.caretPos) != "undefined") { 
		var caretPos = textarea.caretPos;
		caretPos.text = text;
		caretPos.select();
		textarea.focus();

	// Mozish...
	} else if (typeof(textarea.selectionStart) != "undefined") { 
		var begin = textarea.value.substr(0, textarea.selectionStart);
		var end = textarea.value.substr(textarea.selectionEnd);
		var scrollPos = textarea.scrollTop;
		textarea.value = begin + text + end;
		textarea.scrollTop = scrollPos;
		textarea.setSelectionRange(begin.length + text.length, begin.length + text.length );
		textarea.focus();

	// whateva..
	} else {
		textarea.value += text;
		textarea.focus(textarea.value.length - 1);
	}
}

function addcolor(colorer){
	var color=MM_findObj(colorer);
	color=color.value;
	if(color!=''){
	var ot="["+color+"]";
	var et="[/span]";
	SurroundText("message", ot, et);
	}
}

function addlink(textarea){
var url, linkname;
url=prompt("What is the URL?","http://");
if(url!=null){ linkname=prompt("What is the link name?","My Link"); }
if((url!=null) && (linkname!=null)){
var code="[url="+url+"]name="+linkname+"[/url]";
InsertText(textarea, code);
}
}

function addimg(textarea){
var src, alt;
src=prompt("What is the URL of the image?","http://");
if(src!=null){ alt=prompt("What is the image name?","My Image"); }
if((src!=null) && (alt!=null)){
var code="[img="+src+" alt="+alt+"][/img]";
InsertText(textarea, code);
}
}

function confirmdel(a){
a=MM_findObj(a).value;
var yoz=confirm('Are you sure you want to delete '+a+'?');
if(yoz==true){
document.returndelval=true;
return true;
}
else{
document.returndelval=false;
return false;
}
}

function accadmined(z){/**/
var selectedusr=MM_findObj("selectedusr2").value;
if(selectedusr!=undefined && selectedusr!=""){
	if(z=="edi"){ location.href="accountsadmin.php?action=edi&selectedusr=" + selectedusr; }
	else if(z=="del"){
	var yoz=confirm('Are you sure you want to delete the account of member '+selectedusr+'?');
		if(yoz==true){
		location.href="accountsadmin.php?action=del&selectedusr="+selectedusr;
		}
		else{
		location.href="accountsadmin.php";
		}
	}
}
else { location.href="accountsadmin.php"; }
}/**/

function add(a, word) {
var x=MM_findObj(a);
x.value = word;
//alert('Selected: '+x.value);
}

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_showHideLayers() { //v6.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_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function validatenric(ini){ //validate nric
ini=MM_findObj(ini); 
ini.value=ini.value.toUpperCase();
if(ini.value!=''){/**/
var symbols=new Array("<", ">", "~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "-", "=", "{", "}", "[", "]", "|", "\\", ":", ";", "\"", "'", "?", ",", ".", "/");
var alphebet=new Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
var x,y,w,error=0,k,j;
if(ini.value.length<9){
alert("NRIC "+ini.value+" is invalid!");
ini.value='';
ini.focus();
error=1;
}
if (error==0){//111
for(x=0; x<symbols.length; x++){ //1
if(ini.value.indexOf(symbols[x])>0){ //2
alert("NRIC "+ini.value+" is invalid!");
ini.value='';
ini.focus();
error=1;
break;
} //2
} //1
}//111
if(error==0) { //3
for (y=0; y<=9; y++){//4
j=ini.value.indexOf(y);
if(j==0 || j==8){ //5
alert("NRIC "+ini.value+" is invalid!");  
ini.value='';
ini.focus();
error=1;
break;
} //5
}//4
} //3
if(error==0) { //3
for (y=0; y<=9; y++){//4
j=ini.value.lastIndexOf(y);
if(j==0 || j==8){ //5
alert("NRIC "+ini.value+" is invalid!");  
ini.value='';
ini.focus();
error=1;
break;
} //5
}//4
} //3
if(error==0) { //3
for (w=0; w<alphebet.length; w++){//4
k=ini.value.indexOf(alphebet[w],1);
if(k>0 && k<8){ //5
alert("NRIC "+ini.value+" is invalid!");  
ini.value='';
ini.focus();
error=1;
break;
} //5
}//4
} //3
}/**/ 
} //validatenric


function validatename(ini){ //validate name
ini=MM_findObj(ini);

var restricted=new Array("<", ">", "~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "{", "}", "[", "]", "|", "\\", ":", ";", "\"", "'", "?", ",", ".");
var z;
for(z=0; z<restricted.length; z++){ //1
if(ini.value.indexOf(restricted[z])!=-1){ //2
alert("The name "+ini.value+" is invalid!\n Name can contain A-Z and / only.");
ini.value='';
ini.focus();
break;
} //2
} //1
} //validate name


function MM_validateForm() { //v4.0
/*parameters: R toABC toabc toAbc toaBC isEmail isName isNRIC isNum inRangeX:X */
  var s,pn,domain,sa,i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
//  alert(args.length);
//  blw -2 to get 1st arg tat is element name; i+=3 to get element name in args only
  for (i=0; i<(args.length-2); i+=3) {
//  blw i+2 to test=last.arg.belonging.to.da.element
  test=args[i+2]; val=MM_findObj(args[i]); pn=args[i+1]; //val=element; pn=element.properName
//  blw nm=element.name; val=element.value
    if (val) { nm=val.name; if ((val=val.value)!="") { // if value not blank
//alert(test);
	  var field=MM_findObj(nm);
	  if(test.indexOf('toABC')!=-1){ field.value=val.toUpperCase(); }
	  else if(test.indexOf('toabc')!=-1){ field.value=val.toLowerCase(); }
	  else if(test.indexOf('toAbc')!=-1){
	  var c,str='',sep=val.split(' '); 
	  for(c=0; c<(sep.length); c++){
	  str+=sep[c].charAt(0).toUpperCase();
	  str+=sep[c].substring(1,sep[c].length);
	  str+=" ";
	  }
	  str=str.substring(0,(str.length)-1);
	  if(str.indexOf('S/o')!=-1){ str=str.split('S/o'); field.value=str[0]+"S/O"+str[1]; }
	  else if(str.indexOf('D/o')!=-1){ str=str.split('D/o'); field.value=str[0]+"D/O"+str[1]; }
	  else{ field.value=str; }
	  }
	  else if(test.indexOf('toaBC')!=-1){ val=val.toUpperCase();
	  var sc,sstr='',ssep=val.split(' '); 
	  for(sc=0; sc<(ssep.length); sc++){
	  sstr+=ssep[sc].charAt(0).toLowerCase();
	  sstr+=ssep[sc].substring(1,ssep[sc].length);
	  sstr+=" ";
	  }
	  sstr=sstr.substring(0,(sstr.length)-1);
	  field.value=sstr; }

//	blw condition=-1 if validating for isEmail
      if (test.indexOf('isEmail')!=-1) { // if validate for email

	  sa=val.split(',');
	  for(s=0; s<(sa.length); s++){
//	alert(sa[s]);
	  sa[s]=sa[s].replace(' ', '');
//	alert(sa[s]);
	var regexEmail=/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/;
	  if(sa[s].search(regexEmail)<0 || sa[s]==''){p=0; break;}
	  }
	  
      if (p<1 || p==(val.length-1)) errors+='- '+pn+' must contain an e-mail address or addresses seperated by comma. Avoid extra commas.\n';
      }
//	  blw test!=-1 if validating for isName;
	  else if(test.indexOf('isName') != -1) {
	  var regexName = /^[A-Za-z]+(?: [A-Za-z]+)*(?: [SsDd]\/[Oo] [A-Za-z]+(?: [A-Za-z]+)*)?$/;
	  if (val.search(regexName)<0){
		 errors+='- '+pn+' can contain alphabets, S/O or D/O only. Avoid extra spaces.\n'; }
	    /*var z;
		var restricted=new Array("<", ">", "~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "{", "}", "[", "]", "|", "\\", ":", ";", "\"", "'", "?", ",", ".");		
		for(z=0; z<restricted.length; z++){ //1
		if(val.indexOf(restricted[z])!=-1){ //2
		errors+='- '+pn+' can contain alphabets and / only.\n';
		break;
		} //2
		} //1          
		*/} //isName	 
	  else if(test.indexOf('isNRIC') != -1) {
	  var regexNRIC = /^(?:[A-Za-z][0-9]{7}[A-Za-z])$/;
	  if (val.search(regexNRIC)<0){ errors+='- '+pn+' must be a valid NRIC / FIN.\n'; }
	    } //isNRIC // blw test!=required.only;
	  else if (test!='R' && test.indexOf('isNum')!=-1) { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+pn+' must contain a number.\n';
//	blw condition=-1 if validating for inRange
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+pn+' must contain a number between '+min+' and '+max+'.\n'; 
		  }
	    }
	 }
	 else if (test.charAt(0) == 'R') errors += '- '+pn+' is required.\n'; 
    }
  }
  if (errors) alert('The following error(s) occurred:\n\n'+errors);
  document.MM_returnValue = (errors == '');
}

var gObj,gHex,timer;
function NN_tr_start(obj,hex,type){
var isMoz = parseInt(navigator.appVersion) >= 5 && navigator.appName == 'Netscape' ? true : false;
if (type == 'fade' && !isMoz){gHex=hex;gObj=obj;NN_tr_fadeIn();
} else { obj.style.backgroundColor=hex;}
obj.style.cursor='default';}function NN_tr_fadeIn(){
var cntr=0,pObj=gObj.style.backgroundColor;
var r = parseInt(gHex.substring(1,3),16),g = parseInt(gHex.substring(3,5),16), b = parseInt(gHex.substring(5,7),16);
var rr = parseInt(pObj.substring(1,3),16),gg = parseInt(pObj.substring(3,5),16),bb = parseInt(pObj.substring(5,7),16);
if (r!=rr){if(rr<r){rr++;}else{rr--;}}else{cntr++;}
if (g!=gg){if(gg<g){gg++;}else{gg--;}}else{cntr++;}
if (b!=bb){if(bb<b){bb++;}else{bb--;}}else{cntr++;}
rr=rr.toString(16);gg=gg.toString(16);bb=bb.toString(16);
rr=rr.length==1?'0'+rr:rr;gg=gg.length==1?'0'+gg:gg;bb=bb.length==1?'0'+bb:bb;
gObj.style.backgroundColor='#'+rr.toUpperCase()+gg.toUpperCase()+bb.toUpperCase();
if (cntr!=3){timer=setTimeout('NN_tr_fadeIn()',1);}}function NN_tr_reset(obj,hex){
obj.style.backgroundColor=hex;clearTimeout(timer);}



function validatefilename(ini){ //validate filename
ini=MM_findObj(ini);
var r=true;
var restricted=new Array("<", ">", "*", "|", "\\", ":", "\"", "?", "/");
var rext=new Array("EXE","exe","COM","com","PHP","php","CGI","cgi", "ASP", "asp", "JSP", "jsp", "");
var z,y;
var ext=ini.value.split(".");

for(z=0; z<restricted.length; z++){ //1
if(ini.value.indexOf(restricted[z])!=-1){ //2
alert("File/Folder name cannot contain the symbols:\n< > * | \\ / : ? \"");
ini.focus();
r=false;
break;
} //2
} //1
if(ini.value==''){ r=false; alert('File/Folder name must not be blank!'); ini.focus(); }
else{
var ext1=ext[ext.length-1];
for(y=0; y<rext.length; y++){
if(ext1==rext[y]){ alert('The extension .'+ext1+' is restricted!'); ini.focus(); r=false; break;}
}
}

return r;
} //validate filename


function sendEmail(count){ //sendemail
var re=false;
var ze;
var to=MM_findObj("to");
if(to.value!=''){ to.value=''; }
for(ze=0; ze<count; ze++){ //1
var ini=MM_findObj("cb"+ze);
if(ini.checked==true){ //2
to.value+=ini.value+', ';
re=true;
ini.checked=true;
} //2
} //1
var l=to.value.length;
to.value=to.value.slice(0,(l-2));

if(to.value==''){ alert('Select the checkbox(es) inline with the name \nof the person(s) you prefer to send email to \nand then click Send Email >> .'); }

document.re=re;
} //sendemail


function selectAllvspsls(n){
var i;
for(i=0; i<n; i++){
MM_findObj("cb".concat(i)).checked=true;
}
}
/*
function SS_highlight(trname ,UChex, Chex){
var obj=document.getElementById(trname);
if(obj.style.backgroundColor==Chex){
obj.style.backgroundColor=UChex;
}
else if(obj.style.backgroundColor==UChex){
obj.style.backgroundColor=Chex;
}
}
*/

function SS_highlight(trno ,UChex, Chex){
//alert(trno);
var cbstat=MM_findObj('cb'+trno);
var trcol=document.getElementById('tr'+trno);
//alert(trcol.style.backgroundColor);
if(cbstat.checked==true){ trcol.style.backgroundColor=Chex; }
else if(cbstat.checked==false){ trcol.style.backgroundColor=UChex; }
//alert(trcol.style.backgroundColor);
}

function SS_allHighlight(i ,UChex, Chex){
var trno;
for(trno=0; trno<i; trno++){
var cbstat=MM_findObj('cb'+trno);
var trcol=document.getElementById('tr'+trno);
//alert(trcol.style.backgroundColor);
if(cbstat.checked==true){ trcol.style.backgroundColor=Chex; }
else if(cbstat.checked==false){ trcol.style.backgroundColor=UChex; }
//alert(trcol.style.backgroundColor);
}
}

function SS_radioHighlight(rd, UChex, Chex){
var erd=MM_findObj(rd), n=erd.length, c;
for(c=0; c<n; c++){
var etr=document.getElementById('tr'+c);
//alert('Radio '+c+': '+erd[c].checked);
if(erd[c].checked==true){ etr.style.backgroundColor=Chex; }
else { etr.style.backgroundColor=UChex; }
//alert('test 2');
}
}

function SS_cb(obj){
var obj=MM_findObj(obj);
if (obj.checked==true){ obj.checked=false; }
else if (obj.checked==false){ obj.checked=true; }
}

function usr(n){a='forum/memview.php?us='+n;dd=window.open(a,'usr','height=355,width=312,resizable=0');dd.focus()}

//-->

