/* Strona */
var last='';
var lmod='main';
var halt=0;
function test(a,force)
	{
	if(halt && !force)
		return false;
		
	dohalt();
		vars=a.rel.split("|");
		mod=vars[0];
		lang=vars[1];
		tag=vars[2];
		if(mod+lang==last)
			{
			new Effect.Shake(document.getElementById(tag));	
			window.setTimeout("unhalt()",1000);
			}
		else
			{
			last=mod+lang;
			lmod=mod;
			url='/?lang='+lang+'&mod='+mod+'&alone=1';
			start(url,tag);
			}
	}
function start(url, tag)
	{
		new Effect.Shrink(document.getElementById(tag));	
		window.setTimeout("ajx(url,tag)",1000);
	}
function end(tag)
	{
		new Effect.Grow(document.getElementById(tag));
		window.setTimeout("unhalt()",1000);
	}
function ajx(url, tag, force)
	{
	new Ajax.Request(url,
 		{
   		method:'get',
    	onSuccess: function(transport)
			{
			//x="end('"+tag+"')";
			if(!force)
				window.setTimeout("end(tag)",100);
      		var response = transport.responseText || "no response text";
      		document.getElementById(tag).innerHTML=response;
    		},
    	onFailure: function()
			{ 
			ajx('/?lang='+lang+'&mod=main&alone=1',tag,force);
			//alert('Something went wrong...') 
			}
		}
		);
	}
/* ~Strona */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *?
/* Menu */
var mlast='';
function mtest(a)
	{
	if(halt)
		return false;
		
	dohalt();
		vars=a.rel.split("|");
		lang=vars[0];
		tag=vars[1];
		if(lang==mlast)
			{
			new Effect.Shake(document.getElementById('mainset'));	
			//new Effect.Shake(document.getElementById('right-side'));	
			window.setTimeout("unhalt()",1000);
			}
		else
			{
			mlast=lang;
			url=new Array();
			url[0]='/?lang='+lang+'&alone=2';
			url[1]='/?lang='+lang+'&alone=3';
			mstart(url,tag);
			}
	}
function mstart(url, tag)
	{
		new Effect.BlindUp(document.getElementById(tag));
		new Effect.BlindUp(document.getElementById(tag.substring(1)));
		new Effect.BlindUp(document.getElementById('t'+tag.substring(1)));
		//alert("1");
		window.setTimeout("majx(url[0],tag)",1000);
		window.setTimeout("tajx(url[1],'t'+tag.substring(1))",1000);
		
		url[2]='/?lang='+mlast+'&mod='+lmod+'&alone=1';
		window.setTimeout("ajx(url[2],tag.substring(1),1)",1000);
		//alert("2");
	}
function mend(tag)
	{
		new Effect.BlindDown(document.getElementById(tag));
		new Effect.BlindDown(document.getElementById(tag.substring(1)));
		new Effect.BlindDown(document.getElementById('t'+tag.substring(1)));
		
		
		//a= new Array();
		//a['rel']=lmod+'|'+mlast+'|inside';
		//url='/?lang='+mlast+'&mod='+lmod+'&alone=1';
		//test(a,1);
		//window.setTimeout("test(a,1);",2000, a);
		window.setTimeout("unhalt()",2000);
	}
function majx(url, tag)
	{
	new Ajax.Request(url,
 		{
   		method:'get',
    	onSuccess: function(transport)
			{
			//x="mend('"+tag+"')";
			window.setTimeout("mend(tag)",500);
      		var response = transport.responseText || "no response text";
      		document.getElementById(tag).innerHTML=response;
    		},
    	onFailure: function()
			{ 
			alert('Something went wrong...') 
			}
		}
		);
	}
function tajx(url, tag)
	{
	new Ajax.Request(url,
 		{
   		method:'get',
    	onSuccess: function(transport)
			{
      		var response = transport.responseText || "no response text";
      		document.getElementById(tag).innerHTML=response;
    		},
    	onFailure: function()
			{ 
			alert('Something went wrong...') 
			}
		}
		);
	}
/* ~Menu */
//HALT

function unhalt()
	{
		halt=0;
		document.getElementById('mainset').style.cursor='';
	}
function dohalt()
	{
		halt=1;
		document.getElementById('mainset').style.cursor='wait';
	}
/* LISTA DOWN */
var rhalt=0;
function roll(list) 
	{
	sequence=Sortable.sequence('examplelist');
	newsequence=new Array();
  	newsequence[0]=sequence[(sequence.length-1)];
  	for (j=0; j<(sequence.length-1); j++) 
		{
		newsequence[(j+1)]=sequence[j];
		}
    Sortable.setSequence('examplelist',newsequence);
	if(!rhalt)
		{
		setTimeout("roll()",500);
		}
	else
		rhalt=0;
	
  	}
function dorhalt()
	{
		rhalt=1;
	}

/* ~LISTA DOWN */


function tragedy()
	{
		setTimeout("tragedy1()",5000);
	}

function tragedy1()
	{
		new Effect.Shake(document.getElementById('mainset'));
		setTimeout("tragedy2()",5000);
	}
function tragedy2()
	{
		new Effect.Shake(document.getElementById('mainset'));
		setTimeout("tragedy1()",5000);
	}