
/*******************************************************
 FORM FUNCTIONS

 *******************************************************/

function clearField(tar) {
	tar.value = '';
}

function fillField(tar, def) {
	if (tar.value == '')
		tar.value = def;
}


function popupWindow(url, wi, he)
{
	newwindow = window.open(url, 'Detail picture', 'statusbar=0, toolbar=0, scrollbars=0, resizeable=0, width='+ wi +', height='+ he +'');
	if (window.focus) { newwindow.focus(); }
	return false;
}



/*******************************************************
 jQuery functions

 *******************************************************/

$(document).ready(function() {
	
	$("a.fancy").fancybox();
	
	$('textarea[maxlength]').keyup(function(){
		//get the limit from maxlength attribute
		var limit = parseInt($(this).attr('maxlength'));
		//get the current text inside the textarea
		var text = $(this).val();
		//count the number of characters in the text
		var chars = text.length;

		//check if there are more characters then allowed
		if(chars > limit){
			//and if there are use substr to get the text before the limit
			var new_text = text.substr(0, limit);

			//and change the current text with the new text
			$(this).val(new_text);
		}
	});
	
	$('#form-newsletter').dialog({ autoOpen: false, title: 'Sign up for newsletter', width: 400, height: 175, modal: true, buttons: {
		'Close': function() { location.href = ""; }
	} });

	$('#btn-newsletter').click(function(e)
	{
		e.preventDefault();
		$("#form-newsletter").dialog("open");
		return false;
	});
	
	$( ".jq-btn" ).button({
		icons: false,
		text: true
	})
	
	$.panzoom();	
});


$(function()
{
	$('.scroll-pane').jScrollPane();
});

function businessType(value)
{
	if (value == 'Market Stall' || value == 'Online Store' || value == 'Other')
	{
		$('#business-other').fadeIn();
		$('#business-shop').hide();
	}
	
	if (value == 'Shop')
	{
		$('#business-other').hide();
		$('#business-shop').fadeIn();
	}
	
	if (value == 'Party Plan')
	{
		$('#business-other').hide();
		$('#business-shop').hide();
	}
}

$(window).load(function() {
	$('#slider').nivoSlider({
		effect: 'sliceDown',
		directionNav: false,
		directionNavHide: false,
		animSpeed: 500,
		pauseTime: 4000,
		captionOpacity: 1
	});
});

