// JScript source code
        //cofiguration for the zoom and large image
        dheight=387; //default zoom size
        dwidth=303;
        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 largecomplete=false;
	   var smallcomplete=false;
	   var mytimeout;
	   var thumbhover=false;
	   var menuinuse=false;
	   var initialised=false;
	   var defaultimage=true;
	//get all target div and images 
       var smallimg;
       var largeimg;
       var square;
       var divlarge;
       var startpoint;  
       var zoom_top;

       var thefilter ;  
       var productdetail; 
       var HDVal;
       var atable;
       var zoomZone;
       var sel10;
	   var sel11;
	   var sel12;
       var insideimg;
       var show_review;
       var moveMainDIV=false;
       var square_width = 0;
       var square_Height = 0;
       var borderwidth = 1;
	   var square_borderwidth = 2;
	   
       function setup()
	   {
	   //enable_zoom=true;
	   //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");
	   initpoint = document.getElementById("prodIMAGES");
       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");

       if (square == null) { enable_zoom = false;return false; }
       divlarge.style.top = startpoint.offsetTop + "px";
	   
	   initialised = true;
	   setloadingimg();
	   
	   }  

	   function overset(e)
	   {
	   //alert(enable_zoom);
	   
	   large_image_file_name = largeimg.src;
	   
	   aims(e);
	   
	   
	   
	   if (!enable_zoom){return false;}
	   if (smallimg==null){return false;}
	   aimg=new Image();
       aimg.src=largeimg.src;
       //alert(largeimg.src);
       //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="#000000";
	   
	   square.style.backgroundColor="#000000";
	   
       Set_Trans("o_top",20);
       //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=Math.round(dheight/rate) +"px";
       thefilter.style.width=Math.round(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);
	    
	   }
	   
	   
	   
	   function checkzoom(e) {
		   
		   if(initialised==true){
		  		
				
				
				setloadingimg(oldImage, large_image_file_name);
			
				if (large_image_file_name == undefined){document.getElementById('smlloadingdiv').style.display = 'none';}
			   else if (large_image_file_name == ''){document.getElementById('smlloadingdiv').style.display = 'none';}
			   else if (oldImage == undefined){document.getElementById('smlloadingdiv').style.display = 'none';}
			   else if (oldImage == ''){document.getElementById('smlloadingdiv').style.display = 'none';}
			   else {
				
					overset(e);
					
			   }
			}
		   
	   }
	   
	   function setloadingimg(sml, lge) {
		   
		   if (lge == undefined){document.getElementById('smlloadingdiv').style.display = 'none';}
		   else if (lge == ''){document.getElementById('smlloadingdiv').style.display = 'none';}
		   else if (sml == undefined){document.getElementById('smlloadingdiv').style.display = 'none';}
		   else if (sml == ''){document.getElementById('smlloadingdiv').style.display = 'none';}
		   else {
			   
			   //document.getElementById('holder_CRUMB_PRODUCT').innerHTML = enable_zoom + ' , ' + largecomplete + ' , ' + smallcomplete;
			   
			   if (enable_zoom == false) {
				   
				   document.getElementById('smlloadingdiv').style.display = 'block';
				   menuinuse=false;
				   
				   //alert();
				   largecomplete = false;
				   smallcomplete = false;
				   
				   var newsmallimg = new Image;
				   newsmallimg.src = sml;
				   
				   var newlargeimg = new Image;
				   newlargeimg.src = lge;
				   
				   
				   
				   //if (newlargeimg.src==''){alert('');}
				   //else if (newlargeimg.src=='undefined'){alert('');}
				   
				   
					if (newsmallimg.complete && newlargeimg.complete && thumbhover == false) {
						enable_zoom=true;
						
					}
					else {
						enable_zoom=false;
					}
				   
				   if (newlargeimg.complete) {
						largecomplete = true; 
						
				   }
				   if (newsmallimg.complete) {
						smallcomplete = true; 
						
				   }
				   
				   
				   if (enable_zoom == false && thumbhover == false ) {
						
						if ( smallcomplete == true && largecomplete == false ) {
							document.getElementById('smlloadingdiv').innerHTML = 'Loading Zoom Image...';
						
						}
						else {
							document.getElementById('smlloadingdiv').innerHTML = 'Loading Image...';
						}
						
						document.getElementById('smlloadingdiv').style.display = 'block'; 
		
						mytimeout = setTimeout("setloadingimg(oldImage, large_image_file_name)", 100);
						
				   }
				   else {
						document.getElementById('smlloadingdiv').style.display = 'none'; 
		
						clearTimeout(mytimeout);
						
				   }
			  
			   }
			   else {
					
				clearTimeout(mytimeout);	
					document.getElementById('smlloadingdiv').style.display = 'none'; 
				}
				
		   }
		  		   
	   }
	   
	   
       function aims(e){ 
       //alert('hi');
       //catch cursor position
			
			
			if (initialised==true) {

			
			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){
			  
				var newxpos = (newx - startpoint.offsetLeft);
				var newypos = (newy - startpoint.offsetTop);
				
				
				if ( (newxpos < (square_width / 2)+borderwidth) && (newypos < (square_Height / 2)+borderwidth) ) {
					square.style.left = startpoint.offsetLeft+borderwidth + "px";
					square.style.top = startpoint.offsetTop +borderwidth + "px";
					if(divlarge.style.display=="none"){ 
							divlarge.style.display="block"; 
							trans_value=0;
							tranp=setTimeout("tdisplay()",300);
						} 
				}
				
				else if ( (newxpos < (square_width / 2)+borderwidth) && (newypos > (smallimg.offsetHeight - (square_Height / 2)-borderwidth) ) ) {
					square.style.left = startpoint.offsetLeft+borderwidth + "px";
					square.style.top = startpoint.offsetTop + smallimg.offsetHeight - square_Height -borderwidth + "px";
					if(divlarge.style.display=="none"){ 
							divlarge.style.display="block"; 
							trans_value=0;
							tranp=setTimeout("tdisplay()",300);
						} 
				}
				
				else if ( (newxpos > (smallimg.offsetWidth - (square_width / 2)-borderwidth) ) && (newypos > (smallimg.offsetHeight - (square_Height / 2)-borderwidth) ) ) {
					square.style.left = startpoint.offsetLeft + smallimg.offsetWidth - square_width -borderwidth + "px";
					square.style.top = startpoint.offsetTop + smallimg.offsetHeight - square_Height -borderwidth + "px";
					if(divlarge.style.display=="none"){ 
							divlarge.style.display="block"; 
							trans_value=0;
							tranp=setTimeout("tdisplay()",300);
						} 
				}
				
				else if ( (newxpos > (smallimg.offsetWidth - (square_width / 2)-borderwidth) ) && (newypos < (square_Height / 2)+borderwidth) ) {
					square.style.left = startpoint.offsetLeft + smallimg.offsetWidth - square_width -borderwidth + "px";
					square.style.top = startpoint.offsetTop +borderwidth + "px";
					if(divlarge.style.display=="none"){ 
							divlarge.style.display="block"; 
							trans_value=0;
							tranp=setTimeout("tdisplay()",300);
						} 
				}
				
				else if (newxpos < (square_width / 2)+borderwidth) {
					
					square.style.left = startpoint.offsetLeft+borderwidth + "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 if (newxpos > (smallimg.offsetWidth - (square_width / 2)-borderwidth) ) {
				
					square.style.left = startpoint.offsetLeft + smallimg.offsetWidth - square_width -borderwidth + "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 if (newypos < (square_Height / 2)+borderwidth) {
					
					square.style.top = startpoint.offsetTop +borderwidth + "px";
					square.style.left=newx-parseInt(square.style.width)/2+"px";
					if(divlarge.style.display=="none"){ 
							divlarge.style.display="block"; 
							trans_value=0;
							tranp=setTimeout("tdisplay()",300);
						} 
				}
				
				else if (newypos > (smallimg.offsetHeight - (square_Height / 2)-borderwidth) ) {
					
					square.style.top = startpoint.offsetTop + smallimg.offsetHeight - square_Height -borderwidth + "px";
					square.style.left=newx-parseInt(square.style.width)/2+"px";
					if(divlarge.style.display=="none"){ 
							divlarge.style.display="block"; 
							trans_value=0;
							tranp=setTimeout("tdisplay()",300);
						} 
				}
				
				
				
				else {
					
						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-0.05);
				catchzoom("inside_img",newx-minx,newy-miny,square.style.width,square.style.height,1);
		   
				
		   }
		   
		}
       }        
	   
	   
       function catchzoom(imgid,newx,newy,sx,sy,rate){       
        //relative div
        
       		if ((newy < (square_Height / 2 +borderwidth) ) && (newx < (square_width / 2 +borderwidth) )) {
					
				aimg=document.getElementById(imgid);        
				dx= parseInt(newx)-parseInt(sx)/2;
				dy= parseInt(newy)-parseInt(sy)/2;      
				aimg.style.left= -borderwidth*2 + "px" ;
				aimg.style.top = -borderwidth*2 + "px";    
									
			}
			
			else if ((newy < (square_Height / 2 +borderwidth) ) && (newx > (smallimg.offsetWidth - (square_width / 2 +borderwidth))) ) {
					
				aimg=document.getElementById(imgid);        
				dx= parseInt(newx)-parseInt(sx)/2;
				dy= parseInt(newy)-parseInt(sy)/2;      	
				aimg.style.left= -(smallimg.offsetWidth - square_width)*rate + "px" ;
				aimg.style.top = -borderwidth*2 + "px";    		
					
			}
			
			else if ((newy > (smallimg.offsetHeight - (square_Height / 2 +borderwidth)) ) && (newx > (smallimg.offsetWidth - (square_width / 2 +borderwidth))) ) {
					
				aimg=document.getElementById(imgid);        
				dx= parseInt(newx)-parseInt(sx)/2;
				dy= parseInt(newy)-parseInt(sy)/2;      		
				aimg.style.left= -(smallimg.offsetWidth - square_width)*rate + "px" ; 
				aimg.style.top= -(smallimg.offsetHeight - square_Height)*rate + "px" ;		
					
			}
			
			else if ((newy > (smallimg.offsetHeight - (square_Height / 2 +borderwidth)) ) && (newx < (square_width / 2 +borderwidth) )) {
					
				aimg=document.getElementById(imgid);        
				dx= parseInt(newx)-parseInt(sx)/2;
				dy= parseInt(newy)-parseInt(sy)/2;      		
				aimg.style.left= -borderwidth*2 + "px" ;
				aimg.style.top= -(smallimg.offsetHeight - square_Height)*rate + "px" ;	
					
			}
			
			else if (newy < (square_Height / 2 +borderwidth) ) {
					
				aimg=document.getElementById(imgid);        
				dx= parseInt(newx)-parseInt(sx)/2;
				dy= parseInt(newy)-parseInt(sy)/2;      
				aimg.style.left= -(dx+borderwidth)*rate + "px" ;
				aimg.style.top = -borderwidth*2 + "px";    
					
			}
			
			else if (newy > (smallimg.offsetHeight - (square_Height / 2 +borderwidth)) ) {
					
				aimg=document.getElementById(imgid);        
				dx= parseInt(newx)-parseInt(sx)/2;
				dy= parseInt(newy)-parseInt(sy)/2;      
				aimg.style.left= -(dx+borderwidth)*rate + "px" ;
				aimg.style.top= -(smallimg.offsetHeight - square_Height )*rate + "px" ;	    
					
			}
			
			else if (newx < (square_width / 2 +borderwidth) ) {
					
				aimg=document.getElementById(imgid);        
				dx= parseInt(newx)-parseInt(sx)/2;
				dy= parseInt(newy)-parseInt(sy)/2;      		
				aimg.style.left= -borderwidth*2 + "px" ;
				aimg.style.top = -(dy+borderwidth)*rate  + "px";    

			}
			
			else if (newx > (smallimg.offsetWidth - (square_width / 2 +borderwidth)) ) {
					
				aimg=document.getElementById(imgid);        
				dx= parseInt(newx)-parseInt(sx)/2;
				dy= parseInt(newy)-parseInt(sy)/2;      
				aimg.style.left= -(smallimg.offsetWidth - square_width )*rate + "px" ;
				aimg.style.top = -(dy+borderwidth)*rate  + "px";    
							
			}
			
			else {
			
				aimg=document.getElementById(imgid);        
				dx= parseInt(newx)-parseInt(sx)/2;
				dy= parseInt(newy)-parseInt(sy)/2;        
				aimg.style.left= -(dx+borderwidth)*rate + "px" ;
				aimg.style.top = -(dy+borderwidth)*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';}
        }
