 var wym;

 var checkLogin = {};
 var submitListing = {};
 var delListing = {};
 var delImage = {};
 var accessDenied = {};
 var updateTypes = {};

$(document).ready(function () {

 $('#loginUser').focus(function() {
 	$('#loginUser').removeClass('loginUser');
 });

 $('#loginUser').blur(function() {
	if ($('#loginUser').attr('value') == '') {
	 	$('#loginUser').addClass('loginUser');
	}
 });

 $('#loginPass').focus(function() {
 	$('#loginPass').removeClass('loginPass');
 });

 $('#loginPass').blur(function() {
	if ($('#loginPass').attr('value') == '') {
	 	$('#loginPass').addClass('loginPass');
	}
 });

 $("#loginForm").submit(function() {
	if (($("#loginUser").attr('value') == '') || ($("#loginPass").attr('value') == '')) {
	 	alert('Please enter your username and password.');
	 	return false;
	} else {
		return true;
	}
 });

 $(".thumbLink").click(function () {
  var id_bits = this.id.split("_");
	for (i=1; i<=3; i++) {
		if (i == id_bits[1]) {
			$("#large_"+i).show();
		} else {
			$("#large_"+i).hide();
		}
	}
  });

 delListing = function(ref) {
  var msg = window.confirm("Are you sure you want to delete this listing?");
  if (msg) {
  	window.open('index.php?do=my&action=del&ref='+ref,'_self');
  }
 };
 
 delImage = function(id,num) {
  var msg = window.confirm("Are you sure you want to delete this image?");
  if (msg) {
  	window.open('index.php?do=my&action=del_image&id='+id+'&num='+num,'_self');
  }
 };

 $("#buttonLogout").click(function () {
	window.open('index.php?do=logout','_self');
 });

 $("#buttonMyAccount").click(function () {
	window.open('index.php?do=my','_self');
 });

 submitListing = function() {
	$("#map_zoom").attr("value",map.getZoom())
	return true;
 };

 accessDenied = function(type) {
	var msg = window.confirm('To continue you need to be registered and logged in. To register click OK. To login use the "Members Login" in the top right.');
	if (msg) {
		if (type != '') {
			var append = '&type='+type;
		}
		window.open('https://secure.harbourworld.com/?do=register&direct=1'+append,'_self');
	}	
 };

 /* Update types */
 
 updateTypes = function(section) {

	//alert(section);

	$('#subsection').find('option').show();

	$('#subsection').each(function(i) {
		$('option', this).each(function() {
			var bits = $(this).val().split("|");
			if (bits[0] != section) {
				$(this).hide();
				//return false;
			}
		});
	});




 };

});