//Steve Holmes Jan 2008 //
//Write debug information to firebug console (http://www.getfirebug.com/) if available//

//use query string to set/unset a cookie to drive debugging//
if (self.location.search.indexOf("debug=true")!=-1){
 	var myCookie = "";
 	// Set up a cookie expiry date 1000 years hence
	var expires = new Date();
	var expiryDate = "";
	expires.setYear(expires.getFullYear() + 1000);
	expires.setTime(expires.getTime());
	expiryDate += expires.toGMTString();
 	myCookie= "debug=true;expires="+expiryDate+";path=/"; 
 	document.cookie=myCookie;
}
if (self.location.search.indexOf(debug=false)!=-1){
	document.cookie="debug=false;path=/"; 
}

//write debug to the firebug console if available//
debug = function(msg){
	//var DEBUG = 0;
	var DEBUG= document.cookie.indexOf("debug=true");
	if (DEBUG!=-1){
		try {
		console.log(msg);
		}catch(exception){
		//Nothing in here, this is just to prevent IE throwing a hissy fit
		}
	}
}

