ns4 = document.layers;
ie4 = document.all;
nn6 = document.getElementById && !document.all;

// set to true by addDefalutText
clearOnFocus = false;

/*
	Hide the specified info popup
*/
function hideInfoPopup(popupID) {
  $('infoPopupWrapper' + popupID).fade('out');
}

/*
	display the info popup and position it correctly in relation to the info icon
*/
function showInfoPopup(popupID, event) {
	var myEvent = new Event(event);
	var infoIcon = $('infoPopupWrapper' + popupID);
	
	infoIcon.setStyle('top', (myEvent.page.y - infoIcon.getHeight())+ 'px');
	infoIcon.setStyle('left', myEvent.page.x + 'px');

	infoIcon.set('tween', {duration: 'short'});
	infoIcon.fade('hide');
	infoIcon.fade('in');
}


//adds the specificed default value to an input field if it's blank
function addDefaultText(inputFieldID, defaultValue) {
	inputField = document.getElementById(inputFieldID);
	
	if(inputField.value == undefined || inputField.value == "" || inputField.value == "670000000000000000" || inputField.value == "0000000000000000") {		
		inputField.value = defaultValue;
		inputField.style.color = "#cccccc";
		clearOnFocus = true;
	}
}

//clear out a default value if one was previously added
function clearDefaultValue(inputFieldID) {
	if(clearOnFocus == true) {
		clearOnFocus = false;
		inputField.style.color = "#000000";
		inputField.value = "";
	}
}

//disable double click
function disableSubmit(whichButton)
{
    if (document.getElementById)
    {
        // this is the way the standards work
        document.getElementById(whichButton).onclick = function(){return false;};
        return true;
    }
    else if (document.all)
    {
        // this is the way old msie versions work
        document.all[whichButton].getElementById(whichButton).onclick = function(){return false;};
        return true;
    }
    else if (document.layers)
    {
        // this is the way nn4 works
        document.layers[whichButton].getElementById(whichButton).onclick = function(){return false;};
        return true;
    }
}


//selects balance alert checkbox if any values are entered in it's form fields
function checkWeeklyAlertCheckboxes(){
	//check balance alert
	if ((document.getElementById('weekly_id').value != -1) && (document.getElementById('time_id').value != -1)) {
		document.getElementById('weeklyCheckbox').checked = true;
	}
}	
	
//selects trigger alert checkbox if any values are entered in it's form fields
function checkBalanceAlertCheckboxes(){	
	//check 'less than' alert
	if(document.getElementById('lessThan').value.length > 0) {
		document.getElementById('lessThanCheckbox').checked = true;
	}
	
	//check 'more than' alert
	if(document.getElementById('moreThan').value.length > 0) {
		document.getElementById('moreThanCheckbox').checked = true;
	}
}

