var useSlider1 = true;
var useSlider2 = true;

if(useSlider1){
    /*My Take on an Image Scroller!!*/
    var maxspeed=10; //Speed 
    var neutral=200; // Set Neutral Area
    var startwhere=0; // Right-1, Left-0, Center-2

    // Get the Length of Divs
    var gi = document.getElementById('gallery-images');
    var div = gi.getElementsByTagName('div');
    var divL = 0;
	    for (i=0; i<div.length; i++){
		    if (div[i].className == 'sliderTd1'){
			    divL++;
		    }
	    }
    var divW = 200; // Set Table Width!!
    var maxwidth= divL * divW;  //Set Width
    var wid = maxwidth;// - "75";


    // Set in CSS
    var sW = gi.parentNode;
	    sW.style.width = maxwidth + "px";

    // Everything else should be good!!
    var iedom=document.all||document.getElementById, scrollspeed=0, movestate='', actualwidth='', cross_scroll, ns_scroll, statusdiv, 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";
			    document.getElementById("right-arrow").style.visibility = "visible";
			    document.getElementById("left-arrow").style.visibility = "visible";
    			
		    }
		    else {
			    document.getElementById("right-arrow").style.visibility = "hidden";
			    document.getElementById("left-arrow").style.visibility = "visible";
		    }
	    }
	    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";
			    document.getElementById("left-arrow").style.visibility = "visible";
			    document.getElementById("right-arrow").style.visibility = "visible";
		    }
		    else {
			    document.getElementById("left-arrow").style.visibility = "hidden";
			    document.getElementById("right-arrow").style.visibility = "visible";
		    }
	    }
	    righttime=setTimeout("moveright()",10);
    }

    // The Engine that moves the images nicely!!!
    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-neutral)/2;
	    var rightbound=(menuwidth+neutral)/2;
	    if (curposy>rightbound){
		    scrollspeed=(curposy-rightbound)/((menuwidth-neutral)/2) * maxspeed;
		    clearTimeout(righttime);
		    if (movestate!="left") moveleft();
	    }
	    else if (curposy<leftbound){
		    scrollspeed=(leftbound-curposy)/((menuwidth-neutral)/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 stopmotion(e){
	    if (!window.opera||(window.opera&&e.relatedTarget!==null))
	    if ((window.event&&!crossmain.contains(event.toElement)) || (e && e.currentTarget && e.currentTarget!= e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget))){
		    clearTimeout(lefttime);
		    clearTimeout(righttime);
		    movestate="";
	    }
    }

    function fillup(){
	    if (iedom){
		    crossmain=document.getElementById? document.getElementById("gallery") : document.all.gallery;
		    if(typeof crossmain.style.maxWidth!=='undefined')
			    crossmain.style.maxWidth=maxwidth+'px';
		    menuwidth=crossmain.offsetWidth;
		    cross_scroll=document.getElementById? document.getElementById("gallery-inner") : document.all.gallery-inner;
		    actualwidth=document.getElementById? document.getElementById("gallery-images").offsetWidth : document.all['gallery-images'].offsetWidth;
		    

		leftar=document.getElementById? document.getElementById("left-arrow") : document.all.left-arrow;
		rightar=document.getElementById? document.getElementById("right-arrow") : document.all.right-arrow;

		if (startwhere)
			    cross_scroll.style.left=(menuwidth-actualwidth)/startwhere+'px';
    		
		    crossmain.onmousemove=function(e){
			    motionengine(e);
		    }

		    crossmain.onmouseout=function(e){
			    stopmotion(e);
		    }
	    		
		leftar.onmousemove=function(e){
                            motionengine(e);
                    }

                    leftar.onmouseout=function(e){
                            stopmotion(e);
                    }

                rightar.onmousemove=function(e){
                            motionengine(e);
                    }

                    rightar.onmouseout=function(e){
                            stopmotion(e);
                    }			
		}
		    loadedyes=1
	    if (document.body.filters)
		    onresize()
	    }

	    onresize=function(){
		    if (typeof gallery!=='undefined'&&gallery.filters){
			    gallery.style.width="0";
			    gallery.style.width="";
			    gallery.style.width=Math.min(gallery.offsetWidth, maxwidth)+'px';
		    }
			    menuwidth=crossmain.offsetWidth;
			    cross_scroll.style.left=startwhere? (menuwidth-actualwidth)/startwhere+'px' : 0;
    }
}

