// используется для выезжания текста
function openclose(id){

	var da = document.getElementById('open'+id);
	var dt = document.getElementById('htxt'+id);
	
	if(dt.className == 'hidden-txt'){
		//dt.style.display = 'block';
		dt.className = 'open-txt';
		da.className = 'close';
		

		
		//dplusminus.className = 'cathaschopen';
		//dcatopenclose.className = 'catopen';
		
	}else{
		//dt.style.display = 'none';
		dt.className = 'hidden-txt';
		da.className = 'open';

		
		//dplusminus.className = 'cathaschclose';
		//dcatopenclose.className = 'catclose';
	}

	return false;
}

function opencloserecommended(ttype){

	var tt = document.getElementById('titlerekomended-tury');
	var th = document.getElementById('titlerekomended-hotels');
	var tp = document.getElementById('titlerekomended-places');
	var tc = document.getElementById('titlerekomended-countryes');
	
	var dt = document.getElementById('drekomended-tury');
	var dh = document.getElementById('drekomended-hotels');
	var dp = document.getElementById('drekomended-places');
	var dc = document.getElementById('drekomended-countryes');
	
	if( ttype == 'tury'){

		tt.className = 'title2-selected';
		th.className = 'title2';
		tp.className = 'title2';
		tc.className = 'title2';
		
		dt.className = 'drekomended';
		dh.className = 'drekomended drhidden';
		dp.className = 'drekomended drhidden';
		dc.className = 'drekomended drhidden';
				
	}else if( ttype == 'hotels'){

		tt.className = 'title2';
		th.className = 'title2-selected';
		tp.className = 'title2';
		tc.className = 'title2';
		
		dt.className = 'drekomended drhidden';
		dh.className = 'drekomended';
		dp.className = 'drekomended drhidden';
		dc.className = 'drekomended drhidden';
		
	}else if( ttype == 'places'){

		tt.className = 'title2';
		th.className = 'title2';
		tp.className = 'title2-selected';
		tc.className = 'title2';
		
		dt.className = 'drekomended drhidden';
		dh.className = 'drekomended drhidden';
		dp.className = 'drekomended';
		dc.className = 'drekomended drhidden';

	}else if( ttype == 'countryes'){

		tt.className = 'title2';
		th.className = 'title2';
		tp.className = 'title2';
		tc.className = 'title2-selected';
		
		dt.className = 'drekomended drhidden';
		dh.className = 'drekomended drhidden';
		dp.className = 'drekomended drhidden';
		dc.className = 'drekomended';

	}
		
	return false;
}

function opencloserecountrycommended(ttype){

	var tt = document.getElementById('titlerekomended-tury');
	var th = document.getElementById('titlerekomended-hotels');
	var tp = document.getElementById('titlerekomended-places');

	var dt = document.getElementById('drekomended-tury');
	var dh = document.getElementById('drekomended-hotels');
	var dp = document.getElementById('drekomended-places');
	
	if( ttype == 'tury'){

		tt.className = 'title2-selected';
		if(th){th.className = 'title2';}
		if(tp){tp.className = 'title2';}
		
		dt.className = 'ccountryrecommended';
		if(dh){dh.className = 'ccountryrecommended drhidden';}
		if(dp){dp.className = 'ccountryrecommended drhidden';}
				
	}else if( ttype == 'hotels'){

		if(tt){tt.className = 'title2';}
		th.className = 'title2-selected';
		if(tp){tp.className = 'title2';}
		
		if(dt){dt.className = 'ccountryrecommended drhidden';}
		dh.className = 'ccountryrecommended';
		if(dp){dp.className = 'ccountryrecommended drhidden';}
		
	}else if( ttype == 'places'){

		if(tt){tt.className = 'title2';}
		if(th){th.className = 'title2';}
		tp.className = 'title2-selected';
		
		if(dt){dt.className = 'ccountryrecommended drhidden';}
		if(dh){dh.className = 'ccountryrecommended drhidden';}
		dp.className = 'ccountryrecommended';

	}
		
	return false;
}

function view_countrymenu(){

	var menu = document.getElementById('dcountrymenu');
	
	menu.style.display = 'block';
	
}

function close_countrymenu(){

	var menu = document.getElementById('dcountrymenu');
	
	menu.style.display = 'none';
	
}


/* форма поиска отелей */
function loadcity(){

	var country =  document.getElementById('fcountry');
	//alert(country.value);
	
	var url = "/hotels.html?action=loadcity&idcountry=" + country.value ;
	
	//alert(url);
	
	displayHotelsResult('<p>загрузка...</p>');
	requestHotelsData(url);
}

