/*
 * HiDef Global Library
 * 
 * An assortment of global functions
 * 
 * Eric Mills
 * February 2009
 */
// Easy alias for conducting JSON AJAX via POST
$.postJSON = function(url, data, callback){$.post(url, data, callback, "json");};
// Simple replace() alias
$.fn.replace = function(o) { return this.before(o).remove(); };
// Returns a complete url from the root of the web server
function rootUrl(url){ return $hidef.rootUrl + url; }
function isAnalyticsEnabled(){ return ($hidef.analytics.enabled === "true") ? true : false; }
function isPixelsEnabled(){ return ($hidef.pixels.enabled === "true") ? true : false; }
function isDebugEnabled(){ return $hidef.debug }
function debugLog(data){
	if( isDebugEnabled() ){
		if (typeof console !== "undefined") { console.log(data);}
		else{ alert(data); }
	}
}
// Switch the provided image dom to an animated activity icon
function activityIconSmall(img){
	img.unbind();
	img.attr("alt", "Processing...").attr("src", rootUrl("/images/activity/activity-button-small.gif")).css('cursor','default');
}
function activityIconLarge(img){
	img.unbind();
	img.attr("alt", "Processing...").attr("src", rootUrl("/images/activity/activity-button-large.gif")).css('cursor','default');
}
function determineTimeZone() {
	var now = new Date();
	var jan1 = new Date(now.getFullYear(), 0, 1, 0, 0, 0, 0);
	var temp = jan1.toGMTString();
	var jan1gmt = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
	var hoursDiff = (jan1 - jan1gmt) / (1000 * 60 * 60);
	return hoursDiff;
}