﻿var lacomax = {	
       	 currentslide:0,
       	 maxslides:3,
       	 startWidthSize:200,
       	 startHeightSize:143,
	     endWidthSize:290,
	     endHeightSize:207,
	     	     
	     init : function () {	    
	    		    	
	        var imgarr=[["img/LACoMAX_construction.png,LACoMAX_browse.aspx?search=Construction", "img/LACoMAX_metal.png,LACoMAX_browse.aspx?search=Metal", "img/LACoMAX_plastic.png,LACoMAX_browse.aspx?search=Plastic", "img/LACoMAX_construction.png,LACoMAX_browse.aspx?search=Construction"], 
                        ["img/LACoMAX_container.png,LACoMAX_browse.aspx?search=Containers", "img/LACoMAX_organic.png,LACoMAX_browse.aspx?search=Organics", "img/LACoMAX_rubber.png,LACoMAX_browse.aspx?search=Rubber", "img/LACoMAX_container.png,LACoMAX_browse.aspx?search=Containers"],
                        ["img/LACoMAX_durable_goods.png,LACoMAX_browse.aspx?search=Durable Goods", "img/LACoMAX_paint.png,LACoMAX_browse.aspx?search=Paint", "img/LACoMAX_textile.png,LACoMAX_browse.aspx?search=Textile", "img/LACoMAX_durable_goods.png,LACoMAX_browse.aspx?search=Durable Goods"],
                        ["img/LACoMAX_electronics.png,LACoMAX_browse.aspx?search=Electronics", "img/LACoMAX_paper.png,LACoMAX_browse.aspx?search=Paper", "img/LACoMAX_wood.png,LACoMAX_browse.aspx?search=Wood", "img/LACoMAX_electronics.png,LACoMAX_browse.aspx?search=Electronics"]];                         
            
            var slideElements = document.getElementById("media");            
            if(lacomax.currentslide==0){                             
               for(var i=0; i<=lacomax.maxslides; i++) {			     
			      lacomax.imgSource(slideElements,imgarr,i,0);
			   }
            }            
            
		    var el = document.getElementById("slideshow").getElementsByTagName("img");    		
		    for(var i=0; i<el.length; i++) {
			    var y = el[i];				
			    y.onclick = startSlideShow;			
			    y.onmouseover=fishEyeEffect;	
			    y.onmouseout=restoreSize;		   
		    }
		    
		    function startSlideShow() 
		    {					      
		       if(this.id != ''){		
		         if(this.id=='next-arrow'){
		            lacomax.currentslide++; 
		            if(lacomax.currentslide>lacomax.maxslides) lacomax.currentslide=0;		           
		            lacomax.slideShowAnimation(imgarr, lacomax.currentslide, slideElements);		           
		        }
		        else if(this.id=='prev-arrow'){		           
		           lacomax.currentslide--; 			      
			       if(lacomax.currentslide<0) lacomax.currentslide=lacomax.maxslides; 
			       lacomax.slideShowAnimation(imgarr, lacomax.currentslide, slideElements);
		        }	
		        else
		           location.href=this.id;	        
		      }
		    }		
		    
		    function fishEyeEffect() 
		    {			
		       if(this.id != ''){		
		         if(this.id !='next-arrow' && this.id !='prev-arrow'){		              
		            this.width= lacomax.endWidthSize;
		            this.height=lacomax.endHeightSize;
		        }	
		        else
		        {
		           this.style.cursor='pointer';
		        }	           
		      }
		    }		
		    
		    function restoreSize() 
		    {			
		       if(this.id != ''){		
		         if(this.id !='next-arrow' && this.id !='prev-arrow'){		            
		            this.width=lacomax.startWidthSize;
		            this.height=lacomax.startHeightSize;
		        }
		        else
		        {
		           this.style.cursor='default';
		        }		           
		      }
		    }		       
		 }, 
		 
	     imgSource : function (obj,elem,slideId,x) {	     	    
		    var val = elem[slideId][x];   	   
		    
		    var imgObj=obj.getElementsByTagName("img")[slideId];
		    imgObj.setAttribute("src", val.split(",")[0]);	
		    imgObj.setAttribute("id", val.split(",")[1]);	
		    imgObj.setAttribute("width", lacomax.startWidthSize);	  
		    imgObj.setAttribute("height", lacomax.startHeightSize);		   
		    imgObj.setAttribute("alt", "");		   
		  
		    var hrefObj=obj.getElementsByTagName("a")[slideId];	   
		    hrefObj.setAttribute("href", val.split(",")[1]);	    
	     },	     	    
	    
	     slideShowAnimation : function (elem, slideId, slideElem) {
            for(var i=0; i<=lacomax.maxslides; i++) {			  
			   lacomax.imgSource(slideElem,elem,i,slideId);
			}	
	     }  
    	
    }

    // Add event with wide browser support
    window.onload = lacomax.init;


