
jQuery(function(){
	// Navigation
	$("#navigation li").hover(
		function(){
			if($(this).find("ul").css('display')=='none')
				$(this).find("ul").slideDown("fast");
		},
		function(){
			$(this).find("ul").slideUp("fast");
		}
	);
    
    $("#navigation li:last").addClass("last");
    
    $("a.addinput").click(function(){
        var inputd = $(this).parent().parent().find("input:last").clone();
        var newid = inputd.attr('id').split('-');
        var oldid = parseInt(newid.pop());
        newid.push(oldid+1); newid = newid.join("-");
        inputd.attr('id',newid); inputd.attr('name',newid); inputd.attr('value','');
        $(this).parent().parent().append("<span></span>");
        $(this).parent().parent().find("span:last").append($('<label>&nbsp;</label>'));
        $(this).parent().parent().find("span:last").append(inputd);
        $(this).parent().parent().find("span:last").append($('<a class="removeinput" href="#" ><img src="/media/images/icons/cancel.png" alt="Remove this" title="Remove this" /></a>'));
        return false;
    });
    
    $("a.removeinput").live('click',function(){ 
        $(this).parent().remove();
        return false;
    });    

});
