
//	$(function() {
$(document).ready(function(){


		// Fix things in chrome
		var is_chrome = /chrome/.test( navigator.userAgent.toLowerCase() );
		if ( is_chrome == true ) {
			// fix navigation tabs
			$("#topnav").children("li").css("margin-top", "-2px");
			// fix apply online etc buttons
			//$(".jobpagebuttons").css("margin-top", "-150px");
			//$(".jobpagebuttons").css("clear", "none");
		}

		// Convert <select> elements to graphical ones
		$("select").sSelect();

		// hide all middle boxes
		$(".middlebox").children("p").hide();
		$(".middlebox").addClass("middlebox_closed");



		// hide all right boxes
		$(".right_collapse").children("p").hide();
		//$(".right_box").children("h4").hide();
		$(".right_collapse").addClass("right_box_closed");

		// Show the middle boxes when h2 is clicked
		$(".middlebox h2").click(function() {
			$(this).parent().toggleClass("middlebox_closed");
			$(this).parent().children("p").toggle("slow");
			//alert($(this).attr("id"));
			return false;
		});

		// Underline middle boxes on mouseover
		$(".middlebox h2").mouseover(function(){
			$(this).css("text-decoration", "underline");
		});
		$(".middlebox h2").mouseout(function(){
			$(this).css("text-decoration", "none");
		});

		
		// Add delete buttons to the buy form
		$(".buytable").find("input").after(" <a href='#' class='buydelete' ><img src='/images/delete.gif' alt='Delete' /></a>");

		$(".buydelete").click(function(){
			$(this).prev("input").attr("value", "0");
			$(this).parents("form").submit();
			return false;
		});

		// Don't let the user buy things that are coming soon
		$(".buy_comingsoon").css("color", "#ababab");
		//$(".buy_comingsoon").find("img").hide();
		$(".buy_comingsoon").find("input").attr("disabled", "disabled");
		$(".buy_comingsoon").children("td:first-child").append("<br/>(Coming Soon!)");




		// Show the right boxes when h3 is clicked
		$(".right_collapse h3").click(function() {
			$(this).parent().parent().toggleClass("right_box_closed", "normal");
			$(this).parent().parent().children("p").toggle("slow");
			//$(this).parent().children("h4").toggle("slow");
			return false;
		});

		// Underline right box headings onmouseover
		$(".right_collapse h3").mouseover(function(){
			$(this).css("text-decoration", "underline");
		});
		$(".right_collapse h3").mouseout(function(){
			$(this).css("text-decoration", "none");
		});



		// Grey out the search boxes...
		$(".input_search").css("color", "#ababab");

		// ... until they are clicked
		$(".input_search").focus(function() {
			$(this).css("color", "#000000");
			$(this).val("");
			return false;
		});


		// ... until they are clicked
		$(".selectedTxt").click(function() {
			$(this).css("color", "#000000");
			return false;
		});
		$(".newListSelected").click(function() {
			$(this).css("color", "#000000");
			return false;
		});





		// Hide big list of sectors in footer
		$("#jobsectors_hide").hide();

		// Hide big list of locations in footer
		$("#joblocations_hide").hide();
		
		// Add spell check to relevent elements
		$(".spellthis").spellcheck();

		// Add tooltips to relevent elements
		$(".tooltipthis").tooltip({showURL: false});

		// Add confirmation dialog to relevant alements
		$(".confirmlink").click(function(){
			if (confirm("Confirm action?"))
			{
				document.location = $(this).attr("href");
			}
			return false;
		});

		// Convert buttons to graphics
		
		$(".makebrown").each(function(el) { 
			$(this).html("<div class='brownbutton'><a href='#' onclick='$(this).parents(\"form\").submit(); return false;'>" + $(this).children("input").val() + "</a></div>");
			$(this).append("<input type='submit' />");
			$(this).children("input").hide();
			//$(this).after("<div class='clearboth'>&nbsp;</div>");
		});




		//$(".bigmiddlebox").append("<div class='clearboth'>&nbsp;</div>");
		//$(".middlebox").append("<div>&nbsp;</div>");

		//$(".makebrown").html("<div id='brownbutton'><a href='#'>" + $(this).children("input").val() + "</a></div>");

		// Make external links open in a new window

		$(".external").attr('target','_blank')


		// Place date pickers on apropriate objects
		//$(".datepicker").datepicker('option', {dateFormat: "dd/mm/yyyy"});
		$(".datepicker").datepicker({ dateFormat: 'dd/mm/yy' });
;


		// Hide everything that should be initially hiddne
		$(".initialhide").hide();


		







	});









function showDropDown(parentElement, dropdownElement) {
	var parentPosition = $(parentElement).position();
	var newTop = parentPosition.top + 30;
	$("#" + dropdownElement).css({top: newTop, left: parentPosition.left});
	$("#" + dropdownElement).toggle("blind");
}



    $("#toggle_registration").blur(function () {
		$("#" + dropdownElement).toggle("blind");
    });







$(document).ready(function() {
	setPaypalPos();
});


function setPaypalPos() {
		// Show Paypal overlay
		var pos = $(".showpaypal_overlay").offset();  
		var width = $(".showpaypal_overlay").width();
		var height = pos.top;
		height = height - 15;
		width = width - 35;
		$("#paypal_overlay").css({"left": (pos.left + width) + "px", "top":height + "px"});
		if ( pos.left == 0 ) {
			$("#paypal_overlay").hide();
		}
}

$(window).load(function(){
	setPaypalPos();

});


