/*
+----------------------------------------------------------------+
|										       						|
|	WordPress 2.7 Plugin: Most-MU Front 0.1								|
|	Copyright (c) 2009 Blog Online B.V., Andrew Gerssen								|
|																							|
|	File Written By:																	|
|	- Andrew Gerssen															|
|															|
|																							|
|	File Information:																	|
|	- Most-MU Front Javascript File													|
|	- wp-content/plugins/most_mufront/most_mu-js.php				|
|																							|
+----------------------------------------------------------------+
*/


// Variables
var mostmu = new sack(mostmufront_ajax_url);
var value, type, elid, max, channel;
var docelm, docelement;
var minsecs,TimerRunning,TimerID;
TimerRunning=false;

function refresh_page()
{
	mostmu.reset();
	
	if(type == "channel")
	{				
		for(var i=0; i < max+1; i++)
		{
			docelement = document.getElementById('channel' + i);
			
			if(i == elid)
			{
				/*docelement.setAttribute("class", "blog_selected");*/
				docelement.className = "blog_selected";
			}
			else
			{
				/*docelement.setAttribute("class", "blog_deselected");*/
				docelement.className = "blog_deselected";
			}
		}
		
		if(channel == undefined)
		{
			docelm = document.getElementById('bread');
			docelm.style.display = 'inline';
			
			docelm = document.getElementById('breadcat');
			docelm.innerHTML = 'Alle Magazines';
		}
		else
		{
			docelm = document.getElementById('bread');
			docelm.style.display = 'inline';
			
			docelm = document.getElementById('breadcat');
			docelm.innerHTML = channel;
		}
			
		mostmu.setVar("channel", value);
		mostmu.element = 'mostmu_body';
		mostmu.method = 'GET';
		mostmu.runAJAX();
	}
	
	if(type == "show")
	{
		for(var i=0; i < max; i++)
		{
			docelement = document.getElementById('tab' + i);
			
			if(i == elid)
			{
				/*docelement.setAttribute("class", "select");*/
				docelement.className = "select";
			}
			else
			{
				/*docelement.setAttribute("class", "deselect");*/
				docelement.className = "deselect";
			}
		}		
		
		mostmu.setVar("show", value);
		mostmu.element = 'mostmu_body';
		mostmu.method = 'GET';
		mostmu.runAJAX();
	}
}

function StopTimer()
{
	if(TimerRunning)
	{
   		clearTimeout(TimerID);
   	}
	TimerRunning=false;
}

function StartTimer()
{
	TimerRunning=true;
	TimerID=self.setTimeout("StartTimer()",1);

	if(minsecs===0)
	{	   
	   StopTimer();
	   refresh_page();
	}

	minsecs--;
}


function TimerInit(Minsecs) //call the Init function when u need to start the timer
{
	minsecs = Minsecs;
	StopTimer();
	StartTimer();
}

function process_page(Value, Type, ElID, Max, Channel)
{
	value = Value;
	type = Type;
	max = Max;
	elid = ElID;
	channel = Channel;
	
	TimerInit(20);
}


