$(function() {
	$('#biopopup2 .author a').hover(function() {
		var authorwidth = $('#biopopup2 .author').width() + 20;
		$('.popcont').css({'left':authorwidth});
		$('.popcont').show();
		clearTimeout(popconttimer);
	},
	function() {
		popconttimer = setTimeout("hidePopcont()", '500');
	});
	$('.popcont').hover(function() {
		clearTimeout(popconttimer);
	},
	function() 
	{
		popconttimer = setTimeout("hidePopcont()", '500');
	});
});
function hidePopcont() {
	$('.popcont').hide();
}

$(function() { 

	$('.share a').each(function() {
		/*
		$(this).bind("mouseover", function() {
		var url = escape(window.location.href);
		//alert(url);
		var title = escape($('#galleryHeader h1').text() + ' | EW.com');
		//alert(title);
		return addthis_open(this, '', '[URL]', '[TITLE]');
		});
		$('.bookmarkMenu').bind("mouseout", function() {
			addthis_close();
		});
		
	*/
		$(this).bind("click", function() {
			return addthis_sendto();
		});
	});
	if (($.browser.msie) && ($.browser.version.substring(0,1) === '6')) {
		$('#newPackageContainer .photobox').css({'position':'static'});
		$('#newPackageContainer .cnt').css({'background-image':'http://img2.timeinc.net/ew/static/i/gallery_pagenumber_bg.gif'});
	}
	var service = "fark";
	var url = "http://www.addthis.com/bookmark.php?v=152&winname=addthis&pub=ewcom&source=men-250&lng=en-US&s=" + service + "&url=" + escape(window.location.href)+ "&title=" + escape($('#galleryHeader h1').text() + ' | EW.com');	
	$('.fark a').attr('href', url).attr('target', '_blank');
	service = "digg";
	url = "http://www.addthis.com/bookmark.php?v=152&winname=addthis&pub=ewcom&source=men-250&lng=en-US&s=" + service + "&url=" + escape(window.location.href)+ "&title=" + escape($('#galleryHeader h1').text() + ' | EW.com');	
	$('.digg a').attr('href', url).attr('target', '_blank');
	service = "facebook";
	url = "http://www.addthis.com/bookmark.php?v=152&winname=addthis&pub=ewcom&source=men-250&lng=en-US&s=" + service + "&url=" + escape(window.location.href)+ "&title=" + escape($('#galleryHeader h1').text() + ' | EW.com');	
	$('.facebook a').attr('href', url).attr('target', '_blank');
	service = "twitter";
	url = "http://www.addthis.com/bookmark.php?v=152&winname=addthis&pub=ewcom&source=men-250&lng=en-US&s=" + service + "&url=" + escape(window.location.href)+ "&title=" + escape($('#galleryHeader h1').text() + ' | EW.com');	
	$('.twitter a').attr('href', url).attr('target', '_blank');
	service = "stumbleupon";
	url = "http://www.addthis.com/bookmark.php?v=152&winname=addthis&pub=ewcom&source=men-250&lng=en-US&s=" + service + "&url=" + escape(window.location.href)+ "&title=" + escape($('#galleryHeader h1').text() + ' | EW.com');	
	$('.stumbleupon a').attr('href', url).attr('target', '_blank');
	$('.galleryListBlock .tout:visible:gt(5)').hide();
	$('.galleryListBlock .tout:visible:last').addClass('last').css({'padding-right':'0px'});
});
$(function() {
	$('#div_20309000_20333339').click(function() {
		document.domain = 'ew.com';
		if ($('#emailiframe').text() == '') {
			var email_iframe = 'http://www.ew.com/ew/static/h/DigitalNL-subscribe-NEW.html';
			var frame = '<iframe id="emailiframe" src="' + email_iframe + '" width="500" height="500"/>';
			var offset = $(this).offset();
			var new_top = offset.top - 100 + 'px';
			$('#container').append(frame);
			$('#emailiframe').css({
				'position': 'absolute',
				'top': new_top,
				'left': '200px',
				'z-index': '200'
			});
		}
		return false;
	});
});
function removeEmail() {
	jQuery('#emailiframe').remove();
}
