/**
 * JQuery function: blindToggle
 * Toggles hidden content using a 'blind' effect. Works by using a negative margin to 'hide' a block-level entity.
 */
jQuery.fn.blindToggle = function(speed, easing, callback) {
	var h = this.height() + parseInt(this.css('paddingTop')) + parseInt(this.css('paddingBottom'));
	return this.animate({marginTop: parseInt(this.css('marginTop')) < 0 ? 0 : -h}, speed, easing, callback);
};

/**
 * Toggles on/off hidden content using the JQuery blindToggle method, above.
 */
function blindToggle(elementID) {
	$('#'+elementID).blindToggle('normal');
}

function showHelpText(element, text) {
	$('#'+element).attr('value',text);
}
function doClear(element) {
	$('#'+element).attr('value','');
}

/* Facebook Click to Share */
function fbs_click() {
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

/* ThickBox send message dialog. Re-usable ajax-based messaging dialog. */
function tbSendMsg(elmId,targetUrl)
{
		var $name = $('#'+elmId+'_name').val();
		var $msg = $('#'+elmId+'_message').val();
		var $bookingref = $('#'+elmId+'_bookingref').val();
		var $agentref = $('#'+elmId+'_ref').val();
		var $email = $('#'+elmId+'_email').val();
		var $phone = $('#'+elmId+'_phone').val();
		var $trip = $('#'+elmId+'_trip_id').val();
		
		if(targetUrl.length > 0)
		{
				$.ajax({
						type: 'POST',
						url: '#',
						data: 'name='+$name+'&message='+$msg+'&agentref='+$agentref+'&bookingref='+$bookingref+'&email='+$email+'&phone='+$phone+'&trip_id='+$trip,
						success: function() {
								alert('success');tb_remove(); //Close modal dialog
						},
						error: function() {
							alert('There was an error sending your message.');
							$('#'+elmId+' span').show();
						}
				});
		}
}

/* The following old JS functions are retained in case later required.
function show(prefix, elementref, high_id)
{
	for (i=1; i<=high_id; i++)
	{
		obj = document.getElementById(prefix+"c_h"+i)
			if (obj != null) { obj.style.display = "none"; }
		obj = document.getElementById(prefix+"c_c"+i)
			if (obj != null) { obj.style.display = "none"; }
	}
	obj = document.getElementById(prefix+"c_h"+elementref)
		if (obj != null) { obj.style.display = "inline"; }
	obj = document.getElementById(prefix+"c_c"+elementref)
		if (obj != null) { obj.style.display = "inline"; }
}


function showWelcomeMore() {
	document.getElementById('welcome_more').innerHTML = "<br />"+
		"We are pleased to continue to offer a wide variety of destinations plus a great service.  We remain one of the best value ski operators in the country as we offer travel by coach, therefore keeping the cost of your holiday down.  If coach travel is not your thing then we offer a variety of destinations were you can purchase accommodation and options through us and make your own way to your destination whether that be fly drive, self drive or snow train.   As we continue to grow and offer more our ethos has remained the same over our last 4 years of operating and that is to take snow lovers to the best resorts in Europe at unbelievable prices.";
}

function hideWelcomeMore() {
	document.getElementById('welcome_more').innerHTML = "";
}

function showPic(picURL,picTitle,picWidth,picHeight){
	newWindow=window.open(picURL,'newWin','toolbar=no,width='+picWidth+',height='+picHeight)
	newWindow.document.write('<html><title>'+picTitle+'<\/title><head><\/head><body topmargin="0" leftmargin="0"><img src="'+picURL+'"><\/body><\/html>')
	newWindow.focus()
}
*/
