// Deploved - Complic Network 2008
// Complic H2 - http://www.complic.net

function showActualSize(image) {

new Ajax.Updater('boxcontent', '/view/actual_image/'+image, {asynchronous:true, evalScripts:true, onComplete:function(request){showBox()}, onLoading:function(request){showLoader()}}); return false;
}    
function showScaledSize() {
Element.hide('actualImage');
new Effect.Appear('scaledImage');
}    
function showLoader(){
var arrayPageSize = getPageSize();
Element.setHeight('overlay', arrayPageSize[1]);
new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.9 });
}   
function showBox(){
    Element.hide('loader');
var arrayPageSize = getPageSize();
var arrayPageScroll = getPageScroll();
var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 15);

Element.setTop('box', lightboxTop);
center('box');
    Element.show('box');
    return false;
} 
<!--
function changeColor(color) {
 //   document.getElementById("overlay").style.background = color;
 new Effect.Highlight('overlay', {duration: 0.5, restorecolor:color, startcolor:'#000000', endcolor:color})
}
//-->   
    function fadeInfo() {
      if(Element.visible('imgControls')) Effect.Fade('imgControls'); 
      if(Element.visible('closeImage')) Effect.Fade('closeImage');
    }
	
	
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
function slider()  {
	
	var listitems = document.getElementsByTagName('li');
	var panel = document.getElementById('panel2');
	/*panel.style.width = (listitems.length * 120) + 15 +"px";*/
	panel.style.width = liLenght +"px";
	
	var timer = null;
	document.getElementById('panel1').onmouseover = function() {
		trackthemouse();
		timer = setInterval("movePanel()",10);
	}
	document.getElementById('panel1').onmouseout = function() {
		donttrackthemouse();
		clearInterval(timer);
	}

	var links = document.getElementsByTagName('A');
	for (var i=0; i<links.length; i++) {
		if(links[i].getAttribute('id') == "moveLeft") {
			var ref = this;
			links[i].timerleft = null;
			links[i].onmouseover = function() {
				ref.timerleft = setInterval("moveLeft(2)",10);
			}
			links[i].onmouseout = function() {
				clearInterval(ref.timerleft);
			}
		}
		if(links[i].getAttribute('id') == "moveRight") {
			var ref = this;
			links[i].timerright = null;
			links[i].onmouseover = function() {
				ref.timerright = setInterval("moveRight(2)",10);
			}
			links[i].onmouseout = function() {
				clearInterval(ref.timerright);
			}
		}
	}
}
///////////////////////////////
function trackthemouse() {
	document.onmousemove = getMouseXY;
	var IE = document.all?true:false;
	if (!IE) document.captureEvents(Event.MOUSEMOVE);
	function getMouseXY(e) {
		if (IE) {
			tempX = event.clientX + document.body.scrollLeft
		} else {
			tempX = e.pageX
		} 
	if (self.innerWidth) {
		frameWidth = self.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth) {
		frameWidth = document.documentElement.clientWidth;
	}
	else if (document.body) {
		frameWidth = document.body.clientWidth;
	}
	var windowMiddle = (frameWidth/2);
	if (tempX < 0) {
		tempX = 0;
	}
		mouseX = tempX - windowMiddle;
	}
}

function donttrackthemouse() {
	document.onmousemove = null;
}

function movePanel() {
	var panel = document.getElementById('panel2');
	var distance = mouseX/30;
	if (distance < 0)	{
		distance = -(distance);
	}
	if (mouseX < 0) {
		moveRight(distance);
	}
	// If the mouse moves to the right, the photo will scroll to the left:
	if (mouseX > 0) {
		moveLeft(distance);
	}
}

function moveLeft(distance) {
	var panel1 = document.getElementById('panel1');
	var panel2 = document.getElementById('panel2');
	var panel1width = parseInt(panel1.offsetWidth);
	var panel2width = parseInt(panel2.offsetWidth);
	var panel2X = panel2.offsetLeft;
	var limit = 0 - panel2width + panel1width;
	if(panel2X <= 0 && panel2X > limit) {
		panel2X  = panel2X - distance;
		panel2.style.left = panel2X +"px";
		if(panel2X > limit && panel2X <= limit + distance) {
			panel2X  = limit;
			panel2.style.left = panel2X +"px";
		}
	}
}

function moveRight(distance) {
	var panel2 = document.getElementById('panel2');
	var panel2X = panel2.offsetLeft;
	if(panel2X >= 0 - distance) {
		panel2X  = panel2X + distance;
		panel2.style.left = 0 +"px";
	}
	if(panel2X < 0 ) {
		panel2X  = panel2X + distance;
		panel2.style.left = panel2X +"px";
	}
}

addLoadEvent(slider);	
