
function prod_box_resize()
{
	//resizing prod boxes on products startup page
	var prodSquareHolder = $(".prod_square_holder");
	if (prodSquareHolder)
	{
		var ccWidth = parseInt($("#center_content").width(),10);
		var hWidth = ccWidth - 20;
		var minContainerWidth = 180;
		$(".prod_box").css({ 'width' : minContainerWidth});
		var containerOuterWidth = parseInt($(".prod_box").outerWidth(true),10);
		var minNumContainers = Math.floor(hWidth / containerOuterWidth);
		var leftOverSpace = hWidth - (minNumContainers*containerOuterWidth);
		var addition = Math.floor(leftOverSpace / minNumContainers);
		var newContainerInnerWidth = minContainerWidth + addition;
		$(".prod_box").css({ 'width' : newContainerInnerWidth});
	}
}

$(document).ready(function(){
	
	$(window).bind("resize", resizeWindow);
	function resizeWindow( e ){	prod_box_resize();}
	
	prod_box_resize();
	
	if ($('#more_info_holder').length > 0) { $('#more_info_holder').tabs(); }
	
	if ($('#t_specs').length > 0) { CKEDITOR.replace('t_specs'); }
	if ($('#features').length > 0) { CKEDITOR.replace('features'); }
	if ($('#desc').length > 0) {CKEDITOR.replace('desc');}
	
	if ($('#cust_price1').val() == '') $('#priceCustomFilter').hide();
	$('#priceCustomFilter').css("visibility", "visible");
	$('a#customPriceLink').click(function() {
		$('#priceCustomFilter').toggle(300);
		return false;
	});
	
	/*
		$("a[rel='cb_image']").lightbox(); 
	*/
	
	$('.cb').openDOMWindow({ 
		height:500, 
		width:600,
		eventType:'click',
		windowSource:'iframe', 
		windowPadding:0, 
		loader:1, 
		loaderImagePath:'http://computerelite.net/images/ajax-loader.gif', 
		loaderHeight:16, 
		loaderWidth:17,
		functionCallOnClose:function(){if(get_cookie(cookieName)==null){document.location.href='products.php';}}
	});
		
	$('.dlogin').openDOMWindow({ 
		height:500, 
		width:600,
		eventType:'click',
		windowSource:'iframe', 
		windowPadding:0, 
		loader:1, 
		loaderImagePath:'http://computerelite.net/images/ajax-loader.gif', 
		loaderHeight:16, 
		loaderWidth:17,
		functionCallOnClose:function(){document.location.href=document.location.href;}
	});
	
	$('.feedback').openDOMWindow({ 
		height:500, 
		width:600,
		eventType:'click',
		windowSource:'iframe', 
		windowPadding:0, 
		loader:1, 
		loaderImagePath:'http://computerelite.net/images/ajax-loader.gif', 
		loaderHeight:16, 
		loaderWidth:17 
	});
	
	$('.addProduct').openDOMWindow({ 
		height:220, 
		width:400,
		eventType:'click',
		windowSource:'iframe', 
		windowPadding:0, 
		loader:1, 
		loaderImagePath:'http://computerelite.net/images/ajax-loader.gif', 
		loaderHeight:16, 
		loaderWidth:17,
		functionCallOnClose:function(){return true;}
	});
	
	$('.editCategory').openDOMWindow({ 
		height:60, 
		width:350,
		eventType:'click',
		windowSource:'iframe', 
		windowPadding:0, 
		loader:1, 
		loaderImagePath:'http://computerelite.net/images/ajax-loader.gif', 
		loaderHeight:16, 
		loaderWidth:17,
		functionCallOnClose:function(){if(get_cookie(cookieName)==null){document.location.href='products.php';}}
	});
	
	$('.speedtest').openDOMWindow({ 
		height:250, 
		width:450,
		eventType:'click',
		windowSource:'iframe', 
		windowPadding:0, 
		loader:1, 
		loaderImagePath:'http://computerelite.net/images/ajax-loader.gif', 
		loaderHeight:16, 
		loaderWidth:17 
	}); 
	
});

//preload certain images
if (document.images){
	pic1= new Image(114,42); 
	pic1.src="http://computerelite.net/images/button_small.png";
	pic2= new Image(114,42); 
	pic2.src="http://computerelite.net/images/button_small_hover.png";
	pic3 = new Image(600,150);
	pic3.src="http://computerelite.net/images/dealer_login_banner.png";
	pic4 = new Image(600,150);
	pic4.src="http://computerelite.net/images/dealer_registration_banner.png";
	pic5 = new Image(600,150);
	pic5.src="http://computerelite.net/images/submit_order_banner.png";
	pic6 = new Image(600,150);
	pic6.src="http://computerelite.net/images/forgotten_password_banner.png";
}
