/*	-----------------------------------------------------------------------	
	Copyright:	umlungu consulting (pty) ltd
	Author:		Alan Benington
	Started:	2008-02-08
	Status:		live
	Version:	2.0.0
	Build:		20080706
	License:	GNU General Public License
	-----------------------------------------------------------------------	*/
	try {
		var x_form = new ClassFormX(x_debug);
		var x_valid = new ClassValidX(x_debug);
	} catch(e) {
		alert("loading error(x_form): "+e.description);	
	}
	
/*	-----------------------------------------------------------------------	
	ClassFormX:	Page javascript class
	-----------------------------------------------------------------------	*/
function ClassFormX(dbg) {
	/*	-------------------------------------------	*/
	/// <remarks>Properties: Public</remarks>
	/*	-------------------------------------------	*/
	this.parameter = "";
	/*	-------------------------------------------	*/
	/// <remarks>Properties: Private</remarks>
	/*	-------------------------------------------	*/
	var _self = this;	// self allows for a method/property to be called internally
	var _debug = (dbg)? dbg : false;
	var _id = "ClassSiteForm";
	var _frm;
	/*	-------------------------------------------	*/
	/// <remarks>Region: Accessor methods</remarks>
	/*	-------------------------------------------	*/
	this.GetForm = function() { return(_frm); };
	/*	-------------------------------------------	*/
	/// <remarks>Region: Public methods</remarks>
	/*	-------------------------------------------	*/
	this.KeyPress = _KeyPress;
	this.Check = _Check;
	this.Validate = _Validate;
	this.Submit = _Submit;
	this.Previous = _Previous;
	this.ShowHint = _ShowHint;
	this.Clear = _Clear;
	this.SetEmailConfirm = _SetEmailConfirm;
	this.CalcDate = _CalcDate;
	this.SelectCheck = _SelectCheck;
	this.SetDrop = _SetDrop;
	this.ShowBox = _ShowBox;
	this.SetCheck = _SetCheck;
	this.UpdateValue = _UpdateValue;
	this.Compare = _Compare;
	this.SubmitOnce = _SubmitOnce;
	this.EnableButton = _EnableButton;
	this.SetRadio = _SetRadio;
	this.SetValue = _SetValue;
	this.SetVisibility = _SetVisibility;
	this.SetHidden = _SetHidden;
	this.SetVisibile = _SetVisibile;
	this.SetHiddenSubmit = _SetHiddenSubmit;
	this.SetSmsRemain = _SetSmsRemain;
	///  Method:_SetHiddenSubmit
	function _SetHiddenSubmit(frm, fl, vl){//form obj field id value 
		_Debug("_Set:", "fm", frm, "fl", fl, "vl", vl);
		if (typeof(frm)=="string") {
			_frm = _getFormByName(frm);
		} else{//assume frm is object of type form 
			_frm = frm;	
			frm = _frm.name;
		}
		var fld = document.getElementById(fl);
		if (fld)
			fld.value = vl;
		_frm.submit();
	}
	///  Method:_KeyPress
	function _KeyPress(frm) {
		var ky;
		if (window.event) {
			ky = window.event.keyCode;
			if (window.event.srcElement.type == "textarea")
				return true;
		} else if (!frm.name)
			return false;
		else 
			return true;
			
		if (ky == 13) {
			switch(frm.name) {
			    case "loginForm":			_Check(frm, "inline", validateLogin);	break;
				case "logon_form":			_Check(frm, "login");		break;
				case "contact_form":		_Check(frm, "contact");		break;
				case "feedback_form":		_Check(frm, "feedback");	break;
				case "poll_form":			_Check(frm, "poll");		break;
				default:					_Check(frm, "default", validateForm);	break;
			}
		}
		return true;
	}
	///  Method:_Check
	function _Check(frm, typ, func) {
		_Debug("_Check", "frm", frm);				
		if (typeof(frm) == "string") {
			_frm = _getFormByName(frm);
		} else {//assume frm is object of type form 
			_frm = frm;	
			frm = _frm.name;
		}
		_Debug("_Check", "name", _frm.name, " type", typ, " function", typeof(func));
		switch (typ) {
			case "login":		if (_ValidateLogin())		{_SubmitOnce(frm); _frm.submit(); }	break;
			case "email":		if (_ValidateEmail())		_SendEmail();	break;
			case "faqs":		if (_ValidateFaqs())		_frm.submit();	break;
			case "contact":		if (_ValidateContact())		{_SubmitOnce(frm); _frm.submit(); }	break;
			case "feedback":	if (_ValidateFeedback())	{_SubmitOnce(frm); _frm.submit(); }	break;
			case "poll":		if (_ValidatePoll())		{_SubmitOnce(frm); _frm.submit(); }	break;
			case "vfaxaction":	if (_ValidateVFax())		{_SubmitOnce(frm); _frm.submit(); }	break;
			case "select":		_frm.submit();	break;
			case "back":		_Previous();	break;
			case "clear":		_Clear();		break;
			case "valid":
			default:			if (typeof(func) != "function")
									_frm.submit(); 	// submit if validate function does not exist
								else {
									self.Validate = func;
									_Debug("_Check:before self.Validate");
									if (self.Validate(_frm, self)) {
										_Debug("_Check", "OK", true);
										_frm.submit();
									} else {
										_Debug("_Check", "OK", false);
									}
								}
								break;
		}
	}
	///  Method:_Submit
	function _Submit(frm, url, chk, typ, nme, prc, id, param) {
		_Debug("_Submit", frm.name, " url:", url);
		_frm = frm;
		var thisurl = url;
		if (typ) {
			thisurl += "&type=" + typ;
			thisurl += "&name=" + nme;
			thisurl += "&process=" + prc;
		}
		if (id)
			thisurl += "&id=" + id;
		if (param)
			thisurl += "&" + param;
		_frm.action = thisurl;
		if (chk)
			_Check(frm, typ);
		else
			_frm.submit();
	}
	///  Method:_Validate
	function _Validate(frm) {
		_Debug("_Validate", "frm", frm.name);
	}
	///  Method:_ValidateFeedback
	function _ValidateFeedback() {
		return (x_valid.Radio(_frm.Feedback, "Please rate us"));
	}
	///  Method:_ValidatePoll
	function _ValidatePoll() {
		_Debug("_ValidatePoll", "_frm", typeof(_frm));
		return (x_valid.Radio(_frm.x_radio_btn, "Please choose a poll option"));
	}
	///  Method:_ValidateVFax
	function _ValidateVFax() {
		_Debug("_ValidateVFax", "_frm", typeof(_frm));
		return (x_valid.Drop(_frm.VirtualFaxAction, "Please choose an action"));
	}
	///  Method:_ValidateLogin
	function _ValidateLogin(){
		_Debug("_ValidateLogin");
		if (!x_valid.Text(_frm.Username, "Please enter your username"))
			return false;
		if (!x_valid.Text(_frm.Pin, "Please enter your password"))
			return false;
		return true;
	}
	///  Method:_ValidateEmail
	function _ValidateEmail(){
		if (!x_valid.Email(_frm.Email_Addr_To, "Please enter the recipients email address"))
			return false;
		if (!x_valid.Text(_frm.Email_From, "Please enter your name or email address"))
			return false;
		if (!x_valid.Text(_frm.Email_Subject, "Please enter the subject of the email"))
			return false;
		return true;
	}
	///  Method:_ValidateFaqs
	function _ValidateFaqs(){
		if (!x_valid.Text(_frm.Name, "Please enter your name"))
			return false;
		if (!x_valid.Email(_frm.Email, "Please enter your email address"))
			return false;
		if (!x_valid.Text(_frm.Cell_No, "Please enter your contact number"))
			return false;
		return true;
	}
	///  Method:_ValidateContact
	function _ValidateContact(){
		if (!x_valid.Text(_frm.Name, "Please enter your name"))
			return false;
		if (!x_valid.Email(_frm.Email, "Please enter your email address"))
			return false;
		if (!x_valid.Text(_frm.Cell_No, "Please enter your contact number"))
			return false;
		return true;
	}
	///  Method:_SendEmail
	function _SendEmail() {
		var act = "nm_email.asp" + document.location.search;
		act = act.replace("siteid=ver5_email", "siteid=ver5_print");
		_frm.action = act;
		_frm.submit();
	}
	///  Method:_Previous
	function _Previous() {
		window.history.back();
	}
	///  Method:_ShowHint
	function _ShowHint(hintelem, hinttext) {
		var thishint = document.getElementById(hintelem);
		if (thishint)
			thishint.innerHTML = hinttext;
	}
	///  Method:_Previous
	function _Clear(frm) {
		if (frm)
			_frm = frm;
		_frm.reset();
	}
	///  Method:_SetEmailConfirm
	function _SetEmailConfirm(fldnme, thischk) {
		var thisfld = document.getElementById(fldnme);
		if (thischk.checked === true) {
			thisfld.disabled = false;
			thisfld.focus();
		} else
			thisfld.disabled = true;
	}
	///  Method:_CalcDate
	function _CalcDate(fldid) {
		thisid = fldid.id;
		var thisdd = document.getElementById(thisid + "_day");
		var thismm = document.getElementById(thisid + "_month");
		var thisyy = document.getElementById(thisid + "_year");
		
		var dd = (thisdd.value == "Date")? "" : thisdd.value;
		var mm = (thismm.value == "Month")? "" : thismm.value;
		var yy = (thisyy.value == "Year")? "" : thisyy.value;
		
		fldid.value = yy + "-" + mm + "-" + dd;
		_Debug("_CalcDate", "fldid", fldid.value);
	}
	///  Method:_SelectCheck
	function _SelectCheck(thisfld, ischeckbox) {
		if (ischeckbox === true) {
			if (thisfld.checked === false) {
				var re = /_check/i;	//	regular expression pattern.
				var fldname = thisfld.name;
				var thisdrop = document.getElementById(fldname.substr(0, fldname.search(re)));
				thisdrop.value = 0;
			}
		} else {
			var thischeck = document.getElementById(thisfld.id + "_check");
			thischeck.checked = (thisfld.value === 0)? false : true;
		}
	}
	///  Method:_SetDrop
	function _SetDrop(val, sel, i_arr, s_ord, s_arr, t_ord, t_arr) {
		_Debug("_SetDrop", "val", val, "t_ord", t_ord);
		var i, t_val, t, cnt;
		for (i=0; i<s_arr.length; i++) {
			if(s_arr[i][1] == val) {
				t_val = s_arr[i][0];
				break;
			}
		}
		for (i=0, cnt=1; i<i_arr.length; i++) {
			if(i_arr[i][s_ord] == t_val) {
				t = setTarget(i_arr[i][t_ord]);
				if (t) {
					sel.options[cnt] = t;
					cnt++;
				}
			}
		}
		sel.options.length = cnt;
		function setTarget(val) {
			for(var i=0; i<t_arr.length; i++) {
				if(t_arr[i][0] == val) {
					//_Debug("setTarget", "2", t_arr[i][2], "1", t_arr[i][1]);
					return (new Option(t_arr[i][2], t_arr[i][1]));
				}
			}
			return(null);
		}
	}
	///  Method:_ShowBox
	function _ShowBox(obj, thisid, thisval) {
		var root = (document.all)? document.all : document;
		var val = (thisval)? obj.value : obj.selectedIndex;
		if (!thisval && val <= 4) {
			root[thisid][0].style.display = 'block';
		} else if (thisval && val == thisval) {
			root[thisid][0].style.display = 'block';
		} else {
			root[thisid][0].style.display = 'none';
		}
	}
	///  Method:_SetCheck
	function _SetCheck(chkName, wantval) {
		var ck = "", ckFld, ckEl, ckEls = document.getElementsByName(chkName);
		for (var i=0; i<ckEls.length; i++) {
			ckEl = ckEls.item(i);
			if (ckEl.type == "hidden")
				ckFld = ckEl;
			else {
				if (wantval)
					ck += (ckEl.checked)? ckEl.value + " " : "-";
				else
					ck += (ckEl.checked)? "yes" : "no";
				if (i!=ckEls.length-1)
					ck+= (wantval)? "" : "|";
			}
		}
		//_Debug("setCheck", "ck", ck);
		if (ckFld)
			ckFld.value = ck;
	}
	///  Method:_UpdateValue
	function _UpdateValue(chkObj, chkName, chkValue) {
		var val = chkName.value.substr(1) * 1;
		val = (chkObj.checked) ? val + chkValue * 1 + 0.0001 : val - chkValue * 1 + 0.0001;
		var str = "R" + val.toString();
		var i = str.indexOf(".");
		chkName.value = str.substr(0, i + 3);
	}
	///  Method:_Compare
	function _Compare(frmName, fldNames, minsel, maxsel) {
		var frm = _getFormByName(frmName);
		var fld = frm.elements[fldNames];
		var cnt = 0;
		for (i=0;i<fld.length;i++) {
			if (fld[i].checked) cnt++;
		}
		if (cnt<minsel) {
			alert("Please select at least " + minsel + " items to compare");
		} else if (cnt>maxsel) {
			alert("Please select up to " + maxsel + " items to compare");
		} else {
			frm.submit();
		}
	}	

	///  Method:_SubmitOnce - disable the submit button after validation.
	function _SubmitOnce(frmName) {
		var frm = _getFormByName(frmName);
		for (var i=0; i<frm.length; i++) {
			var obj = frm.elements[i];
			if(obj.type.toLowerCase()=="button") {
				obj.disabled = true;
				if (obj.style.cursor)	// need this test because of problems with IE5.x
					obj.style.cursor = "not-allowed";
				var found = true;
			}
		}
		if (found)
			window.setTimeout("x_form.EnableButton(x_form.GetForm());", 10000); // need to send global variable x_form.GetForm due to settimeout context
		return false;
	}
	
	///  Method: _EnableButton - re-enables the submit button after a period of time.
	function _EnableButton(frm) {
		for (var i=0; i<frm.length; i++) {
			var obj = frm.elements[i];
			if(obj.type.toLowerCase()=="button") {
				obj.disabled = false;
				obj.style.cursor = "default";
			}
		}
	}
	///  Method: _SetRadio
	function _SetRadio(id, val) { 
		var fl = document.getElementById(id);
		if (fl)
			fl.value = val;
	}
	///  Method: _SetValue
	function _SetValue(fld, val) { 
		_Debug("_SetValue", "fld", fld, "val", val);
		var fl = document.getElementById(fld);
		if (fl) {
			fl.value = val;
			_Debug("_SetValue", "value", fl.value);
		}
	}
	///  Method: _SetVisibility
	function _SetVisibility(vis, elt, fld, nos) { 
		_Debug("_SetVisibility", "vis", vis, "fld", fld, "elt", elt);
		if (vis)
			_SetVisibile(elt, nos);
		else
			_SetHidden(elt, nos);
		var fl = document.getElementById(fld);
		if (fl) {
			fl.value = (fl && !vis)? "n/a" : "";
			_Debug("_SetVisibility", "value", fl.value);
		}
	}
	///  Method: _SetHidden - .
	function _SetHidden(elt, nospace) { 
		_Debug("_SetHidden", "elt", elt, "nospace", nospace);
		var el = document.getElementById(elt);
		if (el) {
			(nospace)? el.style.display = 'none' : el.style.visibility = "hidden";
		}
	}
	///  Method: _SetVisibile - .
	function _SetVisibile(elt, nospace) { 
		_Debug("_SetVisibile", "elt", elt, "nospace", nospace);
		var el = document.getElementById(elt);
		if (el) {
			_Debug("_SetVisibile", "display", (el.style.display), "nospace", nospace);
			(nospace)? el.style.display = 'block' : el.style.visibility = "visible";
		}
	}
	///  Method: _getFormByName - retrieves the form object based on a reference passed.
	function _getFormByName(frmName) {
		var frm = document.getElementById(frmName);
		if (!frm)	// used if the form has a name instead of id
			frm = document.forms[frmName];
		return frm;
	}
	///  Method:_SetSmsRemain
	function _SetSmsRemain(thistxt, thishint) {
		var thiscnt = document.getElementById(thistxt.id + "_count");
		var thismsg = thistxt.value;
		var thislen = thismsg.length;
		if (thislen > 160)
			alert(thishint);
		else
			thiscnt.value = 160 - thislen;
	}
	
	///  Method:_Debug - write debugging message. First param is the method label, followed by name, value pairs
	function _Debug(arg) {
		if (_debug) {
			s = "<!-- ClassSiteForm::";
			s = s.concat(arguments[0], ":");
			var argn = arguments.length;
			for(var i=1; i<argn; i=i+2)
				s = s.concat(arguments[i], ":", arguments[i+1], " ");
			alert(s.concat("-->\n"));
		}
	}
}
/*	=======================================================================	*/
/// <remarks>
/// Class: ClassValidX
/// The ClassValidX object class has the following purpose/function:
///	- supplies client-side properties and methods for 'form' objects
/// </remarks>
/*	-----------------------------------------------------------------------	*/
// 
/// The ClassValidX object class is constructed as follows:
///		var thisobj = new ClassValidX(dbg);
/// - where:
///		- dbg:	debugging switch
/// 
function ClassValidX(dbg) {
	/*	-------------------------------------------	*/
	/// <remarks>Properties: Private</remarks>
	/*	-------------------------------------------	*/
	var _self = this;	// self allows for a method/property to be called internally
	var _debug = (dbg)? dbg : false;
	var _Domains = ["webmail.co.za", "exclusivemail.co.z", "executivemail.co.za", "homemail.co.za", "magicmail.co.za", "mailbox.co.za", "ravemail.co.za", "starmail.co.za", "thecricket.co.za", "thegolf.co.za", "thepub.co.za", "therugby.co.za", "websurfer.co.za", "workmail.co.za"];

	/*	-------------------------------------------	*/
	/// <remarks>Region: Public methods</remarks>
	/*	-------------------------------------------	*/
	this.Text = _Text;
	this.Info = _Info;
	this.Date = _Date;
	this.Password = _Password;
	this.Email = _Email;
	this.EmailDomain = _EmailDomain;
	this.Username = _Username;
	this.Check = _Check;
	this.Radio = _Radio;
	this.Drop = _Drop;
	this.Number = _Number;
	this.Cell = _Cell;
	this.DateRange = _DateRange;
	this.PostalCode = _PostalCode;
	this.ID = _ID;
	this.TextDrop = _TextDrop;
	this.NumDrop = _NumDrop;
	this.Checks = _Checks;
	this.Expiry = _Expiry;
	this.Debug = _Debug;
	
	function _getF(fi) { return $(":text#"+fi).get(0); }
	function _getP(fi) { return $(":password#"+fi).get(0); }
	function _getR(fi) { return $(":radio#"+fi).get(); }
	function _getS(fi) { return $("select#"+fi).get(0); }
	function _getT(fi) { return $("textarea#"+fi).get(0); }
	
	// Method:_Text
	function _Text(fi, ht) {
		var fl = _getF(fi);
		if (!fl.value)
			return _Notify(ht, fl, true);
		return true;
	}
	// Method:_Info
	function _Info(fi, ht) {
		var fl = _getT(fi);
		if (!fl.value)
			return _Notify(ht, fl, true);
		return true;
	}
	// Method:_Date
	function _Date(fi, ht) {
		var fl = _getF(fi);
		if (!fl.value)
			return _Notify(ht, fl, false);
		return true;
	}
	// Method:_Password
	function _Password(fi, ht) {
		var fl = _getP(fi);
		if (!fl.value || fl.value.indexOf(" ")>=0)
			return _Notify(ht, fl, true);
		return true;
	}
	// Method:_Email
	function _Email(fi, ht){
		var fl = _getF(fi);
		validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
		var eml = fl.value;
		if (eml) {
			// search email text for regular exp matches
			if (eml.search(validRegExp) == -1)
				return _Notify(ht, fl, true);
			return true; 
		} else {
			alert(ht);
			return false;
		}
	}
	/// Method:_EmailDomain
	function _EmailDomain(fi, ht){
		var fl = _getF(fi);
		var eml = fl.value;
		if (eml) {
			var ndx, len;
			for (var i=0;i<_Domains.length;i++) {
				len = _Domains[i].length;
				ndx = eml.indexOf(_Domains[i]);
				if (ndx > 0 && eml.length > len)
					return true;
			}
			return _Notify(ht, fl, true);
		} else {
			alert(ht);
			return false;
		}
	}
	// Method:_Username
	function _Username(fi, ht) {
		if (_Email(fi, ht)) {
			var fl = _getF(fi);
			var act = fl.form.action;
			var usrdom = fl.value.substr(fl.value.indexOf("@")+1);
			var pre = act.indexOf(".");
			var sep = act.indexOf("/",7);
			var actpre = act.substr(0, pre+1);
			var actdom = act.substr(pre+1, sep-pre-1);
			var actpst = act.substr(sep);
			if (usrdom != actdom) {
				var ul = actpre.concat(usrdom, actpst);
				fl.form.action = ul;
			}
			return true;
		}
	}
	// Method:_Check
	function _Check(fi, ht) {
		var fl = _getF(fi);
		if (!fl.checked)
			return _Notify(ht, fl, true);
		return true;
	}
	// Method:_Radio
	function _Radio(fi, ht) {
		_Debug('_Radio', "fi",fi);
		var fls = _getR(fi);
		_Debug('_Radio', "fls",typeof(fls));
		_Debug('_Radio', "fls.lengh",fls.length);
		var bChecked = false;
		for (i=0;i<fls.length;i++) {
			if (fls[i].checked)
			   return true;
		}
		alert(ht);
		window.navigate("#" + $(":radio#"+fi).get(0).id);
		return false;
	}
	// Method:_Drop
	function _Drop(fi, ht) {
		var fl = _getS(fi);
		if (fi.selectedIndex === 0)
			return _Notify(ht, fl, true);
		return true;
	}
	
	// Method:_TextDrop
	function _TextDrop(fi, ht) {
		if (_Text(fi, ht) && _Drop(fi+"_drop", ht))
			return true;
		else
			return false;
	}
	
	// Method:_NumDrop
	function _NumDrop(fi, ht) {
		if(_TextDrop(fi, ht) && _Number(fi, ht))
			return true;
		else
			return false;
	}
	// Method:_Number
	function _Number(fi, ht, fic, tyc) {
		var fl = _getF(fi);
		var flc = _getF(fic);
		var validRegExp = /(^-*\d+$)|(^-*\d+\.\d+$)/i;
		var strVal = fl.value;
		var isvalid = true;
		if (strVal) {
			if (strVal.search(validRegExp) == -1)
				isvalid = false;
			else if (flc) {
				var thisval = parseFloat(strVal);
				var chckval = parseFloat(flc.value);
				if (isNaN(thisval) || isNaN(thisval)) 
					isvalid = false;
				else {
					// use tyc (later..)
					if (thisval < chckval)
						isvalid = false;
				}
			}
		}
		else 
			isvalid = false;
		
		if (isvalid)
			return true;
		else
			return _Notify(ht, fl, true);
	}
	// Method:_Cell
	function _Cell(fi, ht) {
		var fl = _getF(fi);
		var retval = (fl.value)? 0 : 1;
		if (!retval) {
			var val = fl.value;
			var cellexp = /[0-9]{10}/;		// NB this will accept more than 10 digits!
			var strtexp = /0[789][123467890]/ ;
			if (cellexp.test(val) && val.length==10) {
				retval = (strtexp.test(val)) ? 0 : 1;
				if (retval)
					ht = ht.concat(" (must start 07, 08 or 09)");
			} else {
				ht = ht.concat(" (must be 10 digits)");
				retval = 1;
			}
		}
		if (retval)
			return _Notify(ht, fl, false);
		else
			return true;
	}
	// Method:_DateRange
	function _DateRange(fi, ht){
		var fl = _getF(fi);
		if (_Radio(fi, ht)) {
			var thischk = "";
			var thisid = "";
			for (i=0;i<fl.length;i++) {
				if (fi[i].checked) {
				   thischk = fl[i].value;
				   thisid = fl[i].id;
				   break;
			   }
			}
			if (thischk == "Date") {
				var thisdate = document.getElementById(thisid + "_date");
				if (_Drop(thisdate, ht)) {
					var thismnth = document.getElementById(thisid + "_month");
					return(_Drop(thismnth, ht));
				}
				else
					return false;
			}
			return true;
		}
		else
			return false;
	}
	// Method:_PostalCode
	function _PostalCode(fi, ht) {
		var fl = _getF(fi);
		var validRegExp = /[0-9]{4,4}/;
		var strVal = fl.value;
		var isvalid = true;
		if (strVal && validRegExp.test(strVal) && strVal.length==4)
			isvalid = true;
		else 
			isvalid = false;
		
		if (isvalid)
			return true;
		else
			return _Notify(ht, fl, true);
	}
	// Method:_ID
	function _ID(fi, ht) {
		var fl = _getF(fi);
		var stripexp = /[()\- ]/g;
		fl.value = fl.value.replace(stripexp, "");
		return _validID(fi, ht);
	}
	// Method:_validID
	function _validID(fi, ht) {
		var fl = _getF(fi);
		var validRegExp = /[0-9]{13,13}/;
		var strVal = fl.value;
		var isvalid = true;
		if (strVal) {
			if (strVal.search(validRegExp) == -1)
				isvalid = false;
			else
				isvalid = (strVal.length == 13);
		}
		else 
			isvalid = false;
		
		if (isvalid)
			return true;
		else
			return _Notify(ht, fl, true);
	}
	// Method:_Checks
	function _Checks(fi, ht) {
		var fl = _getF(fi);
		var fld;
		for (var i=0; i<fl.length; i++) {
			fld = fl.item(i);
			if (fid.checked)
				return true;
		}
		return _Notify(ht, fl, false);
	}
	// Method:_Expiry
	function _Expiry(fi, ht) {
		var fl = _getF(fi);
		var validRegExp = /[0-9]{6,6}/;
		var strVal = fl.value;
		var isvalid = true;
		if (strVal && validRegExp.test(strVal) && strVal.length==6)
			isvalid = true;
		else 
			isvalid = false;
		
		return (isvalid)? true : _Notify(ht, fl, true);
	}
	// Method:_Notify - show validation message, select, set focus.
	function _Notify(hnt, fld, sel) {
		alert(hnt);
		sel = (typeof(sel)!="undefined")? sel : true;
		if (sel && fld.style.visibility == "visible") {
			fld.select();
			fld.focus();
		}
		return false;
	}
	
	// Method:_Debug - write debugging message.
	function _Debug(arg) {
		if (_debug) {
			s = "<!-- ClassValidX::";
			s = s.concat(arguments[0], ":");
			var argn = arguments.length;
			for(var i=1; i<argn; i=i+2)
				s = s.concat(arguments[i], ":", arguments[i+1], " ");
			alert(s.concat("-->\n"));
		}
	}
}
