/***********************************************
* Ultimate Fade-In Slideshow (v1.51): © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
 
var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]=["xm_client/client_images/Homeshow/Homeshow1.jpg", "", ""] //plain image syntax
fadeimages[1]=["xm_client/client_images/Homeshow/Homeshow2.jpg", "", ""] //image with link syntax
fadeimages[2]=["xm_client/client_images/Homeshow/Homeshow3.jpg", "", ""] //image with link syntax
fadeimages[3]=["xm_client/client_images/Homeshow/Homeshow4.jpg", "", ""] //image with link syntax
fadeimages[4]=["xm_client/client_images/Homeshow/Homeshow5.jpg", "", ""] //image with link syntax

//fadeimages[2]=["../images/3.jpg", "http://www.google.com", "_new"] //image with link and target syntax
 
//var fadeimages2=new Array() //2nd array for a different show on the same site
//SET IMAGE PATHS. Extend or contract array as needed
//fadeimages2[0]=["../images/1.jpg", "", ""] //plain image syntax
//fadeimages2[1]=["../images/2.jpg", "http://www.cssdrive.com", ""] //image with link syntax
//fadeimages2[2]=["../images/3.jpg", "http://www.javascriptkit.com", "_new"] //image with link and target syntax
 
var fadebgcolor="white"

////NO need to edit beyond here/////////////
 
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all
var stop_showing = 0;
 
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
this.pausecheck=pause
this.mouseovercheck=0
this.delay=delay
this.degree=10 //initial opacity degree (10%)
this.curimageindex=0
this.nextimageindex=1
fadearray[fadearray.length]=this
this.slideshowid=fadearray.length-1
this.canvasbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.theimages=theimages
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]

}
 
var fadewidth=fadewidth+this.imageborder*2
var fadeheight=fadeheight+this.imageborder*2
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div></div>')
else
document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}

function fadepic(obj){
if (obj.degree<100){
obj.degree+=10
if (obj.tempobj.filters&&obj.tempobj.filters[0]){
if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
obj.tempobj.filters[0].opacity=obj.degree
else //else if IE5.5-
obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
}
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
else if (obj.tempobj.style.opacity&&!obj.tempobj.filters)
obj.tempobj.style.opacity=obj.degree/101
}
else{
clearInterval(fadeclear[obj.slideshowid])
obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
obj.populateslide(obj.tempobj, obj.nextimageindex)
obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex){
var slideHTML=""
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML+='</a>'
picobj.innerHTML=slideHTML
}
 
 
fadeshow.prototype.rotateimage=function(){
if (stop_showing == 1) { return false } //remove to loop
if (this.pausecheck==1) //if pause onMouseover enabled, cache object
var cacheobj=this
if (this.mouseovercheck==1)
setTimeout(function(){cacheobj.rotateimage()}, 100)
else if (iebrowser&&dom||dom){
this.resetit()
var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
crossobj.style.zIndex++
fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
}
else{
var ns4imgobj=document.images['defaultslide'+this.slideshowid]
ns4imgobj.src=this.postimages[this.curimageindex].src
}
//BRAD'S CUSTOMIZATION
 if (this.curimageindex < this.postimages.length) {  // adding -1 to .length will stop on the showing of the 3rd image
 	this.curimageindex = this.curimageindex+1;
 } else {
 	//stop_showing = 1; //use this line to stop at first image on the second loop
 	this.curimageindex = 0   //use this line for continuous loop
 }
}
 
fadeshow.prototype.resetit=function(){
this.degree=10
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if (crossobj.filters&&crossobj.filters[0]){
if (typeof crossobj.filters[0].opacity=="number") //if IE6+
crossobj.filters(0).opacity=this.degree
else //else if IE5.5-
crossobj.style.filter="alpha(opacity="+this.degree+")"
}
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=this.degree/100
else if (crossobj.style.opacity&&!crossobj.filters)
crossobj.style.opacity=this.degree/101
}
 
 
fadeshow.prototype.startit=function(){
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
this.populateslide(crossobj, this.curimageindex)
if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
var cacheobj=this
var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
}
this.rotateimage()
}



ypSlideOutMenu.Registry=[];
ypSlideOutMenu.aniLen=250;
ypSlideOutMenu.hideDelay=1000;
ypSlideOutMenu.minCPUResolution=10;

function ypSlideOutMenu(id,_2,_3,_4,_5,_6){
    this.ie=document.all?1:0;
    this.ns4=document.layers?1:0;
    this.dom=document.getElementById?1:0;this.css="";
    if(this.ie||this.ns4||this.dom){
        this.id=id;
        this.dir=_2;
        this.orientation=_2=="left"||_2=="right"?"h":"v";
        this.dirType=_2=="right"||_2=="down"?"-":"+";
        this.dim=this.orientation=="h"?_5:_6;
        this.hideTimer=false;this.aniTimer=false;
        this.open=false;this.over=false;
        this.startTime=0;this.gRef="ypSlideOutMenu_"+id;
        eval(this.gRef+"=this");
        ypSlideOutMenu.Registry[id]=this;
        
        var d=document;
        var _8="";
        _8+="#"+this.id+"Container{visibility:hidden;";
        _8+="left:"+_3+"px;";_8+="top:"+_4+"px;";
        _8+="overflow:hidden;z-index:10000;}";
        _8+="#"+this.id+"Container,#"+this.id+"Content{position:absolute;";
        _8+="width:"+_5+"px;";
        _8+="height:"+_6+"px;";
        _8+="clip:rect(0"+_5+""+_6+"0);";
        _8+="}";
        this.css=_8;
        this.load();
    }
}

ypSlideOutMenu.writeCSS=function(){
    document.writeln("<style type=\"text/css\">");
    for(var id in ypSlideOutMenu.Registry){
        document.writeln(ypSlideOutMenu.Registry[id].css);
    }
    document.writeln("</style>");
};

ypSlideOutMenu.prototype.load=function(){
    var d=document;
    var _10=this.id+"Container";
    var _11=this.id+"Content";
    var _12=this.dom?d.getElementById(_10):this.ie?d.all[_10]:d.layers[_10];
    if(_12){
        var _13=this.ns4?_12.layers[_11]:this.ie?d.all[_11]:d.getElementById(_11);
    }
    var _14;
    if(!_12||!_13){
        window.setTimeout(this.gRef+".load()",100);
    }else{
        this.container=_12;this.menu=_13;
        this.style=this.ns4?this.menu:this.menu.style;
        this.homePos=eval("0"+this.dirType+this.dim);
        this.outPos=0;this.accelConst=(this.outPos-this.homePos)/ypSlideOutMenu.aniLen/ypSlideOutMenu.aniLen;
        if(this.ns4){
            this.menu.captureEvents(Event.MOUSEOVER|Event.MOUSEOUT);
        }
        this.menu.onmouseover=new Function("ypSlideOutMenu.showMenu('"+this.id+"')");
        this.menu.onmouseout=new Function("ypSlideOutMenu.hideMenu('"+this.id+"')");
        this.endSlide();
    }
};

ypSlideOutMenu.showMenu=function(id){
    var reg=ypSlideOutMenu.Registry;
    var obj=ypSlideOutMenu.Registry[id];
    if(obj.container){
        obj.over=true;
        for(menu in reg){
            if(id!=menu){
                ypSlideOutMenu.hide(menu);
            }
        }
        
        if(obj.hideTimer){
            reg[id].hideTimer=window.clearTimeout(reg[id].hideTimer);
        }
        
        if(!obj.open&&!obj.aniTimer){
            reg[id].startSlide(true);
        }
    }
};

ypSlideOutMenu.hideMenu=function(id){
    var obj=ypSlideOutMenu.Registry[id];
    if(obj.container){
        if(obj.hideTimer){
        window.clearTimeout(obj.hideTimer);
        }
        obj.hideTimer=window.setTimeout("ypSlideOutMenu.hide('"+id+"')",ypSlideOutMenu.hideDelay);
    }
};

ypSlideOutMenu.hideAll=function(){
    var reg=ypSlideOutMenu.Registry;
    for(menu in reg){
        ypSlideOutMenu.hide(menu);
        if(menu.hideTimer){
            window.clearTimeout(menu.hideTimer);
        }
    }
};

ypSlideOutMenu.hide=function(id){
    var obj=ypSlideOutMenu.Registry[id];
    obj.over=false;
    if(obj.hideTimer){
        window.clearTimeout(obj.hideTimer);
    }
    obj.hideTimer=0;
    if(obj.open&&!obj.aniTimer){
        obj.startSlide(false);
    }
    
};

ypSlideOutMenu.prototype.startSlide=function(_21){
    this[_21?"onactivate":"ondeactivate"]();
    this.open=_21;
    if(_21){
        this.setVisibility(true);
    }

    this.startTime=(new Date()).getTime();
    this.aniTimer=window.setInterval(this.gRef+".slide()",ypSlideOutMenu.minCPUResolution);
};

ypSlideOutMenu.prototype.slide=function(){
    var _22=(new Date()).getTime()-this.startTime;
    if(_22>ypSlideOutMenu.aniLen){
        this.endSlide();
    }else{
        var d=Math.round(Math.pow(ypSlideOutMenu.aniLen-_22,2)*this.accelConst);
        if(this.open&&this.dirType=="-"){
            d=-d;
        }else{
            if(this.open&&this.dirType=="+"){
                d=-d;
            }else{
                if(!this.open&&this.dirType=="-"){
                    d=-this.dim+d;
                }else{
                    d=this.dim+d;
                }
            }
        }
        this.moveTo(d);
    }
};

ypSlideOutMenu.prototype.endSlide=function(){
    this.aniTimer=window.clearTimeout(this.aniTimer);
    this.moveTo(this.open?this.outPos:this.homePos);
    if(!this.open){
        this.setVisibility(false);
    }
    if((this.open&&!this.over)||(!this.open&&this.over)){
        this.startSlide(this.over);
    }
};

ypSlideOutMenu.prototype.setVisibility=function(_24){
    var s=this.ns4?this.container:this.container.style;
    s.visibility=_24?"visible":"hidden";
};

ypSlideOutMenu.prototype.moveTo=function(p){
    this.style[this.orientation=="h"?"left":"top"]=this.ns4?p:p+"px";
};

ypSlideOutMenu.prototype.getPos=function(c){
    return parseInt(this.style[c]);
};

ypSlideOutMenu.prototype.onactivate=function(){};

ypSlideOutMenu.prototype.ondeactivate=function(){};



  var menus = [
    new ypSlideOutMenu("menu1", "down", 5, 80, 170, 59),
    new ypSlideOutMenu("menu2", "down", 57, 80, 170, 40),
    new ypSlideOutMenu("menu3", "down", 147, 80, 170, 97),
    new ypSlideOutMenu("menu4", "down", 237, 80, 170, 21)
  ]
/*
  for (var i = 0; i < menus.length; i++) {
    menus[i].onactivate = new Function("document.getElementById('act" + i + "').className='active';");
    menus[i].ondeactivate = new Function("document.getElementById('act" + i + "').className='';");
  }
*/
  ypSlideOutMenu.writeCSS();
  
  function getCoor(imgId) {
	var d = document;
	  
	var x = (d.layers)?d[imgId].x:d[imgId].offsetLeft;
	var y = (d.layers)?d[imgId].y:d[imgId].offsetTop;
	return x;
}
  
  
  
    function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }
  
  
  function adjustx($name,$lenght)
  {
	  	document.getElementById($name + "Container").style.left = (parseInt(allcord) + $lenght)  + "px";
  }
