var ProductBrowse = function(){
	
	this.changeImage = function(obj,nodeIDX,imageSize){
		$j("#productBrowseThumbnails").find('img').each(function(i,o){
			$j(o).attr('class','productBrowseImage hyperlink');
		});
		
		obj.className = 'productBrowseSelectedImage';
		if(imageSize == 'small')
			$j("#productBrowseMainImage").attr('src','index.php?name=File&nodeIDX='+nodeIDX+'&thumb=true&width=190&height=190');
		else if(imageSize == 'big')
			$j("#productBrowseMainImage").attr('src','index.php?name=File&nodeIDX='+nodeIDX+'&thumb=true&width=500&height=375');
		$j("#productBrowseMainImageSpan").attr('nodeIDX',nodeIDX);
	}
	
	this.viewLargerImage = function(obj,productIDX,title){
		var nodeIDX = $j(obj).attr('nodeIDX');
		
		if(document.getElementById('productBrowseImageDialog'))
			var addCategoryDiv = $j("#productBrowseImageDialog");
		else
			var addCategoryDiv = $j("<div id='productBrowseImageDialog'></div>");
		addCategoryDiv.appendTo("#body");
		addCategoryDiv.load("index.php?name=ProductBrowse&method=imagesDialog&imageIDX="+nodeIDX+"&productIDX="+productIDX+"&blocks=ah");
		
		dlg_viewLargerImage = $j("#productBrowseImageDialog").modal({
			onClose: function(dialog){
				dialog.data.fadeOut('fast', function () {
					dialog.container.hide('fast', function () {
						$j.modal.close();
					});
				});
			},
			containerHeaderText: title
		});
	}
	
	this.change_option = function(obj){
		$j.ajax({
			url: "index.php?name=ProductBrowse&method=get_option_info&nodeIDX="+$j(obj).val()+"&blocks=aj",
			type: "GET",
			dataType: "json",
	  		success: function(json){
	  			$j("#product_image_container_"+obj.id.split("_")[2]).html(json.html);
	  			$j("#product_price_"+obj.id.split("_")[2]).html(json.price);
	  			$j("#product_availability_"+obj.id.split("_")[2]).html(json.availability);
			}
		});
	}
}
var ProductBrowse = new ProductBrowse;
