// global vars - this is an example of global vars -
// put this at top of the 'controller' to set the path to the root

var baseURL = window.location.href.match(/:\/\/(.[^/]+)/)[1];
var siteRoot = '';

switch(baseURL){
	case "aapcpublishing.net":
	case "aapctextbooks.net":
	case "asperger.net":
		siteRoot = '/public_html';
		break;
	case "i10midwest.com":
		siteRoot = '/aapcpublishing.net/public_html';
		break;
	default: siteRoot = '';
}
/*
if (window.location.href.indexOf("/aapcpublishing.net/") > 5) {
	var siteRoot = '/public_html';
} else {
	var siteRoot = '';
}
*/

var pathToRoot = ( $("body#sub-page-selectors, #you-can-list-like-this").length ) ? '../' : './';
var aniSpeed1 = 400;
var imageHeight = 0;
//********************
// load/execute Scripts
function loadScript(path) {
	var js = document.createElement('script');
	js.setAttribute('type', 'text/javascript');
	js.setAttribute('src', path);
	js.setAttribute('defer', 'defer');
	window.document.body.appendChild(js);
	return true;
}
//********************
// If you want the convenience of the $ function for jQuery without
// colliding with some other use of the global $ function
(function($) {
	/** log(m, x)
	* @author Russell Madsen
	* @version Jan.2010
	* @param m: The message you are wanting to log - it  could be an object, or string
	* @param x: The logging classification
	**/
	$.log = function(m, x){
		var showMsgs = true;
		//if logging is enabled, allow user to log messages
		if (!showMsgs) {return false;}
		else if('console' in window && console.debug) {
			// Actions for console enabled browsers:
			switch(x){
				case  'debug':	console.debug("[debug] \n"+m);break;
				case  'error':	console.error("[error] \n"+m);break;
				case  'info':	console.info("[info] \n"+m); break;
				case  'warn':	console.warn("[warn] \n"+m); break;
				default:  		console.log(m);  break;
			}
		} else {
			// Actions for browsers without console
			//[ie: "alert(m);"]
		}
		return true;
	}
	//********************
	/** fieldClear
	 * This will show/hide suggestions along with applying the initField class
	 **/
	$.fn.fieldClear = function() {
		return this.focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = "";
				$(this).removeClass("initField");
			}
		}).blur(function() {
			if( !this.value.length ) {
				this.value = this.defaultValue;
				$(this).addClass("initField");
			}
		});
	};
	//********************
	// fade item to .75
	$.fn.fadeTo75 = function(){
		return $(this).stop().animate({ opacity: .75 }, 'fast');
	}
	//********************
	//for each in the collection, find the maximum height and set all elements to that height
	$.fn.equalHeight = function() {
		var tallest = 0;
		//**********
		$(this).each(function() {
			var thisHeight = $(this).height();
			//**********
			if(thisHeight > tallest) {
				tallest = thisHeight;
			}
		});
		//**********
		$(this).height(tallest);
	}

})(jQuery);
