
var observer = {};
var observerLogo = {};


observer.nextEffect = false;
observer.onPostEffect = function(e){
	if (this.nextEffect)
	{
		var eff = this.nextEffect;
		setTimeout(function(){eff.start();}, 10);
	}

	this.nextEffect = false;
}

observerLogo.nextEffect = false;
observerLogo.onPostEffect = function(e){
	if (this.nextEffect)
	{
		var eff = this.nextEffect;
		setTimeout(function(){eff.start();}, 10);
	}

	this.nextEffect = false;
}


function myPanelsSlides(currentPanel)
{
    // The list of all the panels that need sliding
	var panels = ['slide1', 'slide2', 'slide3', 'slide4', 'slide5', 'slide6'];
	var opened = -1;

	// Let's check if we have an effect for each of these sliding panels
	if (typeof effects == 'undefined')
		effects = {};

	for (var i=0; i < panels.length; i++)
	{
		if (typeof effects[panels[i]] == 'undefined'){
			effects[panels[i]] = new Spry.Effect.Slide(panels[i], {from: '0%', to: '100%', duration:500, toggle: true});
	
			effects[panels[i]].addObserver(observer);
		}
		 
		if (effects[panels[i]].direction == Spry.forwards && currentPanel != panels[i])
			opened = i;

		//prevent too fast clicks on the buttons
		if (effects[panels[i]].direction == Spry.backwards && effects[panels[i]].isRunning)
		{
			observer.nextEffect = effects[currentPanel];
			
			return;
		}
	}

	if (opened != -1)
	{
		observer.nextEffect = effects[currentPanel];
	
		effects[panels[opened]].start();
	} 
	else if (effects[currentPanel].direction != Spry.forwards)
	{
		effects[currentPanel].start();
	
	}
};

function myLogoSlides(currentPanel)
{
	
  // The list of all the panels that need sliding
	var panels = ['logo1', 'logo2'];
	var opened = -1;

	// Let's check if we have an effect for each of these sliding panels
	if (typeof effects == 'undefined')
		effects = {};

	
	for (var i=0; i < panels.length; i++)
	{
		/*alert("if (typeof effects[" + panels[i] + "] == 'undefined')" + typeof effects[panels[i]]);*/
		if (typeof effects[panels[i]] == 'undefined'){
			effects[panels[i]] = new Spry.Effect.Slide(panels[i], {from: '0%', to: '100%', duration:500, toggle: true});
			/*alert("effects[" + panels[i] + "] = new Spry.Effect.Slide(panels[i], {from: '0%', to: '100%', duration:500, toggle: true})" + "; OberserverLogo = " + observerLogo);*/
			effects[panels[i]].addObserver(observerLogo);
		}
			
		if (effects[panels[i]].direction == Spry.forwards && currentPanel != panels[i])
			{
				/*alert("if (effects[panels[i]].direction == Spry.forwards && currentPanel != panels[i]): CurrentPanel = " + currentPanel + "; Panels[i] = " + panels[i]);*/
				opened = i;
			}

		//prevent too fast clicks on the buttons
		if (effects[panels[i]].direction == Spry.backwards && effects[panels[i]].isRunning)
		{
			/*alert("if (effects[panels[i]].direction == Spry.backwards && effects[panels[i]].isRunning): Panels[i] = " + panels[i]);*/
			observerLogo.nextEffect = effects[currentPanel];
			 
			return;
		}
	}

	if (opened != -1)
	{
		/*alert("if (opened != -1): Opened = " + opened + " CurrentPanel = " + currentPanel + " Effects[currentPanel] = " + effects[currentPanel]);*/
		observerLogo.nextEffect = effects[currentPanel];
	
		effects[panels[opened]].start();
	} 
	else if (effects[currentPanel].direction != Spry.forwards)
	{
		/*alert("else if (effects[currentPanel].direction != Spry.forwards): CurrentPanel = " + currentPanel);*/
		effects[currentPanel].start();
	
	}
};



