if (navigator.appVersion.indexOf("Mac") !=-1 && navigator.appName=="Microsoft Internet Explorer"){
document.write('<style>.searchBox {COLOR: black; BACKGROUND-COLOR: white;font-family:arial,helvetica,sans-serif;font-size:10px;line-height:10px;width:50px;height:13px;border-style:none;vertical-align:top;margin-top:2px;margin-bottom:2px;margin-left:2px;margin-right:2px;}.radio{height:12px;line-height:10px;}.clear-radio{height:12px;line-height:10px;}.checkbox-13{height:13px;}</style>');
} 
else if (navigator.appVersion.indexOf("Mac") !=-1){
document.write('<style>.searchBox {COLOR: black; BACKGROUND-COLOR: white;font-family:arial,helvetica,sans-serif; font-size:10px;line-height:12px;vertical-align:top;}.radio{height:12px;line-height:10px;}.clear-radio{height:12px;line-height:10px;}.checkbox-13{height:13px;}</style>');
}
else if (document.layers && !document.getElementById){
document.captureEvents(Event.KEYPRESS) 
document.write('<style>.searchBox {COLOR: black; BACKGROUND-COLOR: white;font-family:arial,helvetica,sans-serif; font-size:10px;line-height:12px;vertical-align:top;}.radio{background-color:#EEF2FB;color:#EEF2FB;height:10px;line-height:10px;}.clear-radio{height:12px;line-height:10px;}.checkbox-13{height:13px;}</style>');
}
else if (document.getElementById && !document.all){
document.write('<style>.searchBox {COLOR: black; BACKGROUND-COLOR: white;font-family:arial,helvetica,sans-serif; font-size:10px;line-height:10px;vertical-align:top;height:18px;width:60px;}.radio{height:12px;line-height:10px;}.clear-radio{height:12px;line-height:10px;}.checkbox-13{height:13px;}</style>');
}
else if (document.all){
document.writeln('<style>.searchBox {COLOR: black; BACKGROUND-COLOR: white;font-family:arial,helvetica,sans-serif;font-size:10px;line-height:10px;width:50px;height:13px;border-style:none;vertical-align:top;margin-top:2px;margin-bottom:2px;margin-left:2px;margin-right:2px;}.radio{background-color:#EEF2FB;color:#EEF2FB;height:10px;line-height:10px;}.clear-radio{height:12px;line-height:10px;}.checkbox-13{height:13px;}</style>');
}


/**
 * Limits the amount of text in the specified text area (formName.textAreaName) to 'maxLength'
 * number of characters.
 * 
 * @param formName the form that contains the text area
 * @param textAreaName the text area to check
 * @param counterName the counter form field to update
 * @param maxLength the maximum number of characters allowed in the form field.
 */
function countText( formName, textAreaName, counterName, maxLength , hiddenMessageText) {

	currentLength = eval( 'document.'+formName+'.'+textAreaName+'.value.length' );
	if(hiddenMessageText && currentLength != maxLength){
	  eval( 'document.' + formName + '.elements[\"'+hiddenMessageText + '\"].value = ' + currentLength );  
    }
	// If the user entered more than 'maxLength' characters, truncate the string
	if ( currentLength >= maxLength ) {
		eval( 'document.'+formName+'.'+textAreaName+'.value = document.'+formName+'.'+textAreaName+'.value.substr( 0, '+maxLength+')' );
	}

	// Update the value of the counter field
	eval( 'document.'+formName+'.'+counterName+'.value = ' + maxLength + ' - document.'+formName+'.'+textAreaName+'.value.length' );      
}

function changeUrl( form, newFormAction, selectOptionToChangeOn, optionSelected ) {
	alert("current form action: " + form.action);
	alert("new form action: " + newFormAction);
	alert("selectOptionToChangeOn = " + selectOptionToChangeOn);
	alert("optionSelected = " + optionSelected);
	if(selectOptionToChangeOn == optionSelected) {
		form.action = newFormAction;
		alert("current form action: " + form.action);
		form.submit();
	}
}

function defaultTreeItem(divId , childDivId) {
	collapseExpand(divId);
	if(childDivId != 'null' && childDivId != 'childDiv') {
		
		if(document.getElementById(childDivId) != null )  {
			document.getElementById(childDivId).style.fontWeight = 'bold';
		}
	}
	
}

function collapseExpand(divId) {
	var styleClassName='';
	if(divId != 'null' && divId != 'subDiv') {
		var mainDivId = "mainDiv" + divId ;
		
		if(document.getElementById(divId) != null ) {
			if(document.getElementById(divId).style.display == 'block') {
				document.getElementById(divId).style.display ='none';
				if(document.getElementById(mainDivId).className == 'first contract') {
					styleClassName = 'first expand';
				} else if(document.getElementById(mainDivId).className == 'last contract') {
					styleClassName = 'last expand';
				}else {
					styleClassName = 'expand';
				}
				document.getElementById(mainDivId).className =styleClassName;
			} else {
				document.getElementById(divId).style.display ='block';
				if(document.getElementById(mainDivId).className == 'first expand') {
					styleClassName = 'first contract';
				} else if(document.getElementById(mainDivId).className == 'last expand') {
					styleClassName = 'last contract';
				}
				else {
					styleClassName = 'contract';
				}
				document.getElementById(mainDivId).className =styleClassName;
			}
		}	
	}
	
}

function setUserAgent(userAgentVar) {
	if(userAgentVar != null) {
		userAgentVar.value = navigator.userAgent;
	}
}

function submitWebServicesForm(form , formName) {
var eventName = eval('document.'+ formName +'.eventName.value');
var selectedValue = eval('document.'+ formName +'.emailSubject.value');
	if(eventName == "passwordHelp" && selectedValue != "Password / Site Login") {
		form.action = "/contactAA/forwardPasswordHelpFormSubmit.do?eventName=passwordHelp&forwardForm=true";
		form.submit();
	} else if(eventName == "webServices" && selectedValue == "Password / Site Login") {
		form.action = "/contactAA/forwardWebServicesFormSubmit.do?eventName=webServices&forwardForm=true";
		form.submit();
	}	
}

