// Global JavaScripts

/* Function to add routines to page load event */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

// To make dropdown menus work in IE6
function sfHover() {
	var sfEls = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.setAttribute('hclassname', this.className);
			this.className+=" selected sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.getAttribute('hclassname');
		}
	}
}

/* Just add class="preload" to any images in the photo gallersy so that they'll be loaded in the background for quicker transitions */
function preloadImages() {
	if (!document.getElementById) return;
	var aPreLoad = new Array();
	var aImages = document.getElementsByTagName('img');
	for (var i = 0; i < aImages.length; i++) {
		if (aImages[i].className == 'preload') {
			var src = aImages[i].getAttribute('src');
			aPreLoad[i] = new Image();
			aPreLoad[i].src = src;
		}
	}
}

addLoadEvent(preloadImages);
addLoadEvent(sfHover);










// Default window ornaments for the live help dialog
var _liveHelpDialogFeature = "status=1,width=500,height=400,resizable=1";

function OpenLiveSupport() {
    var encode = escape
    if (typeof (encodeURIComponent) != "undefined")
        encode = encodeURIComponent;

    var url = "/live-support/CuteSoft_Client/CuteChat/SupportRedirect.aspx?Referrer=" + encode(document.referrer) + "&Url=" + encode(location.href) + "&_time=" + (new Date().getTime());
    var win;
    try {
        win = window.open(url, '', _liveHelpDialogFeature);
    }
    catch (x) {
    }

    if (win == null) {
        alert("Pop-up Blocker Detected.");
    }
}