// JavaScript Document
	var picnext = 0;
	var picback = 0;
	
	function popup(id){
		
		if($("#popup").length==0){
			$('body').append('<div id="popup"></div>');
			$("#popup").hide();
		}
		if($(id).length==0){
			$("#popup").fadeOut("fast");
		}else{
			var imgurl;
			var newsize;
			newsize = ".fit." + (Math.round((document.documentElement.clientWidth-100)/100)*100) + "x" + (Math.round((document.documentElement.clientHeight-150)/100)*100) + ".jpg";
			imgurl = $(id).attr("href").replace(".jpg", newsize);
			var html = '<a href="javascript:popup(0);" style="background-image:url(' + imgurl + ');" class="i">&nbsp;</a><p><a href="#" class="back">Back</a><a href="' + $(id).attr("href") + '" class="save">Download</a><a href="#" class="close">Close</a><a href="#" class="next">Next</a></p>';
			$("#popup").html(html);
			$("#popup").fadeIn("slow");
					

			var picnext = $(id).next("a");
			var picback = $(id).prev("a");
					
			$('#popup>p>a.close').click(function(){return popup(0);});
			$('#popup>p>a.next').click(function(){return popup(picnext); });
			$('#popup>p>a.back').click(function(){return popup(picback); });
			return false;
			
			//$("body").find("div").eq(2).addClass("blue");
		}
		
	}

	$(function(){
		// Escorts PopUp
		$('a.ip').hover(function(){pop_escort(this,"i")},function(){pop_escort_hide()});
		$('a.tp').hover(function(){pop_escort(this,"t")},function(){pop_escort_hide()});
		
		$('a[href$=".jpg"]').click(function(){return popup(this);});
		$('a[href^="http://www.youtube.com"]').click(function(){
			html = '<div id="youtube" style="height:' + $(this).height() + 'px;width:' + $(this).width() + 'px;"><object class="youtube" type="application/x-shockwave-flash" data="' + this.href + '?rel=0&border=0&showinfo=0&autoplay=1&ap=%2526fmt%3D22" height="' + $(this).height() + '" width="' + $(this).width() + '" allowscriptaccess="always" allowfullscreen="true"><param name="movie" value="' + this.href + '?rel=0&border=0&showinfo=0&autoplay=1&ap=%2526fmt%3D22" /><param name="wmode" value="transparent" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="true" /></object></div>';
			$(this).replaceWith(html);
			return false;
		});

   	});	
