//---------------------------
// Core
function O(){var a=arguments,o=new Object(),i;for(i=0;i<a.length;i+=2)o[a[i]]=a[i+1];return o}
function REg(s,sP){var sRE='new RegExp(';sRE+=((s)?(sP)?'\''+s+'\',\''+sP+'\'':'\''+s+'\'':'')+')';return eval(sRE)} // Regular Expression

oWin=window,oDoc=document;
function Cb(a){return Boolean(a)}
function Cn(a){return Number(a)}
function Cs(a){return String(a)}
function C2(n){var s=Cs(n);return(s.length<2)?'0'+s:Cs(s)}

function Ch(a){return typeof(a)}
function ChS(a){return Ch(a)=='string'}
function ChN(a){return Ch(a)=='number'}
function ChO(a){return Ch(a)=='object'}
function ChF(a){return Ch(a)=='function'}

function O(){var a=arguments,o=new Object(),i;for(i=0;i<a.length;i+=2)o[a[i]]=a[i+1];return o};
b=O('ns4',Cb(oDoc.layers),'ie',Cb(oDoc.all),'dom',Cb(oDoc.getElementById));
b.ns=Cb(b.ns4||(b.dom&&!b.ie)),b.ieDom=Cb(b.ie&&b.dom),b.nsDom=Cb(b.ns&&b.dom);

String.prototype.mask=function(){return this.replace(/\S/g,'*')};
with(Math)var MR=round,MF=floor,MA=abs,ML=log,MM=max,MS=sqrt,ME=exp,MRnd=random,MCos=cos,MSin=sin,MAtan=atan;
if(!window.aOnLoad){
	window.aOnLoad=[];
	aOnLoad[aOnLoad.length]=window.onload;
	window.onload=function(){
		window.loaded = true;
		for(var i=0;i<aOnLoad.length;i++){
			if(aOnLoad[i])aOnLoad[i]();
		}
		window.loaded = true;
	}
}
function addOnLoad(fHandler) {	
	if (ChF(fHandler)) aOnLoad[aOnLoad.length] = fHandler;
}

// String Methods/Extentions
with (String.prototype) {
	String.prototype.Cl=toLowerCase,String.prototype.Cu=toUpperCase,String.prototype.C=charAt,String.prototype.I=indexOf,String.prototype.R=replace,String.prototype.SS=substr,String.prototype.SStr=substring,String.prototype.Sp=split;
}
Number.sF=['th','st','nd','rd'];
Number.prototype.Csf = function(){var s=Cs(this),n=s.length,s1=s.C(n-1),s2=s.C(n-2);return(this>0)?this+Number.sF[(s2!='1'&&s1>0&&s1<4)?Cn(s1):0]:this};
Number.prototype.ChE=function(){return Cb((this%2)==0)};
function getRndN(nMn,nMx){if(ChN(nMn)){if(ChN(nMx))nMx-=nMn;else nMx=nMn,nMn=0}else nMn=0,nMx=100;return MF(MRnd()*nMx)+nMn}

Date.prototype.format=function(sM){
	var aM=['January','February','March','April','May','June','July','August','September','October','November','December'];
	var aD=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
	var sF=sM||'DD-MMM-YY',i,aL='DMYHdhmst'.Sp(''),nLL=aL.length,aT=[],nC=0,oRE_A,oRE_B=/\[(\d+)\]/;
	var nDate=this.getDate(),nM=this.getMonth(),nY=this.getFullYear().toString(),nD=this.getDay(),nTH=this.getHours(),nTM=this.getMinutes(),nTS=this.getSeconds();
	var oF=O();
	oF.d=nDate.Csf();
	oF.D=nDate;
	oF.DD=C2(nDate);
	oF.DDDD=Cs(aD[nD]);
	oF.DDD=oF.DDDD.SStr(0,3);
	oF.M=nM+1;
	oF.MM=C2(oF.M);
	oF.MMMM=Cs(aM[nM]);
	oF.MMM=oF.MMMM.SStr(0,3);
	oF.Y=(nY.C(2)=='0')?nY.C(3):nY.SStr(2,4);
	oF.YY=nY.SStr(2,4);
	oF.YYYY=nY;
	
	oF.H=nTH;
	oF.HH=C2(nTH);
	oF.h=(nTH>12||nTH==0)?MA(nTH-12):nTH;
	oF.hh=C2(oF.h);
	oF.m=nTM;
	oF.mm=C2(nTM);
	oF.s=nTM;
	oF.ss=C2(nTM);
	oF.t=(nTH<12)?'A':'P';
	oF.tt=oF.t+'M';
	
	for(i=0;i<nLL;i++){
		oRE_A=REg('('+aL[i]+'+)');
		while(oRE_A.test(sF))aT[nC]=RegExp.$1,sF=sF.R(RegExp.$1,'['+(nC++)+']')
	}
	while(oRE_B.test(sF))sF=sF.R(oRE_B,oF[aT[RegExp.$1]]);
		
	return sF
};

