var lightbox_width = 160;

function init(){
	banner_h = $('banner').getPosition().height;
	search_h = $('search_options').getPosition().height;
	footer_h = $('footer').getPosition().height;
	var lb_width = $('lightbox').getPosition().width;
	hideLB();
	$('grid').setStyle('width',Window.getWidth()+'px');
	$('grid').setStyle('height',Window.getHeight()-(banner_h+search_h+footer_h+22)+'px');
	
	/**************************SJW************************************/
	/****************Browser fix for IE tool menu********************/
	if (jQuery.browser.msie && parseInt(jQuery.browser.version)< 7) {
	            jQuery("#tabs li").hover(
                    function() {
            	        jQuery(this).addClass("sf");
                    },
                    function() {
		        jQuery(this).removeClass("sf");
                    });                                   
	}		 
	/****************End browser fix for IE tool menu******************/
	/*****************************************************************/
}


//*************Added the following function to handle resizing of window**********// 
function reinit()
{
	banner_h = $('banner').getPosition().height;
	search_h = $('search_options').getPosition().height;
	footer_h = $('footer').getPosition().height;
	
	var lb_width = $('lightbox').getPosition().width;
	$('grid').setStyle('margin-right','0px');
	
	setGridSize();
	setLbSize();
	
	if(!lb_visible)
	{
		$('grid').setStyle('width',Window.getWidth()+'px');
	}
	else
	{
		$('grid').setStyle('width',Window.getWidth()-(lb_width)+'px');
	}
	
	
	if(lb_max)
	{
		$('grid').setStyle('display','none');
		$('page_menu_top').setStyle('display','none');
	}
	else
	{
		$('grid').setStyle('display','block');
		$('page_menu_top').setStyle('display','block');
	}
}

//
function setGridSize()
{
	var lb_width = $('lightbox').getPosition().width;
	var grid_h = Window.getHeight()-(banner_h+search_h+footer_h+22);
	
	if(lb_visible == false)
	{
		var gw = Window.getWidth()-1;
	}
	else
	{
		var gw = Window.getWidth()-(lb_width);
	}
	
	$('grid').setStyle('width',gw+'px');
	$('grid').setStyle('height',grid_h+'px');/*grid_h+'px'*/
}
function setFooterPos()
{
	footer_h = $('footer').getPosition().height;
	$('footer').setStyle('width',(Window.getWidth()-21)+'px');
}
function setLbSize()
{
	setFooterPos();
	var content_height = $('content').getPosition().height;
	var lbh = Window.getHeight()-(banner_h+search_h+footer_h);
	var lbheader_h = $('lb_header').getPosition().height;
	var lb_height = lbh-lbheader_h;
	
	if(lb_max == true)
	{
		var gw = Window.getWidth();
		$('lightbox').setStyle('width','100%');
	}
	else
	{
		$('lightbox').setStyle('width','160px');
	}
	
	$('lightbox').setStyle('height',lbh+'px');
	$('lb_grid').setStyle('height',lb_height+'px');
}

//hide the lightbox
function hideLB()
{
	lb_visible = false;
	lb_max = false;
	$('grid').setStyle('margin-right','0px');
	$('grid').setStyle('display','block');
	$('page_menu_top').setStyle('display','block');
	$('lightbox').setStyle('display','none');
	setGridSize();
	setLbSize();
	$('grid').setStyle('width',Window.getWidth()-(1)+'px');
}

//show minimized lightbox
function showLB()
{
	lb_visible = true;
	lb_max = false;
	$('grid').setStyle('display','block');
	$('page_menu_top').setStyle('display','block');
	$('lightbox').setStyle('display','block');
	$('lb_view').setStyle('display','none');
	$('lb_amount').setStyle('display','none');
	$('lb_actions').setStyle('display','none');
	$('lightbox').setStyle('width','160px');
	setGridSize();
	//removing the following line seems to have no effect.
	setLbSize();
}

//set the lightbox to full screen
function maxLB()
{
	lb_visible = true;
	lb_max = true;
	$('lightbox').setStyle('display','block');
	$('grid').setStyle('display','none');
	$('lightbox').setStyle('width',Window.getWidth()+'px');
	$('lightbox').setStyle('height','100%');
	$('page_menu_top').setStyle('display','none');
	$('lb_view').setStyle('display','block');
	$('lb_amount').setStyle('display','block');
	$('lb_actions').setStyle('display','block');
	setLbSize();
}