var roach = new Array();

function specOnLoad() {
	preload2(
	'../subcommon/pod_04.gif', '../subcommon/pod_04f.gif',
	'../subcommon/pod_08.gif', '../subcommon/pod_08f.gif',
	'../subcommon/pod_11.gif', '../subcommon/pod_11f.gif',
	'../subcommon/pod_15.gif', '../subcommon/pod_15f.gif',
	'images/val_18.gif', 'images/val_18f.gif',
	'../subcommon/pod_20.gif', '../subcommon/pod_20f.gif'
	);
	roach = new Array();
	roach[0] = new Array();
	roach[0][0] = new Image();
	roach[0][0].src = 'images/gek1.gif';
	roach[0][1] = new Image();
	roach[0][1].src = 'images/gek3.gif';
	roach[0][2] = new Image();
	roach[0][2].src = 'images/gek1.gif';
	roach[0][3] = new Image();
	roach[0][3].src = 'images/gek2.gif';

	with (roachCBE = cbeGetElementById('roach').cbe) {
		zIndex(100);
		roachW = width();
		roachH = height();
	}
	blockRoach()
	
}


function resetSlide() {

}


var roachX = 200;
var roachY = 300;
var roachDX = 0;
var roachDY = -20;
var roachStepTime = 150;
var roachSleepTime = 10000;
var roachPauseTime = 3000;
var roachPauseProb = 0.02;
var roachW = 0;
var roachH = 0;
var roachType = 0;
var roachShot = 0;

var roachBlocked = true;

function resetRoach() {
	cbeGetElementById('roach').cbe.hide();
	roachY = document.cbe.scrollTop() + document.cbe.height();
	roachX = Math.random() * document.cbe.width();
	setTimeout("roachStep()", roachSleepTime);
}

function roachPause() {

	setTimeout("roachStep()", roachPauseTime);
}

function blockRoach() {
	roachBlocked = !roachBlocked;
	if (roachBlocked) {
		if (cbeGetElementById('fumigator') != null) 
			cbeGetElementById('fumigator').innerHTML="okaz singapurskiej fauny";
	}
	if (!roachBlocked) {
		if (cbeGetElementById('fumigator') != null)
			cbeGetElementById('fumigator').innerHTML="stop robactwu!";
		cbeGetElementById('roach').cbe.show();
		resetRoach();
	}
}

function roachStep() {
	if (roachBlocked) {
		cbeGetElementById('roach').cbe.hide();
	}
	else {
		with (roachCBE = cbeGetElementById('roach').cbe) {
			show();
			document.images['roachImg'].src = roach[roachType][roachShot].src;
			roachShot++;
			roachShot %= 4;
			if (roachShot % 2 == 1) {
				moveTo(roachX, roachY);
				roachX += roachDX;
				roachY += roachDY;
				if ( roachPauseProb > Math.random() ) {
					roachPause();
					return;
				}
			}
			if ((roachY + roachH - document.cbe.scrollTop() < 0)) // || (roachY > document.cbe.height()) || (roachX < 0) || (roachX > document.cbe.width()))
				resetRoach();
			else
				setTimeout("roachStep()", roachStepTime);
		}
	}
}


// resize of the elements specific to the valencia subpage. returns offset (top, left) of the content
function resizeSpecific() {

	if (cbeGetElementById('userpane') != null) {
		with (uPane = cbeGetElementById('userpane').cbe) {
			moveTo(uPane.parentNode.width(),250);
			show();
		}
	}
	
	if (cbeGetElementById('pod-15') != null) {
		with (pod15 = cbeGetElementById('pod-15').cbe) {
			var currTop = pod15.top()
			pod15.top(currTop + 50);
		}
	}
	
	if (cbeGetElementById('monthpane') != null) {
	
		with (mPane = cbeGetElementById('monthpane').cbe) {
			moveTo(mPane.parentNode.width()+50,150);
			resizeTo(150, height());
			show();
		}
	}

	if (cbeGetElementById('ticker') != null) {
		with (tPane = cbeGetElementById('ticker').cbe) {
			moveTo(100,90);
			//resizeTo(500, height());
			zIndex(50);
			show();
		}
	}

	if (cbeGetElementById('navbar') != null) {
		with (navBar = cbeGetElementById('navbar').cbe) {
			moveTo(100,10);
			zIndex(20);
			show();
		}
	}
	
	
	//with (col1 = cbeGetElementById('col1').cbe) {
		//zIndex(40);
	//	show();
	//}

	
	var myoffset = { x : 0, y : 0 };  
	return myoffset;
}