if(useSlider2){
    /*My Take on an Image Scroller!!*/
    var maxspeed2=10; //Speed 
    var neutral2=50; // Set Neutral Area
    var startwhere2=0; // Right-1, Left-0, Center-2

    // Get the Length of Divs
    var gi2 = document.getElementById('gallery-images2');
    var div2 = gi2.getElementsByTagName('div');
    var divL2 = 0;
	    for (i=0; i<div2.length; i++){
		    if (div2[i].className == 'sliderTd1'){
			    divL2++;
		    }
	    }
    var divW2 = 200; // Set Table Width!!	
    var maxwidth2= divL2 * divW2;  //Set Width
    var wid2 = maxwidth2;// - "75";

    // Set in CSS
    var sW2 = gi2.parentNode;
	    sW2.style.width = maxwidth2 + "px";

    // Everything else should be good!!
    var iedom2=document.all||document.getElementById, scrollspeed2=0, movestate2='', actualwidth2='', cross_scroll2, ns_scroll2, statusdiv2, loadedyes2=0, lefttime2, righttime2;

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

    function positiondiv2(){
	    var mainobjoffset2=getposOffset2(crossmain2, "left"),
	    menuheight2=parseInt(crossmain2.offsetHeight),
	    mainobjoffsetH2=getposOffset2(crossmain2, "top");
    }


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


    function moveleft2(){
	    if (loadedyes2){
		    movestate2="left";
		    if (iedom2&&parseInt(cross_scroll2.style.left)>(menuwidth2-actualwidth2)){
			    cross_scroll2.style.left=parseInt(cross_scroll2.style.left)-scrollspeed2+"px";
			    document.getElementById("right-arrow2").style.visibility = "visible";
			    document.getElementById("left-arrow2").style.visibility = "visible";
    			
		    }
		    else {
			    document.getElementById("right-arrow2").style.visibility = "hidden";
			    document.getElementById("left-arrow2").style.visibility = "visible";
		    }
	    }
	    lefttime2=setTimeout("moveleft2()",10);
    }

    function moveright2(){
	    if (loadedyes2){
		    movestate2="right";
		    if (iedom2&&parseInt(cross_scroll2.style.left)<0){
			    cross_scroll2.style.left=parseInt(cross_scroll2.style.left)+scrollspeed2+"px";
			    document.getElementById("left-arrow2").style.visibility = "visible";
			    document.getElementById("right-arrow2").style.visibility = "visible";
		    }
		    else {
			    document.getElementById("left-arrow2").style.visibility = "hidden";
			    document.getElementById("right-arrow2").style.visibility = "visible";
		    }
	    }
	    righttime2=setTimeout("moveright2()",10);
    }

    // The Engine that moves the images nicely!!!
    function motionengine2(e2){
	    var mainobjoffset2=getposOffset2(crossmain2, "left"),
		    dsocx2=(window.pageXOffset)? pageXOffset: ietruebody2().scrollLeft,
		    dsocy2=(window.pageYOffset)? pageYOffset : ietruebody2().scrollTop,
		    curposy2=window.event? event.clientX : e2.clientX? e2.clientX: "";
		    curposy2-=mainobjoffset2-dsocx2;		
	    var leftbound2=(menuwidth2-neutral2)/2;
	    var rightbound2=(menuwidth2+neutral2)/2;
	    if (curposy2>rightbound2){
		    scrollspeed2=(curposy2-rightbound2)/((menuwidth2-neutral2)/2) * maxspeed2;
		    clearTimeout(righttime2);
		    if (movestate2!="left") moveleft2();
	    }
	    else if (curposy2<leftbound2){
		    scrollspeed2=(leftbound2-curposy2)/((menuwidth2-neutral2)/2) * maxspeed2;
		    clearTimeout(lefttime2);
		    if (movestate2!="right") {
			    moveright2();
		    }
	    }
	    else {
		    scrollspeed2=0;
	    }
    }

    function contains_ns62(a2, b2) {
	    if (b2!==null)
	    while (b2.parentNode)
	    if ((b2 = b2.parentNode) == a2)
	    return true;
	    return false;
    }

    function stopmotion2(e2){
	    if (!window.opera||(window.opera&&e.relatedTarget!==null))
	    if ((window.event&&!crossmain2.contains(event.toElement)) || (e2 && e2.currentTarget && e2.currentTarget!= e2.relatedTarget && !contains_ns62(e2.currentTarget, e2.relatedTarget))){
		    clearTimeout(lefttime2);
		    clearTimeout(righttime2);
		    movestate2="";
	    }
    }

    function fillup2(){
	    if (iedom2){
		    crossmain2=document.getElementById? document.getElementById("gallery2") : document.all.gallery2;
		    if(typeof crossmain2.style.maxWidth!=='undefined')
			    crossmain2.style.maxWidth=maxwidth2+'px';
		    menuwidth2=crossmain2.offsetWidth;
		    cross_scroll2=document.getElementById? document.getElementById("gallery-inner2") : document.all.gallery-inner2;
		    actualwidth2=document.getElementById? document.getElementById("gallery-images2").offsetWidth : document.all['gallery-images2'].offsetWidth;
		    

		leftar2=document.getElementById? document.getElementById("left-arrow2") : document.all.left-arrow2;
                rightar2=document.getElementById? document.getElementById("right-arrow2") : document.all.right-arrow2;
	
		if (startwhere2)
			    cross_scroll2.style.left=(menuwidth2-actualwidth2)/startwhere2+'px';
    		
		    crossmain2.onmousemove=function(e2){
			    motionengine2(e2);
		    }

		    crossmain2.onmouseout=function(e2){
			    stopmotion2(e2);
		    }
		leftar2.onmousemove=function(e){
                            motionengine2(e);
                    }

                    leftar2.onmouseout=function(e){
                            stopmotion2(e);
                    }

                rightar2.onmousemove=function(e){
                            motionengine2(e);
                    }

                    rightar2.onmouseout=function(e){
                            stopmotion2(e);
                    }    
	}
		    loadedyes2=1
	    if (document.body.filters)
		    onresize2()
	    }

	    onresize2=function(){
		    if (typeof gallery2!=='undefined'&&gallery2.filters){
			    gallery2.style.width="0";
			    gallery2.style.width="";
			    gallery2.style.width=Math.min(gallery2.offsetWidth, maxwidth2)+'px';
		    }
			    menuwidth2=crossmain2.offsetWidth;
			    cross_scroll2.style.left=startwhere2? (menuwidth2-actualwidth2)/startwhere2+'px' : 0;
    }

}
