/***********************************************************************************************
	
	Copyright (c) 2005 - Alf Magne Kalleland post@dhtmlgoodies.com
	
	UPDATE LOG:
	
	March, 10th, 2006 : Added support for a message while large image is loading
	
	Get this and other scripts at www.dhtmlgoodies.com
	
	You can use this script freely as long as this copyright message is kept intact.
	
	***********************************************************************************************/ 

    var cantToShow = -1;   	
	var displayWaitMessage=false;	// Display a please wait message while images are loading?   		
	var activeImage = false;
	var imageGalleryLeftPos = false;
	var imageGalleryWidth = false;
	var imageGalleryObj = false;
	var maxGalleryXPos = false;
	var slideSpeed = 0;
	var imageGalleryCaptions = new Array();
	function startSlide(e)
	{
		if(this.id=='imgarrow_right'){
			slideSpeed = -5;
			if (SlideType == 'GALLERY')
		    {
		        this.src = 'images/layout/gallery_move_next_over.png';   
		    }
		    else
		    {
		        this.src = 'images/layout/facultyBoxFeclahDer_over.png';    
		    }
		}else{
			slideSpeed = 5;
			if (SlideType == 'GALLERY')
		    {
		        this.src = 'images/layout/gallery_move_previous_over.png';    
		    }
		    else
		    {
		        this.src = 'images/layout/facultyBoxFeclahIzq_over.png';    
		    }
		}
	}
	
	function releaseSlide()
	{
		if(this.id=='imgarrow_right')
		{
		    if (SlideType == 'GALLERY')
		    {
		        this.src = 'images/layout/gallery_move_next.png';
		    }
		    else
		    {
		        this.src = 'images/layout/facultyBoxFeclahDer.png';   
		    }
		}else
		{			
		    if (SlideType == 'GALLERY')
		    {
		        this.src = 'images/layout/gallery_move_previous.png';
		    }
		    else
		    {
		        this.src = 'images/layout/facultyBoxFeclahIzq.png';    
		    }
		}
		slideSpeed=0;
	}
		
	function gallerySlide()
	{
		if(slideSpeed!=0){
			var leftPos = imageGalleryObj.offsetLeft;
			leftPos = leftPos/1 + slideSpeed;
			if(leftPos>maxGalleryXPos){
				leftPos = maxGalleryXPos;
				slideSpeed = 0;
			}
			if(leftPos<minGalleryXPos){
				leftPos = minGalleryXPos;
				slideSpeed=0;
			}
			
			imageGalleryObj.style.left = leftPos + 'px';
		}
		setTimeout('gallerySlide()',20);
	}
	
	function showImage()
	{
		activeImage = this;	
	}
	
	function initSlideShow()
	{
		if($('imgarrow_left'))
		{ 
			$('imgarrow_left').onmousemove = startSlide;
			$('imgarrow_left').onmouseout = releaseSlide;
		}
		
		if($('imgarrow_right'))
		{
			$('imgarrow_right').onmousemove = startSlide;
			$('imgarrow_right').onmouseout = releaseSlide;
		}
		
		if($('theImages'))
		{
			imageGalleryObj = $('theImages');
			
			var listObject = null;
			if (SlideType == 'GALLERY')
		    {
		        listObject = xx('ImageGallery', imageGalleryObj);
		    }
		    else
		    {
		        listObject = xx('ImageFaculty', imageGalleryObj);
		    }
		    
			if (cantToShow != -1)
			{
			    if (listObject.length <= cantToShow)
			    {
			        $('imgarrow_right').style.display = 'none';   
			        $('imgarrow_left').style.display = 'none';   
			    }
			}
			else if (listObject.length <= 5)
			{
			    $('imgarrow_right').style.display = 'none';   
			    $('imgarrow_left').style.display = 'none';   
			}
			
			imageGalleryLeftPos = imageGalleryObj.offsetLeft;
			imageGalleryWidth = $('galleryContainer').offsetWidth - 10;
			maxGalleryXPos = imageGalleryObj.offsetLeft; 
			minGalleryXPos = imageGalleryWidth - $('slideEnd').offsetLeft;
			var slideshowImages = imageGalleryObj.getElementsByTagName('IMG');
			for(var no=0;no<slideshowImages.length;no++){
				slideshowImages[no].onmouseover = showImage;
			}
			
			var divs = imageGalleryObj.getElementsByTagName('DIV');
			for(var no=0;no<divs.length;no++){
				if(divs[no].className=='imageCaption')imageGalleryCaptions[imageGalleryCaptions.length] = divs[no].innerHTML;
			}
			gallerySlide();
		}
	}
	
	function DisplayItemFaculty(ItemFaculty, action)
	{
	    if (action == 'OVER')
	    {
	        ItemFaculty.style.background = '#006c85';
	    }
	    else if (action = 'OUT')
	    {
	        ItemFaculty.style.background = '#ffffff';
	    }
	}