function requestHotelsData(url) {

    var oXHR = zXmlHttp.createRequest();
    oXHR.open("get", url, true);
	
    oXHR.onreadystatechange = function () {
        if (oXHR.readyState == 4) {
            if (oXHR.status == 200 || oXHR.status == 304) {
                displayHotelsResult(oXHR.responseText);
            } else {
                displayHotelsResult("An error occurred: " + oXHR.statusText); //statusText is not always accurate
            }
        }            
    };
	
    oXHR.send(null);
}

function displayHotelsResult(sText) {

	//alert(sText);
	
	var cityblck = document.getElementById('fcityblck');
    //var divCustomerInfo = document.getElementById("divCustomerInfo");
    cityblck.innerHTML = sText;
}

/* Copyright (c) 2006 Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 *
 * $LastChangedDate: 2007-12-14 23:57:10 -0600 (Fri, 14 Dec 2007) $
 * $Rev: 4163 $
 *
 * Version: 3.0
 *
 * Requires: $ 1.2.2+
 */
(function($){
  $.event.special.mousewheel={
    setup:function(){
      var handler=$.event.special.mousewheel.handler;
      if($.browser.mozilla)$(this).bind('mousemove.mousewheel',function(event){
        $.data(this,'mwcursorposdata',{
          pageX:event.pageX,
          pageY:event.pageY,
          clientX:event.clientX,
          clientY:event.clientY
          });
      });
      if(this.addEventListener)this.addEventListener(($.browser.mozilla?'DOMMouseScroll':'mousewheel'),handler,false);else
      this.onmousewheel=handler;
      },
    teardown:function(){
      var handler=$.event.special.mousewheel.handler;$(this).unbind('mousemove.mousewheel');if(this.removeEventListener)this.removeEventListener(($.browser.mozilla?'DOMMouseScroll':'mousewheel'),handler,false);else
      this.onmousewheel=function(){};
      $.removeData(this,'mwcursorposdata');
      },
  handler:function(event){
      var args=Array.prototype.slice.call(arguments,1);event=$.event.fix(event||window.event);$.extend(event,$.data(this,'mwcursorposdata')||{});var delta=0,returnValue=true;if(event.wheelDelta)delta=event.wheelDelta/120;if(event.detail)delta=-event.detail/3;if($.browser.opera)delta=-event.wheelDelta;event.data=event.data||{};
      event.type="mousewheel";args.unshift(delta);args.unshift(event);return $.event.handle.apply(this,args);
      }
    };
    $.fn.extend({
      mousewheel:function(fn){
      return fn?this.bind("mousewheel",fn):this.trigger("mousewheel");
      },
  unmousewheel:function(fn){
      return this.unbind("mousewheel",fn);
      }
    });
  })(jQuery);

/**
 *            Easing functions
 */
  /*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 *
 * Open source under the BSD License.
 *
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this list of
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list
 * of conditions and the following disclaimer in the documentation and/or other materials
 * provided with the distribution.
 *
 * Neither the name of the author nor the names of contributors may be used to endorse
 * or promote products derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
*/
  jQuery.extend(jQuery.easing, {
    easeOutExpo: function (x, t, b, c, d) {
            return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
    }
    });

/*
 * Content scroll to anchor (or top)
 */

(function($){
 
  $(function(){
  
    var $scrollable = $.browser.webkit ? $('body') : $('html');
    
    $(document).mousewheel(function() {
      $scrollable.stop();
    });
  
    $('a[href*=#]').each(function() {
      if ( this.href && this.hash && (/.*#.+/.test(this.href)) ) {                
        var $target = $('a[name="' + this.hash.slice(1) + '"], #' + this.hash.slice(1)).eq(0);
        if ( this.hash.slice(1) == 'top' && $target.length < 1 )
          $target = $(document.body);
        if ($target.length > 0) {
          $(this).click(function() {
            var targetOffset = $target.offset().top;
            var linkOffset = $(this).offset().top;
            var duration = Math.abs(targetOffset - linkOffset);
            $scrollable.animate({
              scrollTop : targetOffset
            }, /section\-/.test(this.hash.slice(1)) ? 800 : duration * 0.4, 'easeOutExpo');
            return false;
          });
        }
      }
    });
    
  });
  
})(jQuery);
// Content scroll to anchor (or top)
