﻿$(document).ready(
	function() {

$('a.cNotes').cluetip({ local: true, cursor: 'pointer'});

	
    $("ul#benches").sortable({ items: "li", revert: true, axis: "y" });

    $('#menuAdd > li a').bind('click', function(event) {
        $(this).parent().hide();
        event.stopPropagation();
        event.preventDefault();

        newId = "#product_" + $(this).parent().attr("id").split("_")[1];
        $('ul#benches').append($(newId).slideDown("normal"));
        //$('ul#benches').SortableAddItem(document.getElementById(newId));


        //				$("#product_1").slideDown("normal");
    }
		);
    $('a.cClose').bind('click', function(event) {

        newId = "#add_" + $(this).parent().parent().attr("id").split("_")[1];
        $(newId).show();
        $(this).parent().parent().slideUp("normal");
        event.preventDefault();

        //$("ul#menuAdd").hide();


    }
		);
    $('ul#benches > li:visible').each(function() {
        newId = "#add_" + this.id.split("_")[1];
        $(newId).hide();
    });
    $("#additem").toggle(
			function() {
        $("ul#menuAdd").slideDown('fast');
    },
			function() {
        $("ul#menuAdd").slideUp('fast');
    }
		);
    $('#permalink').bind('click', function(event) {
        serial = "";
        isFirst = true;
        $('ul#benches > li:visible').each(function() {
            if (isFirst) {
                isFirst = false;
                serial += this.id.split("_")[1];
            }
            else {
                serial += "." + this.id.split("_")[1];
            }

        });
        serial = basePageUrl + serial;
        $('#permatext').val(serial).show();

        
        event.preventDefault();

    }
			);

    //		$("a#additem").hoverIntent(OpenMenu,CloseMenu);
    //$("a#additem").mouseover( function() {
    //    $("ul#menuAdd").animate({height:"show",opacity:"show"},"slow"); return false;
    //  });
}
);
function OpenMenu() { $("ul#menuAdd").slideDown(); }
function CloseMenu() { $("ul#menuAdd").slideUp(); }

