function Question(Bark, URL) {
	if (confirm(Bark)) {
		window.location = URL;
	}
}

function CreateBookmarkLink(title, url) {
	url = location.href;
	title = document.title;

	if (window.sidebar) {
		window.sidebar.addPanel(title, url, "");
	} else if (window.external) {
		window.external.AddFavorite(url, title);
	} else {
		alert('Uw webbrowser wordt helaas niet ondersteund..');
	}
}

function limitText(textArea, countDown, Limit) {
	if (textArea.value.length > Limit) {
		textArea.value = textArea.value.substring( 0, Limit );
	} else {
		countDown.innerHTML = Limit - textArea.value.length;
	}
}

function FocusBlur(Type, Field, Value) {
	if (Type == 'focus') {
		if (Field.value == Value) {
			Field.value = '';
		}
 	} else {
		if (Field.value == '') {
			Field.value = Value;
		}
	}
}

function clearInput(textPrice, Value) {
	if (Value != 0) {
		document.getElementById(textPrice).value = '';
	}
}

var count	= 0;
var id		= 0;

function addRow( elementId ) {
	if (count >= 15) {
		alert( 'U heeft het maximaal aantal velden berijkt.' );
	} else {
		element = document.getElementById( elementId );
		element.innerHTML += '<input type="text" name="url_titles[]" style="width: 38%;" value="" id="title_' + id + '" /> <input type="text" name="urls[]" style="width: 59%;" value="http://" id="url_' + id + '" /> <input type="button" value="X" onclick="javascript:delRow(\'' + elementId + '\', \'' + id + '\');" id="button_' + id + '" /><br id="br_' + id + '" />' + "\n";

		count++;
		id++;
	}
}

function delRow(elementId, rowId) {
	if ( count == 1 ) {
		alert( 'U kunt niet alle velden verwijderen, er blijft er 1 staan.' );
	} else {
		element = document.getElementById( elementId );
		element.removeChild(document.getElementById('title_' + rowId));
		element.removeChild(document.getElementById('url_' + rowId));
		element.removeChild(document.getElementById('button_' + rowId));
		element.removeChild(document.getElementById('br_' + rowId));

		count--;
	}
}



function createDropDown(div,select){
	var source = $("#"+select);
	var selected = source.find("option[selected]");
	var options = $("option", source);
	
	$("#"+div).append('<dl id="target'+div+'" class="dropdown"></dl>')
	$("#target"+div).append('<dt><a href="#" onclick="return false;">' + selected.text() + 
		'<span class="value">' + selected.val() + 
		'</span></a></dt>')
	$("#target"+div).append('<dd><ul></ul></dd>')

	options.each(function(){
		$("#target"+div+" dd ul").append('<li><a href="#" onclick="return false;">' + 
			$(this).text() + '<span class="value">' + 
			$(this).val() + '</span></a></li>');
	});

				
	$("#"+div+" .dropdown dd ul li a").click(function() {
		var text = $(this).html();
		$("#"+div+" .dropdown dt a").html(text);
		$("#"+div+" .dropdown dd ul").hide();
		
		var source = $("#"+select);
		source.val($(this).find("span.value").html());

		if (select == 'catSelect') {
			if (source.val() != '') document.location.href='/categorie/'+source.val();
		}
	});


	$("#"+div+" .dropdown dt a").click(function() {
		$("#"+div+" .dropdown dd ul").toggle();
	});

	$(document).bind('click', function(e) {
		var $clicked = $(e.target);
		if (! $clicked.parents().hasClass("dropdown"))
			$("#"+div+" .dropdown dd ul").hide();
	});


	 document.getElementById(select).style.display='none';
}


function createBookmark(BookmarkURL,BookmarkTitle) {
	if (document.all)
	{
		window.external.AddFavorite(BookmarkURL,BookmarkTitle)
	} else {
		window.sidebar.addPanel(BookmarkTitle, BookmarkURL, '');
	}
}

function setPriceAlert(product,value) {
	$.prettyPhoto.open('product/'+product+'/pricealert/'+escape(value)+'?iframe=true&width=600&height=250');
}