// Array Extention Methods
//if(!Array.prototype.slice)
Array.prototype.slice=function(nI,nL){var a=[],i,nTL=this.length;nI=nI||0,nL=(nL&&nL<nTL)?nL:nTL;for(i=nI;i<nL;i++)a[a.length]=this[i];return a}
//if(!Array.prototype.splice)
Array.prototype.splice=function(nSI,nD){if(!ChN(nD))nD=this.length-nSI;var aT=this.clone(),aN=[],i,n=nSI+nD;this.length=0;for(i=0;i<nSI;i++)this[i]=aT[i];for(i=n;i<aT.length;i++)this[this.length]=aT[i];return aT.slice(nSI,n)};
Array.prototype.clone=function(){return this.slice()};
Array.prototype.rnd=function(){var a=this.clone(),nL=a.length,aT=[];while(aT.length<nL)aT[aT.length]=a.splice(getRndN(0,a.length-1),1);return aT};
//Array.prototype.contains=function(s,bC,bW){var sA=Cs(this),sC=(bC)?'i':'';if(bW&&s.length<sA.length){var nI=sA.search(RE(s,sC));if(nI>0)s=','+s;if(nI+s.length<sA.length)s+=','}return RE(s,sC).test(sA)};
//Array.prototype.sortByProp=function(sP,bR){return this.sort(function(a1,a2){return(a1[sP]<a2[sP])?(bR)?1:-1:(a1[sP]>a2[sP])?(bR)?-1:1:0})};

// Div Toggle
var sHidden=(!b.ns4)?'hidden':'hide', sSizeProp=(!b.ns4)?'style':'clip';
function showDiv(sId) {
	var oDiv = document.getElementById(sId);
	if (oDiv) oDiv.style.visibility='inherit';
}
function hideDiv(sId) {
	var oDiv = document.getElementById(sId);
	if (oDiv) oDiv.style.visibility=sHidden;
}
function toggleDiv(sId) {
	var oDiv = document.getElementById(sId);
	if (oDiv) oDiv.style.visibility=(oDiv.style.visibility==sHidden)?'inherit':sHidden;
}


function getDivX(sId) {
	var oDiv = document.getElementById(sId), n = 0;
	if (oDiv) {
		n = parseInt(oDiv.style.left || 0);
	}
	return n
}
function getDivY(sId) {
	var oDiv = document.getElementById(sId), n = 0;
	if (oDiv) {
		n = parseInt(oDiv.style.top || 0);
	}
	return n
}
function getDivW(sId) {
	var oDiv = document.getElementById(sId), n = 0;
	if (oDiv) {
		n = ((!b.ns4)? oDiv.offsetWidth : oDiv.clip.width) || 0;
	}
	return n
}
function getDivH(sId) {
	var oDiv = document.getElementById(sId), n = 0;
	if (oDiv) {
		n = ((!b.ns4)? oDiv.offsetHeight : oDiv.clip.height) || 0;
	}
	return n
}
function setDivX(sId, n) {
	var oDiv = document.getElementById(sId);
	if (oDiv) {
		oDiv.style.left=(!b.ns4)?n+'px':n;
	}
}
function setDivY(sId, n) {
	var oDiv = document.getElementById(sId);
	if (oDiv) {
		oDiv.style.top=(!b.ns4)?n+'px':n;
	}
}



