var x=0;
var init=2;
var curdirv,xpos;
var pwidth=7217;
var dsect="";
if (self.innerWidth){
	var xavspc=self.innerWidth;
}
else if(document.documentElement&&document.documentElement.clientWidth){
	var xavspc=document.documentElement.clientWidth;
}
else if(document.body){
	var xavspc=document.body.clientWidth;
}
var limg=0.4*xavspc;
var limd=0.6*xavspc;
chint();
document.onmousemove=getPosition;
window.onresize=function(){
	window.location="./"+dsect;
}
window.onload=function(){
	if(document.getElementById&&pwidth){
		document.getElementById("ctrl").onmouseover=function(){init=1;scroll();return false;}
		document.getElementById("ctrl").onmouseout=function(){init=0;return false;}
		chlinks();
		scroll();
	}
}
function chint() {
	(document.getElementById("portfolio"))?document.getElementById("portfolio").style.overflow="hidden":setTimeout("chint()",10);
}
function chlinks() {
	if(document.getElementsByTagName){
		tag=document.getElementsByTagName("img");
		for(i=0;i<tag.length;i++){
			if(tag[i].id.indexOf("kto")!=-1){
				tag[i].subid=tag[i].id.split("kto")[1];
				if(tag[i].subid!="p_0"){
					tag[i].onmouseover=function(){document.getElementById(this.id).src="http://www.ltplamondon.com/images/"+this.subid+"b.jpg";return false;}
					tag[i].onmouseout=function(){document.getElementById(this.id).src="http://www.ltplamondon.com/images/"+this.subid+".jpg";return false;}
				}
				if(tag[i].id.split("kto")[0]=="jl")tag[i].onclick=function(){navto(this.subid);return false;}
			}
		}
	}
}
function getPosition(e) {
	if(!e)var e=window.event;
	(document.body)?documentbody=document.body:documentbody=document.documentElement;
	(e.pageX)?xpos=e.pageX:xpos=e.clientX+documentbody.scrollLeft-document.documentElement.clientLeft;
}
function scroll(){
	if(init==1){
		if(xpos<=limg){
			curdirv=(25*(limg-xpos)/limg);
			if(x<(-1*(pwidth-xavspc)))x=(-1*(pwidth-xavspc));
		}
		else if(xpos>=limd){
			curdirv=(-25*(xpos-limd)/limg);
			if(x>0)x=0;
		}
		else {
			curdirv=0;
		}
		if((x+curdirv)<=0&&(x+curdirv)>=(-1*(pwidth-xavspc))){
			x+=curdirv;
			document.getElementById("pcontenant").style.left=x+"px";
		}
		setTimeout("scroll()",10);
	}
	else if(init==2){
		curdirv=-1;
		if((x+curdirv)<=0&&(x+curdirv)>=(-1*(pwidth-xavspc))){
			x+=curdirv;
			document.getElementById("pcontenant").style.left=x+"px";
		}
		setTimeout("scroll()",10);
	}
}
function navto(tosect){
	if(dsect)document.getElementById(dsect).style.display="none";
	if(document.getElementById(tosect)&&tosect!=dsect){
		document.getElementById(tosect).style.display="block";
		dsect=tosect;
	}
	else if(tosect==dsect){
		dsect="";
	}
}