function open_dialog(){
	if($('#search_box').css('display')=='none')
		$('#search_box').fadeIn('slow');
	else
		$('#search_box').fadeOut('slow');
}
function reset_input(bool,value){
	if(bool){
		$('#s').attr('value','');
	}
	else{
	if($('#s').attr('value')=='')
		$('#s').attr('value',value);
	}
}
var i=1; var img_array= Array();
$(document).ready(function ()
{	
	$("#pikame").PikaChoose({transition:[4],speed:5000});
	$(".previous").html("");
	$(".next").html("");
	
	$('#tappeti img:nth-child(2)').each(function(){
		img_array[i]=($(this).attr('src'));
		i++;
	});
	$('#gallery-1 a').lightBox();
	$('#news_container').cycle({timeoutFn: calculateTimeoutNews});
	i=1;
	$('.slideshow').after('<ul id="promonav">').cycle(
	{
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		pager:  '#promonav',
		prev: '.previous',
        next: '.next',
		pause: 1,
		height : 500,
		timeoutFn: calculateTimeout,
		pagerAnchorBuilder: function(idx, slide)
		{
			var ret= '<li><a class="trial" href="#"><div class="number"><img src="'+img_array[i]+'" width="78" height="101" /></div></a></li>';
			i++;
			return ret;
		}
	});
	Cufon.now();			
});

function calculateTimeout(currElement, nextElement, opts, isForward) { 
    // here we set even number slides to have a 2 second timeout; 
    // by returning false for odd number slides we let those slides 
    // inherit the default timeout value (4 sec) 
    var index = opts.currSlide; 
    return 60000; 
}

function calculateTimeoutNews(currElement, nextElement, opts, isForward) { 
    // here we set even number slides to have a 2 second timeout; 
    // by returning false for odd number slides we let those slides 
    // inherit the default timeout value (4 sec) 
    var index = opts.currSlide; 
    return 5000; 
} 