var nScrW, nScrH;
with (screen) nScrW=availWidth || width, nScrH=availHeight || height;

//-------------------------
// validate.js

V=O('aV',O(),'aFE',O());
V.FormElm=function(vForm,vFormElm,bReq,sType,errEvt){
	var i,vF=vForm,vE=vFormElm,oF,oFE,sFName,sFEName;
	if(vE&&ChO(vE))oFE=vE,sFName=vE.form.name,sFEName=vE.name;
	else{
		if(vF&&ChO(vF))oF=vF,sFName=vF.name;
		else oF=oDoc.forms[(sFName=vF)];
		if(!oF)return null;
		if(vFormElm&&ChO(vFormElm))oFE=vFormElm,sFEName=oFE.name;
		else sFEName=vFormElm;
		if(oF){
			V.pageLoaded = true;
			if(oF.elements)oFE=oF.elements[sFEName];
			else if(oF.length){
				for(i=0;i<oF.length;i++){
					if(oF[i].elements[sFEName]){
						if(!oFE)oFE=[];
						oFE[oFE.length]=oF[i].elements[sFEName]
					}
				}
			}
		}
	}
	if(!oFE)return null;
	this.elm=oFE;
	this.req=Cb(bReq);
	this.routine=(sType)?V.aV[this.type=sType]:null;
	this.evt=errEvt||null;
	return V.aFE[sFName+'_'+sFEName]=this
};
V.Type=function(sName,sMsg,RE){
	if(!RE)RE=this.RE;if(!ChS(sMsg))sMsg=this.msg;
	if(!sName||!ChS(sName)||!RE)return;
	this.msg=sMsg||'';
	this.RE=RE;
	this.f=(RE.test)?function(s){return V.aV[this.name].RE.test(s)}:function(s,oE){var o=V.aV[this.name];return o.RE(s,o,oE)};
	V.aV[this.name=sName]=this
};
V.overwriteRule=V.addType=function(sName,sMsg,RE){
	new V.Type(sName,sMsg,RE)
};
V.addFormElm=function(sFrm, sFElm, bReq, sType, errEvt){
/*	if (sFElm == 'dlNum') {
		alert(sFElm + ', ' + bReq + ', ' + sType + ', ' + errEvt);
	}*/
	return new V.FormElm(sFrm, sFElm, bReq, sType, errEvt);
	
};
V.FormElm.prototype.overrideDefaultMsg = function(p_sMsg) {
	this.defaultMsgOverride = true;
	this.defaultMsg = p_sMsg || '';
};
V.FormElm.prototype.overrideReqMsg = function(p_sMsg) {
	this.reqMsgOverride = true;
	this.reqMsg = p_sMsg || '';
};
V.validate = function(p_vForm){	

	if (!V.pageLoaded) return false;	
	
	
	if (!p_vForm || (!ChS(p_vForm) && !ChO(p_vForm))) return true;
	
	var oForm			= (ChS(p_vForm))? oDoc.forms[p_vForm] : p_vForm;
	if (!oForm) return false;

	var sForm		= oForm.name;
	var bChecked		= false;
	var sFormElm		= '';
	var sFormElm_type	= '';
	var oFormElm		= null;
	var oFormElmElm		= null;
	var oFormElm_current	= null; // what we are going to end up with
	var nFEEL		= null;
	var nFEEI		= 0;
	
	var sValue		= '';
	var aFormElm		= oForm.elements;
	var nFEL		= aFormElm.length;
	var nFEI		= 0;
	
	var oFE_wrapper		= null;
	var oFE_wrapperElm	= null;
	var sError		= '';
	var bError		= false;
	
	//' loop through form elements
	for (nFEI; nFEI<nFEL; nFEI++) {
		//' grab current element
		oFormElm	= aFormElm[nFEI];
		sFormElm	= oFormElm.name;
		sFormElm_type	= oFormElm.type;
		bChecked	= false; // reset
		sValue		= '';	// reset
		
		//' and its' object
		oFE_wrapper	= V.aFE[sForm + '_' + sFormElm];
	
		if (oFE_wrapper) {
			//' grab the collection if it is a radio or checkbox
			if (sFormElm_type == 'radio' || sFormElm_type == 'checkbox') {
				oFormElm = aFormElm[sFormElm];
				nFEEL = oFormElm.length;
				
				//' now increment the main loop to bypass the elements with the same name
				if (aFormElm[nFEI].name) {
					while (aFormElm[nFEI] && aFormElm[nFEI].name == sFormElm) nFEI++
					nFEI--
				}
				
				// is there is more than one
				if (nFEEL) {
					// and we need to loop through these  .. if there is one
					// selected or not and if so, its' value
					nFEEI	= 0;
					while (nFEEI < nFEEL) {
						oFormElmElm	= oFormElm[nFEEI++]; // grab element
						
						if (oFormElmElm.checked) { // oFormElmElm.form == oForm && <-- cannot rememebr why we do this condition
							sValue = oFormElmElm.value || '';
							bChecked = true;
							oFormElm_current = oFormElmElm; // set the current elm to the selected one
							break;
						}
						// else there is no selected elm, set the current elm to the first element, if any
						if (!bChecked && oFormElm[0]) oFormElm_current = oFormElm[0];
					}
				} else {
					
					// there is only one
					if (oFormElm.checked) {
						sValue = oFormElm.value || '';
						bChecked = true;
						oFormElm_current = oFormElm; // set the current elm to the selected one
						break;
					}
					// else there is no selected elm, set the current elm to the first element, if any
					if (!bChecked && oFormElm) oFormElm_current = oFormElm;
				}
				
			} else {
				oFormElm_current = oFormElm; // the current element is the same
				
				if (oFormElm.options) {
					// if there are options, we need to set the value to the current selected value
					sValue	= oFormElm.options[oFormElm.options.selectedIndex].value || '';
				} else {
					// we are in a normal form element.. grab it's value
					sValue	= oFormElm.value || '';
				}
			}
			
			//' if it is a required element, and it is not selected / there is no value
			if (oFE_wrapper.req) { //' this is a required element
				if (
					((sFormElm_type == 'radio' || sFormElm_type == 'checkbox') && !bChecked) ||
					((sFormElm_type != 'radio' && sFormElm_type != 'checkbox') && !sValue)
				) {
					bError = true;
					if (!oFE_wrapper.reqMsgOverride) {
						sError += 'You must enter data into all of the required fields. (' + sFormElm + ')\n';
					} else if (oFE_wrapper.reqMsg) {
						sError += oFE_wrapper.reqMsg + '\n';
					}
				}
				if (bError) break; // we found an error -- break out of the loop
			}
			if (oFE_wrapper.routine && (sValue || oFE_wrapper.routine.name == 'special')) { //' there is a value (or special) & routine
	
				//'alert("Name: " + oFE_wrapper.routine.name);
	
				if (!oFE_wrapper.routine.f(sValue, oFormElm_current)) { //' do I need to pass in the CurrElm here?
					bError = true;
					
					if (!oFE_wrapper.defaultMsgOverride) {
						// put in default message
						//sError += '"' + ((sFormElm_type != 'password')? sValue : sValue.mask()) + '" is not a valid entry.\n';
					} else if (oFE_wrapper.defaultMsg) {
						// else the default is overridden and there is a new default message
						sError += oFE_wrapper.defaultMsg + '\n';
					}
					sError += oFE_wrapper.routine.msg;
				}
				if (bError) break; // we found an error -- break out of the loop
			}
		}
	}
	
	//' ok, there is an error, lets handle it!
	if (bError) {
		if (ChF(oFE_wrapper.evt)) oFE_wrapper.evt(oFE_wrapperElm);
		
		if (sError) alert(sError);
		
		//' if this is a real element, lets focus it
		if (sFormElm_type != 'hidden') {
			if (b.ns4) {
				if (oFormElm_current.focus) oFormElm_current.focus();
			} else {
				if (oFormElm_current.focus && sFormElm_type != 'text' && sFormElm_type != 'password' && sFormElm_type != 'textarea') oFormElm_current.focus();
				else if (oFormElm_current.select) oFormElm_current.select();
			}
		}
	} else {
		//' we are all good, submit the form
		oForm.submit();
	}
	
	return false
};

