var loadEvent = {
	fnList : [],
	timer : null,
	domLoadElementId : "dom-load",
	add : function(fn)
	{
		loadEvent.fnList.push(fn)
		if(loadEvent.domLoaded == undefined)
		{
			loadEvent.domLoaded=false;
			loadEvent.domLoad();
			window.onload = function()
			{
				if(document.getElementById(loadEvent.domLoadElementId) == undefined)
				{
					window.defaultStatus = "Error: domLoadElementId[\""+loadEvent.domLoadElementId+"\"] is not embeded.";
				}
			}
		}
	},
	domLoad : function()
	{
		loadEvent.timer = setInterval(function() { // doesnt work in IE/Mac
		if((document.getElementsByTagName("body")[0] != null || document.body != null) && document.getElementById(loadEvent.domLoadElementId)) {
			loadEvent.runFnList();
			clearInterval(loadEvent.timer);
		}
		}, 250);
		if (typeof document.addEventListener != "undefined") {
			document.addEventListener("DOMContentLoaded", function() { loadEvent.runFnList(); clearInterval(loadEvent.timer); } , null); // Mozilla only
		}
	},
	runFnList : function()
	{
		if(loadEvent.domLoaded) return // for Mozilla, only execute once
		loadEvent.domLoaded = true; 
		for(var i=0,fn;fn=loadEvent.fnList[i];i++)
		{
			fn();
		}
	}
}

// ===============================================================


uniqueId = 0;
function giveUniqueID()
{
	return "BRUniq"+ ++uniqueId
}


function getElementsByClassName(className,nodeElm,elmType)
{
	var elementList = [];
	var elementsByClassName = [];
	if(elmType) elementList = nodeElm.getElementsByTagName(elmType);
	else elementList = document.all || document.getElementsByTagName("*");
	for(var i=0,elm;elm=elementList[i];i++)
	{
		if(hasClassName(elm,className))
		{
			elementsByClassName.push(elm);
		}
	}
	return elementsByClassName;
}


function hasClassName(elm,className)
{
	var re = RegExp("(^|\\s)"+className+"(\\s|$)");
	return re.test(elm.className);
}

function getNextSibling(elm){
	nextElm=elm.nextSibling;
	while(nextElm.nodeType!=1){
		nextElm = nextElm.nextSibling;
	}
	return nextElm;
}

function getPreviousSibling(elm){
	previousElm=elm.previousSibling;
	while(previousElm.nodeType!=1){
		previousElm = previousElm.nextSibling;
	}
	return previousElm;
}
function goto_URL(object) {
    window.location.href = object.options[object.selectedIndex].value;
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=440,height=300,left = 292,top = 234');");
}

function loadContentBg(blnEnglish) {
	if(blnEnglish)
		setTimeout('UFO.create( { movie:"/includes/flash/brands_en.swf",width:"181",height:"409",base:".",majorversion:"7", build:"",wmode:"opaque",bgcolor:"#ffffff",flashvars:""}, "brands",true)',2000);
	else	
		setTimeout('UFO.create( { movie:"/includes/flash/brands.swf",width:"181",height:"409",base:".",majorversion:"7", build:"",wmode:"opaque",bgcolor:"#ffffff",flashvars:""}, "brands",true)',2000);
	//document.getElementById('base-content').style.backgroundColor = 'transparent';
	//document.getElementById('base-content').style.backgroundImage = 'url(/images/bg_content.gif)';
	//document.body.style.backgroundImage = 'url(/images/bg.jpg)';
}
