/*function id(a) {
	return document.getElementById(a);
}
window.onload = function() {
	document.body.setAttribute("class", "attribute-test");
	if (document.body.className == "attribute-test")
	{
		/для W3C-браузеров
		id("firstlink").getElementsByTagName("a")[0].setAttribute("onmouseover", "active_now_is('first')");
		id("secondlink").getElementsByTagName("a")[0].setAttribute("onmouseover", "active_now_is('second')");
		id("thirdlink").getElementsByTagName("a")[0].setAttribute("onmouseover", "active_now_is('third')");
	}
	else
	{
		////для IE
		id("firstlink").getElementsByTagName("a")[0].setAttribute("onmouseover",new Function ("active_now_is('first')"));
		id("secondlink").getElementsByTagName("a")[0].setAttribute("onmouseover",new Function ("active_now_is('second')"));
		id("thirdlink").getElementsByTagName("a")[0].setAttribute("onmouseover",new Function ("active_now_is('third')"));
	}
}
function active_now_is(count) {
	var link = count + "link";
	id("firstlink").className = "first_level";
	id("firstlink").getElementsByTagName("ul")[0].className += " hide";
	id("secondlink").className = "first_level";
	id("secondlink").getElementsByTagName("ul")[0].className += " hide";
	id("thirdlink").className = "first_level";
	id("thirdlink").getElementsByTagName("ul")[0].className += " hide";
	id(link).className = "first_level active";
	id(link).getElementsByTagName("ul")[0].className = "second_level";
}
*/
function ShowVacancy(obj)
{
  $(obj).parent().each(function(){$(this).attr('class', ($(this).attr('class') == 'active' ? '' : 'active'))}).parent().find("div.vacansy_descr").animate({opacity:"toggle", height:"toggle"}, 300);
}

function HideVacancy()
{
  $("ul.vacansy_list").find('h3').each(function(index){if(index>0) $(this).removeClass('active')}).end().find('div.vacansy_descr').each(function(index){if(index>0) $(this).removeClass('active')});
}

function ChangeStructureMenu() {
	$("#menu_main > li.first_level").each(function(){
  		this.onclick = function(){
  			$(this).parent().parent().find("li.first_level").removeClass('active').find("ul").addClass('hide');
	  		$(this).find('ul').removeClass('hide').parent().addClass('active')
  		};
	  	/*this.onmouseout = function(){
  			$(this).find('ul').addClass('hide').parent().removeClass('active').parent().find("li.first_level[@active='1']").addClass('active').find("ul").removeClass('hide')
	  	}*/
	});
}
var item = new Array();
var imgCnt = 0;
function ShowItemProperties(ID)
{
  if(ID>0)
  {
    document.documentElement.scrollTop ? (document.documentElement.scrollTop=0) : (document.body.scrollTop=0);
    item = items[ID];
    ItemShowImg(0);
    $('#popup_hotel').find('#item_description').html(item.desc).end().animate({opacity:"show"}, 300);
    $('#shadow').animate({height:document.body.offsetHeight+20, opacity:0.54}, 300);
  }
  else
  {
    alert('Не выбрано значение');
  }
  return false;
}

function HideItemProperties()
{
  $('#popup_hotel').animate({height:"hide"}, 300);
  $('#shadow').animate({opacity:"hide"}, 300);
  imgCnt = 0;
  return false;
}


function ItemShowImg(nav)
{
  imgCnt += nav;
  
  if(imgCnt >= item.imgs.length)
    imgCnt = 0;
    
  if(imgCnt < 0)
    imgCnt = item.imgs.length-1
    
  var image = item.imgs[imgCnt] || item.imgs[imgCnt][0];

  $('#item_img').animate({opacity:0.1}, 300, function(){$('#item_img').attr('src', image.src).animate({opacity:1}, 500);});
}
var showingTimer = 0;
function ShowControls()
{
  $('#control_elements').animate({opacity:'show'}, 300);
  window.clearInterval(showingTimer);
}

function HideControls()
{
  showingTimer = window.setInterval(function(){$('#control_elements').animate({opacity:'hide'}, 500)}, 2000);
}


function Init()
{  
  ChangeStructureMenu();
 // HideVacancy();

  
}

$(document).ready(Init);

