/*
 Select.Link
 Richard Pratt
 2011-09-15
*/

$(document).ready(function () {

    $('.makejump').each(function(ia) {
		
		var newSelect = document.createElement("select");
		newSelect.setAttribute("name", "jumpselect");
		
		var option;
		option = document.createElement("option");
		option.setAttribute("value", '#');
		option.innerHTML = 'Select Link';
		newSelect.appendChild(option);

		$(this).find('a').each(function(ib) {
			option = document.createElement("option");
			option.setAttribute("value", $(this).attr('href'));
			option.innerHTML = $(this).text();
			newSelect.appendChild(option);
		});

		var newFormP = document.createElement('p');
		newFormP.appendChild(newSelect);

		var newForm = document.createElement('form');
		newForm.setAttribute('action', '?')
		newForm.setAttribute('method', 'get')
		newForm.setAttribute('class', 'jumplist');
		newForm.appendChild(newFormP);

		$(this).before(newForm);

	});

    $('.jumplist select').change(function () {
		document.location.href = $(this).find('option:selected').val();
	})
});
