

if($("a[href='#top']").length) { $("a[href='#top']").click ( function() { $("html").animate({ scrollTop: 0 }, "slow"); return false; }); }

$(document).ready(function() 
{
	//$(document).pngFix();
	
	if($('.positions a, a.lgbox').length) { $('.positions a, a.lgbox').lightBox(); }
	if($('input,textarea,select').length)
	{	
		$('input,textarea,select').focus ( function() { $(this).addClass("fhgl"); } ); 
		$('input,textarea,select').blur ( function() { $(this).removeClass("fhgl");	} );
	}
	
	if($('.thumb img').length)
	{
		$('.thumb img').each
		(
			function() 
			{
				var maxWidth = 60;
				var maxHeight = 100;
				var ratio = 0;
				var width = $(this).width();
				var height = $(this).height();
			
				if(width > maxWidth)
				{
					ratio = maxWidth / width;
					$(this).css("width", maxWidth);
					$(this).css("height", height * ratio);
					height = height * ratio;
				}
			
				if(height > maxHeight)
				{
					ratio = maxHeight / height;
					$(this).css("height", maxHeight);
					$(this).css("width", width * ratio);
					width = width * ratio;
				}
			}
		);
	}
	
	if($('#homevplay1, #homevplay2').length) {$("#homevplay1, #homevplay2").fancybox({});}
	
	if($('#cvideo1, #cvideo2').length) {$("#cvideo1, #cvideo2").fancybox({});}
	
	if($('#signpv1, #signpv2').length) {$("#signpv1, #signpv2").fancybox({});}
	

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


	if($('#menu ul ul').length)
	{
		$('#menu ul ul').each(function(){ $(this).css({'top': ($(this).parent('li').offset().top + 29) +'px', 'left': $(this).parent('li').offset().left+'px'}); });
		$('#menu ul li').hover(function() { $('ul', this).slideDown(); },function() { $('ul', this).slideUp(); });
	}
});


function callpopup(strID)
{
	if($('#'+strID).attr('id')=== undefined)
	{
		$("#popup_content, #popup_overlay").fadeOut('slow');
	}
	else
	{
		showpopup(strID);
		$('#popup_overlay, .popup-close').click(function()
		{
			$("#popup_content, #popup_overlay").fadeOut('slow');
		});
	}
}

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



