if(typeof locale == "undefined"){
	var locale="/"
	//var locale="http://hal.ai.dev/sitecore/"

} else {
	locale = "/locale/"+locale+"/";
}
var HELPERS =
{
	// Container for image preloads //
	popupprefs : [],
	linkPopups : function(popupClass, popupOptions)
	{
		if(typeof popupClass.href == "string"){
			var ops = popupOptions;
			popupClass.onclick = function(){
				var mywin=open(this.href, 'Actuate', ops);
				this.blur();
				return false;
			}
		} else {
			HELPERS.popupprefs[popupClass] = popupOptions
			var x = $A(document.getElementsByTagName("a"))
			x.each(function(pl){
				if(Element.hasClassName(pl, popupClass))
				pl.onclick = HELPERS.launchPopup;
		   })
		}
	},

	launchPopup : function(){
		var  i, prefs;
		prefs = "";
		// cycle through class names and match to popupprefs
		// this enables multiple classes to be applied to an anchor
		this.className.split(' ').each(function(cn){
			if(typeof HELPERS.popupprefs[cn] == "string"){
				prefs = HELPERS.popupprefs[cn];
			}
		})
		mywin=open(this.href, 'Actuate', prefs);
		this.blur();
		return false;
	},

	// Smart Text Input (e.g. search fields)
	memorizeTextInput : function(id){
		var input = $(id);
		if(!input) return false;
		input.oldval = input.value;
		input.onfocus = function(){
			if(this.value == this.oldval)
 			this.value = "";
        }
        input.onblur = function(){
            if(this.value == "")
            this.value = this.oldval;
        }
    },

	pause : function(millis)
	{
		date = new Date();
		var curDate = null;
		do { var curDate = new Date(); }
		while(curDate-date < millis);
	},

	linkexpander: function(divid, linktext)
	{
		if(!$(divid)) return;
		var openlinkp = document.createElement("p");
		var openlink = document.createElement("a");
		openlinkp.className = "morelink"
		openlink.appendChild(document.createTextNode(linktext));
		openlinkp.appendChild(openlink)
		openlink.onclick = function(){if($(divid).getStyle("display") == "none")new Effect.BlindDown($(divid));}
		$(divid).parentNode.insertBefore(openlinkp, $(divid))
		$(divid).hide()
	}

};

function linkFlash(vars){
	var doflash= new domFunction(function(){
		if(!$(vars["divid"])) return;
	    var so = new SWFObject(vars["swfsrc"], [vars["divid"]+"_swf"], vars["width"], vars["height"], vars["bg"])
		so.addParam("wmode", "transparent")
		so.write(vars["divid"])
	}, vars["divid"])
}

// domFunction (will load things faster than addEvent can)
// http://brothercake.com/site/resources/scripts/domready/
function domFunction(f, a)
{ var n = 0; var t = setInterval(function()
{ var c = true; n++; if(typeof document.getElementsByTagName != 'undefined' && (document.getElementsByTagName('body')[0] != null || document.body != null))
{ c = false; if(typeof a == 'object')
{ for(var i in a)
{ if
( (a[i] == 'id' && document.getElementById(i) == null) || (a[i] == 'tag' && document.getElementsByTagName(i).length < 1)
)
{ c = true; break;}
}
}
if(!c) { f(); clearInterval(t);}
}
if(n >= 60)
{ clearInterval(t);}
}, 250);};

if(typeof sIFR == "object"){
	/* sIFR setup */
	var metaplusmedium = {
 		src: locale+"swfs/metaplusmedium.swf"
		,ratios: [10,1.32,16,1.27,23,1.23,24,1.21,25,1.22,31,1.21,38,1.2,42,1.19,43,1.2,62,1.19,66,1.18,67,1.19,113,1.18,114,1.17,119,1.18,120,1.17,1.18]
	};
	 // sIFR.domains = ['novemberborn.net'] // Don't check for domains in this demo

	sIFR.activate(metaplusmedium);
    sIFR.fitExactly = true;
	//sIFR.debug.ratios(metaplusmedium, {selector: '#content h3'});

	sIFR.replace(metaplusmedium, {
		selector: '.landing .introtext p'
		,css: ['.sIFR-root {color:#929191; leading: 11}']
		,wmode: 'transparent'
	})

	sIFR.replace(metaplusmedium, {
		selector: '.landing #content h2.pagetitle, .home .text h2'
		,css: ['.sIFR-root {color:#FFFFFF;}']
		,wmode: 'transparent'
	})

	sIFR.replace(metaplusmedium, {
		selector: '#content h2.pagetitle'
		,css: ['.sIFR-root {color:#646464; leading: 4}, a {color:#C73318; text-decoration:none}']
		,wmode: 'transparent'
	})

	sIFR.replace(metaplusmedium, {
		selector: '#content h2, #content h3'
		,css: ['.sIFR-root {color:#4b4f5b;}, a {color:#C73318; text-decoration:none}, a:hover{color:#C73318; text-decoration:none}']
		,wmode: 'transparent'
	})
}

var RotatingLogos = {
	currentNode: "",
	init: function(){
		RotatingLogos.currentNode = $("rotating_logos").firstDescendant();
		$("rotating_logos").onclick = function(){document.location.href = "#"}
		setTimeout("RotatingLogos.fadeNext()", 2500);
	},
	fadeNext: function(){
		Effect.Fade(RotatingLogos.currentNode, {afterFinish: function(){
			if(RotatingLogos.currentNode.next() != null)
				RotatingLogos.currentNode = RotatingLogos.currentNode.next();
			else
				RotatingLogos.currentNode = RotatingLogos.currentNode.ancestors()[0].firstDescendant();
			Effect.Appear(RotatingLogos.currentNode, {afterFinish: function(){
				setTimeout("RotatingLogos.fadeNext()", 2500);
			}})
		}})
	}
}

var rotatingLogos = new domFunction(function(){
	if(!$("rotating_logos")) return;
    RotatingLogos.init()
}, "rotating_logos")

var linkwebinars = new domFunction(function(){
	HELPERS.linkexpander("webinars_more", "More Webinars >")
}, "webinars_more")

var linkwhitepapers = new domFunction(function(){
	HELPERS.linkexpander("whitepapers_more", "More White Papers >")
}, "whitepapers_more")

var linkbrochures = new domFunction(function(){
	HELPERS.linkexpander("brochures_more", "More Brochures >")
}, "brochures_more")

