﻿ie = jQuery.browser.msie && jQuery.browser.version == 6;

jQuery(document).ready(function(){
	$('#lang >a').click(function(){
		$(this).next('ul').slideToggle(150);
		
		return(false);
	});
	$('#lang >ul a').click(function(){
		var ul = $(this).parent().parent();
		$(ul).slideToggle(150).prev('a').children('span').html($(this).html());
		$('a',ul).removeClass();
		$(this).addClass('current');
	});
	
	if(ie){
		$('#menu li').hover(function(){
			$(this).stop(true).addClass('over');
			if( $('>ul',this).length ) $(this).addClass('folder');
			//$(this).stop(true).children('div.sub-menu').show();
		},function(){
			$(this).delay(100).queue(function(){
				$(this).removeClass();
				$(this).dequeue();
			});
		});
	}
	
	$('#right-search input').searchInp();

	/*
	$('ul.ul-contact >li >h6 >a').click(function(){
		$(this).parent().next('div').slideToggle(300);
		return(false);
	});
	*/
	
	parts=String(document.location).split("?",2);
	if(parts.length>1){
		parts=parts[1].split("&");
		for (i=0; i<parts.length; i++) {
			curr = parts[i].split('=');
			if(curr[0] == 'city') $('#'+curr[1]).show();
		}
	}
});

jQuery.fn.searchInp = function(){
	$(this).data('val',$(this).attr('value'));
	$(this).focus(function(){
		if($(this).attr('value') == $(this).data('val')) $(this).attr('value','');
		$(this).animate({width:165},150);
		$('#right-search').css('z-index',5);
	}).blur(function(){
		if(!$(this).attr('value')) $(this).attr('value',$(this).data('val'));
		$(this).animate({width:54},150,function(){ $('#right-search').css('z-index',0); });
	});
}




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){
	alert('Нажмите Ctrl+D для добавления в закладки (Command+D для MacOS) после клика на кнопке Ok');
	} else if(window.chrome){
	alert('Нажмите Ctrl+D для добавления в закладки (Command+D для MacOS) после клика на кнопке Ok');
	}
}
