function ge(ident) {
	try {
		return document.getElementById(ident);
	} catch (error) {
		if (_debug) alert(error);
		return null;
	}
}

function trim(_str) {
    try {
        return _str.replace(/^\s*|\s*$/g, "");
    } catch (error) {
        return _str;
    }
}

//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    } else if(window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP");
    } else {
    	if (confirm("Your browser is unable to handle tampabay.com advanced search functionality.\n\nPress OK to upgrade"))
    		document.location.href='http://www.getfirefox.com/';
    }
}

function isNumeric(strString) {
	if (strString.length == 0)
		return false;

	var strValidChars = "0123456789.-";
	var strChar;
	var _result = true;

	for (i = 0; i < strString.length && _result; i++) {
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
			_result = false;
	}

	return _result;
}

//-- RANTS -------------------------------------------------------------------

var RANT_MAX_LEN = 250;

function hilite(obj, state) {
    obj.style.backgroundColor = (state) ? "FloralWhite" : "Snow";
    return true;
}

function limitRantText(obj) {
    var elem = document.forms['rant'].elements['comment'];
    if (elem.value.length > RANT_MAX_LEN)
        elem.value = elem.value.substring(0, RANT_MAX_LEN);
    else
        document.getElementById("rantCharCount").innerHTML = RANT_MAX_LEN - elem.value.length;
}

function canSubmitRantForm() {
	var _f = document.forms['rant'];

	document.getElementById('rantMessages').innerHTML = '';

	var _name = trim(_f.elements['name'].value);
	var _loc  = trim(_f.elements['location'].value);
	var _rant = trim(_f.elements['comment'].value);

	var _errorMsg = '';

	if (_name == '' || _loc == '' || _rant == '') {
		_errorMsg += 'Please address the following:<ul>';

		if (_name == '')
			_errorMsg += '<li>Please enter your name</li>';
		if (_loc == '')
			_errorMsg += '<li>Please enter your location</li>';
		if (_rant == '')
			_errorMsg += '<li>Please enter a comment</li>';

		_errorMsg += '</ul>';

		document.getElementById('rantMessages').innerHTML = _errorMsg;
		return false;
	}

	return true;
}

function unhideRantBox() {
	document.getElementById('story-rant-submit-container').style.display = "none";
	document.getElementById('story-rant-form-container').style.display = "block";
}

function unhideEmailBox() {
	document.getElementById('story-email-message-container').style.display = "none";
	document.getElementById('story-email-form-container').style.display = "block";
}

