


// will return query param info.  format  of URL like this: http://www.a.com?scott=dude&larry=sam
window.GetQueryParam = function(paramName) {
   var re = new RegExp( "[?&]" + paramName + "=([^&$]*)", "i" );
   var offset = window.location.search.search(re);
   if ( offset == -1 ) return null;
   var outStr = unescape(RegExp.$1);
   outStr = outStr.replace('/',''); // path url and strip this
   return outStr;
}

window.SetSourceCookie = function(theValue) {
	SetSecureCookie('source', theValue);
};

window.GetSecureCookie = function(cookieName) {
	var theName = cookieName + "=";
	var nameLength = theName.length;
	var theDocument = this.document;
	var theCookies = theDocument.cookie;
	var startPos = theCookies.indexOf(theName);
	if (startPos < 0) return null;
	var endValue = theCookies.indexOf(";", startPos + nameLength);
	if (endValue == -1) endValue = theCookies.length + 1;
	var returnData = unescape(theCookies.substring(startPos + nameLength, endValue));
	return returnData;
};


window.SetSecureCookie = function(cookieName, theValue) {
	try {
		var today = new Date();
		var expires_date = new Date(today.getTime() + (365 * 1000 * 60 * 60 * 24));	// 1 year
		var cookStr = cookieName + "=" + escape(theValue) + ";expires=" + expires_date.toGMTString() + ";path=/secure";
		var theDocument = this.document;
		theDocument.cookie = cookStr;  // Firefox throws an error here!
	} catch(e) {
	}
};


function SetElementStyle(theElement, theStyle) {
	var element = document.getElementById(theElement);
	if (element) {
		element.className = theStyle ? theStyle : '';
	}
};


function HideShowItem(theItem, show) {
	var theNav2 = document.getElementById(theItem);
	if (theNav2) {
		if (show) {
			theNav2.style.display = 'block';
		} else {
			theNav2.style.display = 'none';
		}
	}
};


function IsValidEMailAddress(theAddress) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return (filter.test(theAddress));
};

