/* ------------------------------------------------------------------------
	Class: zoomwindow
	Author: Jonathan Boyer (http://www.grafikart.fr)
	Version: 1.1
------------------------------------------------------------------------- */
zoomwindow = {
	/***************************************
	 *
	 *     	CONFIGURATION
	 * 
	 * **********************************/
	Dwidth : 		640, 		// Default width
	Dheight: 		480,		// Default height
	duration:		750,		// Animation duration (ms)
	animation:		"all",		// Do we animate the size of the box ?  (all : animation everytime, img: animation only on link with an img, no : no size animation)
	maskOpacity:	0.4,		// Opacity of the black overlay,
	FLVPlayer:		"/js/zoomwindow/FLVplayer.swf",   // URL of the FLV Player
	MP3Player:	"/js/zoomwindow/MP3player.swf",  // URL of the MP3 Player
	allowOverflow:	false,	// Automatically adjust width/height of the box if the content is larger than the window
	bindable:		"a[rel^='zoomwindow']",  // (jQuery expression) elements which have the zoomwindow behaviour
	theme:		"default", 			// Define the theme to use
	fixed:		false,			// Do we fix the box ? => when we scroll the box follow the window or not ?
	
	/**
	 * You can define here your own custom structure to create a new look for the box (\ at the end of lines are used to make multiline string)
	 *	IMPORTANT ELEMENTS
	 *	#zoomwindow			=> Needed to select all the box elements (don't delete !)
	 *	.zoomwindow_close 	=> A Click on these elements will close the box
	 *	#zoomwindow_aplat	=> The black overlay
	 *	#zoomwindow_content	=> The content will be placed here
	 *	#zoomwindow_title span		=> Title of the link will be displayed here
	 *	#zoomwindow_next, zoomwindow_prev => Clickable button used to navigate in the galery
	 * */
	themes:{
		"default" :	 '\
			<div id="zoomwindow"> \
				<div id="zoomwindow_aplat" class="zoomwindow_close"></div>\
				<div id="zoomwindow_contener">\
					<div id="zoomwindow_relative">\
						<div id="zoomwindow_close" class="zoomwindow_close"></div>\
						<div id="zoomwindow_content"></div>\
						<div id="zoomwindow_bg"><div class="zoomwindow_bg_h"></div><div class="zoomwindow_bg_b"></div><div class="zoomwindow_bg_d"></div><div class="zoomwindow_bg_g"></div><div class="zoomwindow_bg_bg"></div><div class="zoomwindow_bg_bd"></div><div class="zoomwindow_bg_hg"></div><div class="zoomwindow_bg_hd"></div></div>\
						<div id="zoomwindow_nav">\
							<table>\
								<tr>\
									<td width="39"><div id="zoomwindow_prev"></div></td>\
									<td><div id="zoomwindow_title"><span></span></div></td>\
									<td width="39"><div id="zoomwindow_next"></div></td>\
								</tr>\
							</table>\
						</div>\
					</div>\
				</div>\
			</div>\
			',
		// A theme that imitate the lightbox design
		"lightbox" :	 '\
			<div id="zoomwindow" class="lightbox"> \
				<div id="zoomwindow_aplat" class="zoomwindow_close"></div>\
				<div id="zoomwindow_contener">\
					<div id="zoomwindow_relative">\
						<div id="zoomwindow_content"></div>\
						<div id="zoomwindow_bg"><div class="zoomwindow_bg_h"></div><div class="zoomwindow_bg_b"></div><div class="zoomwindow_bg_d"></div><div class="zoomwindow_bg_g"></div><div class="zoomwindow_bg_bg"></div><div class="zoomwindow_bg_bd"></div><div class="zoomwindow_bg_hg"></div><div class="zoomwindow_bg_hd"></div></div>\
						<div id="zoomwindow_infos"<div id="zoomwindow_title"><span></span></div></div>\
						<div id="zoomwindow_close" class="zoomwindow_close"></div>\
						<div id="zoomwindow_next"></div><div id="zoomwindow_prev"></div>\
					</div>\
				</div>\
			</div>\
			'
	},


	/***************************************
	 *
	 *     	VARIABLES
	 * 
	 * **********************************/
	// Needed variable and their explanation
	inCSS:		null, 			// Initial CSS propertires
	
	width:		0,
	height:		0,
	
	url:			null,			// Url loaded in the box
	title:			null,			// Title of the link
	type:		"multimedia",	// Keep the type of media loaded in the box
	animateOpening: false,		// Do we use animation for opening/closing the box ?
	timer:		null,			// Timer to load an img
	loaded:		false,		// Is the image loaded ?
	gallery:		"",			// Gallery of the current element
	position:		0,			// Current position in the gallery
	margesH:		null,			// Horizontal marges of contener
	margesV:		null,			// Vertical marges of contener

	// Regular expressions needed for the content
	filtreImg:			/(\.jpg)|(\.jpeg)|(\.bmp)|(\.gif)|(\.png)/i,
	filtreMP3:			/(\.mp3)/i,
	filtreFLV:			/(\.flv)/i,
	filtreSWF:			/(\.swf)/i,
	filtreQuicktime:	/(\.mov)|(\.mp4)/i,
	filtreWMV:			/(\.wmv)|(\.avi)/i,
	filtreDailymotion:	/(http:\/\/www.dailymotion)|(http:\/\/dailymotion)/i,
	filtreVimeo:		/(http:\/\/www.vimeo)|(http:\/\/vimeo)/i,
	filtreYoutube:		/(youtube\.)/i,
	filtreKoreus:		/(http:\/\/www\.koreus)|(http:\/\/koreus)/i,
	filtreDeezer:		/(http:\/\/www\.deezer)|(http:\/\/deezer)/i,
	
	galleryRegExp:  /\[(?:.*)\]/,
	
	
	/***************************************
	 *
	 *     	FUNCTIONS
	 * 
	 * **********************************/
	/**
	 * Init the box binding "click" on every links with rel="zoomwindow and doing some cool stuff
	 * */
	init : function(){
		$(zoomwindow.bindable).each(function(){
			$(this).unbind('click');
		});
		zoomwindow.images = new Array();	  // Array used to stock the "gallery"
		$(zoomwindow.bindable).each(function(){
			var gallery = zoomwindow.galleryRegExp.exec($(this).attr("rel"));
			if(!zoomwindow.images[gallery]){
				zoomwindow.images[gallery]=new Array();
			}
			zoomwindow.images[gallery].push($(this));
			
			//We bind click on every elements
			$(this).bind('click',function(){
				zoomwindow.click($(this));
				return false;
			});
		});
		$(window).resize(zoomwindow.resize);
		$(window).scroll(zoomwindow.resize);
		$(document).keyup(function(event){ zoomwindow.keyboard(event); });
	},
	
	/**
	 * Function called when we click one an element OR when we use next or before
	 * */
	click : function(div){
		zoomwindow.gallery=zoomwindow.galleryRegExp.exec(div.attr("rel"));	// The current Gallery
		// The position of the image in the current Gallery
		for (var i = 0; i < zoomwindow.images[zoomwindow.gallery].length; i++){
			if($(zoomwindow.images[zoomwindow.gallery][i]).html()  == div.html() && $(zoomwindow.images[zoomwindow.gallery][i]).attr("href") == div.attr("href") ){
				zoomwindow.position=i;
				break;
			}
		}
		zoomwindow.animateOpening=false;
		
		// We adjust the size and position of the box to fit with the current element if animation is needed
		if(zoomwindow.animation=="all"){
			zoomwindow.animateOpening=true;
			zoomwindow.inCSS = {
				"top" :	 div.offset().top,
				"left" :	div.offset().left,
				"width":	div.width(),
				"height":   div.height()
			}
		}
		if(div.children("img").length && (zoomwindow.animation=="all" || zoomwindow.animation=="img")){
			zoomwindow.inCSS = {
				"top" :	 div.children("img").offset().top,
				"left" :	div.children("img").offset().left,
				"width":	div.children("img").width(),
				"height":   div.children("img").height()
			}
			zoomwindow.animateOpening=true;
		}
						
		// We keep important informations
		zoomwindow.url=div.attr("href");			// We keep the url
		zoomwindow.title=div.attr("title");			// We keep the title
		dimensions =div.attr("rel").split(' ');		// We parse the rel attr to get the size of the box
		if((dimensions[1])&&(dimensions[2]) && parseInt(dimensions[1])>0  && parseInt(dimensions[2])>0 ){ zoomwindow.width = parseInt(dimensions[1]); zoomwindow.height =  parseInt(dimensions[2]);}
		else{zoomwindow.width=zoomwindow.Dwidth; zoomwindow.height=zoomwindow.Dheight;}
				
		zoomwindow.open();
		return false;
	},
	
	/**
	 * Open the box, this function could be called with javascript if you want to open a box with a specific action.
	 * @param url The link that you want to open in the box
	 * @param width (optional) Width of the box
	 * @param height (optional) Height of the box
	 * */
	open : function(url,width,height){
		// Do we use the function alone ?
		if(url!=undefined){
			zoomwindow.url=url;
			if(width==undefined){	zoomwindow.width=zoomwindow.Dwidth;	}	else{	zoomwindow.width=width;	}
			if(height==undefined){	zoomwindow.height=zoomwindow.Dheight;	}	else{	zoomwindow.height=height;	}	
			zoomwindow.animateOpening=false;
			zoomwindow.title = null;
		}
		// if the content is an img
		if(zoomwindow.filtreImg.test(zoomwindow.url) && zoomwindow.loaded==false){
		    img=new Image();
			img.src=zoomwindow.url;
			zoomwindow.type="img";
			$("body").append('<div id="zoomwindow_loader"></div>');
			$("#zoomwindow_loader").css("marginTop",zoomwindow.scrollY());
			zoomwindow.timer = window.setInterval("zoomwindow.loadImg(img)",100);
			return false;
		}
		zoomwindow.loaded=false;
		
		// Let's begin !!
		// If there isn't already a zoomwindow opened
		if(!$("#zoomwindow").length){
			$("body").append(zoomwindow.themes[zoomwindow.theme]);	// We create the zoomwindow structure
			// We place the overlay
			$("#zoomwindow_aplat").css({
				"height":zoomwindow.windowH(),
				"width":zoomwindow.windowW()
			});
			// we find the width/height of the marges
			if(zoomwindow.margesH==null){ zoomwindow.margesH = parseInt($("#zoomwindow_contener").css("paddingLeft")) + parseInt($("#zoomwindow_contener").css("paddingRight")) + parseInt($("#zoomwindow_contener").css("marginLeft")) + parseInt($("#zoomwindow_contener").css("marginRight")); }
			if(zoomwindow.margesV==null){ zoomwindow.margesV = parseInt($("#zoomwindow_contener").css("paddingTop")) + parseInt($("#zoomwindow_contener").css("paddingBottom")) + parseInt($("#zoomwindow_contener").css("marginTop")) + parseInt($("#zoomwindow_contener").css("marginBottom")); }
			
			$("#zoomwindow_next").hide();				// We hide some elements, we'll display them later if ther are needed
			$("#zoomwindow_prev").hide();
			$("#zoomwindow_title").hide();
			$(".zoomwindow_close").click(zoomwindow.close);		// We bind the "close" event
			$("#zoomwindow_next").click(zoomwindow.next);		// We bind the "next" event
			$("#zoomwindow_prev").click(zoomwindow.prev);		// We bind the "next" event
			$("embed").css("visibility","hidden"); 			// embed and object elements can generate overflow problem so we hide them
			$("object").css("visibility","hidden");
			if(zoomwindow.gallery){
				if(zoomwindow.position<zoomwindow.images[zoomwindow.gallery].length-1){
					$("#zoomwindow_next").show();
				}
				if(zoomwindow.position>0){
					$("#zoomwindow_prev").show();
				}
			}
			// We animate the black overlay
			$('#zoomwindow_aplat').css({'opacity': 0});
			$('#zoomwindow_aplat').fadeTo(zoomwindow.duration,zoomwindow.maskOpacity);
			// We adjust Two parameters that calculate the initial position of the box adding box margin
			if(zoomwindow.inCSS!=null){
				zoomwindow.inCSS.left-=parseInt($("#zoomwindow_contener").css("paddingLeft"))+parseInt($("#zoomwindow_contener").css("marginLeft"));
				zoomwindow.inCSS.top-=parseInt($("#zoomwindow_contener").css("paddingTop"))+parseInt($("#zoomwindow_contener").css("marginTop"));
			}
			var boxBeginCSS = zoomwindow.inCSS;
		}
		// If there is already a zoomwindow it's because we want a cool transition, so let's make some change.
		else{
			$("#zoomwindow_title span").empty();
			$("#zoomwindow_content").empty();				

			var boxBeginCSS = {
				"width":$("#zoomwindow_contener").css("width"),
				"height":$("#zoomwindow_contener").css("height"),
				"top":$("#zoomwindow_contener").css("top"),
				"left":$("#zoomwindow_contener").css("left")
			}
			var transition = true;
		}
		
		var content = zoomwindow.getContent(zoomwindow.url);					// What we want to insert
		if(zoomwindow.type=="img"){ $("#zoomwindow_content").append(content); }		// If it's an image we inset NOW
		if(transition){ $("#zoomwindow_content img").hide(); }					// If it's a transition (next or prev) we hide the image for a fadeIn
		if(zoomwindow.title && zoomwindow.title!="" && zoomwindow.title!=null){ $("#zoomwindow_title span").append(zoomwindow.title); $("#zoomwindow_title").show();   }  // Do we have a title ?
		else{ $("#zoomwindow_title").hide();	$("#zoomwindow_titlel").hide();	$("#zoomwindow_title").hide(); }// The box won't fit in the window
		if(zoomwindow.allowOverflow==false && (zoomwindow.height+120)>zoomwindow.windowH()){
			zoomwindow.width=zoomwindow.width*((zoomwindow.windowH()-120)/zoomwindow.height);
			zoomwindow.height=(zoomwindow.windowH()-120);
			var content = zoomwindow.getContent(zoomwindow.url);
		}
		
		// The new CSS for the box, final position
		var topPos = (zoomwindow.windowH() - zoomwindow.height - zoomwindow.margesV)/2 + zoomwindow.scrollY();
		var leftPos = (zoomwindow.windowW() - zoomwindow.width - zoomwindow.margesH)/2;

		var cssProp = {
			"width":zoomwindow.width,
			"height":zoomwindow.height,
			"top":topPos,
			"left":leftPos
		}
		
		//Do we want animation ? 
		if(zoomwindow.animateOpening==false && transition !=true){
			$("#zoomwindow_contener").css(cssProp);
			$('#zoomwindow_contener').hide();
			$('#zoomwindow_contener').show();
			$("#zoomwindow_content").empty().append(content);
		}
		else{
			$("#zoomwindow_contener").css(boxBeginCSS);
			$("#zoomwindow_contener").animate(cssProp,zoomwindow.duration,function(){
				if(zoomwindow.type=="img"){
						$("#zoomwindow_content img").fadeIn(zoomwindow.duration/2);
				}
				else{
					$("#zoomwindow_content").empty().append(content);
				}
			});
		}
	},
	
	/**
	 * Close the box
	 * */
	close : function(){
		window.clearInterval(zoomwindow.timer);
		// To avoid lags we remove the content before animation if it isn't an image
		if(zoomwindow.type!="img"){	$("#zoomwindow_content").empty();	}	
		if(zoomwindow.animateOpening==true){
			zoomwindow.inCSS.opacity = 0; 
			$("#zoomwindow_contener").animate(zoomwindow.inCSS,zoomwindow.duration);
		}
		else{
			$("#zoomwindow_contener").remove();
		}
		$("#zoomwindow_aplat").animate({"opacity":0},zoomwindow.duration,zoomwindow.remove);
	},
	
	/**
	 * Destroy the zoomwindow structure
	 * */
	remove : function(){
		$("#zoomwindow").remove();
		$("#zoomwindow_loader").remove();
		$("embed").css("visibility","visible");  // embed and object elements can generate overflow problem so we hide them
		$("object").css("visibility","visible");
	},
	
	/**
	 *	When the window is resized we reposition the box
	 * */
	resize : function(){
		// The new CSS for the box, final position
		var topPos = (zoomwindow.windowH() - zoomwindow.height - zoomwindow.margesV)/2 + zoomwindow.scrollY();
		var leftPos = (zoomwindow.windowW() - zoomwindow.width - zoomwindow.margesH)/2;
		$("#zoomwindow_contener").css("left",leftPos);
		// We place the overlay
		$("#zoomwindow_aplat").css({
			"height":zoomwindow.windowH(),
			"width":zoomwindow.windowW()
		});
		// Do we fix the box ?
		if(zoomwindow.fixed){	$("#zoomwindow_contener").css("top",topPos);	}
	},
	
	/**
	 *   If we press some keys when zoomwindow is opened
	 *   */
	keyboard : function(event){
      		if(event.keyCode==39){
      			zoomwindow.next();
      		}
      		else if(event.keyCode==37){
      			zoomwindow.prev()
      		}
      		else if(event.keyCode==27){
      			zoomwindow.close();
		}
	},
	/**
	 * Go to the next element in the gallery
	 * */
	next : function(){
		if(zoomwindow.gallery!=null){
			zoomwindow.position++;
			if(zoomwindow.position==zoomwindow.images[zoomwindow.gallery].length-1){
				$("#zoomwindow_next").fadeOut();
			}
			if($("#zoomwindow_prev").is(":hidden")){
				$("#zoomwindow_prev").fadeIn();
			}
			zoomwindow.click(zoomwindow.images[zoomwindow.gallery][zoomwindow.position]);
		}
	},
	
	/**
	 * Go to the previous element in the gallery
	 * */
	prev : function(){
		if(zoomwindow.gallery!=null){
			zoomwindow.position--;
			if(zoomwindow.position==0){
				$("#zoomwindow_prev").fadeOut();
			}
			if($("#zoomwindow_next").is(":hidden")){
				$("#zoomwindow_next").fadeIn();
			}
			zoomwindow.click(zoomwindow.images[zoomwindow.gallery][zoomwindow.position]);
		}
	},

	/**
	 * Used with timer this function animate the loading of an image
	 * */
	loadImg : function(img){
			if(img.complete){
				window.clearInterval(zoomwindow.timer);
				zoomwindow.loaded=true;
				zoomwindow.width=img.width;
				zoomwindow.height=img.height;
				$('#zoomwindow_loader').remove();
				// There is already an img in the content, FADE OUT !!
				if($('#zoomwindow_content img').length){
					$('#zoomwindow_content img').fadeOut(zoomwindow.duration/2,function(){$('#zoomwindow_content').empty(); zoomwindow.open();})
				}
				else{
					$('#zoomwindow_content').empty();
					zoomwindow.open();
				}
			}	
			// On anim le loader
			if(typeof(j)=='undefined'){j=0;}
 			$('#zoomwindow_loader').css({'background-position': "0px "+j+"px"});
			j=j-40;
			if(j<(-440)){j=0;}
	},
	
	 /**
	 * Return the HTML content depending of the link
	 * */
	getContent : function(url){
			var content
			
			// Some regular expression to test the filetype
			zoomwindow.type="multimedia";
	
			if(zoomwindow.filtreImg.test(url)){
				content='<img src="'+img.src+'" width="100%" height="100%"/>';
				zoomwindow.type="img";
			}
			else if(zoomwindow.filtreMP3.test(url)){
				zoomwindow.width=300;
				zoomwindow.height=40;
				content ='<object type="application/x-shockwave-flash" data="'+zoomwindow.MP3Player+'?son='+url+'" width="'+zoomwindow.width+'" height="'+zoomwindow.height+'">';
				content+='<param name="movie" value="'+zoomwindow.MP3Player+'?son='+url+'" /></object>';
			}		
			
			else if(zoomwindow.filtreFLV.test(url)){
				content='<embed src="'+zoomwindow.FLVPlayer+'" width="'+zoomwindow.width+'" height="'+zoomwindow.height+'" allowscriptaccess="always" allowfullscreen="true" flashvars="file='+url+'&width='+zoomwindow.width+'&height='+zoomwindow.height+'&autostart=true" wmode="transparent" />';			
			}
			
			else if(zoomwindow.filtreSWF.test(url)){
				content='<object width="'+zoomwindow.width+'" height="'+zoomwindow.height+'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="'+url+'" /><embed src="'+url+'" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+zoomwindow.width+'" height="'+zoomwindow.height+'" wmode="transparent"></embed></object>';		
			}
			
			else if(zoomwindow.filtreQuicktime.test(url)){
				zoomwindow.height = zoomwindow.height+20;
				content='<embed src="'+url+'" width="'+zoomwindow.width+'" height="'+zoomwindow.height+'" controller="true" cache="true" autoplay="true"/>';
			}
			
			else if(zoomwindow.filtreWMV.test(url)){
				content='<embed src="'+url+'" width="'+zoomwindow.width+'" height="'+zoomwindow.height+'" controller="true" cache="true" autoplay="true" wmode="transparent" />';
			}

			else if(zoomwindow.filtreDailymotion.test(url)){
				id=url.split('_');
				id=id[0].split('/');
				id=id[id.length-1];
				content='<object width="'+zoomwindow.width+'" height="'+zoomwindow.height+'"><param name="movie" value="http://www.dailymotion.com/swf/'+id+'&colors=background:000000;glow:000000;foreground:FFFFFF;special:000000;&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/'+id+'&colors=background:000000;glow:000000;foreground:FFFFFF;special:000000;&related=0" type="application/x-shockwave-flash" width="'+zoomwindow.width+'" height="'+zoomwindow.height+'" allowFullScreen="true" allowScriptAccess="always" wmode="transparent" ></embed></object>';
			}
			
			
			else if(zoomwindow.filtreVimeo.test(url)){
				id=url.split('/');
				id=id[3];
				content='<object width="'+zoomwindow.width+'" height="'+zoomwindow.height+'"><param name="allowfullscreen" value="true" />	<param name="allowscriptaccess" value="always" />	<param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id='+id+'&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00AAEB&amp;fullscreen=1" />	<embed src="http://www.vimeo.com/moogaloop.swf?clip_id='+id+'&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00AAEB&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+zoomwindow.width+'" height="'+zoomwindow.height+'" wmode="transparent" ></embed></object>';
			}
			
			
			else if(zoomwindow.filtreYoutube.test(url)){
				id=url.split('watch?v=');
				id=id[1].split('&');
				id=id[0];
				content='<object width="'+zoomwindow.width+'" height="'+zoomwindow.height+'"><param name="movie" value="http://www.youtube.com/v/'+id+'&hl=fr&rel=0&color1=0xFFFFFF&color2=0xFFFFFF&hd=1"></param><embed src="http://www.youtube.com/v/'+id+'&hl=fr&rel=0&color1=0xFFFFFF&color2=0xFFFFFF&hd=1" type="application/x-shockwave-flash" width="'+zoomwindow.width+'" height="'+zoomwindow.height+'" wmode="transparent"></embed></object>';
			}
			
			
			else if(zoomwindow.filtreKoreus.test(url)){
				url=url.split('.html');
				url=url[0];
				content='<object type="application/x-shockwave-flash" data="'+url+'" width="'+zoomwindow.width+'" height="'+zoomwindow.height+'"><param name="movie" value="'+url+'"><embed src="'+url+'" type="application/x-shockwave-flash" width="'+zoomwindow.width+'" height="'+zoomwindow.height+'"  wmode="transparent"></embed></object>';
			}
			
			
			else if(zoomwindow.filtreDeezer.test(url)){
				zoomwindow.width=220;
				zoomwindow.height=55;
				id=url.split('/');
				id=id[id.length-1];
				content='<object width="220" height="55"><param name="movie" value="http://www.deezer.com/embedded/small-widget-v2.swf?idSong='+id+'&colorBackground=0x000000&textColor1=0xFFFFFF&colorVolume=0xFF6600&autoplay=0"></param><embed src="http://www.deezer.com/embedded/small-widget-v2.swf?idSong='+id+'&colorBackground=0x000000&textColor1=0xFFFFFF&colorVolume=0xFF6600&autoplay=0" type="application/x-shockwave-flash" width="220" height="55" wmode="transparent"></embed></object>';
			}
			
			else{
				if(zoomwindow.width==zoomwindow.Dwidth && zoomwindow.height==zoomwindow.Dheight){
					zoomwindow.width=zoomwindow.windowW()-100;
					zoomwindow.height=zoomwindow.windowH()-100;
				}
				content='<iframe style="-moz-transform: scale(0.75)" src="'+url+'" width="'+zoomwindow.width+'" height="'+zoomwindow.height+'" border="0"></iframe>';
			}
			return content;
	},
	
	/**
	* Return the window height
	* */
	windowH : function(){
		if (window.innerHeight) return window.innerHeight  ;
		else{return $(window).height();}
	},
	
	/**
	 * Return the window width
	 * */
	windowW : function(){
		if (window.innerWidth) return window.innerWidth  ;
		else{return $(window).width();}
	},
	
	/**
	 *  Return the position of the top
	 *  */
	scrollY : function() {
		scrOfY = 0;
		if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			scrOfY = window.pageYOffset;
		} else if( document.body && ( document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
		} else if( document.documentElement && ( document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
		}
		return scrOfY;
	},

	/**
	 *  Return the position of the left scroll
	 *  */
	scrollX : function() {
		scrOfX = 0;
		if( typeof( window.pageXOffset ) == 'number' ) {
			//Netscape compliant
			scrOfX = window.pageXOffset;
		} else if( document.body && ( document.body.scrollLeft ) ) {
			//DOM compliant
			scrOfX = document.body.scrollLeft;
		} else if( document.documentElement && ( document.documentElement.scrollLeft ) ) {
			//IE6 standards compliant mode
			scrOfX = document.documentElement.scrollLeft;
		}
		 return scrOfX;
	}
};

$(document).ready(function(){
	zoomwindow.init();
});
