$(document).ready(function() {
$("select#region").change(function() {
    $.ajax({
		url: "/members/select_html.php",
		data: {region: $(this).val(), ajax: 'true'},
		success: function(theResponse){
      $("select#the_town").html(theResponse);
			},
		error: function(a,b,c) {
		console.log(a + "   " + b + "    " + c);
		}
  })
	})

$('p#submitjoinform').html('<input class="noborder submitjoin" type="image" src="/site/images/reg.png" name="submit" />');
$('form#enquiryprop').attr('action','../../../../form-processing/ajaxenq.php')
$('form#enquiryprop').submit(function(e) {
__formid = this;
e.preventDefault();
enqform = form;
enqform.formid = __formid;
enqform.toupdate = $("#add");
enqform.sendData();
});
$("area").hover(function(e) {
var __this = this;
var linkstr = "#" + $(this).attr('id') + "link";
$(linkstr).addClass('blue');
var titleText = $(this).attr('title');
$(this)
.data('tipText', titleText)
.removeAttr('title');
$('<p class="tooltip"></p>')
.text(titleText)
.appendTo('body')
.css('top', (e.pageY - 10) + 'px')
.css('left', (e.pageX + 20) + 'px')
.fadeIn('slow');
}, function() {
$(this).attr('title', $(this).data('tipText'));
$('.tooltip').remove();
linkstr = "#" + $(this).attr('id') + "link";
$(linkstr).removeClass('blue');
}
);
$("area").mousemove(function(t) {
$('.tooltip')
.css('top', (t.pageY - 10) + 'px')
.css('left', (t.pageX + 20) + 'px');
});
$("#dates").hide();
$("#reason").change(function(e) {
if ($(this).val() == "Interested in Booking") {
$("#dates").show('slow');
}
else { $("#dates").hide(); }
});
$("#dp1,#dp2").datepicker({
changeMonth:true,
changeYear:true});
$('#mainimg ul').data('currLI','one');
setInterval('fader()',10000);
var text = $("#textblock").html();
	$("#textblock").css('text-align','center').html('<h2>Welcome to Rent Turkey Property.com</h2><a id="info" href="#"><img class="noborder" src="../../site/images/infoicon.jpg" alt="" width="50" align="center"></a>');
	$("#info").click(function(w) {
	w.preventDefault();
	$("#textblock").css('text-align','left').hide(10).html(text).fadeIn(500);
	});
$(".submitjoin").click(function() {
document.joinform.submit;
});
$('a.shortlist').attr("href","/site/scripts/ajax.php")
$("a.shortlist").fancybox({
		ajax: {
		type : 'get',
		data : 'getshortlist=true'
		}
	});
$("a.addtoshortlist").attr("href","/site/scripts/addto.php")
$("a.addtoshortlist").fancybox({
ajax: {
type: 'get',
data: "addto="+$("a.addtoshortlist").attr('rel')
},
'onClosed' : function() {
$('.addto a img').attr('src','/site/images/sla.gif');
}
})

});

function fader() {
var last = $('#mainimg ul li:last').attr('id');
var currID = $('#mainimg ul').data('currLI');
var currLiStr = '#mainimg ul li#' + currID;
nextID = (currID == last) ? 'one' : $(currLiStr).next().attr('id');
nextLiStr = $('#mainimg ul li#' + nextID);
$(currLiStr).fadeOut(3000);
$(nextLiStr).fadeIn(2000);
$('#mainimg ul').data('currLI',nextID);
}


