	
	function clearInuput(obj,compare) {
		if(obj.value == compare) {
			obj.value = '';
		}
	}
	function checkFRM(frm) {	
		var fail = false;
							
		if(!frm.firstname.value || frm.firstname.value == 'First Name') { alert('Please enter your First Name'); frm.firstname.focus(); return false; }
//		if(!frm.lastname.value || frm.lastname.value == 'Last Name') { alert('Please enter your Last Name '); frm.lastname.focus(); return false; }
		if(!valideml(frm.email)) { alert('Please use a correctly formatted email address'); frm.email.focus(); return false; }			 
											
		if(fail) {
			return false;
		}else {
			document.getElementById('submitb').disabled=true;
			document.getElementById('submitb').value = "Please wait ...";
									
			setTimeout("document.getElementById('submitb').value='SUBMIT';document.getElementById('submitb').disabled=false",31000);
		
			return true;
		}					

	}
	function recheck(msg,obj){
		if(msg)alert(msg);
		
		if(!document.layers)try{obj.select();}catch(e){ }
		return false;
	}
	
	function numbersonly(data){
		val = data.replace(/[^0-9.]/g,"")
		if(!val)return 0;
		else return val;
	}
	function round2(str){
		return Math.round(str * 100) / 100;
	}
	function setAmount(frm) {
		//var num = new Number(frm.amount.value+99);
		var et;
		et =  "$" + CurrencyFormatted(parseFloat(numbersonly(frm.temp_amount.value)) + parseFloat(.35));
		frm.display.value = et; 
		frm.amount.value = et; 

	}
	function CurrencyFormatted(amount){
		var i = parseFloat(amount);
		if(isNaN(i)) { i = 0.00; }
		var minus = '';
		if(i < 0) { minus = '-'; }
		i = Math.abs(i);
		i = parseInt((i + .005) * 100);
		i = i / 100;
		s = new String(i);
		if(s.indexOf('.') < 0) { s += '.00'; }
		if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
		s = minus + s;
		return s;
	}
	function formatAsMoney(mnt) {
		mnt -= 0;
		mnt = (Math.round(mnt*100)/100);
		if(mnt == Math.floor(mnt) ){
			mnt = mnt + '.00';
		}else{
			if  (mnt*10 == Math.floor(mnt*10)){
				mnt = mnt + '0';
			}else{
				mnt = mnt;
			}
		}
		return mnt;
	}
	function formatCurrency(num) {
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + '$' + num + '.' + cents);
	}

	//Makes sure that the entered value is a number
	// use via onKeyPress="checkNum()" on the textbox
	function checkNum(){
		try{
			var carCode = (is.ie) ? window.event.keyCode : this.keyCode;
			if ((carCode < 48) || (carCode > 57)){
				alert('Please enter only numbers.');
				event.cancelBubble = true
				event.returnValue = false;
			}
		}catch(e){
			window.status='JS Exception ('+e+')';	
		}
	}
	function capturekey(e){//on text field
		var key=(typeof event!='undefined')?window.event.keyCode:e.keyCode;
		alert('keycode : '+key);
	}
	/*************
	//on document
	if(navigator.appName!= "Mozilla"){
		document.onkeypress=capturekey;
	}else{
		document.addEventListener("keyup",capturekey,true);
	} 
	*******************/
	
	// use conf to auto confirm the deletion
	function filterWords(data, conf){
		val = data.replace(/[^a-zA-Z0-9.]/g,"");
		if(!val) {
			return 0;
		}else if(val != data) {
			if(conf) {
				if(confirm('We have removed all non-alphanumeric characters from your password. (ex: #$!@ and spaces are not valid)\nPress OK to submit this password\nPress CANCEL to reenter your password')) {
					return val;
				}else {
					return 0;
				}
			}else {
				return val;
			}
		}else {
			return data;
		}
	}
	
	/* send in an id of type button or href to disable submittions, 
	*
	*/
	function sendANDdisable(id,type,frm) {
		
		targ = getEl(id);
		
		switch(type) {
			case 'href': // experminetal, i cant reattch the original onclick
				var oc = targ.onClick;

				targ.onclick=function(){
					alert('Page is currently loading.  Please wait a moment.');
				}
				//setTimeout("getEl('" + id + "').onclick=" + oc,2000);				
				break;
			case 'button':
				targ.disabled=true;
				targ.value='Please wait...';
				setTimeout("targ.disabled=false",6000);
				break;
		}
			
		
		if(frm) {
			getEl(frm).submit();
		}
	}
	
	function preCheck(msg,id,serial,multi,email){
		var targ = '';
		var msgtarg = '';
		var pass = true;
		
		if(msg && id){
			if(serial) {
				targ = getEl(serial+id);
			}else {
				targ = getEl(id);
			}
						
			if(targ.value) {
				if(email) {
					//val = valideml(serial + id);
					val = valideml(targ);
					
					if(val == 0) {
						if(!msg) {
							msg = 'Please enter your username as a correctly formatted email address (ex@example.com)';
						}
						pass = false;
					}
				}
			}else {
				pass = false;
			}
			
			if(pass) {
				// check marker
				try {
					msgtarg = getEl('frm['+id+']');	
					inject = msgtarg.innerText;
					msgtarg.innerHTML = '<img src="images/check.gif" width="17" height="16"> ' + inject;
				}catch(e) {}
				
				// Remove Message
				try {
					//message = getEl('frm_msg' + multi);
					//message.innerHTML = '';
					//message.className = 'hide';
				}catch(e) {}
			}else {
				// Display Message
				try {
					message = getEl('frm_msg' + multi);
					message.innerHTML += '<img src="images/x.gif" width="17" height="16"> ' + msg + '<br/>';
					message.className = 'show';
				}catch(e) {
					alert(msg);
				}
				// error marker
				try {
					msgtarg = getEl('frm['+id+']');	
					inject = msgtarg.innerText;
					msgtarg.innerHTML = '<img src="images/x.gif" width="17" height="16"> ' + inject;
				}catch(e) {}
			
			
				targ.focus();
				return false;
			}
		}
		
		return true;
	}
	
	/**
 	*	User friendly multi-select
 	*/
 	function markCheckBox(mode,id,force) {		
		var targ = getEl(mode + '['+id+']');
		targUI = getEl(mode + '_ui['+id+']');
		getEl('confirm_' + mode).checked = true;
		
		if(force == 'check') {							// Force check no matter what 
			targUI.className = 'hand multicheck';
			targ.checked = true;
		}else if(force == 'uncheck') {					// Force uncheck no matter what
			targUI.className = 'hand';
			targ.checked = false;
		}else {											// Auto Toggle check
			if(targ.checked) {							
				targUI.className = 'hand';
				targ.checked = false;
			}else {
				targUI.className = 'hand multicheck';
				targ.checked = true;
			}
		}
		
		///// Update the status to show how many are selected
		targ = getEl('holdData['+mode+']');	// FULL LIST (auto created in functions.inc.php / multiSelect())
		targlen = targ.options.length;
		var cur = 0;		// Currently selected items
		var total = 0;		// Total Items
		for(var o = 0; o < targlen; o++) {
			targSel = getEl(mode + '['+targ.options[o].value+']'); // target selection
			if(targSel.checked == true) {
				cur++;
			}
			total++;	
		}
		var statusTxt = getEl('status['+mode+']');	// Status text
		statusTxt.innerHTML = cur + ' of '+ total + ' selected';
	}
	
	/**
	*	Select a sublist of a list
	*/
	function selectList(new_list,mode,reset) {
		
		// 1. Reset current list
		var targ = getEl('holdData['+mode+']');	// FULL LIST (auto created in functions.inc.php / multiSelect())
		var targlen = targ.options.length;	
		for(var o = 0; o < targlen; o++) {
			markCheckBox(mode,targ.options[o].value,'uncheck');
		}
		
		
		// 2. Check the new_list
		if(!reset) {
			if(!new_list) {	// 3. New list may be the full list (ALL)
				for(var o = 0; o < targlen; o++) {
					markCheckBox(mode,targ.options[o].value,'check');
				}
			}else {			// 4. New list is a specific user created list (developer must create this using function.inc.php singSelect())
				targ = getEl(new_list);
				targlen = targ.options.length;	
				for(var o = 0; o < targlen; o++) {
					markCheckBox(mode,targ.options[o].value,'check');
				}
			}
		}		
	}
