
function ShowPicture(url,title,width,height)
{
	var features = "toolbar=0,location=0,directoties=0,status=0,menubar=0,scrollbars=no,resizable=yes,width="+(width)+",height="+height+",left="+(screen.availWidth-width)/2+",top="+(screen.availHeight-height)/2;
	var w=window.open("/picture.php?url="+url+"&title="+title+"&width="+width+"px"+"&height="+height, title, features);
}

// Функция проверки на положительное целое число
function is_positive_int(src)
{ 
	var res = false; 
	var re = /^[-]?\d*\.?\d*$/;
	var str = src.toString();
	if (str.match(re)>0) 
	{ 
		res = true; 
	} 
	return res; 
}


function clearSelect(theList) 
{
	var len = theList.length-2;
	for (var i = 0; i < len; i++)
	{
		theList.options[2]=null;
	}
}

function loadSelect(theList, aData)
{
	var aDataSource = new Array();
	var aNewOption = new Array();

	aData = aData.split("|");
	var j = 2;
	for (var i = 0; i < aData.length-1; i++)
	{
		var tmp = aData[i].split("-");
		option = new Option(tmp[1], tmp[0]);
		theList.options[j]=option;
		j++;
	}
}

function getData(what,f2)
{
	var myselect;
	if (f2) {myselect = "myselect"+f2;} else {myselect = "myselect";} // (oparin)
	var f=document.forms[myselect];
	if (what == "resort")
	{
		var cn = f.country.value;
		f.resort.disabled = true;
		f.category.disabled = true;
	} else
	{
		var cn = f.resort.value
		f.category.disabled = true;
	}
	if ( is_positive_int(cn) )
	{
		var o = (what == "resort") ? f.resort : f.category;
		clearSelect(o);
	    JsHttpRequest.query(
		'/getselect.php', 
		{
			'what'	: what,  
			'nomer' : cn,
			'f2' : f2
		},
		function(result, errors) 
		{ 
			if (result["list"] && result["list"] != "empty")
			{
				o.disabled = false;
				loadSelect(o, result["list"]);
			} 
		}
	    );
	}
}

function checkMySelect(f2)
{
	var myselect;
	if (f2) {myselect = "myselect"+f2;} else {myselect = "myselect";}
	var f=document.forms[myselect];
	
	if (f.country.value == 0)
	{
		alert("Выберите страну!"); return false;
	} else if (f.resort.value == 0)
	{
		alert("Выберите курорт!"); return false;
	} else if (f.category.value == 0)
	{
		document.location = "http://www.hotel-select.ru/index.php?country="+f.country.value+"&resort="+f.resort.value;
		return false;
	} else if (f2) // (oparin)
	{
		document.location = "http://www.hotel-select.ru/index.php?country="+f.country.value+"&resort="+f.resort.value+"&hotel="+f.category.value+"#go_comments";
		return false;
	} else
	{
		document.location = "http://www.hotel-select.ru/index.php?country="+f.country.value+"&resort="+f.resort.value+"&category="+f.category.value;
		return false;
	}
}

function checkSearch()
{
	var i=document.forms['search'];
	var re_str=/[^\s+]/;
	if (!re_str.test(i.searchstr.value) || i.searchstr.value.length<3)
	{
		i.searchstr.focus();
		alert("Введите название отеля (не менее 3 символов)!"); return false;
	} else
	{
		return true;
	}
}

function changefilter(num)
{
	if (document.images['filterimg'].src.indexOf("filter_plus")>=0)
	{document.images['filterimg'].src='img/filter_minus.gif'; document.getElementById('filterform').className = 'opened';} else 
	{ document.images['filterimg'].src='img/filter_plus.gif'; document.getElementById('filterform').className = 'closed';}
}

function FilterReset(num)
{
	var i=document.forms['filter']; 
	document.forms['filter'].filterreset.value=1;
	i.submit();
	return false;
}

function FilterSubmit(num)
{
	var i=document.forms['filter']; 
	i.submit();
	return false;
}