
Trendy.Gallery = {
	highlight: function(dom){
		$(dom).addClass('on');
	},
	
	highlightOff: function(dom){
		$(dom).removeClass('on');
	},
	
	linkToProductDetails: function(idProduct,idSaleDesigner){
		document.location.href = '/produit/details/?id=' + idProduct +'&ic=' +idSaleDesigner;
	},
	
	linkToDesigner: function(strPseudo){
		document.location.href = '/galerie/' + strPseudo;
	},
	addToFavoriteDesigners: function(id){
		$.ajax({
			type: "POST",
			url: '/myworkshop/ajaxaddfavoritedesigner/',
			data: "id="+id,
			success: function(data){
				//$(".addToFavoriteDesigners").fadeOut(function(){$(".addToFavoriteDesigners").fadeIn().addClass('on');});
				$(".addToFavoriteDesigners").fadeOut();
			}
		});
	},
	
	initializeForm: function(){
		var form;
		form = $("#addCommentForm");
		$("#addCommentForm .submit").click(function(){
			if(Trendy.Auth.isLogged() == false){
				Trendy.Lightbox.open(Trendy.Subscribe.url, "Trendy.Subscribe.initializeForm()",null);
				return false;
			}else 
				form.submit();
		});
		var options = {
			url: '/designer/add-comment/',
			success: function(idClient){
				Trendy.Lightbox.close();
				$("#designerComments").fadeOut(function(){
					$(this).load('/designer/comments/?id='+idClient, function(){$(this).fadeIn(function(){
						$("#pageContent.gallery .content.col23 #designerComments.scroll-pane").jScrollPane({"scrollbarWidth":13,"showArrows":true, "arrowSize":"10"});
						$("#addCommentForm textarea[name=strComment]").val('');
					});});
				});
			}
		}
		$("#addCommentForm").validate({
			rules:{
				strComment: {required:true}
			},
			messages:{
				strComment: ''
			},
			submitHandler: function(error) {
				$("#addCommentForm").ajaxSubmit(options);
			}
		});
	}
}

$().ready(function() {
	Trendy.Gallery.initializeForm();
	$("#designerComments.scroll-pane").jScrollPane({"scrollbarWidth":13,"showArrows":true, "arrowSize":"10"});
//	$("#pageContent.gallery .content.col23 #designerComments.scroll-pane").jScrollPane({"scrollbarWidth":13,"showArrows":true, "arrowSize":"10"});
});