var timer;

function manual_change(cont) {
  clearTimeout(window.timer);
  change_pic(cont);
}

function change_pic(cont) {
	var num;
	str = $('#main_pic').attr('src');
	old_pic = str.substr(str.indexOf('.jpeg')-1,1);
	str = $('#cont' + cont + ' img:first').attr('id');
	num = str.substr(5,1);
	$('#main_pic').fadeOut('slow', function() {
		$('#main_pic').attr('src','skins/hotel/img/gallery1/pic_'+num+'.jpeg');
		$('#main_pic').fadeIn('slow');
	});
/*
	$('#cont'+cont).fadeOut('slow', function() {
		$('#cont'+cont).html('<img id="thmb_' + old_pic + '" alt="pic" src="skins/hotel/img/gallery1/thmb_' + old_pic + '.jpeg" onclick="manual_change(' + cont + ');">');
		$('#cont'+cont).fadeIn('slow');
	});
*/
}

function timedFunc(cont)
{	
	var nextCont;
	if (cont == 9) {
		nextCont = 2;
	} else {
		nextCont = cont + 1;
	}
	change_pic(cont);
	window.timer = setTimeout('timedFunc(' + nextCont + ')', 5000);
}

function checkPop() {
	var str = location.search;
	var pos = str.indexOf('pop=');
	if (pos > 0) {
		var event = parseInt(str.substr(pos + 4));
		$('#pop' + event).click();
	}
}

function seltimer(id, check)
{
	var seltime='<select name="'+id+'" id="'+id+'" >';
	for(i=1;i<=24;i++)
	{
		if(i==check)
		{
			seltime+= '<option selected>'+i+':00 &laquo;</option>';
		} else {
			seltime+= '<option>'+i+':00</option>';
		}
	}
	seltime+= '</select>';
	return seltime;
}
function time_in_out(idtime)
{
	$('#'+idtime).html('<div ><p>заезда '+seltimer('time_in',14)+', выезда'+seltimer('time_out',12)+'</p></div>');
}
function check_order_form()
{
	//document.getElementById('order_form').submit();
	show_aj_place('feed_result', 'order.php?', '', 'POST', 'order_form');
}