// Global value used to turn on and 
// off CC validation
var CC_validation_required_ = true;

// Validation Routines
function CC(p_sValue, p_oFE_wrapper, p_oFE){	
	
	// for development, remove this!
	if (p_sValue == '!16' || p_sValue == '1212121212121212' || p_sValue == '1313131313131313' || CC_validation_required_ == false) return true;
	
	var sCC	= p_sValue.replace(/\D/g, ''), nCL = sCC.length;
	if (nCL < 13 || nCL > 16) return false;
	//' mastercard - 51,52,53,54,55
	//' amex 34,37 <--??
	//' discover 6011 <--??
	var oCC_type = { visa : '4', americanexpress : '37', mastercard : '5', discover : '6' };
	var aCC_type = p_oFE.form.elements.ccTypes;	

	var sCC_type = (aCC_type)? sCC_type = aCC_type.options[aCC_type.selectedIndex].value.toLowerCase() : '';

	if (!oCC_type[sCC_type] || sCC.indexOf(oCC_type[sCC_type])) return false;
	
	var nCI = 1, nTotal = 0, nCC = 0;
	nCL = 16;
	while (sCC.length < nCL) sCC = '0' + sCC;
	while (nCI <= nCL) {
		nCC = Cn(sCC.charAt(nCI-1)) * (1 + (nCI % 2));
		if (nCC > 9) nCC -= 9;
		nTotal += nCC;
		nCI++
	}
	
	return ((nTotal % 10) == 0);
}
function formatPhone(oE) {
    var sV	= oE.value.replace(/\D/g,'');
	var nL	= sV.length;
	if (nL > 10) sV	= sV.substr(0, 10);
		nL = sV.length;
	if (nL >= 1 && sV.charAt(0) == 1) sV = sV.substr(1);
	if (!sV) {
		oE.value = sV;
		return
	}
		nL = sV.length;
	if (nL >= 7) {
		formatPhone.RE.exec(sV);
		oE.value = sV.replace(formatPhone.RE, '($1) $2-$3');
	}
}
formatPhone.RE = /^(\d{1,3})(\d{0,3})(\d{0,4})$/;

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}
	
