	function validateDate(item,time){
		try{
			if(current_year==1){

			}
		}catch(e){
			current_year=2008;
		}
		if(time==1){
				var date=item.value;
				var temp=date.split("/");
				if(date==""){
					
				}else if(temp.length < 3){
					alert("Invalid Date. Please use format mm/dd/yyyy - hh:mm PM");
					item.value="";
				}else{
					temp2=temp[2].split(" - ");
					if(temp2.length!=2){
						validateDate(item);
						item.value=item.value + " - 12:00 PM";
					}else{
						temp3=temp2[1].split(":");
						if(temp3.length!=2){
							validateDate(item);
							item.value=item.value + " - 12:00 PM";
						}else{
							temp4=temp3[1].split(" ");
							if(temp3.length!=2){
								validateDate(item);
								item.value=item.value + " - 12:00 PM";
							}else{
								temp[0]=parseInt(temp[0],10);
								temp[1]=parseInt(temp[1],10);
								temp[2]=parseInt(temp2[0],10);
								temp[3]=parseInt(temp3[0],10);
								temp[4]=parseInt(temp4[0],10);
								temp[5]=temp4[1];


								if(temp[0] < 1){
									temp[0]=1;
								}else if(temp[0] > 12){
									temp[0]=12;
								}
								if(temp[2].toString().length==2){
									if(temp[2] > 40){
										temp[2]="19" + temp[2];
									}else{
										temp[2]="20" + temp[2];
									}
								}else if(temp[2].toString().length==1){
									temp[2]="200" + temp[2];
								}
								
								if(temp[2] < 1900){
									temp[2]=current_year;
								}else if(temp[2] > 2050){
									temp[2]=current_year;
								}

								if(temp[1] < 1){
									temp[1]=1;
								}else if(temp[1] > 31){
									temp[1]=31;
								}
								if(temp[1] > 28){
									switch(temp[0]){
										case 1:
										case 3:
										case 5:
										case 7:
										case 8:
										case 10:
										case 12:
											
										break;
										case 4:
										case 6:
										case 9:
										case 11:
											if(temp[1] > 30){
												temp[1]=30;
											}
										break;
										case 2:
											if(temp[2]%4==0){
												if(temp[1] > 29){
													temp[1]=29;
												}
											}else{
												if(temp[1] > 28){
													temp[1]=28;
												}
											}
										break;
									}
								}
								if(temp[0] < 10){
									temp[0]="0" + temp[0];
								}

								if(temp[3] < 1){
									temp[3]=1;
								}else if(temp[3] > 12){
									temp[3]=12;
								}

								if(temp[3] < 10){
									temp[3]="0" + temp[3];
								}

								if(temp[4] < 0){
									temp[4]=0;
								}else if(temp[4] > 59){
									temp[4]=59;
								}

								if(temp[4] < 10){
									temp[4]="0" + temp[4];
								}

								if(temp[5]=="AM" || temp[5]=="am" || temp[5]=="A" || temp[5]=="a" || temp[5]=="Am" || temp[5]=="aM"){
									temp[5]="AM";
								}else{
									temp[5]="PM";
								}
								

								item.value=temp[0] + "/" + temp[1] + "/" + temp[2] + " - " + temp[3] + ":" + temp[4] + " " + temp[5];
							}
						}
					}
				}
		}else{

				var date=item.value;
				var temp=date.split("/");
				if(date==""){
					
				}else if(temp.length < 3){
					alert("Invalid Date. Please use format mm/dd/yyyy");
					item.value="";
				}else{
					temp[0]=parseInt(temp[0],10);
					temp[1]=parseInt(temp[1],10);
					temp[2]=parseInt(temp[2],10);


					if(temp[0] < 1){
						temp[0]=1;
					}else if(temp[0] > 12){
						temp[0]=12;
					}
					if(temp[2].toString().length==2){
						if(temp[2] > 40){
							temp[2]="19" + temp[2];
						}else{
							temp[2]="20" + temp[2];
						}
					}else if(temp[2].toString().length==1){
						temp[2]="200" + temp[2];
					}
					
					if(temp[2] < 1900){
						temp[2]=current_year;
					}else if(temp[2] > 2050){
						temp[2]=current_year;
					}

					if(temp[1] < 1){
						temp[1]=1;
					}else if(temp[1] > 31){
						temp[1]=31;
					}
					if(temp[1] > 28){
						switch(temp[0]){
							case 1:
							case 3:
							case 5:
							case 7:
							case 8:
							case 10:
							case 12:
								
							break;
							case 4:
							case 6:
							case 9:
							case 11:
								if(temp[1] > 30){
									temp[1]=30;
								}
							break;
							case 2:
								if(temp[2]%4==0){
									if(temp[1] > 29){
										temp[1]=29;
									}
								}else{
									if(temp[1] > 28){
										temp[1]=28;
									}
								}
							break;
						}
					}
					if(temp[0] < 10){
						temp[0]="0" + temp[0];
					}
					if(temp[1] < 10){
						temp[1]="0" + temp[1];
					}
					item.value=temp[0] + "/" + temp[1] + "/" + temp[2];
				}
			}
	}


	function isHex(which,form){
		var undef;
		if(form==undef){
			form="form1";
		}
		var f=document[form];

		var checkOK = "ABCDEFabcdef0123456789";
		var checkStr = f[which].value;
		var allValid = true;
		for (i = 0;  i < checkStr.length;  i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++)
				if (ch == checkOK.charAt(j))
					break;
			if (j == checkOK.length)
			{
				allValid = false;
				break;
			}
		}
		if (!allValid)
		{
			alert("Hex codes may only contain numbers and the letters A through F." );
			f[which].value=document.form1[which + "_default"].value;
			document.getElementById(which + "Row").style.backgroundColor=document.form1[which + "_default"].value;
		}
		
		// require at least 5 characters in the password field
		if (checkStr.length != 6)
		{
			alert("Hex codes must be 6 characters in length." );
			f[which].value=document.form1[which + "_default"].value;
			document.getElementById(which + "Row").style.backgroundColor=f[which + "_default"].value;
		}

		document.getElementById(which + "Row").style.backgroundColor=checkStr;
		f[which + "_default"].value=checkStr;
	}
		
	function parseMe(something,parse,min,max){
		var temp;
		if(parse=='int'){
			something.value=parseInt(something.value);
		}else if(parse=='float'){
			something.value=parseFloat(something.value);
			//alert(something.value);
			something.value *= 100;
			//alert(something.value);
			something.value=parseInt(something.value);
			//alert(something.value);
			something.value = something.value/100;
			//alert(something.value);
		}else{
			something.value=parseInt(something.value);
		}	
		if(something.value=="NaN" || something.value=="Na" || something.value=="N"){
			something.value=0;
		}
		if(min == temp){
			min=0;
		}
		if(max == temp){
			max=99999999999;
		}
		//alert(something.value + " " + min + " " + max);
		if(something.value < parseFloat(min)){
			//alert(something.value + " < " + min);
			something.value=min;
		}
		if(something.value > parseFloat(max)){
			//alert(something.value + " > " + max);
			something.value=max;
		}
		if(parse=='float'){
			something.value=currency(something.value);
		}


	}

	function getFormGroup(name) {
			return document.getElementsByName(name);
	}

	function getRadio(name) {
		elements = getFormGroup(name);
		if (elements)/* loop over all the radio buttons */
			for (i = 0; i < elements.length; i++)
				if (elements[i].checked)
					return elements[i];/* either no group by that name was foundor none were selected */
		return null;
	}

	function getRadioValue(name) {
		element = getRadio(name);
			if (element)
				return element.value;/* there must not have been a radio buttonselected */
		return null;
	}

	function clearRadio(name) {
		elements = getFormGroup(name);
		if (elements)
			for (i = 0; i < elements.length; i++)
				if (elements[i].checked)
					elements[i].checked=false;
	}
	function selectRadio(name,val){
		elements = getFormGroup(name);
		if (elements){
			for (i = 0; i < elements.length; i++){
				if (elements[i].value==val){
					elements[i].checked=true;
					break;
				}
			}
		}
	}

	function currency(something2){
		
		newstring="";
		flagStarted=0;
		flagDecimal=0;
		postDecimal=0;
		var something="" + something2;
		for(i=0;i<something.length;i++){
			if((flagStarted!=0 || something.charAt(i)!="0") && postDecimal < 2){
				if(flagDecimal==1){
					postDecimal++;
				}
				if(something.charAt(i)=="."){
					if(flagStarted==0){
						newstring += "0";
					}
					flagDecimal=1;
				}
				flagStarted=1;
				newstring += something.charAt(i);
			}
		}
		if(flagDecimal==0){
			newstring += ".00";
		}else{
			if(postDecimal==0){
				newstring += "00";
			}else if(postDecimal==1){
				newstring += "0";
			}
		}
		
		
		return newstring;
	}

	function isCreditCard(card) {
		len = card.length - 1;

		if ((len > 19) || (len < 0))
			return (false);

		weight = 2;
		card_sum = 0;

		for (i = len - 1;i >= 0 ;i = i - 1)
		{
			digit = card.substr(i,1) - 0;
			digit_sum = digit * weight;
			tens = Math.floor(digit_sum / 10);
			card_sum += tens + (digit_sum % 10);
			if(weight > 1) 
				weight = 1;
			else 
				weight = 2;		
		}
		result = (10 - card_sum % 10) % 10;

		if (result == card.substr(len,1))
			return true;
		else 
			return false;
	}

	//0 is numbers, 1 is letters, 2 is alpha numeric, 3 is alpha numeric with spaces
	function parseFix(something,type){

		curval=something.value;
		type=parseInt(type);
		if(type!=0 && type!=1 && type!=2 && type!=3){
			type=0;
		}		
		if(type==0){
			check="0123456789";
		}else if(type==1){
			check="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		}else if(type==2){
			check="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		}else{
			check="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
		}

		newstring="";

		for(i=0;i<curval.length;i++){
			flag=0;
			for(j=0;j<check.length;j++){
				cur=curval.charAt(i);
				if(cur==check.substr(j,1)){
					flag=1;
				}
			}
			if(flag==1){
				newstring += "" + curval.charAt(i);
			}
		}

		something.value=newstring;
	}

	 var focused_fields=new Array();
	function clearFocused(which,type){
		for(x in focused_fields){
			if(x!=which){
				focused_fields[x]=0;
				document.getElementsByName(x).className=type;
			}
		}
	}
	 function forceFocused(which){
		var found=0;
		for(x in focused_fields){
			if(x==which){
				found=1;
			}
		}
		if(found==0){
			focused_fields[which]=0;
		}
	 }
	  function mouseOver2(field,type){
		  
	   field.className=type + '-hover';
	  
	 }
	 function mouseOut2(field,type){
	   field.className=type;
	 }
	 function mouseOver(field,type){
	   forceFocused(field.name);
	   if(focused_fields[field.name]!=1){
		field.className=type + '-hover';
	   }
	 }
	 function mouseOut(field,type){
	  forceFocused(field.name);
	   if(focused_fields[field.name]!=1){
		field.className=type;
	   } 
	 }
	 function mouseFocus(field,type){
	   forceFocused(field.name);
	   focused_fields[field.name]=1;
	   field.className=type + '-active';
	  // clearFocused(field.name,type);
	 }
	 function mouseBlur(field,type){
	   forceFocused(field.name);
	   focused_fields[field.name]=0;
	   field.className=type;
	 }

	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	var isIE = (navigator.appName.indexOf("Microsoft")!=-1);

	function autoTab(input,len, e) {
		if(isIE){
			len=len+1;
		}
		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 check(e) {
		var key = window.event ? e.keyCode : e.which;
		var keychar = String.fromCharCode(key);
		
		if(key =="8" || key=="0"){ //allow delete key and arrows to pass through
		return true;
		}
		
		reg = /\d/;
		return reg.test(keychar);
	}

	function uberReplace(from,to,string){
		var strReplaceAll = string;
		var intIndexOfMatch = strReplaceAll.indexOf( from);
		while (intIndexOfMatch != -1){
			strReplaceAll = strReplaceAll.replace( from, to )
			intIndexOfMatch = strReplaceAll.indexOf( from );
		}
		return strReplaceAll;
	}

	function scrubFile(field){
		var temp=field.value;
		temp=uberReplace('"','',temp);
		temp=uberReplace('|','',temp);
		temp=uberReplace('?','',temp);
		temp=uberReplace('/','',temp);
		temp=uberReplace('\\','',temp);
		temp=uberReplace('*','',temp);
		temp=uberReplace(':','',temp);
		temp=uberReplace('<','',temp);
		temp=uberReplace('>','',temp);
		field.value=temp;
	}
