/*
 * favicon.js
 * 
 * A quick-n-dirty means of injecting favicon link element into head (will be unnecessary
 * once introduced into Wendigo Dashboard).
 */
(function() {
	var head = document.getElementsByTagName("head")[0];
	var link = document.createElement("link");
	link.type = "image/x-icon";
	link.rel = "shortcut icon";
	link.href = "/_uploads/imgs/favicon.ico";
	head.appendChild(link);    
	
	// QnD fix for what SEEMS to be a not-same-domain Ajax issue
	var url = window.location.href;
	var i = url.indexOf("http://www");
	if (i == -1) {
		i = url.indexOf("https://www");
	}
	if (i == -1) {
		i = url.indexOf("http://");
	    if (i == 0) {
	        url = url.substr("http://".length);
	        window.location.href = "http://www." + url;         
	    } else {
	        url = url.substr("https://".length);
	        window.location.href = "https://www." + url;         
	    }   		
	}
	/*
	if (url.indexOf("http://www.") != 0 && url.indexOf("https://www.") != 0) {
		if (url.indexOf("http://") == 0) {
            window.location.href = "http://www." + url;			
		} else {
            window.location.href = "https://www." + url;			
		}
	}
	*/
	
	/*
	=================================================================== 
       TEMP CODE - REMOVE/COMMENT-OUT AFTER LIVE DEPLOYMENT COMPLETE
    =================================================================== 
	 */
	/*
	window. _getip = function(json) {
		if (json.ip != "75.207.27.173" && json.ip != "24.123.20.94" && json.ip != "97.200.133.134") {
			window.location.href = "underconst/index.html"
		}
	}
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "https://jsonip.appspot.com/?callback=_getip";
    head.appendChild(script);
	*/
	

})();

