function UI_Init(){
if(($(".category-box").length>0 || $(".product-box").length>0) && $(".header-box .header-text").height()>100){$(".header-box .header-text").addClass("text-collapse");$(".header-box").append("<a id='header-text-control' href='#' class='button' onclick='return toggleHeaderText();'>See More</a>")}
$("input[type='submit'],input[type='reset'],button,a.button").button();

$(".box").addClass("ui-widget ui-widget-content ui-corner-all ui-tabs");
$(".box .box-title").addClass("ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");

$("#prod_buy").addClass("ui-widget ui-widget-content ui-corner-all ui-tabs");
$("#prod_name").addClass("ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");

$(".header-box, .footer-box").addClass("ui-widget ui-widget-content ui-corner-all ui-tabs").append("<div style='clear:right;'></div>");
$(".header-box .header-box-title").addClass("ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");

$(".product, .category").addClass("ui-widget ui-widget-content ui-corner-all ui-tabs");
$(".category .category-title").addClass("ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");

$(".category img, .product img").addClass("ui-corner-all");

$(".category-box,.product-box").append("<div style='clear:left;width:100%'></div>")
$(".product-box, .category-box, .product-info-box, .product-line-box").addClass("ui-widget ui-widget-content ui-corner-all ui-tabs");
$(".product-box-title, .category-box-title, .product-info-box-title").addClass("ui-state-default ui-corner-all");

UI_Init_Basket();

$("#tabs").tabs();

$("img").ready(function(){$("img").error(function(){$(this).attr("src","/common/Error.png");});});
setInterval("columnFix()",1000);
$("#buyIt input").click(function(){setTimeout("updateInventory()",500)});
}
function toggleHeaderText(){
$(".header-text").toggleClass("text-collapse");
if($(".header-text").hasClass("text-collapse")){$("#header-text-control span").text("See More");}
else{$("#header-text-control span").text("See Less");}
return false;
}
function updateInventory(){
$("#buyIt input[type='submit']").button("refresh");
}
function columnFix(){
	var max=Math.max($(".content").height(),$(".left").height(),$(".right").height());
	if($(".right").height()<max){$(".right").css("height",max+"px")}
	if($(".left").height()<max){$(".left").css("height",max+"px")}
}
function UI_Init_Basket(){
	$(".minibasket .item a:first,.filters .item a:first").button();
	$(".minibasket .item a.delete").button({text:false,icons:{primary: "ui-icon-trash"}}).click(function(){	$(".minibasket .ajax").html("<img width='160' src='/common/sgraphics/load.gif' />");$.get($(this).attr("href")+"&JQuery=1",refreshBasket);return false;});
	$(".filters .item a.delete").button({text:false,icons:{primary: "ui-icon-close"}});
	$(".minibasket .item,.filters .item").buttonset();
	$("#shipcalc").click(function(){
		$.get("/mm5/merchant.mvc?Screen=SHIPCALC&TKShip=1",function(data){
			$("body").append("<div title='Shipping Calculator' id='SC' style='text-align:center;padding-top:10px;'>"+data+"</div>");
			$("#SC").dialog({modal: true,width: 250,buttons: {Ok: function() {$(this).dialog('close');$("#SC").remove();}}});
		});
		return false;
	});
}
function jqueryPopup(html,title,width){
   if ( title === undefined ) {
      title = "";
   }
   if ( width === undefined ) {
      width = 300;
   }
	$("#POPUP").remove();
	$("body").append("<div title='"+title+"' id='POPUP' style='display:none'></div>");
	$("#POPUP").html(html);
	$("#POPUP").dialog({modal: true, width:width, buttons: {OK: function() {$(this).dialog('close');$("#POPUP").remove();}}});
	return false;
}
