﻿/**
*
* @author Manu Van De Poel / Manuvdp.be
* @version 1.01
**/
    var ie = false;
	
	
	// Bannerania Object
	function Bannerania(_FlashObjId,_thisObjName)
	{
	   //document.write("function "+_FlashObjId+"_DoFSCommand(command, args) {eval(command+\"(\"+args+\")\");  }");
	    this.myPlayerId = _FlashObjId;
	    this.myPlayerObj = null;
	    this.myThisName = _thisObjName;
	    this.myDirection = 1;
	    this.mySpeedSlower = 8; // the bigger, the slower
        this.myArofexPlayerHeight =0;
        this.myTimer = null; 
        this.myLastWantedHeight =-1;
        this.SizeSubscribersTick = new Array();
        this.onSlideIsLoaded = new Array();
        this.myPicsFlags = new Object();
        
	}
	Bannerania.prototype.TellArofexPlayer = function(functionData)
	{
	    this.myPlayerObj.SetVariable("TellSequencer", functionData); 
	}
	Bannerania.prototype.Init = function()
	{
	    this.myPlayerObj = document[this.myPlayerId];
	    if (this.myPlayerObj== null || this.myPlayerObj == undefined)
	    {
	        this.myPlayerObj = GetElement(this.myPlayerId);
	    }
	}
   Bannerania.prototype.SetPlayerHeight = function(descriptionHeight)
    {
		// check if it comes from the button
		if (this.myLastWantedHeight!=-1)
		{
			// if its from an animation it may not be animated
			// ex.: if we press the close button, it may not open/close anymore
			if (this.myLastWantedHeight != descriptionHeight) return;
		}
        obbjj = this.myPlayerObj;
        if (this.myArofexPlayerHeight == descriptionHeight) return;
		
		var a = Math.round(descriptionHeight);
		var b = Math.round(this.myArofexPlayerHeight);
        if (b>a)
	    {
	        this.myDirection = -1;
	        this.moveTitle(descriptionHeight)
	    }
	    else
	    {
	        this.myDirection = 1;
	        this.moveTitle(descriptionHeight)
	    }
	    this.myArofexPlayerHeight = descriptionHeight;
        this.myTimer = setTimeout(this.myThisName+".flashObjectTick()",10);
    }
    Bannerania.prototype.flashObjectTick = function()
    {
        obbjj = this.myPlayerObj;
	    var _theheight = Number(obbjj.height);
	    if (this.myDirection==1)
	    {
	        _theheight = _theheight +((this.myArofexPlayerHeight-_theheight)/this.mySpeedSlower)+1; //20;
	        if (_theheight >= this.myArofexPlayerHeight) 
	        {
				
	        }
	        else
	        {
				
		        this.myTimer = setTimeout(this.myThisName+".flashObjectTick()",10);
	        }
	    }
	    else
	    {
	        _theheight = _theheight +((this.myArofexPlayerHeight-_theheight)/this.mySpeedSlower); //20;
	        if (_theheight > this.myArofexPlayerHeight) 
	        {
		        this.myTimer = setTimeout(this.myThisName+".flashObjectTick()",10);
	        }
	    }
	    obbjj.height = _theheight+"px";
	   // send tick to subscribed functions
	   for (i=0;i<this.SizeSubscribersTick.length;i++)
	   {
	        eval(this.SizeSubscribersTick[i]+"("+_theheight+")");
	        
	   }
    }


    Bannerania.prototype.moveTitle = function(y)
    {
       this.myPlayerObj.SetVariable("TitleY", y); 
	}
	Bannerania.prototype.SetTitle = function(titlename)
    {
	   this.myPlayerObj.SetVariable("PageTitle", titlename); 
	}
	Bannerania.prototype.SetLastWantedHeight = function(value)
	{
		this.myLastWantedHeight = value;
	}
	Bannerania.prototype.SubscribeSizeTick = function(_function)
	{
	    this.SizeSubscribersTick.push(_function);
	}
	Bannerania.prototype.FlashPlayPress = function()
    {
    }
    Bannerania.prototype.FlashPausePress = function()
    {
    }
    Bannerania.prototype.ShowPic = function(picid)
    {
        if (this.myPicsFlags[picid] == null) this.myPicsFlags[picid] = false;
        var len = this.myPicsFlags.length;
        // hide all images
        var querystring = "";
        for (var _element in this.myPicsFlags)
        {
            if (_element == picid)
            {
                if (this.myPicsFlags[_element] == true)
                {
                    querystring += 'Sequencer.'+_element+'.setMc("_alpha","0");';
                    this.myPicsFlags[_element] = false;
                }
                else
                {
                    querystring += 'Sequencer.openPlayer.doStart();';
                    querystring += 'Sequencer.'+_element+'.setMc("_alpha","100");';
                    querystring += 'Sequencer.'+picid+'.doStart();';
                    this.myPicsFlags[_element] = true;
                }
            }
            else
            {
                querystring += 'Sequencer.'+_element+'.setMc("_alpha","0");';
                 //querystring += 'Sequencer.'+picid+'.doEnd();';
                this.myPicsFlags[_element] = false;
            }
       }
       this.TellArofexPlayer(querystring);
    }
    Bannerania.prototype.SubscribeSlideIsLoaded = function (_function)
    {
        this.onSlideIsLoaded.push(_function);
    }
    Bannerania.prototype.SlideIsLoaded = function (_SlideId)
    {
        // send to subscribed functions
	   for (i=0;i<this.onSlideIsLoaded.length;i++)
	   {
	        eval(this.onSlideIsLoaded[i]+"("+_SlideId+")");
	   }
    }
    // Bannerania Object
   
    
    
	
	function OpenUrl (Name,query,target,method)
	{
		
		if (method.toLowerCase()=="post")
		{
			// get all variables
			var items;
			items= Array();
			items = query.split("&");
			document.write('<form method="post" action="'+Name+'" name="MyMenuFormke">');
			for (i=0;i<items.length;i++)
			{
				document.write('<input type="hidden" name="'+items[i].split("=")[0]+'" value="'+items[i].split("=")[1]+'">');
			}
			document.write('</form>');
			document.all["MyMenuFormke"].submit();
		}
		else
		{
			var items;
			var parameters;
			items= Array();
			parameters = query.split("&").join(",");
			if (target=="") { target ="_self"; }
			//document.write("Name = "+Name+" !!Quer="+query+" !!target="+target+" !!Param ="+parameters);
			if (Name == "?") { Name = ""; }
			window.open(Name+"?"+query,target,"'"+parameters+"'");
		}
	}
	
	
	function GetElement(elementid)
    {
        if(document.all && !document.getElementById){
			    //"ie"
			    if (document.all[elementid]) return document.all[elementid]; 
	    }
	    if(document.getElementById){
	     ie = false;
			    //"NN6";
		    if (document.getElementById(elementid ))  return document.getElementById(elementid);                 
		}
        if(document.layers){
        ie = false;
			    //"NN4";
		    if (document.layers[elementid]) return document.layers[elementid]; 
	    }
	    
    }
    

	function NullFunction()
	{
		
	}
	
    
	

