/***********************************************
* OO_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
* Object Oriented update 9/19/06
***********************************************/
 // Set message to show at end of gallery(s). Enter "" to disable message.
var endofgallerymsg='';
////NO NEED TO EDIT BELOW THIS LINE////////////
var iedom=document.all||document.getElementById, cgals=[], thewin=null;
function cmotiongallery(id, rest, maxs, maxw, startf)
{
    if(!iedom)
    return;
    this.id=id;
    this.loadedyes=0;
    this.movestate='';
    this.scrollspeed=0;
    this.galid=cgals.length;
    cgals[cgals.length]=this;
    this.rest=rest;
    this.maxs=maxs;
    this.maxw=maxw;
    this.startpos=startf;
    this.fillup();
}
function ietruebody()
{
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
cmotiongallery.prototype.positiondiv=function()
{
    this.mainobjoffset=getposOffset(this.crossmain, "left"),
    this.menuheight=parseInt(this.crossmain.offsetHeight),
    this.mainobjoffsetH=getposOffset(this.crossmain, "top");
}
cmotiongallery.prototype.showhidediv=function(what)
{
    if (endofgallerymsg!="")
    {
        this.positiondiv();
    }
}
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;Y
}
cmotiongallery.prototype.moveleft=function()
{
    if (this.loadedyes)
    {
        this.movestate="left";
        if (iedom&&parseInt(this.cross_scroll.style.left)>(this.menuwidth-this.actualwidth))
        {
            this.cross_scroll.style.left=parseInt(this.cross_scroll.style.left)-this.scrollspeed+"px";
            this.showhidediv("hidden");
        }
        else
            this.showhidediv("visible");
    }
    this.lefttime=setTimeout("cgals["+this.galid+"].moveleft()",10);
}
cmotiongallery.prototype.moveright=function()
{
    if (this.loadedyes)
    {
        this.movestate="right";
        if (iedom&&parseInt(this.cross_scroll.style.left)<0)
        {
            this.cross_scroll.style.left=parseInt(this.cross_scroll.style.left)+this.scrollspeed+"px";
            this.showhidediv("hidden");
        }
        else
            this.showhidediv("visible");
    }
    this.righttime=setTimeout("cgals["+this.galid+"].moveright()",10);
}
cmotiongallery.prototype.motionengine=function(e)
{
    this.mainobjoffset=getposOffset(this.crossmain, "left"),
    dsocx=(window.pageXOffset)? pageXOffset: ietruebody().scrollLeft,
    dsocy=(window.pageYOffset)? pageYOffset : ietruebody().scrollTop,
    curposy=window.event? event.clientX : e.clientX? e.clientX: "";
    curposy-=this.mainobjoffset-dsocx;
    this.leftbound=(this.menuwidth-this.rest)/2;
    this.rightbound=(this.menuwidth+this.rest)/2;
    if (curposy>this.rightbound)
    {
        this.scrollspeed=(curposy-this.rightbound)/((this.menuwidth-this.rest)/2) * this.maxs;
        clearTimeout(this.righttime);
        if (this.movestate!="left") this.moveleft();
    }
    else if (curposy<this.leftbound)
    {
        this.scrollspeed=(this.leftbound-curposy)/((this.menuwidth-this.rest)/2) * this.maxs;
        clearTimeout(this.lefttime);
        if (this.movestate!="right") this.moveright();
    }
    else
        this.scrollspeed=0;
}
function contains_ns6(a, b)
{
    if (b!==null)
        while (b.parentNode)
            if ((b = b.parentNode) == a)
                return true;
    return false;
}
cmotiongallery.prototype.stopmotion=function(e)
{
    if (!window.opera||(window.opera&&e.relatedTarget!==null))
    if ((window.event&&!this.crossmain.contains(event.toElement)) || (e && e.currentTarget && e.currentTarget!= e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget)))
    {
        clearTimeout(this.lefttime);
        clearTimeout(this.righttime);
        this.movestate="";
    }
}
cmotiongallery.prototype.fillup=function()
{
    if (iedom)
    {
        this.crossmain=document.getElementById? document.getElementById("motioncontainer"+this.id) : document.all["motioncontainer"+this.id];
        if(typeof this.crossmain.style.maxWidth!=='undefined')
            this.crossmain.style.maxWidth=this.maxw+'px';
        
        this.menuwidth=this.crossmain.offsetWidth;
        this.cross_scroll=document.getElementById? document.getElementById("motiongallery"+this.id) : document.all["motiongallery"+this.id];
        this.loading=document.getElementsByTagName? document.getElementById('trueContainer'+this.id).getElementsByTagName('img') : document.all['trueContainer'+this.id].all.tags('img');
        for (var i_tem = 0; i_tem < this.loading.length; i_tem++)
            if(typeof this.loading[i_tem].complete=='boolean'&&this.loading[i_tem].complete==false)
            {
                setTimeout("cgals["+this.galid+"].fillup()", 500);
                return;
            }
        this.actualwidth=document.getElementById? document.getElementById("trueContainer"+this.id).offsetWidth : document.all['trueContainer'+this.id].offsetWidth;
        if (this.startpos)
        {
            if (this.startpos <= 0)
                this.cross_scroll.style.left = '0px';
            else
                this.cross_scroll.style.left='-'+this.startpos+'px';
        }
        this.crossmain.onmousemove=new Function("e", "cgals["+this.galid+"].motionengine(e)");

        this.crossmain.onmouseout=new Function("e", "cgals["+this.galid+"].stopmotion(e);cgals["+this.galid+"].showhidediv('hidden')");
    }
    this.loadedyes=1
}
function cmotionresize()
{
    for (var i_tem = 0; i_tem < cgals.length; i_tem++)
    {
        if (document.all&&document.all['motioncontainer'+cgals[i_tem].id] && document.all['motioncontainer'+cgals[i_tem].id].filters)
        {
            document.all['motioncontainer'+cgals[i_tem].id].style.width="0";
            document.all['motioncontainer'+cgals[i_tem].id].style.width=cgals[i_tem].width;
            document.all['motioncontainer'+cgals[i_tem].id].style.width=Math.min(document.all['motioncontainer'+cgals[i_tem].id].offsetWidth, cgals[i_tem].maxw)+'px';
        }
        cgals[i_tem].menuwidth=cgals[i_tem].crossmain.offsetWidth;
        cgals[i_tem].cross_scroll.style.left=cgals[i_tem].startpos? (cgals[i_tem].menuwidth-cgals[i_tem].actualwidth)/cgals[i_tem].startpos+'px' : 0;
    }
}
if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "resize", cmotionresize, false );
else if ( typeof window.attachEvent != "undefined" )
    window.attachEvent( "onresize", cmotionresize );
else 
{
    if ( window.onresize != null ) 
    {
        var oldOnresize = window.onresize;
        window.onresize = function ( e ) 
        {
            oldOnresize( e );
            cmotionresize();
        };
    }
    else
        window.onresize = cmotionresize;
}
