 // Limits the textarea field
 
 jQuery(document).ready(function() {

	$('#coin-slider').coinslider({ width: 430, height:250,hoverPause: true, links : true, effect: 'rain',navigation:false});
	
	$( "#tabs" ).tabs({            
                        //event: 'mouseover'
                fx: { height: 'toggle', opacity: 'toggle'},
                show: function(event, ui) {
                          if (ui.panel.id == "tab-4") {
                                  construct_the_map();
                                }}
                });
	
	$(".mybox").colorbox({
		opacity: 0.85,
		inline:true,
		close:"X"
	});
});
 
 
function textCounter (field, countfield, maxlimit) 
{

	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
	else 
		countfield.value = maxlimit - field.value.length;
}

// Opens the page in a new window
function windowOpen (mypage, w, h)
{
	h=h+140;
	w=w+60;
	if(screen.width)
	{
	
		var winl = (screen.width-w)/2;
		var wint = (screen.height-h)/2;
	
	}
	else
	
	{
	
		winl = 0;wint =0;
	
	}
	
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;
	
	var settings = 'height=' + h + ',';
	settings += 'width=' + w + ',';
	settings += 'top=' + wint + ',';
	settings += 'left=' + winl + ',';
	settings += ' scrollbars=yes ';
	
	var myname = '';
	
	win = window.open(mypage,myname,settings);
	
	win.window.focus();

}

function confirmDelete(msg)
{
	if (!msg) {msg="Êtes-vous sûr de vouloir supprimer ?"}
	var agree=confirm(msg);
	if (agree)
		return true ;
	else
		return false ;
}

function showperday()
{

	obj=$('#listing_type_select');

	if (obj.val() == 4)	
	{
		$('#opt *').hide();
		$('#price_span_total').show();
	}
	else if (obj.val() == 5)
	{	
		$('#opt *').hide();
		$('#price_span_month').show();
	}
	else if (obj.val() == 6)
	{	
		$('#opt *').hide();
		$('#price_span_day').show();
	}
	else if (obj.val() == 7)
	{	
		$('#opt *').hide();
		$('#price_span_month').show();
		$('#price_span_person').show();		
	}
	
	else
	{	
		$('#opt *').hide();
	}		
}  

function add_favorite(id)
{
	dataString = 'favorite_id=' + id;
	$.ajax
	({
	type: "POST",
	url: "ajax_listing.php",
	data: dataString,
	cache: false,
	success: function(html)
	{
		alert(html);
	}
	});
}

function send_message()
{
	$("#message_result").show();
}
