/*
* Ykone.com - JS
* @version 3.0
* @creation date 2009-08-10
* @update date 2009-08-11
* @author Antoine ROESSLINGER <antoine@ykone.com>
* Description :
*/
$(document).ready
(
	function()
	{


		//AUTO COMPLETION - Marques
		function formatItem(row) { return row[0]; }

		//URL Action ajax
		var ajaxbrands		= $("#ajax-brands").val();
		var ajaxcategory	= $("#ajax-category").val();

		//Marquers
		$("#ykoneNotes-brands").autocomplete(ajaxbrands, {
			width: 245,
			minChars: 2,
			selectFirst: true,
			formatItem: formatItem
		}).result(function(event, item) {
			//if(item[1] != undefined)
			  //document.location.href = item[1];
		});

		$("#listing-tags li").hover(
			function() {
				$(this).css('background', '#F5F5F5');
				$(this).css('cursor', 'pointer');
				var id = $(this).attr("id");
				$('#thumb #'+id).css('display','block');
			},
			function() {
				$(this).css('background', 'white');
				var id = $(this).attr("id");
				$('#thumb #'+id).css('display','none');
			}
		);

		$('.deletetag').livequery('click', function(event) {
			var id = $(this).attr("id");

			$.ajax(
				{
					type: "GET",
					url:  '/en/lookbook/deletetag/',
					data: "id="+id,
					cache: false,
					success: function(d)
					{
						//$('#'+id).css('display','none');
						$('#'+id).slideUp('slow');
					}
				});//END AJAX
			return false;
		});



		//ADD TAG
 		/* $("#ykoneNotes").find("input#btn-submit-note").click ( function()
		{

		}); */
		//END GET INFORMATIONS

	   // If we check, we show this input

       $("#ykoneNotes-urlbuy").css("display","none");


        // Add onclick handler to checkbox w/id checkme
       $("#ykoneNotes-forsale").click(function(){

	        // If checked
	        if ($("#ykoneNotes-forsale").is(":checked"))
	        {
	            //show the hidden div
	            $("#ykoneNotes-urlbuy").show("fast");
	        }
	        else
	        {
	            //otherwise, hide it
	            $("#ykoneNotes-urlbuy").hide("fast");
	        }
    	 });

      //if the dressing is empty, we disable the form
      //URL Action ajax
      if(($("#ykoneNotes-category").val() == "Type (obligatoire)") || ($("#ykoneNotes-category").val() == "Type (mandatory)"))
	   {
	   		// Disable
			$('#btn-submit-note').attr('disabled', 'disabled');
	   }else{
	   		// Enable
			$('#btn-submit-note').removeAttr('disabled');
	   }

      $('#ykoneNotes-category').keyup(function(){
		   if(($("#ykoneNotes-category").val() == "Type (mandatory)") || ($("#ykoneNotes-category").val() == ""))
		   {
		   		// Disable
				$('#btn-submit-note').attr('disabled', 'disabled');
		   }else{
		   		// Enable
				$('#btn-submit-note').removeAttr('disabled');
		   }
		});


	}
)