function $X(element) 
{
	element = document.getElementById(element);
	return element;
}

$(document).ready(function(){
	$('#navBackgroundColor, #navTextColor, #hoverTextColor').ColorPicker({
		targetID : '',
		newTimeout : '',
		
		eventName: 'focus',
		
		onSubmit: function(hsb, hex, rgb, el) {
			$(el).val("#" + hex);
			$(el).ColorPickerHide();
		},
		onChange: function(cal, hex, el) {
			$("#" + targetID).val('#' + hex);
		},
		onBeforeShow: function () {
			$(this).ColorPickerSetColor(this.value);
			targetID = this.id;
		}
	});
});

Rows = {
	count : 7,
	Add: function() {
			Rows.count++;
			count = Rows.count;
			div = $X('listmgr');
			list = document.createElement('li');
	    	list.innerHTML = '<span class="form-text"><input type="text" class="text" value="" name="name[]"></span><span class="form-text"><input type="text" class="text" value="" name="link[]"></span></span><span class="delico"><a href="javascript:void(0);" onclick="Rows.Remove(this);"><img src="images/delete.gif" width="16" height="16" alt="delete" /></a></span>';
			div.appendChild(list);
	},
	Remove: function(pTarget) {
		if (Rows.count <= 1) {
			alert("Sorry, you must have at least one URL your navigation bar.");
		}
		else {
			Rows.count--;
		    element = pTarget.parentNode.parentNode;
		    element.parentNode.removeChild(element);
		}
	}
}