var delay = 10; // milliseconds between movements.
var myTimer = null;
var counter =55; // number of times to move the div
var leftfrom=10;
var moving=false;

function moveIt(obj) {
	if (document.getElementById('image_layer')) {
		obj=document.getElementById('image_layer');
		//var leftpos=leftfrom+(100-counter)*Math.sin(counter);
		var leftpos=leftfrom+(55-counter)*9;
		obj.style.left=leftpos+'px';
		if (--counter < 1 && myTimer != null) {
			clearInterval(myTimer);
			document.getElementById('moving_image').onclick=function() {movePictureBack()};
		}
	}
}

function movePicture() {
	if (!moving) {
		moving=true;
		document.getElementById('moving_image').onclick=function(){};
		document.getElementById('movingimagelink').onclick=function(){};
		document.getElementById('movingimagelink').style.visibility='hidden';
		document.getElementById('image_layer').style.zIndex=10;
		myTimer = setInterval("moveIt()", delay);
		moving=false;
	}
}


function moveItBack(obj) {
	if (document.getElementById('image_layer')) {
		obj=document.getElementById('image_layer');
		//var leftpos=leftfrom+(100-counter)*Math.sin(counter);
		var leftpos=505-counter*9;
		obj.style.left=leftpos+'px';
		if (++counter > 55 && myTimer != null) {
			clearInterval(myTimer);
			document.getElementById('moving_image').onclick=function() {movePicture()};
			document.getElementById('movingimagelink').onclick=function(){movePicture()};
			document.getElementById('movingimagelink').style.visibility='visible';
			document.getElementById('image_layer').style.zIndex=-1;
		}
	}
}

function movePictureBack() {
	if (!moving) {
		moving=true;
		document.getElementById('moving_image').onclick=function(){};
		myTimer = setInterval("moveItBack()", delay);
		moving=false;
	}
}

/*
function movePicture() {
	for(var i=0; i<90; i++) {
		alert(Math.sin(i/55));
	}
}
*/


//window.onload=set_pos_new;
//window.onresize=set_pos_new;

function set_pos_new(){
	setTimeout("do_bott()",300);
	}
function do_bott(){
	var minusas=60;//386;
	var agt = navigator.userAgent.toLowerCase();
	if(document.all){	
		if(typeof((document.body.offsetHeight)=='undefined' || (agt.indexOf("msie")==-1) && agt.indexOf("gecko")!=-1) || (agt.indexOf("msie 7.0")>0) || (agt.indexOf("opera")>0)){
			hh=document.body.scrollHeight;
			if (hh<screen.height-200)
				hh=screen.height-200;
		}
		else {
			hh=document.body.offsetHeight+((agt.indexOf("msie") != -1 && (agt.indexOf("opera") == -1))?(-4):0);	
		}
	}
	else {
		if (agt.indexOf("mozilla")>=0 && agt.indexOf("chrome")<0) {//mozilai
			hh = window.innerHeight + window.scrollMaxY;
		}
		else hh=document.body.scrollHeight;
	}

	//document.images.scr_h.height=(((hh-minusas)>0) ? (hh-minusas):1);
	var bottable=document.getElementById('bottomcont');
	var realpos=hh-minusas;
	bottable.style.position='absolute';
	bottable.style.top=realpos+'px';
}