/***********************************************
* CMotion Image Gallery- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for source code
* This copyright notice must stay intact for legal use
* Modified for autowidth and optional starting positions in
* http://www.dynamicdrive.com/forums/showthread.php?t=11839 by jschuer1 8/5/06
***********************************************/

 //1) Set width of the "neutral" area in the center of the gallery.
var restarea=6;
 //2) Set top scroll speed in pixels. Script auto creates a range from 0 to top speed.
var maxspeed=5;
 //4) Set to 1 for left start, 0 for right, 2 for center.
var startpos=0;

function enlargeimage(path, optWidth, optHeight){ //function to enlarge image. Change as desired.
var actualWidth=typeof optWidth!="undefined" ? optWidth : "600px" //set 600px to default width
var actualHeight=typeof optHeight!="undefined" ? optHeight : "500px" //set 500px to  default height
var winattributes="width="+actualWidth+",height="+actualHeight+",resizable=yes"
window.open(path,"", winattributes)
}

////NO NEED TO EDIT BELOW THIS LINE////////////

var iedom=document.all||document.getElementById, scrollspeed=0, movestate='', actualwidth='', cross_scroll, ns_scroll, loadedyes=0, lefttime, righttime;

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function positiondiv(){
var mainobjoffset=getposOffset(crossmain, "left"),
menuheight=parseInt(crossmain.offsetHeight),
mainobjoffsetH=getposOffset(crossmain, "top");
}

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft: what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function moveleft(){
if (loadedyes){
movestate="left";
if (iedom&&parseInt(cross_scroll.style.left)>(menuwidth-actualwidth)){
cross_scroll.style.left=parseInt(cross_scroll.style.left)-scrollspeed+"px";
}
}
lefttime=setTimeout("moveleft()",10);
}

function moveright(){
if (loadedyes){
movestate="right";
if (iedom&&parseInt(cross_scroll.style.left)<0){
cross_scroll.style.left=parseInt(cross_scroll.style.left)+scrollspeed+"px";
}
}
righttime=setTimeout("moveright()",10);
}

function motionengine(e){
var mainobjoffset=getposOffset(crossmain, "left"),
dsocx=(window.pageXOffset)? pageXOffset: ietruebody().scrollLeft,
dsocy=(window.pageYOffset)? pageYOffset : ietruebody().scrollTop,
curposy=window.event? event.clientX : e.clientX? e.clientX: "";
curposy-=mainobjoffset-dsocx;
var leftbound=(menuwidth-restarea)/2;
var rightbound=(menuwidth+restarea)/2;
if (curposy>rightbound){
scrollspeed=(curposy-rightbound)/((menuwidth-restarea)/2) * maxspeed;
clearTimeout(righttime);
if (movestate!="left") moveleft();
}
else if (curposy<leftbound){
scrollspeed=(leftbound-curposy)/((menuwidth-restarea)/2) * maxspeed;
clearTimeout(lefttime);
if (movestate!="right") moveright();
}
else
scrollspeed=0;
}

function contains_ns6(a, b) {
if (b!==null)
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function fillup(){

styleolo1 = document.getElementById("motiongallery");
styleolo2 = document.getElementById("trueContainer");

styleolo1.style.position = 'absolute';
styleolo1.style.top = '0px';
styleolo1.style.left = '0px';
styleolo2.style.margin = '0px';
styleolo2.style.padding = '0px';
if (iedom){
crossmain=document.getElementById("motioncontainer");
menuwidth=crossmain.offsetWidth;
cross_scroll=document.getElementById? document.getElementById("motiongallery") : document.all.motiongallery;
actualwidth=document.getElementById? document.getElementById("trueContainer").offsetWidth : document.all['trueContainer'].offsetWidth;
if (startpos)
cross_scroll.style.left=(menuwidth-actualwidth)/startpos+'px';
crossmain.onmousemove=function(e){
motionengine(e);
}
}
loadedyes=1
}

function thumblow()
	{
	for (i=1;i<GalThumb.length;i++)
		{
		opacity(GalThumb[i],100,50,500);
		document.getElementById(GalThumb[i]).onmouseover = new Function("opacity('"+GalThumb[i]+"',50,100,10)");
		document.getElementById(GalThumb[i]).onmouseout = new Function("opacity('"+GalThumb[i]+"',100,50,500)");
		var i=i+0;
		}
	document.getElementById(GalThumb[0]).style.filter = "alpha(opacity=100)";
	document.getElementById(GalThumb[0]).style.opacity = "1";
	document.getElementById(GalThumb[0]).MozOpacity = "1";
	}
var felsoid = this.value;
function backclick()
	{
	for (i=0;i<GalThumb.length;i++)
		{
		if (document.getElementById(GalThumb[i]).style.opacity == "1")
			{
			if (GalThumb[i] != GalThumb[0])
				{
				opacity(GalThumb[i],100,50,500);
				document.getElementById(GalThumb[i]).onmouseover = new Function("opacity('"+GalThumb[i]+"',50,100,10)");
				document.getElementById(GalThumb[i]).onmouseout = new Function("opacity('"+GalThumb[i]+"',100,50,500)");
				document.getElementById(GalThumb[i-1]).onmouseover = new Function();
				document.getElementById(GalThumb[i-1]).onmouseout = new Function();
				document.getElementById(GalThumb[i-1]).style.filter = "alpha(opacity=100)";
				document.getElementById(GalThumb[i-1]).style.opacity = "1";
				document.getElementById(GalThumb[i-1]).MozOpacity = "1";
				}
			else {}
			}
		var i=i+0;
		}
	}
function forvclick()
	{
	maxkep = GalThumb.length-1;
	for (i=0;i<GalThumb.length;i++)
		{
		if (document.getElementById(GalThumb[i]).style.opacity == "1")
			{
			aktkep = GalThumb[i];
			ujkep = GalThumb[i+1];
			if (GalThumb[i] != GalThumb[maxkep])
				{
				opacity(aktkep,100,50,500);
				document.getElementById(aktkep).onmouseover = new Function("opacity('"+aktkep+"',50,100,10)");
				document.getElementById(aktkep).onmouseout = new Function("opacity('"+aktkep+"',100,50,500)");
				document.getElementById(ujkep).onmouseover = new Function();
				document.getElementById(ujkep).onmouseout = new Function();
				document.getElementById(ujkep).style.filter = "alpha(opacity=100)";
				document.getElementById(ujkep).style.opacity = "1";
				document.getElementById(ujkep).MozOpacity = "1";
				}
			else {}
			}
		}
	}
function thumbclick(felsoid)
	{
	for (i=0;i<GalThumb.length;i++)
		{
		if (GalThumb[i] != felsoid)
			{
			if (document.getElementById(GalThumb[i]).style.opacity == "1")
				{
				opacity(GalThumb[i],100,50,500);
				}
			else {}
			document.getElementById(GalThumb[i]).onmouseover = new Function("opacity('"+GalThumb[i]+"',50,100,10)");
			document.getElementById(GalThumb[i]).onmouseout = new Function("opacity('"+GalThumb[i]+"',100,50,500)");
			}
		else
			{
			document.getElementById(GalThumb[i]).onmouseover = new Function();
			document.getElementById(GalThumb[i]).onmouseout = new Function();
			document.getElementById(GalThumb[i]).style.filter = "alpha(opacity=100)";
			document.getElementById(GalThumb[i]).style.opacity = "1";
			document.getElementById(GalThumb[i]).MozOpacity = "1";
			}
		var i=i+0;
		}
	}