function containsElement(arr, ele) {
	var found = false, index = 0;
	while(!found && index < arr.length)
	if(arr[index] == ele)
		found = true;
	else
		index++;
	return found;
	}
	
function getIndex(input) {
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
	if (input.form[i] == input)index = i;
	else i++;
	return index;
	}
return true;
}

function formatSSN(oE) {
	var sV	= oE.value.replace(/\D/g, '');
	var nL	= sV.length;
	if (nL > 9) sV = sV.substr(0, 9);
		nL	= sV.length;
	if (!sV) {
		oE.value = sV;
		return
	}
	if (nL >= 6) {
		formatSSN.RE.exec(sV);
		oE.value = sV.replace(formatSSN.RE, '$1-$2-$3');
	}
}
formatSSN.RE	= /^(\d{3})(\d{2})(\d{4})$/;

function formatDLDOB(oE) {
	/*
	var sV	= oE.value.replace(/\D/g, '');
	var nL	= sV.length;
	if (nL > 8) sV = sV.substr(0,8);
		nL	= sV.length;
	*/
	return
}

function formatZip(oE) {
	var sV	= oE.value.replace(/\D/g, '');
	var nL	= sV.length;
	if (nL > 9) sV = sV.substr(0, 9);
		nL	= sV.length;
	if (!sV) {
		oE.value = sV;
		return
	}
	if (nL >= 6) {
		formatZip.RE.exec(sV);
		oE.value = sV.replace(formatZip.RE, '$1-$2');
	}
}
formatZip.RE	= /^(\d{5})(\d{1,4})$/;

