// div click
function logoClick(){
	location.href="/";	
}

String.prototype.trim=function() {
     return this.rtrim().ltrim()
}
String.prototype.ltrim=function() {
     return this.replace(/^\s*/,'')
}
String.prototype.rtrim=function() {
     return this.replace(/\s*$/,'')
}
													
function cleanInputString(theInput,replaceType){
	// replaceType: 0:alphanumeric no-case
	//              1:numeric
	//              2:alpha no-case
	//              3:alpha lower
	//              4:alpha upper
	// 				5:alphanumeric no-case with special char
	// 				6:numeric with special char
	var validCharUpperList = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var validCharLowerList = "abcdefghijklmnopqrstuvwxyz";
	var validNumberList = "0123456789";
	var validSpecialCharList = "@._-";
	var validSpaceToList = " ";
	var validList = "";
	var returnVar = "";
	switch(replaceType){
		case 0: validList = validNumberList + validCharLowerList + validCharUpperList; break;
		case 1: validList = validNumberList; break;
		case 2: validList = validCharLowerList + validCharUpperList; break;
		case 3: validList = validCharLowerList; break;
		case 4: validList = validCharUpperList; break;
		case 5: validList = validNumberList + validCharLowerList + validCharUpperList + validSpecialCharList; break;
		case 6: validList = validNumberList + validCharLowerList + validCharUpperList + validSpaceToList; break;
		case 7: validList = validNumberList + validCharLowerList + validCharUpperList + validSpecialCharList + validSpaceToList; break;
		case 8: validList = validNumberList + "-"; break;
	}
	try{
		for (i = 0; i < theInput.length; i++){
			if (validList.indexOf(theInput.charAt(i)) != -1){
				returnVar += theInput.charAt(i);
			}
		}
	}
	catch(e){}
	return returnVar;
}


// formats the input field for a warning event
function warnInputField(formFieldNameID, formFieldLabelId){
	document.getElementById(formFieldNameID).style.paddingLeft='2px';	
	document.getElementById(formFieldNameID).style.paddingTop='1px';
	document.getElementById(formFieldNameID).style.paddingBottom='2px';
	document.getElementById(formFieldNameID).style.backgroundColor='#ffaaaa';
	document.getElementById(formFieldNameID).style.border='1px';
	document.getElementById(formFieldNameID).style.borderStyle='solid';
	document.getElementById(formFieldNameID).style.borderColor='red';
	document.getElementById(formFieldNameID).style.fontSize='12px';
	warnFormFieldName(formFieldLabelId);	
}

// formats field name header where error occurred
function warnFormFieldName(formFieldNameID){
	obj_1=document.getElementById(formFieldNameID);
	obj_1.style.color='red';
	obj_1.style.fontWeight='bold';
}
											
// auto advance used for phone, etc
function advanceToNext(x,y,z){
	//alert(eval(y).value.trim().length)
	try{
		if(eval(y).value.trim().length == x){
			eval(z).focus();
		}
	}
	catch(e){}
}

function getCalendarDate(){
   var months = new Array(13);
   months[0]  = "January";
   months[1]  = "February";
   months[2]  = "March";
   months[3]  = "April";
   months[4]  = "May";
   months[5]  = "June";
   months[6]  = "July";
   months[7]  = "August";
   months[8]  = "September";
   months[9]  = "October";
   months[10] = "November";
   months[11] = "December";
   
   var days = new Array(8);
   days[0]  = "Sunday";
   days[1]  = "Monday";
   days[2]  = "Tuesday";
   days[3]  = "Wednesday";
   days[4]  = "Thursday";
   days[5]  = "Friday";
   days[6]  = "Saturday";
   var now         = new Date();
   var monthnumber = now.getMonth();
   var monthname   = months[monthnumber];
   var monthday    = now.getDate();
   var year        = now.getYear();
   var dayId       = now.getDay();
   var dayName     = days[dayId];
   var dateString = dayName + 
   					', ' + 
					monthname +
                    ' ' +
                    monthday +
                    ', ' +
                    year;
   return dateString;
} // function getCalendarDate()

function getClockTime(){
   var now    = new Date();
   var hour   = now.getHours();
   var minute = now.getMinutes();
   var second = now.getSeconds();
   var ap = "AM";
   if (hour   > 11) { ap = "PM";             }
   if (hour   > 12) { hour = hour - 12;      }
   if (hour   == 0) { hour = 12;             }
   if (hour   < 10) { hour   = "0" + hour;   }
   if (minute < 10) { minute = "0" + minute; }
   if (second < 10) { second = "0" + second; }
   var timeString = hour +
                    ':' +
                    minute +
                    ':' +
                    second +
                    " " +
                    ap;
   return timeString;
} // function getClockTime()

function charFormItemCount(maxCount,formItem,spanIdName){
var currCount = 0;
var remainingCount = 0;
try{
	currCount = formItem.value.length;
	remainingCount = maxCount;
	remainingCount = remainingCount - currCount;
	if(remainingCount < 0){
		formItem.value = formItem.value.substring(0,maxCount);
		remainingCount = 0;
	}
}
catch(e){}
document.getElementById(spanIdName).innerHTML = remainingCount;
}

