
function changeLanguage(sender, param)
{
    $("#setCurrentLang").val(param);
    $("#webform").attr("action", index() + 'template.change_lang/'+param);
    $("#webform").submit();
}

function theRotator() {
	//Set the opacity of all images to 0
	$('div#rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div#rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',7000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	
};

function search_submission()
{
	var searchword = $('#search').val();
	if(searchword == '' || searchword.length < 3)
	{
		alert(msgErrSearch);
		return false;
	}
    $("#webform").attr("action", index()+"shop.list_search");
    $("#webform").submit();
}

function InputFocus(val,param)
{
	if(param.value == val)
		param.value = '';
}
function InputBlur(val,param)
{
	if(param.value == '')
		param.value = val;
}

function fbs_click() 
{
	var left = (screen.width/2)-(626/2);
	var top = (screen.height/2)-(436/2);
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=1,menubar=yes,status=1,width=626,height=436,top='+top+', left='+left);
	return false;
}
function isNumberKey(evt)
{
	 var charCode = (evt.which) ? evt.which : evt.keyCode
	 if (charCode > 31 && (charCode < 48 || charCode > 57))
	    return false;

	 return true;
}
