// JScript source code
        //cofiguration for the zoom and large image
        dheight=169; //default zoom size
        dwidth=140;
        Dbox=false;  //zoom box automatic shrink?
        DReplace=false;  //strecth page the product detail?(false = overlap the product detail)
        trans_value=0;
        tranp=null;
        rate=0;             
        maxx=0;
        minx=0;
        maxy=0;
        miny=0;
        
	    isIE = false; 
	    navVer = navigator.appVersion; 
	    ver = parseFloat(navVer); 
	    IEPos = navVer.indexOf('MSIE'); 
	    if (IEPos !=-1) { 
  	        isIE = true; 
  	        ver = parseFloat(navVer.substring(IEPos+5,navVer.indexOf(';',IEPos))); 
	    }
	    isIE5up = (isIE && ver >= 5);
	   
	   var enable_zoom=false;

	   
	   var square_width=0; 
       var square_Height=0;
		 
       function setup()
	   {
	  
	   //alert(enable_zoom);
	   smallimg=document.getElementById("productImage");
       largeimg=document.getElementById("large_img");
       square=document.getElementById("zoom_square");
       divlarge=document.getElementById("div_large");
       startpoint=document.getElementById("zoom_start");  
       zoom_top=document.getElementById("o_top");

       thefilter =document.getElementById("tbfilter");  
       productdetail=document.getElementById("product_description_block"); 
       HDVal=document.getElementById("HDsrc");
       //atable=document.getElementById("Table1");
       zoomZone=document.getElementById("zoomArea");
       sel10=document.getElementById("sel_10");
	   sel11=document.getElementById("sel_11");
	   sel12=document.getElementById("sel_12");
       insideimg=document.getElementById("inside_img");
       divlarge.style.top = startpoint.offsetTop + "px";
       if (square != null) {
           enable_zoom = true;
       }
       
	   }  

	   function overset(e)
	   {
	   //alert(enable_zoom);
	   if (!enable_zoom){return false;}
	   if (smallimg==null){return false;}
	   aimg=new Image();
       aimg.src=largeimg.src; 
       //alert(aimg.width);
       //if(largeimg.src.indexOf("/large/") <0)
       //{return false;}  
       //if(!isIE5up){allevent=e;}else{allevent=event;}
       //zoomZone.onmousemove=aims(allevent);
       //square.onmousemove=aims(allevent); 
       
       largeimg.style.width=parseInt(aimg.width)+"px";
       largeimg.style.height=parseInt(aimg.height)+"px"; 
       
       //get the rate for zoom sqare and set it size 
       rate=parseInt(largeimg.style.width)/parseInt(smallimg.width);
       //alert(rate);
       if(rate<1){return false;} 
       
       zoom_top.style.display="block";      
       zoom_top.style.width=  smallimg.offsetWidth+"px";
       zoom_top.style.height=  smallimg.offsetHeight+"px";
       zoom_top.style.top=  startpoint.offsetTop+"px";
       zoom_top.style.left=  startpoint.offsetLeft+"px";
       
       divlarge.style.border="solid 1px #E5E1D3";
       divlarge.style.backgroundColor="#F3F1EB";

       Set_Trans("o_top",50);
       //alert(zoom_top.style.width+"," +zoom_top.style.height+","+zoom_top.style.top+","+ zoom_top.style.left);
       
       divlarge.style.height=dheight +"px";
       divlarge.style.width=dwidth + "px";  
      
       square.style.width=Math.round(parseInt(divlarge.style.width)/rate)+"px";
       square.style.height=Math.round(parseInt(divlarge.style.height)/rate)+"px";
       
       square_width = Math.round(parseInt(divlarge.style.width) / rate);
       square_Height = Math.round(parseInt(divlarge.style.height) / rate);

        
       //set the move area 
       maxx=parseInt(smallimg.offsetWidth) + parseInt(startpoint.offsetLeft);
       minx=parseInt(startpoint.offsetLeft);
       maxy=parseInt(smallimg.offsetHeight)+ parseInt(startpoint.offsetTop);
       miny=parseInt(startpoint.offsetTop);
       
       //productdetail.style.display="block";       
       
       thefilter.style.height=dheight/rate +"px";
       thefilter.style.width=dwidth/rate + "px"; 
          
       insideimg.src= smallimg.src;

	   insideimg.style.height=smallimg.offsetHeight+"px";
	   insideimg.style.width=smallimg.offsetWidth+"px";
	   //alert(insideimg.style.height+ "," +insideimg.style.width);
	    aims(e);
	   }
	   
	   
       function aims(e){ 
       //alert('hi');
       //catch cursor position
       
       if (!enable_zoom){return false;}
        if(!isIE5up){allevent=e;}else{allevent=event;}
        if(!isIE5up){
				var newx=e.pageX;
				var newy=e.pageY;
				
			}else{
				var newx=event.clientX + document.documentElement.scrollLeft;
				var newy=event.clientY + document.documentElement.scrollTop;
				
			}
	  //  return false; 
        if (square.offsetWidth < 1 || square.offsetHeight < 1) {
            square.style.width = square_width + "px";
            square.style.height = square_Height + "px";
         }

	    //check cursor position if it's on the product image
	    
		if(newx>minx-1 && newx<maxx+1 && newy>miny-1 && newy<maxy+1){
		  
	        square.style.left=newx-parseInt(square.style.width)/2+"px";
	        square.style.top=newy-parseInt(square.style.height)/2+"px";
	        if(divlarge.style.display=="none"){ 
	            divlarge.style.display="block"; 
	            trans_value=0;
		        tranp=setTimeout("tdisplay()",300);
	        } 

	    }
	    else
	    {
	        //out of image, not diplay, go back
	        hideZoom();	        
	    }
	    
	    //show right part of image in the windiow
	    if(	square)
	    {    
	    catchzoom("large_img",newx-minx,newy-miny,square.style.width,square.style.height,rate);
	    catchzoom("inside_img",newx-minx,newy-miny,square.style.width,square.style.height,1);
	    }
       }        
       
       function catchzoom(imgid,newx,newy,sx,sy,rate){       
        //relative div
        
        aimg=document.getElementById(imgid);        
		dx= parseInt(newx)-parseInt(sx)/2;
		dy= parseInt(newy)-parseInt(sy)/2;        
		aimg.style.left=-2-dx*rate  + "px";
		aimg.style.top=0-dy*rate+ "px";    
        if(isIE5up){
	    //alert(smallimg.style.left);
	       aimg.style.left=-dx*rate  + "px"; 
	    }
        }   
        
         function tdisplay(){
         clearTimeout(tranp);
         trans_value=trans_value+10;
         
         if(trans_value<=100){
            //alert(trans_value);
            Set_Trans("div_large",trans_value);      
            Set_Trans("large_img",trans_value);  
           
            tranp=setTimeout("tdisplay()",20);
         }
         else{
            if(sel10!=null && getIEver()=="IE6"){
	            sel10.style.visibility="hidden";
	        }
            if(sel11!=null  && getIEver()=="IE6"){
	            sel11.style.visibility="hidden";
	        }
	         if(sel12!=null  && getIEver()=="IE6"){
	            sel12.style.visibility="hidden";
	        }
         
         }
         }   
        
        function hideZoom(e){       
        //hide everything about zoom function
           
            if(square){
		    square.style.width="0px";
            square.style.height="0px";   
            zoom_top.style.display="none"; 
 
            divlarge.style.display="none";  
            Set_Trans("div_large",0);      
            Set_Trans("large_img",0);  
            Set_Trans("o_top",0); 
            //productdetail.style.display="block";   
            if(sel10!=null && getIEver()=="IE6"){
	   			sel10.style.visibility="visible";
	   		}
       		if(sel11!=null && getIEver()=="IE6"){
	   			sel11.style.visibility="visible";
	   			
	   		}
	   		if(sel12!=null && getIEver()=="IE6"){
	   			sel12.style.visibility="visible";
	   			
	   		}
	        }
           
        }  
        
         function getIEver() {
            if(detectBrowser()=="IE")
            {
               
                anav=navigator.userAgent;
                if (anav.indexOf("MSIE 6.0")>-1)
                {
                    return "IE6"
                }
                else
                {
                    return "IE7"
                }
            }
            else
            {
                return "not IE";
            }
         }
         
        function detectBrowser() {
            BROWSER_TYPE="";
            aname=navigator.appName;
            anav=navigator.userAgent;
          
            if(aname=="Microsoft Internet Explorer"){
                if(anav.indexOf("Opera")>-1){
                    BROWSER_TYPE="OP";
                }
                else
                {
                    BROWSER_TYPE="IE";
                }
            }
            if(aname=="Netscape"){
                if(anav.indexOf("Firefox")>-1)
                {
                BROWSER_TYPE="FF";
                }
                if(anav.indexOf("Navigator")>-1)
                {
                BROWSER_TYPE="NS";
                }   
                if(anav.indexOf("Safari")>-1)
                {
                BROWSER_TYPE="SF";
                }
                
            }
            if(aname=="Opera"){
                BROWSER_TYPE="OP";
            }
            return(BROWSER_TYPE)
        }
        
    function Set_Trans(objid,aval){
        theobj=document.getElementById(objid);
        if(detectBrowser()=="NS" || detectBrowser()=="FF")
            {
            theobj.style.MozOpacity=aval/100   ;
            }
        if(detectBrowser()=="OP")
            {        		   
		    theobj.style.opacity  = aval/100  ;
		    }
		if(detectBrowser()=="SF")
		    {
		    theobj.style.KhtmlOpacity = aval/100 ;
		    }
		if(detectBrowser()=="IE")
		    {
		    theobj.filters[0].opacity = aval;
		    }    
		
    
    }
    

		
		
		
		function expandItImage(){
				omoreImages = getMyHTMLElement('moreImages').style
				omoreImagesExpansion = getMyHTMLElement('moreImagesExpansion').style
				if (omoreImages.display=="none"){
				omoreImages.display=""
				omoreImagesExpansion.display="none"}
				else{
				omoreImages.display="none"
				omoreImagesExpansion.display=""
				}
				}
		function collapseItImage(){
				omoreImages = getMyHTMLElement('moreImages').style
				omoreImages.display=""
				}
				
		function init_layers(){		
		
		if ( enable_zoom){
	    getMyHTMLElement('secondary_description_block').innerHTML = getMyHTMLElement('product_description_block').innerHTML ;
        getMyHTMLElement('secondary_description_block').style.display = '';
        getMyHTMLElement('product_description_block').style.display = 'none';}
        }
