var rollPadding=0.30;
var rollStep=50;
var IE=d.all?true:false;
// detect mouse moves:
if(!IE)d.captureEvents(Event.MOUSEMOVE);
var d=document;
var i1=null;
var mouseX=0;
var mouseY=0;
function scrollPhotos() {
	var p=d.getElementById("hotPhotos");
	var frame=d.getElementById("hotPhotosFrame");
	var hotPhotosX=-frame.scrollLeft;
	var catalog=d.getElementById("photosTable");
	var catalogWidth=catalog.offsetWidth+32+4;
	//d.getElementById("out").innerHTML=":"+d.getElementById("photosFrame").offsetWidth;
	var x=p.offsetLeft+Math.round(screenWidth*0.07);
	var y=p.offsetTop+564+40;
	var w=p.offsetWidth;
	var h=p.offsetHeight-80;
	//d.getElementById("out").innerHTML=Math.round(screenWidth*0.07)+"-"+x+":"+y+":"+d.documentElement.scrollTop+":"+mouseX+","+mouseY;
	if(mouseX>=x&&mouseX<x+w&&mouseY>=y&&mouseY<y+h){
		//d.getElementById("out").innerHTML="Over";
		var mX=mouseX-x;
		var mY=mouseY-y;

		if(mX<w*(1-rollPadding)&&mX>w*rollPadding)return;
		if(w>catalogWidth)return;

		var p=rollPadding;
		if(mX>w/2)p=(1-rollPadding);
		var f=((w*p-mX)/(w*rollPadding))*1.57;
		if(f>1.57)f=1.57;
		if(f<-1.57)f=-1.57;
		if(mX>w/2)f=Math.cos(f)-1;
		else if(mX<w/2)f=1-Math.cos(f);
		else f=0;
		var o=Math.round(f*rollStep);
		//if(mouseX<=rollSpeedUpWidth)o=rollStep*rollSpeedUp;
		//else if(mouseX>=screenWidth-rollSpeedUpWidth)o=rollStep*-rollSpeedUp;
		hotPhotosX+=o;
		if(w>catalogWidth) hotPhotosX=(w-catalogWidth)/2;
		else {
			if(hotPhotosX<(w-catalogWidth))hotPhotosX=w-catalogWidth;
			else if(hotPhotosX>0)hotPhotosX=0;
		}
		frame.scrollLeft=-hotPhotosX;
		//catalog.style.left=hotPhotosX+"px";
		//catalog.style.visibility="visible";
	}
	//else d.getElementById("out").innerHTML="";
}
// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
	if(IE){ // grab the x-y pos.s if browser is IE
		mouseX=event.clientX+d.documentElement.scrollLeft;
		mouseY=event.clientY+d.documentElement.scrollTop;
	} else{  // grab the x-y pos.s if browser is NS
		mouseX=e.pageX;
		mouseY=e.pageY;
	}  
	// catch possible negative values in NS4
	if(mouseX<0){mouseX=0};
	if(mouseY<0){mouseY=0};
	//document.getElementById("out").innerHTML=mouseX+","+mouseY;
}
function onResize(){
	getScreenSize();
	/*if (document.getElementById("photosFrame")){
		document.getElementById("photosFrame").style.width="1px";
		document.getElementById("photosFrame").style.width=document.getElementById("photos").offsetWidth-4;
	}*/
}
function initHomePage(){
	//d.onmousemove=getMouseXY;
	onEvent(document,"mousemove",getMouseXY);
	onResize();
	onEvent(window,"resize",onResize);
	i1=setInterval("scrollPhotos()",50);
}
onReadys.push(initHomePage);
