// JavaScript Document

<!--

	var InteractiveShow = Class.create();

	InteractiveShow.prototype={

		initialize:function(imageArray,id){

			this.animatedId = null;

			if(arguments.length==2){

				this.animatedId = id;

			}

			

			this.currentIndex = -1;

			this.newImageArray = [];

			this.newImageArray = imageArray;

			this.imageArray = imageArray;

			this.lastIndex = this.imageArray.length;

			

		},

		hasImages:function(){

			if(this.newImageArray.length>0){

				return true;

			}

			return false;

		},

		next:function(){

			this.currentIndex++;

			if(this.currentIndex==this.lastIndex){

				this.currentIndex=0;

			}

		},

		previous:function(){

			this.currentIndex--;

			if(this.currentIndex<0){

				this.currentIndex=this.lastIndex-1;

			}

		},

		animate:function(){

			var id = this.animatedId;

			var newImage = this.newImageArray[this.currentIndex];

			$jquery("#"+id).animate({opacity:0.1},200,function(){

				if(Prototype.Browser.IE){

					var parentNode = $("imgFirstImage").parentNode;

					newImage.setAttribute("id","imgFirstImage");

					newImage.style.width=newImage.width+"px";

					newImage.style.height=530;

					parentNode.removeChild($("imgFirstImage"));

					parentNode.appendChild(newImage);

				}else{

					$("imgFirstImage").src=newImage.src;

					$("imgFirstImage").style.width=newImage.width+"px";

				}

				$jquery("#"+id).animate({opacity:1.0},200);

			});

		}

	};

	var interactiveShow = null;

	

	

	var ImageBackground  = Class.create();

	ImageBackground.prototype = {

		initialize:function(opacity,color,objToHide){

			this.objToHide = null;

			this.totalWidth=$jquery(document).width();

			this.totalHeight=$jquery(document).height();

			this.div = document.createElement("div");

			this.div.style.zIndex=10;

			this.div.style.backgroundColor='#000000';

			this.div.style.position='absolute';

			this.div.style.left=0+'px';

			this.div.style.top=0+'px';

			this.div.style.width=this.totalWidth+'px';

			this.div.style.height=this.totalHeight+"px";

			$(this.div).setOpacity(0.5);

			if(arguments.length==1){

				this.div.setOpacity(opacity);

			}

			if(arguments.length==2 && color!=null){

				this.div.style.backgroundColor=color;

			}

			if(arguments.length==3 && objToHide!=null){

				this.objToHide = objToHide;

			}

			

		},

		show:function(){

			document.body.appendChild(this.div);

		},

		hide:function(){

			document.body.removeChild(this.div);

			if(this.objToHide!=null){

				document.body.removeChild(this.objToHide);

			}

		}

	};

	

	var FSLightBox = Class.create();

	FSLightBox.prototype={

		initialize:function(image){

			

			this.imageBackground = new ImageBackground(0.8);

			this.image = image;

			this.finalWidth = parseInt(image.style.width);

			this.finalHeight = 530;

			this.div = document.createElement("div");

			this.div.style.zIndex=11;

			this.div.style.position='absolute';

			this.div.style.width='200px';

			this.div.style.height='200px';

			this.div.style.backgroundColor='#FFFFFF';

			

			this.totalWidth=$jquery(document).width();

			this.totalHeight=$jquery(document).height();

			

			this.div.style.left=parseInt(this.totalWidth/2)-parseInt(this.div.style.width)/2+"px";

			this.div.style.top=parseInt(this.totalHeight/2)-parseInt(this.div.style.height)/2+'px';

			

			this.divTitle = document.createElement("div");

			var randomTitleId = "divTitle_"+new Date().getTime();

			this.divTitle.setAttribute("id",randomTitleId);

			this.divTitle.style.display='none';

			this.divTitle.style.fontWeight="bold";

			this.divTitle.style.paddingLeft="5px";
			var span = document.createElement("span");
			span.style.color="rgb(255,255,255)";
			span.appendChild(document.createTextNode("Plus Design"));
			this.divTitle.appendChild(span);

			this.divTitle.style.textAlign='left';

			this.divTitle.style.color='rgb(46,153,240)';

			this.divTitle.style.fontSize='12pt';

			this.divTitle.style.fontWeight='bold';

			this.div.appendChild(this.divTitle);

			

			this.divImage = document.createElement("div");

			this.divImage.style.textAlign='center';

			var randomId = "divImage_"+new Date().getTime();

			this.div.appendChild(this.divImage);

			

			this.divClose = document.createElement("div");

			this.divClose.setAttribute("id",randomId);

			this.divClose.style.display='none';

			this.divClose.style.textAlign='right';

			this.closeImage = new Image();

			this.closeImage.src="./images/fsCloseLightBox3.gif";

			this.closeImage.style.cursor='pointer';

			

			this.closeImage.imageBackground=this.imageBackground;

			this.closeImage.div = this.div;

			var closeImage = function(event){

				var elem = Event.element(event);

				elem.imageBackground.hide();

				document.body.removeChild(elem.div);

			};

			$(this.closeImage).observe("click",closeImage);
			this.divClose.style.paddingTop="5px";
			this.divClose.appendChild(this.closeImage);

			this.div.appendChild(this.divClose);

			

		},

		show:function(){

			this.imageBackground.show();

			document.body.appendChild(this.div);

		},

		hide:function(){

			document.body.removeChild(this.div);

			this.imageBackground.hide();

		},

		animate:function(){

			var image = this.image;

			var divParent = this.div;

			divParent.finalHeight = this.finalHeight;

			//alert(false);

			new Effect.Scale(this.div,this.finalWidth/parseInt(this.div.style.width)*100+20,{scaleFromCenter:true,scaleY:false,

									afterFinish:function(effect){

										new Effect.Scale(divParent,divParent.finalHeight/parseInt(divParent.style.height)*100+30,{scaleFromCenter:true,scaleX:false,

											afterFinish:function(effect){

												var divTitle = divParent.childNodes[0];

												$jquery("#"+divTitle.getAttribute("id")).fadeIn(900,function(){});

												divParent.childNodes[1].appendChild(image);

												var divClose = divParent.childNodes[divParent.childNodes.length-1];

												$jquery("#"+divClose.getAttribute("id")).fadeIn(900,function(){

													

												});

											}

										});

									}

								}

							);

		}

	};

	

	

	var FSPlayer = Class.create();

	FSPlayer.prototype = {

		initialize:function(imageArray,imageHolder,image){

			this.paused=false;

			this.imageArray = [];

			this.lastIndex = imageArray.length;

			for(var i=0;i<imageArray.length;i++){

				var curImage = new Image();

				curImage.src= imageArray[i];

				this.imageArray.push(curImage);

			}

			this.currentIndex=-1;

			this.imageHolder = imageHolder;

			this.image = image;

		},

		next:function(){

			this.currentIndex++;

			if(this.currentIndex==this.lastIndex){

				this.currentIndex=0;

			}

		},

		previous:function(){

			this.currentIndex--;

			if(this.currentIndex<0){

				this.currentIndex=this.lastIndex-1;

			}

		},

		start:function(){

			//alert(false);

			this.paused=false;

			this.play();

		},

		play:function(){

			if(!this.paused){

				this.next();

				if($("slideShowLogo")){

					document.body.removeChild($("slideShowLogo"));

				}

				$(this.imageHolder).setOpacity(0.0);

				var newImage = this.imageArray[this.currentIndex];

				this.image.src = newImage.src;

				this.image.style.width=newImage.width+"px";

				//alert(this.image.getAttribute("id"));

				//alert(this.image.src);

				var theImage = this.image;

				var id = this.imageHolder.getAttribute("id");

				var mySelf = this;

				//alert(id);

				$jquery("#"+id).animate({opacity:1.0},300,function(){

					mySelf.next();

					//alert(mySelf.currentIndex);

					var innerFunction = function(){

						$jquery("#"+id).animate({opacity:0.0},300,function(){

							//alert(true);

							if(Prototype.Browser.IE){

								var curImage = mySelf.imageArray[mySelf.currentIndex];

								var parentNode = $("imgFirstImage").parentNode;

								curImage.setAttribute("id","imgFirstImage");

								curImage.style.width=curImage.width+"px";

								curImage.style.height=530;

								parentNode.removeChild($("imgFirstImage"));

								parentNode.appendChild(curImage);

							}else{

								var curImage = mySelf.imageArray[mySelf.currentIndex];

								mySelf.image.src=curImage.src;

								mySelf.image.style.width=curImage.width+"px";

							}

							mySelf.play();

							

						});

					};

					setTimeout(innerFunction,1500);

				});

			}

		},

		pause:function(){

			this.paused=true;

		},

		isPlaying:function(){

			if(this.paused){

				return false;

			}

			return true;

		}

	};

	

	function startSlideShow(oEvent){

		if(fsPlayer!=null && !fsPlayer.isPlaying()){

			var elem = Event.element(oEvent);

			elem.src="./images/pauseSlide.gif";

			fsPlayer.start();

			elem.removeAttribute("onclick");

		}else if(fsPlayer==null){

			var elem = Event.element(oEvent);

			elem.src="./images/pauseSlide.gif";

			fsPlayer = new FSPlayer(playerImageArray,$("topPhoto"),$("imgFirstImage"));

			fsPlayer.start();

		}else if(fsPlayer!=null && fsPlayer.isPlaying()){

			var elem = Event.element(oEvent);

			elem.src="./images/startSlide.gif";

			fsPlayer.pause();

			var oPos = Element.cumulativeOffset($("topPhoto"));

			var width = $("topPhoto").offsetWidth;

			var height = $("topPhoto").offsetHeight;

			var slideShowLogo = new Image();

			slideShowLogo.setAttribute("id","slideShowLogo");

			slideShowLogo.src="./images/slideShowLogo.gif";

			slideShowLogo.style.width='300px';

			slideShowLogo.style.height='100px';

			slideShowLogo.style.position='absolute';

			slideShowLogo.style.left=oPos.left+parseInt(width/2)-parseInt(slideShowLogo.style.width)/2+"px";

			slideShowLogo.style.top=oPos.top+parseInt(height/2)-parseInt(slideShowLogo.style.height)/2+"px";

			document.body.appendChild(slideShowLogo);

		}

	}

	var fsPlayer=null;

//-->
