var etailPicturePlusBrowser='msie';
var W=navigator.userAgent.toLowerCase();
if(W.indexOf("opera")!=-1)
{
  etailPicturePlusBrowser='opera';
}
else if(W.indexOf("msie")!=-1)
{
   etailPicturePlusBrowser='msie';
}
else if(W.indexOf("safari")!=-1)
{
   etailPicturePlusBrowser='safari';
}
else if(W.indexOf("mozilla")!=-1)
{
  etailPicturePlusBrowser='gecko';
}
var etailPictureZooming=new Array();
function _el(id)
{
 return document.getElementById(id);
};
function etailPicturePlusStyle(el,styleProp)
{
  if(el.currentStyle)
  {
    var y=el.currentStyle[styleProp];
    y=parseInt(y)?y:'0px';
  }
  else if(window.getComputedStyle)
  {
    var css=document.defaultView.getComputedStyle(el,null);
    var y=css?css[styleProp]:null;
   }
    return y;
}
 
  function etailPicturePlusBind(e)
  {
    if(e.getBoundingClientRect)
    {
        var r=e.getBoundingClientRect();
        var wx=0;
        var wy=0;
        if(document.body&&(document.body.scrollLeft||document.body.scrollTop))
        {
            wy=document.body.scrollTop;
            wx=document.body.scrollLeft
        }
        else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop))      
        {
            wy=document.documentElement.scrollTop;
            wx=document.documentElement.scrollLeft;
        }
        return{'left':r.left+wx,'top':r.top+wy,'right':r.right+wx,'bottom':r.bottom+wy};
     }
   }
   function etailPicturePlusBindEvent(e)
    {
		
         var x=0;var y=0;
         if(etailPicturePlusBrowser == 'msie')
         {
            y=e.clientY;x=e.clientX;
            if(document.body&&(document.body.scrollLeft||document.body.scrollTop))
            {
              y=e.clientY+document.body.scrollTop;
              x=e.clientX+document.body.scrollLeft
			  
            }
            else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop))
            {
             y=e.clientY+document.documentElement.scrollTop;
             x=e.clientX+document.documentElement.scrollLeft}
			 
            }
            else
            {
                y=e.clientY;x=e.clientX;y+=window.pageYOffset;x+=window.pageXOffset
            }
        return{'x':x,'y':y};
		
    }
    function etailPictureSee()
    {
        return false;
    }
    
    
    var etailPictureElementExtend=function()
    {
        var args=arguments;
        if(!args[1])args=[this,args[0]];
        for(var property in args[1])
            args[0][property]=args[1][property];
       
       return args[0];
     };
     
      function etailPicturePlusEventAddListener(obj,event,listener)
     { 
        if(etailPicturePlusBrowser=='gecko'||etailPicturePlusBrowser=='opera'||etailPicturePlusBrowser=='safari')
        {
            try
            {
               obj.addEventListener(event,listener,false);
            }
            catch(e)
            {
               alert("We Find Error In : "+e+", event="+event);
            }
        }
        else if(etailPicturePlusBrowser =='msie')
        {
           obj.attachEvent("on"+event,listener);
        }
      };
      
      function etailPicturePlusEventListenerRemove(obj,event,listener)
      {
        if(etailPicturePlusBrowser=='gecko'||etailPicturePlusBrowser=='opera'||etailPicturePlusBrowser=='safari')
        {
            obj.removeEventListener(event,listener,false);
        }
        else if(etailPicturePlusBrowser=='msie')
        {
           obj.detachEvent("on"+event,listener);
        }
      };
      function etailPicturePlusImageConcat()
      {
        var result=[]; 
        for(var i=0;i<arguments.length;i++)
            for(var j=0;j<arguments[i].length;j++)
                result.push(arguments[i][j]);
                
            return result;
      };
      
      function etailPicturePlusWithoutImage(sequence,skip)
      {
        result=[];
        for(var i=skip;i<sequence.length;i++)
            result.push(sequence[i]);
            
        return result;
      };
      
      function etailPicturePlusMethodReference(object,methodName)
      {
        var args=etailPicturePlusWithoutImage(arguments,2);
        return function()
        {
            object[methodName].apply(object,etailPicturePlusImageConcat(arguments,args));
        }
      };
      function etailPicturePlusEventPropagationClose(e)
      {
        if(etailPicturePlusBrowser=='gecko'||etailPicturePlusBrowser=='safari'||etailPicturePlusBrowser=='opera')
        {
          e.cancelBubble=true;e.preventDefault();e.stopPropagation();
        }
        else if(etailPicturePlusBrowser=='msie')
        {
            window.event.cancelBubble=true
        }
      };
    function etailPicturePlus(smallImageContId,smallImageId,bigImageContId,bigImageId,settings)
    {
        this.recalculating=false;
        this.smallImageCont=_el(smallImageContId);
        this.smallImage=_el(smallImageId);
        this.bigImageCont=_el(bigImageContId);
        this.bigImage=_el(bigImageId);
        this.pup=0;
        this.settings=settings;
        if(!this.settings["header"]){this.settings["header"]=""}
        this.bigImageSizeX=0;this.bigImageSizeY=0;this.smallImageSizeX=0;this.smallImageSizeY=0;this.popupSizeX=20;
        this.popupSizey=20;this.positionX=0;this.positionY=0;this.bigImageContStyleTop='';this.loadingCont=null;
        if(this.settings["loadingImg"]!=''){this.loadingCont=document.createElement('DIV');
        this.loadingCont.style.position='absolute';
        this.loadingCont.style.visibility='hidden';
        this.loadingCont.className='etailPicturePlusLoading';
        this.loadingCont.style.display='block';
        this.loadingCont.style.textAlign='center';
        this.loadingCont.innerHTML=this.settings["loadingText"]+'<br/><img border="0" alt="'+
        this.settings["loadingText"]+'" src="'+this.settings["loadingImg"]+'"/>';
        this.smallImageCont.appendChild(this.loadingCont)}this.baseuri='';
        this.safariOnLoadStarted=false;etailPictureZooming.push(this);
        this.checkcoords_ref=etailPicturePlusMethodReference(this,"checkcoords");
    }; 
    
    etailPicturePlus.prototype.stopZoom=function()
    {
        etailPicturePlusEventListenerRemove(window.document,"mousemove",this.checkcoords_ref);
        if(this.settings["position"]=="custom")
        {
            _el(this.smallImageCont.id+"-big").removeChild(this.bigImageCont)
        }
    };    
    etailPicturePlus.prototype.checkcoords=function(e)
    {
        var r=etailPicturePlusBindEvent(e);var x=r['x'];var y=r['y'];var smallY=0;var smallX=0;
        var tag=this.smallImage;
        while(tag&&tag.tagName!="BODY"&&tag.tagName!="HTML")
        {
            smallY+=tag.offsetTop;
            smallX+=tag.offsetLeft;
            tag=tag.offsetParent;
        }
        if(etailPicturePlusBrowser=='msie')
        {
            var r=etailPicturePlusBind(this.smallImage);
            smallX=r['left'];
            smallY=r['top']
        }
        smallX+=parseInt(etailPicturePlusStyle(this.smallImage,'borderLeftWidth'));
        smallY+=parseInt(etailPicturePlusStyle(this.smallImage,'borderTopWidth'));
        if(etailPicturePlusBrowser!='msie'||!(document.compatMode&&'backcompat'==document.compatMode.toLowerCase()))
        {
            smallX+=parseInt(etailPicturePlusStyle(this.smallImage,'paddingLeft'));
            smallY+=parseInt(etailPicturePlusStyle(this.smallImage,'paddingTop'))
        }
        if(x>parseInt(smallX+this.smallImageSizeX))
        {
            this.hiderect();
            return false;
        }
        if(x<parseInt(smallX))
        {
            this.hiderect();
            return false
        }
        if(y>parseInt(smallY+this.smallImageSizeY))
        {
            this.hiderect();
            return false;
        }
        if(y<parseInt(smallY))
        {   
            this.hiderect();return false; 
        }
        if(etailPicturePlusBrowser=='msie')
        {
            this.smallImageCont.style.zIndex=1;
        }
        return true;
    };     
    etailPicturePlus.prototype.mousedown=function(e)
    {
        etailPicturePlusEventPropagationClose(e);
        this.smallImageCont.style.cursor='move';
    };
    etailPicturePlus.prototype.mouseup=function(e)
    {
        etailPicturePlusEventPropagationClose(e);
        this.smallImageCont.style.cursor='default';
    	//this.smallImageCont.style.cursor='pointer';
    };
    etailPicturePlus.prototype.mousemove=function(e)
    {
		/*
        etailPicturePlusEventPropagationClose(e);
        for(i=0;i<etailPictureZooming.length;i++)
        {
            if(etailPictureZooming[i]!=this)
            {
                etailPictureZooming[i].checkcoords(e);
            }
         }
    if(this.settings&&this.settings["drag_mode"]==true)
    {
        if(this.smallImageCont.style.cursor!='move')
        {
            return;
        }
    }
    if(this.recalculating)
    {
        return;
    }
    if(!this.checkcoords(e))
    {
        return;
    }
    this.recalculating=true;
    var smallImg=this.smallImage;
    var smallX=0;
    var smallY=0;
    if(etailPicturePlusBrowser=='gecko'||etailPicturePlusBrowser=='opera'||etailPicturePlusBrowser=='safari')
    {
        var tag=smallImg;
        while(tag.tagName!="BODY"&&tag.tagName!="HTML")
        {
            smallY+=tag.offsetTop;
            smallX+=tag.offsetLeft;
            tag=tag.offsetParent;
         }
    }
    else
    {
        var r=etailPicturePlusBind(this.smallImage);
        smallX=r['left'];
        smallY=r['top'];
    }
    smallX+=parseInt(etailPicturePlusStyle(this.smallImage,'borderLeftWidth'));
    smallY+=parseInt(etailPicturePlusStyle(this.smallImage,'borderTopWidth'));
    if(etailPicturePlusBrowser!='msie'||!(document.compatMode&&'backcompat'==document.compatMode.toLowerCase()))
    {
        smallX+=parseInt(etailPicturePlusStyle(this.smallImage,'paddingLeft'));
        smallY+=parseInt(etailPicturePlusStyle(this.smallImage,'paddingTop'));
    }
    var r=etailPicturePlusBindEvent(e);
    var x=r['x'];
    var y=r['y'];
    this.positionX=x-smallX;
    this.positionY=y-smallY;
    if((this.positionX+this.popupSizeX/2)>=this.smallImageSizeX)
    {
        this.positionX=this.smallImageSizeX-this.popupSizeX/2;
    }
    if((this.positionY+this.popupSizeY/2)>=this.smallImageSizeY)
    {
        this.positionY=this.smallImageSizeY-this.popupSizeY/2;
    }
    if((this.positionX-this.popupSizeX/2)<=0)
    {
        this.positionX=this.popupSizeX/2;
    }
    if((this.positionY-this.popupSizeY/2)<=0)
    {
        this.positionY=this.popupSizeY/2;
    }
    setTimeout(etailPicturePlusMethodReference(this,"showrect"),10);
  */
  		if(this.smallImage.width >= 400 && this.smallImage.height >=400) // if condition for big image
		{ 
			/*  start*/
			etailPicturePlusEventPropagationClose(e);
				for(i=0;i<etailPictureZooming.length;i++)
				{
					if(etailPictureZooming[i]!=this)
					{
						etailPictureZooming[i].checkcoords(e);
					}
				 } 
			if(this.settings&&this.settings["drag_mode"]==true)
			{
				if(this.smallImageCont.style.cursor!='move')
				{
					return;
				}
			}
			if(this.recalculating)
			{
				return;
			}
			if(!this.checkcoords(e))
			{
				return;
			}
			this.recalculating=true;
			var smallImg=this.smallImage;
			var smallX=0;
			var smallY=0;
			if(etailPicturePlusBrowser=='gecko'||etailPicturePlusBrowser=='opera'||etailPicturePlusBrowser=='safari')
			{
				var tag=smallImg;
				while(tag.tagName!="BODY"&&tag.tagName!="HTML")
				{
					smallY+=tag.offsetTop;
					smallX+=tag.offsetLeft;
					tag=tag.offsetParent;
				 }
			}
			else
			{
				var r=etailPicturePlusBind(this.smallImage);
				smallX=r['left'];
				smallY=r['top'];
			}
			smallX+=parseInt(etailPicturePlusStyle(this.smallImage,'borderLeftWidth'));
			smallY+=parseInt(etailPicturePlusStyle(this.smallImage,'borderTopWidth'));
			if(etailPicturePlusBrowser!='msie'||!(document.compatMode&&'backcompat'==document.compatMode.toLowerCase()))
			{
				smallX+=parseInt(etailPicturePlusStyle(this.smallImage,'paddingLeft'));
				smallY+=parseInt(etailPicturePlusStyle(this.smallImage,'paddingTop'));
			}
			var r=etailPicturePlusBindEvent(e);
			var x=r['x'];
			var y=r['y'];
			this.positionX=x-smallX;
			this.positionY=y-smallY;
			if((this.positionX+this.popupSizeX/2)>=this.smallImageSizeX)
			{
				this.positionX=this.smallImageSizeX-this.popupSizeX/2;
			}
			if((this.positionY+this.popupSizeY/2)>=this.smallImageSizeY)
			{
				this.positionY=this.smallImageSizeY-this.popupSizeY/2;
			}
			if((this.positionX-this.popupSizeX/2)<=0)
			{
				this.positionX=this.popupSizeX/2;
			}
			if((this.positionY-this.popupSizeY/2)<=0)
			{
				this.positionY=this.popupSizeY/2;
			} 
			setTimeout(etailPicturePlusMethodReference(this,"showrect"),10);
			/* end */
		}
		else if(this.smallImage.width < 400 && this.smallImage.height >=400) // if condition for big image
		{ 	
			/* start */
			
			etailPicturePlusEventPropagationClose(e);
				for(i=0;i<etailPictureZooming.length;i++)
				{
					if(etailPictureZooming[i]!=this)
					{
						etailPictureZooming[i].checkcoords(e);
					}
				 } 
			if(this.settings&&this.settings["drag_mode"]==true)
			{
				if(this.smallImageCont.style.cursor!='move')
				{
					return;
				}
			}
			if(this.recalculating)
			{
				return;
			}
			if(!this.checkcoords(e))
			{
				return;
			}
			this.recalculating=true;
			var smallImg=this.smallImage;
			var smallX=0;
			var smallY=0;
			if(etailPicturePlusBrowser=='gecko'||etailPicturePlusBrowser=='opera'||etailPicturePlusBrowser=='safari')
			{
				var tag=smallImg;
				while(tag.tagName!="BODY"&&tag.tagName!="HTML")
				{
					smallY+=tag.offsetTop;
					smallX+=tag.offsetLeft;
					tag=tag.offsetParent;
				 }
			}
			else
			{
				var r=etailPicturePlusBind(this.smallImage);
				smallX=r['left'];
				smallY=r['top'];
			}
			smallX+=parseInt(etailPicturePlusStyle(this.smallImage,'borderLeftWidth'));
			smallY+=parseInt(etailPicturePlusStyle(this.smallImage,'borderTopWidth'));
			if(etailPicturePlusBrowser!='msie'||!(document.compatMode&&'backcompat'==document.compatMode.toLowerCase()))
			{
				smallX+=parseInt(etailPicturePlusStyle(this.smallImage,'paddingLeft'));
				smallY+=parseInt(etailPicturePlusStyle(this.smallImage,'paddingTop'));
			} 
			var r=etailPicturePlusBindEvent(e);
			var x=r['x'];
			var y=r['y'];
			this.positionX=x-smallX;
			this.positionY=y-smallY;
			if((this.positionX+this.popupSizeX/2)>=this.smallImageSizeX)
			{
				this.positionX=this.smallImageSizeX-this.popupSizeX/2;
			}
			if((this.positionY+this.popupSizeY/2)>=this.smallImageSizeY)
			{
				this.positionY=this.smallImageSizeY-this.popupSizeY/2;
			}
			if((this.positionX-this.popupSizeX/2)<=0)
			{
				this.positionX=this.popupSizeX/2;
			}
			if((this.positionY-this.popupSizeY/2)<=0)
			{
				this.positionY=this.popupSizeY/2;
			}
			setTimeout(etailPicturePlusMethodReference(this,"showrect"),10);
			/* end */
			
		}
		else if(this.smallImage.width >= 400 && this.smallImage.height < 400) // if condition for big image
		{	
			/* start */
			
			etailPicturePlusEventPropagationClose(e);
				for(i=0;i<etailPictureZooming.length;i++)
				{
					if(etailPictureZooming[i]!=this)
					{
						etailPictureZooming[i].checkcoords(e);
					}
				 } 
			if(this.settings&&this.settings["drag_mode"]==true)
			{
				if(this.smallImageCont.style.cursor!='move')
				{
					return;
				}
			}
			if(this.recalculating)
			{
				return;
			}
			if(!this.checkcoords(e))
			{
				return;
			}
			this.recalculating=true;
			var smallImg=this.smallImage;
			var smallX=0;
			var smallY=0;
			if(etailPicturePlusBrowser=='gecko'||etailPicturePlusBrowser=='opera'||etailPicturePlusBrowser=='safari')
			{
				var tag=smallImg;
				while(tag.tagName!="BODY"&&tag.tagName!="HTML")
				{
					smallY+=tag.offsetTop;
					smallX+=tag.offsetLeft;
					tag=tag.offsetParent;
				 }
			}
			else
			{
				var r=etailPicturePlusBind(this.smallImage);
				smallX=r['left'];
				smallY=r['top'];
			}
			smallX+=parseInt(etailPicturePlusStyle(this.smallImage,'borderLeftWidth'));
			smallY+=parseInt(etailPicturePlusStyle(this.smallImage,'borderTopWidth'));
			if(etailPicturePlusBrowser!='msie'||!(document.compatMode&&'backcompat'==document.compatMode.toLowerCase()))
			{
				smallX+=parseInt(etailPicturePlusStyle(this.smallImage,'paddingLeft'));
				smallY+=parseInt(etailPicturePlusStyle(this.smallImage,'paddingTop'));
			}
			var r=etailPicturePlusBindEvent(e);
			var x=r['x'];
			var y=r['y'];
			this.positionX=x-smallX;
			this.positionY=y-smallY;
			if((this.positionX+this.popupSizeX/2)>=this.smallImageSizeX)
			{
				this.positionX=this.smallImageSizeX-this.popupSizeX/2;
			}
			if((this.positionY+this.popupSizeY/2)>=this.smallImageSizeY)
			{
				this.positionY=this.smallImageSizeY-this.popupSizeY/2;
			}
			if((this.positionX-this.popupSizeX/2)<=0)
			{
				this.positionX=this.popupSizeX/2;
			}
			if((this.positionY-this.popupSizeY/2)<=0)
			{
				this.positionY=this.popupSizeY/2;
			}
			setTimeout(etailPicturePlusMethodReference(this,"showrect"),10);
			/* end */
			
		}
		//// added by ankita star 21/2/09
  		else
		{
				this.smallImage.style.cursor='default';
				
		}
		/// end
  	}; 
  etailPicturePlus.prototype.showrect=function()
  {  
        var pleft=this.positionX-this.popupSizeX/2;
        var ptop=this.positionY-this.popupSizeY/2;
        var perX=pleft*(this.bigImageSizeX/this.smallImageSizeX);
        var perY=ptop*(this.bigImageSizeY/this.smallImageSizeY);
        if(document.documentElement.dir=='rtl')
        {
            perX=(this.positionX+this.popupSizeX/2-this.smallImageSizeX)*(this.bigImageSizeX/this.smallImageSizeX);
        }
        pleft+=parseInt(etailPicturePlusStyle(this.smallImage,'borderLeftWidth'));
        ptop+=parseInt(etailPicturePlusStyle(this.smallImage,'borderTopWidth'));
        if(etailPicturePlusBrowser!='msie'||!(document.compatMode&&'backcompat'==document.compatMode.toLowerCase()))
        {
            pleft+=parseInt(etailPicturePlusStyle(this.smallImage,'paddingLeft'));
            ptop+=parseInt(etailPicturePlusStyle(this.smallImage,'paddingTop'));
        }
        this.pup.style.left=pleft+'px';
        this.pup.style.top=ptop+'px';
        this.pup.style.visibility="visible";
        if((this.bigImageSizeX-perX)<parseInt(this.bigImageCont.style.width))
        {
            perX=this.bigImageSizeX-parseInt(this.bigImageCont.style.width);
        }
        if((this.bigImageSizeY-perY)<parseInt(this.bigImageCont.style.height))
        {
            perY=this.bigImageSizeY-parseInt(this.bigImageCont.style.height);
        }

        this.bigImage.style.left=(-perX)+'px';
        this.bigImage.style.top=(-perY)+'px';
        this.bigImageCont.style.top=this.bigImageContStyleTop;
        this.bigImageCont.style.display='block';
        this.bigImageCont.style.visibility='visible';
        this.bigImage.style.display='block';
        this.bigImage.style.visibility='visible';
        this.recalculating=false
   };    
   etailPicturePlus.prototype.hiderect=function()
    {
        if(this.settings&&this.settings["bigImage_always_visible"]==true)
             return;
        if(this.pup)
        {
            this.pup.style.visibility="hidden";
        }
        this.bigImageCont.style.top='-10000px';
        if(etailPicturePlusBrowser=='msie')
        {
            this.smallImageCont.style.zIndex=0;
        }
    };  