var HOST = 'bigkid.dirtchild.com';

// Copyright (c) 1996-1997 Athenia Associates.
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Tomer Shiran.

function setCookie(name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
    document.cookie = curCookie;
}

function getCookie(name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie(name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function setExternalLinks(value) { 
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		anchor.removeAttribute("target");		
		if (value == true) {
			var path = anchor.getAttribute("href");		
			if (path.substring(0,7) == "http://") {
				if (path.substring(0,24) != "http://www.bigkid.com.au" && path.substring(0,20) != "http://bigkid.com.au") { 
					anchor.setAttribute("target", "_blank");			
				}
			}
		}
	} 
} 

function setLinkLaunch(value) {	
	document.cookie = "launchLinks=" + escape(value) + "; expires=Fri, 21-May-2010 00:00:00 GMT; path=/; domain=" + HOST;
	setExternalLinks(value);
}

function init() {
	var launchValue = getCookie("launchLinks");	
	if (document.frmSettings) {
		if (launchValue == "true") {
			setExternalLinks(true);
			document.frmSettings.checkLaunch.checked = true;
		} else {
			setExternalLinks(false);
			document.frmSettings.checkLaunch.checked = false;
		}	
	}
	//
	if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
		alphaBackgrounds();
	}
}

window.onload = init;

function alphaBackgrounds(){
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	if ((rslt != null && Number(rslt[1]) >= 5.5)) {
		document.getElementById("logoHead").style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.bigkid.com.au/wp/wp-content/themes/bigkid/images/bk_head.png', sizingMethod='scale')";
	}
}