var fnQue = [];
var domIsReady;

function domReady(fn){
    if(domIsReady)
        return fn();

    if(!fnQue.length){
        function ready(){
            if(domIsReady)
                return;
            domIsReady = true;
            var i = fnQue.length; while(i--)
                fnQue[i]();

            fnQue = null;
        };
        (function(){
            if(document.body && document.body.lastChild){
                ready();
            } else { 
                return setTimeout(arguments.callee,0);
            }
        })();
        window.onload = ready;
    };
    fnQue.unshift(fn);
};

function listen(evnt, elem, func) {    
	if (elem.addEventListener)  
		elem.addEventListener(evnt,func,false);    
	else if (elem.attachEvent) { 
		var r = elem.attachEvent("on"+evnt, func);	
		return r;    
	}    
	else window.alert('shit dat werkt niet');
} 

function remove_mask() {
		var mask=document.getElementById('loading-mask');
		if (mask) mask.parentNode.removeChild(mask);
		hide_settings();
		
		return false;
}		

function hide_settings() {
	return popup_settings(true,-200,-200);
}

function center_settings() {
	var winWidth = 0, winHeight = 0;
	var left = 0, top = 0;
	sizes=getWindowSize();
  sizeArray=sizes.split(":");
  winWidth=parseInt(sizeArray[0]);
  winHeight=parseInt(sizeArray[1]);  
	obj=document.getElementById('flash-setup');
	if (obj!=null)
	{	
		top=((winHeight) - obj.style.height) / 2;
		left=((winWidth) - obj.style.width) / 2;
	}	
	
	return popup_settings(false,left,top);
}

function show_settings(left,top) {
	return popup_settings(false,left,top);
}

function popup_settings(hide,left,top) {
		var flash=document.getElementById('flash-setup');
		if (flash){
			if (hide) {
				flash.style.visibility='hidden';
				flash.parentNode.style.left=left+"px";
				flash.parentNode.style.top=top+"px";
			}
			else {
				flash.style.visibility='visible';
				flash.parentNode.style.left=left+"px";;
				flash.parentNode.style.top=top+"px";;
			}
		}
		return false;
}

function sendToFlash (scrollName, movieName) 
{
	sizes=getScrollSize(scrollName);
	o=thisMovie(movieName);	
	if (o!=null && o.sendPosition!=null) o.sendPosition(sizes);
	scrollerY(scrollName, movieName);
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}

function getScrollSize(scrollName) 
{	
	var winWidth = 0, winHeight = 0;
	sizes=getWindowSize();
  sizeArray=sizes.split(":");
  winWidth=parseInt(sizeArray[0]);
  winHeight=parseInt(sizeArray[1]);
  obj=document.getElementById(scrollName);
	if (obj!=null)
	{	
		//winWidth=winWidth+obj.scrollLeft;
		winHeight=winHeight;
	}

	//return winWidth+":"+winHeight+":"+obj.scrollTop;
	return winWidth+":"+winHeight;
}

function scrollToCenter(scrollName, movieName) 
{	
	var winWidth = 0, winHeight = 0;
	sizes=getWindowSize();
  sizeArray=sizes.split(":");
  winWidth=parseInt(sizeArray[0]);
  winHeight=parseInt(sizeArray[1]);
  
	obj=document.getElementById(scrollName);
	if (obj!=null)
	{	
		obj.style.width=winWidth+"px";
		//obj.style.height=winHeight+"px";
		obj.scrollLeft=(obj.scrollWidth-winWidth)/2;
		//obj.scrollTop=(obj.scrollHeight-winHeight)/2;
	}
	sendToFlash(scrollName, movieName);
	//alert(">> Hello " + tja + ".");		
	return false;
	//return "size: "+sizeArray+" obj.scrollWidth: "+(obj.scrollWidth-winWidth)/2;
}

function getWindowSize() 
{	
	var winWidth = 0, winHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    winWidth = window.innerWidth;
    winHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    winWidth = document.documentElement.clientWidth;
    winHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    winWidth = document.body.clientWidth;
    winHeight = document.body.clientHeight;
  }
  return winWidth+":"+winHeight;
}

function resizeToScreen(movieName) {              
	var winWidth = 0, winHeight = 0;
	sizes=getWindowSize();
	sizeArray=sizes.split(":");
	winWidth=parseInt(sizeArray[0]);
	winHeight=parseInt(sizeArray[1]);
	resizeMovie(movieName, winWidth, winHeight);
}

function resizeMovie(movieName, width, height){
	obj=document.getElementById(movieName);
	if (obj!=null) {              
	 obj.style.width=width+"px";
	 obj.style.height=height+"px";
	}
}


//___________________________________________________________________________________________________________________________________

function sendScrllToFlash (scrollName, movieName, scrollY) 
{
	o=thisMovie(movieName);	
	//if (o!=null && scrollY!=null) o.scrolwaarde(scrollY);
}

function scrollerY(scrollName, movieName)  
{	
 	scrolwaarde=document.body.scrollTop;
	//alert ('scrollerY: '+scrolwaarde);
	sendScrllToFlash(scrollName, movieName, scrolwaarde);		
	return false;
}
