function open_pop_up(path, name, width, height)
{
    var centerWidth  = (window.screen.width - width) / 2;
    var centerHeight = 200;

    window.open(path, name, 'width=' + width + ', height=' + height + ', scrollbars=yes, left=' + centerWidth + ', top=' + centerHeight);

    return false;
}

//******* requiert jquery ********//

function resize_content(target)
{
	// left_section_content position and margin/padding
    var offset     = Number($(target).offset().top);
    var padTop     = $(target).css("padding-top") != undefined ? Number($(target).css("padding-top").replace("px", "")) : 0;
	var padBottom  = $(target).css("padding-bottom") != undefined ? Number($(target).css("padding-bottom").replace("px", "")) : 0;
	var margTop    = $(target).css("margin-top") != undefined ? Number($(target).css("margin-top").replace("px", "")) : 0;
	var margBottom = $(target).css("margin-bottom") != undefined ? Number($(target).css("margin-bottom").replace("px", "")) : 0;

	$(window).resize(function(){
		resizeWindow();
	});

	function resizeWindow()
	{
		// reset height property
		$(target).css("height", null);
		
		var section_height = $(window).height() - (offset + padTop + padBottom + margTop + margBottom);
		var current_height = $(target).height();

		if(current_height < section_height)
			$(target).css("height", section_height + "px");
		}

	resizeWindow();
}


/**
 *	Slideshow
 */
function slideSwitch(selector)
{
	var $active = $(selector+".active");

	if ( $active.length == 0 ) $active = $(selector+':last');

	// use this to pull the divs in the order they appear in the markup
	var $next =  $active.next().length ? $active.next() : $(selector+':first');

	// uncomment below to pull the divs randomly
	// var $sibs  = $active.siblings();
	// var rndNum = Math.floor(Math.random() * $sibs.length );
	// var $next  = $( $sibs[ rndNum ] );

	$active.addClass('last-active');

	$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
			$active.removeClass('active last-active');
		});
}


/**
 * Rezise background
 */
function resize_background(params)
{
	var minWidth  = params.minWidth;
	var minHeight = params.minHeight;

	$(params.image).css("width", "");
	$(params.image).css("height", "");

	var pageWidth  = $("body").width();
	var pageHeight = $("body").height();

	if(pageWidth < minWidth)
		pageWidth = minWidth;
	if(pageHeight < minHeight)
		pageHeight = minHeight;

	var ww = $(params.container).width();
	var hh = $(params.container).height();
	var WW = pageWidth;
	var HH = WW * hh / ww;
	$(params.image).css("width", WW+"px");
	$(params.image).css("height", HH+"px");

	if (HH < pageHeight)
	{
		HH = pageHeight;
		$(params.image).css("height", HH+"px");
		WW = ww * HH / hh;
		$(params.image).css("width", WW+"px");
	};
}


jQuery(document).ready(function()
{
	resizeParams = {container:"#background DIV.active",
					   image: "#background div img",
					   minWidth: 1000,
					   minHeight: 800};
	$(window).resize(function() {
		resize_background(resizeParams);
	});
	resize_content("#left_section_content");

	setTimeout("resize_background(resizeParams)", 100);
});

//******* requiert jquery ********//

