var $hfst = jQuery.noConflict();
$hfst(document).ready(function($)
{
	if($hfst('.popupads').length)
	{
		$hfst("body").append('<div id="popup_overlay"></div><div id="popup_content"></div>');	
		strID = $hfst('.popupads:first').attr('id');
		intdelay = $hfst('.popupads:first').attr('title');
		setTimeout('callpopup(strID)', intdelay);		
	}
});

function callpopup(strID)
{
	if($hfst('#'+strID).attr('id')=== undefined)
	{
		$hfst("#popup_content, #popup_overlay").fadeOut('slow');
	}
	else
	{
		showpopup(strID);
		$hfst('#popup_overlay, .popup-close, #hf_up_send, #extLinks').click(function()
		{
			$hfst("#popup_content, #popup_overlay").fadeOut('slow');
			$hfst.cookie(strID, "hide", { expires: 7 });
			obj = $hfst('#'+strID).next();
			strNID = obj.attr('id');
			intdelay = obj.attr('title');
			if($hfst('.popupads').length > 1)
				setTimeout('callpopup(strNID)', intdelay);	
		});
	}
}

function showpopup(strID)
{
	$hfst("#popup_overlay").height($hfst(document).height()).css({'opacity' : 0.8, 'top' : '0px', 'left' : '0px'}).fadeIn('slow');
	$hfst('#popup_content').html($hfst("#"+strID).html());
	strTop = $hfst('#'+strID).attr('style');
	strTop = strTop.split(":");
	strTop = strTop[1].split(";");
	$hfst("#popup_content").css('top', strTop[0]);
	$hfst('#popup_content').fadeIn('slow');
	strTop = $hfst('#'+strID).attr('style');
	strTop = strTop.split(":");
	$hfst("#popup_content").css("top", strTop[1]);
    $hfst('#popup_content').css("left", ( $hfst(window).width() - $hfst('#popup_content').width() ) / 2+$hfst(window).scrollLeft() + "px");
	$hfst('#popup_content .btnimg').click(function()
	{
		$hfst(this).parent('form').submit();
		$hfst("#popup_content, #popup_overlay").fadeOut('slow');
	});
}