V.addType('SSN', 'Please enter a valid social security number.\nSocial security numbers are 9 digits', /^\d{9}$/);
V.addType('routing', 'Please enter a valid routing number.\nBank routing numbers are 9 digits', /^\d{9}$/);
V.addType('CC', 'Please enter a valid credit card number.', CC);
V.addType('alpha','Please enter alpha characters only. (a-z, A-Z)',/^[a-z\s]+$/i);
V.addType('numeric','Please enter numeric characters only. (0-9)',/^\d+$/);
V.addType('alpha_numeric');//,'Please enter alpha-numeric characters only. (a-z, A-Z, 0-9)',/^[a-z0-9\s]+$/i);
V.addType('alpha_numeric_under');//,'Please enter alpha-numeric / underscore characters, only. (a-z, A-Z, 0-9, _)',/^\w+$/i);
V.addType('alpha_numeric_under_dot_comma');//,'Please enter alpha-numeric / underscore characters, only. (a-z, A-Z, 0-9, _,.,,#-)',/^[a-z0-9\s\.\,\#\-\_]+$/i);
V.addType('email','Please enter a valid email address.',/^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,4}(\.[a-z]{2}){0,2})$/i);
V.addType('zip','Please enter a valid zip code.',/(^\d{5}$)|(^\d{5}-\d{4}$)/);
V.addType('npa','Please enter a valid area code.',/(^\d{3}$)/);
V.addType('nxx','Please enter a numeric character.',/(^\d{3}$)/);
V.addType('phone','Please enter a valid phone number.',/^([1](\.|-|\s)?|)(\(\d{3}\)|\d{3})(\.|-|\s)?\d{3}(\.|-|\s)?\d{4}(\.|-|\s)?\d*$/);
V.addType('min1','Please enter a positive integer.',function(s){return Cb(/\d/.test(s)&&Cn(s)>0)});


//-------------------------
// normalizeNS4.js

