function addBookmark(title,url)
{
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}

  function CreateNewWin(img) {

    winOpt = "width=600,height=400";
    winOpt = winOpt + 'location="no", menubar="no", status="no", toolbar="no"';

    newWin = window.open("", "hotel_pic", winOpt);

    newWin.document.writeln("<html><body leftMargin=0 topMargin=0 marginheight=0 marginwidth=0><table width='100%' height='100%'><tr><td align='center' valign='center'>");
    newWin.document.writeln("<img src="+img+">");
    newWin.document.writeln("<br><a href='#' onClick='self.close()'>Закрыть</a></td></tr></table></body></html>");
    newWin.document.close();
  }

function get_http(){
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new 
                ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
    @else
        xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
            xmlhttp = false;
        }
    }
    return xmlhttp;
}

function fill (select_id, data){
    
}

function ShowFAQ(id)
{
	var ff = document.getElementById('fb_'+id);
	if (!ff){
		new Ajax.Request('/faq/get-faq/'+id+'/', {
			method: 'get',
			/*parameters: {
					id: id
			},*/
			onFailure: function(tr) {
					alert('Error code: ' + tr.status + '\n');
					alert(tr.responseText);
			},
			onSuccess: function(tr) {
					// поле SELECT в переменную в виде объекта
					if(tr.responseText.length == 0) return;
	
					if ( ! $('fb_'+id) )
					{
							var parent = document.getElementById('f_'+id);
							var faq_body = document.createElement("div");
							faq_body.addClassName('faq_body');
							faq_body.setAttribute('id', 'fb_'+id);
							faq_body.insert(tr.responseText);
							parent.appendChild(faq_body);
					}
			}
		});
	}else if(ff.getAttribute('class') == 'hide'){
		ff.setAttribute('class', 'faq_body');
	}else{
		ff.setAttribute('class', 'hide');
	}
	
	return false;
}

function GetSpa(url, country)
{
	if (country.length < 3 ) return;

	new Ajax.Request(url, {
		method: 'get',
		parameters: {
				country: country
		},
		onFailure: function(tr) {
				alert('Error code: ' + tr.status + '\n');
				alert(tr.responseText);
		},
		onSuccess: function(tr) {
				// поле SELECT в переменную в виде объекта	
				var select = document.getElementById('s');
				var arr = new Array();
				var array_count=select.options.length-1;
					var i =1;
					while (i < array_count) {
					 select.options[i] = null;
					 i++
					}
				// очищаем SELECT
				select.options.length = 1;
				// если данных нет - не делаем больше ничего
				if(tr.responseText.length == 0) return;
				// в массиве arr - строки полученной таблицы
				// для каждой строки
				arr = tr.responseText.split(',');
				var i=0;
				while( i < arr.length)
				{
					select.options[select.options.length]= new Option(arr[i], arr[i], false, false);
					i++;
				}
		}
	});
}

function ViewPhoto(url, width, height)
{
	var xMax = screen.width, yMax = screen.height;
	var xOffset = (xMax - width)/2, yOffset = (yMax - height)/2-25;

	window.open(url,"","scrollbars=0,statusbar=no,resizable=no,minimizable=1,width="+(width+20)+",height="+(height+25)+",top=" + yOffset + ",left=" + xOffset);
}

function ImgShw(ID, width, height, alt)
{
	var scroll = "no";
	var top=0, left=0;

	if ( width > screen.width-10 || height > screen.height-28 ) scroll = "yes";
	if ( height < screen.height-28 ) top = Math.floor((screen.height - height)/2-14);
	if ( width < screen.width-10 ) left = Math.floor((screen.width - width)/2-5);
	width = Math.min(width, screen.width-10);
	height = Math.min(height, screen.height-28);
	var wnd = window.open("","","scrollbars="+scroll+",resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
	wnd.document.write("<html><head>\n");
	wnd.document.write("<"+"script language='JavaScript'>\n");
	wnd.document.write("<!--\n");
	wnd.document.write("function KeyPress()\n");
	wnd.document.write("{\n");
	wnd.document.write("	if(window.event.keyCode == 27)\n");
	wnd.document.write("		window.close();\n");
	wnd.document.write("}\n");
	wnd.document.write("//-->\n");
	wnd.document.write("</"+"script>\n");
	wnd.document.write("<title>"+(alt == ""? "���⨭��":alt)+"</title></head>\n");
	wnd.document.write("<body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" onKeyPress=\"KeyPress()\">\n");
	wnd.document.write("<img src=\""+ID+"\" border=\"0\" alt=\""+alt+"\">");
	wnd.document.write("</body>");
	wnd.document.write("</html>");
	wnd.document.close();
}

function bg_over(obj) {
	obj.style.backgroundColor='#F2F9FF';
	}
function bg_out(obj) {
	obj.style.backgroundColor='#ffffff';
	}
	
function OrderCity(value)
{
	//var state = document.getElementById("cityo").value.toString();
	
	if ( value == "other" )
	{
		$('cityf').style.display='block';
	} else {
		$('cityf').style.display='none';
	}
}

function checkOrderForm()
{
	var cheking = true;
	var month = document.getElementById("month").value.toString();
	var day = document.getElementById("day").value.toString();
	var days = document.getElementById("days").value.toString();
	var people = document.getElementById("people").value.toString();
	var country = document.getElementById("country").value.toString();
	var stars = document.getElementById("stars").value.toString();
	var fio = document.getElementById("fio").value.toString();
	var phone = document.getElementById("phone").value.toString();
	
	if ( month == "" )
	{
		alert('Не указан месяц поездки');
		cheking = false;
	}
	if ( day == "" )
	{
		alert('Не указана дата поездки');
		cheking = false;
	}
	if ( days == "" )
	{
		alert('Не указана длительность поездки');
		cheking = false;
	}
	if ( people < 0 )
	{
		alert('Не указано кол-во взрослых');
		cheking = false;
	}
	if ( country == "--" || country == "" )
	{
		alert('Не указана страна');
		cheking = false;
	}
	if ( stars == "--" || stars == "" )
	{
		alert('Не указана категория отеля');
		cheking = false;
	}
	if ( fio == "" )
	{
		alert('Не указано контактное имя');
		cheking = false;
	}
	if ( phone == "" )
	{
		alert('Не указан контактный телефон');
		cheking = false;
	}

	return cheking;
}