if (b.ns) {
	// normalize global forms (make forms with the same name accessible as an array)
	NS_getGlobalForms=function(){
		var nFormI, aGlobalForms=document.forms, nFL=aGlobalForms.length;
		var oForm, sFormName;
		var aDuplicateForms=O();	// associative array containing forms that have duplicate names
		var oFormTmp, aFormsTemp;
		
		for (nFormI=0; nFormI<nFL; nFormI++) {
			oForm=aGlobalForms[nFormI];	// current form
			sFormName=oForm.name;		// current form's name
			
			if (sFormName) { // if this form has a name
				// if there isn't already this form in the duplicates array, then add it
				if (!aDuplicateForms[sFormName]) aDuplicateForms[sFormName]=oForm;
				else { // otherwise
					oFormTmp = aDuplicateForms[sFormName];
					if (oFormTmp.name) {
						aFormsTemp=aDuplicateForms[sFormName]=[];
						aFormsTemp[aFormsTemp.length]=oFormTmp; // and add the first form
					}
					aFormsTemp=aDuplicateForms[sFormName];
					aFormsTemp[aFormsTemp.length]=oForm;
				}
			}
		}
		if (b.ns4) {
			for (sFormName in aDuplicateForms) {
				delete document.forms[sFormName];
				document.forms[sFormName]=aDuplicateForms[sFormName];
			}
		} else {
			document.aForms=O();
			for (sFormName in aDuplicateForms) document.aForms[sFormName]=aDuplicateForms[sFormName];
		}
	};
	
	//test for NS6+
	if (b.dom) addOnLoad(NS_getGlobalForms);
	else if(b.ns4){
		NS4_getDivsRecursive=function(aL){
			if(aL){
				var i,nL=aL.length,oL,aT,sId,aAll;
				for(i=0;i<nL;i++){
					if(!oDoc.all[(sId=(oL=aL[i]).id)]){
						aT=oDoc.allTags[(oL.tagName='div')],aAll=oDoc.all;
						aT[aT.length]=aAll[sId]=aAll[aAll.length++]=oL.style=oL
					}
					NS4_getDivsRecursive(oL.document.layers)
				}
			}
		};
		NS4_normalizeElements=function(){
			// extend document element
			oDoc.all=O('length',0);oDoc.allTags=O('form',[],'div',[],'img',[]);
			oDoc.getElementById=function(sId){return this.all[sId]||null};
			oDoc.getElementsByTagName=function(sTagName){return this.allTags[sTagName]||null};
			
			// normalize nested divs
			NS4_getDivsRecursive(oDoc.layers);
			
			var nL=oDoc.all.length,i,ii,nL,aF,nFL,aI,nIL,oElm,sName,aDocF=oDoc.forms,aDocI=oDoc.images,oF_tmp;
			for(i=0;i<nL;i++){ // loop through all div elements' documents
				oL=oDoc.all[i],aF=oL.document.forms,nFL=aF.length,aI=oL.document.images,nIL=aI.length;
				
				// normalize nested forms
				for(ii=0;ii<nFL;ii++){
					aDocF[aDocF.length]=oElm=aF[ii],sName=oElm.name;
					if(!aDocF[sName]){
						aDocF[sName]=oElm;
						//alert('normal: '+oElm.name)
					}else{
						oF_tmp=aDocF[sName];
						if(oF_tmp.name){
							aDocF[sName]=[];
							aDocF[sName][aDocF[sName].length]=oF_tmp;
						}
						aDocF[sName][aDocF[sName].length]=oElm;
						//alert('array: ['+aDocF[sName].length+']'+oElm.name)
					}
				}
				// normalize nested images
				for(ii=0;ii<nIL;ii++){
					oElm=aI[ii],sName=oElm.name;
					if(!aDocI[sName])aDocI[aDocI.length]=aDocI[sName]=oElm
				}
			}
			
			// normalize global forms
			NS_getGlobalForms();
		};
		aOnLoad=new Array(function(){NS4_normalizeElements()}).concat(aOnLoad);
		//'onresize=function(){location.reload()};
	}
}
function getForm(sFormName, nFrmI){
	var oForm = null;
	if (!b.nsDom) {
		oForm = oDoc.forms[sFormName][nFrmI] || null;
		if (!oForm.elements) oForm = oDoc.forms[sFormName] || null;	
	} else {
		var aF = oDoc.aForms;
		oForm = ((aF && aF[sFormName])? aF[sFormName][nFrmI] : oDoc.forms[sFormName]) || null;
	}
	return oForm;
}
function getCheckedValue(p_oElm) {
	var oElm	= null;
	var sValue	= '';
	var nL		= p_oElm.length;
	var nI		= 0;
	while (nI < nL) {
		oElm = p_oElm[nI++]
		if (oElm.checked) {
			sValue = oElm.value || '';
			break;
		}
	}
	return sValue;
}
function getSelectIndexByValue(p_oSel, p_sValue) {
	var nSelectedI	= 0;
	var aOptions	= p_oSel.options;
	var nOL			= aOptions.length;
	var nOI			= 0;
	while (nOI < nOL) {
		if (aOptions[nOI].value == p_sValue) {
			nSelectedI = nOI;
			break;
		}
		nOI++
	}
	return nSelectedI;
}

function popup(vLink, nW, nH) {
	if (!nW) nW = 535;
	if (!nH) nH = 500;
	if (vLink) {
		var sHref = (ChO(vLink) && vLink.href)? vLink.href : (ChS(vLink))? vLink : '';
		if (sHref) window.open(sHref, 'oPopup', 'width=' + nW + ',height=' + nH + ',scrollbars=1'); //,resizable=1
	}
	return false;
}

if (window != top) top.location.href = location.href;
/*
if (self.location.href != top.location.href) {
	top.location.pathname	= self.location.pathname
	if (self.location.search) top.location.search	= self.location.search;
}
*/