function voteCheck()
{
    g=document.getElementById('total').value;
    for (var i=1; i<=g; i++)
    {
        if(document.getElementById('choice'+i).checked)
        {
            return true;
        }
    }
    alert('Выберите вариант!');
    return false;
}
function authCheck()
{
    if(document.getElementById('a1').value!='')
    {
        if(document.getElementById('a2').value!='')
        {
            return true;
        }
        else
        {
            alert('Введите пароль!');
            return false;
        }
    }
    else
    {
        alert('Введите E-mail!');
        return false;
    }
}
var m = 0; 
function winOpen5(pic, width, height, title)
{
	m++;
	x = (640 - width)/2, y = (480 - height)/2;
	if (screen) {
		var y = (screen.availHeight - height)/2;
		var x = (screen.availWidth - width)/2;
	}
		if (screen.availWidth > 1800) {
		var x = ((screen.availWidth/2) - width)/2;
	}

	var win = window.open("", m, 'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',titlebar=no,resizable=no,scrollbars=no');

	win.document.open();
	win.document.writeln('<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><title>'+title+'</title></head><body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">');
	win.document.writeln('<table align="center" width="100%" height="100%" cellpadding="0" cellspacing="0" border="0"><tr><td>');
 	win.document.writeln('<a title="Закрыть окно" href="#" onclick="self.close()"><img src="/'+pic+'" width="'+width+'" height="'+height+'" border="0" alt="'+title+'"></a>');
	win.document.writeln('</td></tr></table></body></html>');
	win.document.close();
}

function close_block(id)
{
	$('#'+id).fadeOut("normal");
	$(".arrows td").removeClass("selected");
	$(".list td").removeClass("selected");	
	$('body').unbind('click');
}

function show_list(id)
{
	if($('#block-shops'+id).css('display') == 'block')
	{
		$('#block-shops'+id).fadeOut("normal");
		$(".arrows td").removeClass("selected");
		$(".list td").removeClass("selected");
		$('#for_name'+id).hide();
		$('#for_type'+id).hide();
	}else{
		$('#for_name'+id).hide();
		$('#for_type'+id).hide();
		$('.submenu').fadeOut("normal");
		$(".arrows td").removeClass("selected");
		$(".list td").removeClass("selected");
		
		if(id == 586) $('td.for_type').show();
		else $('td.for_type').hide();
		
		$('#block-shops'+id).fadeIn("normal", function(){
			$('body').click(function(e){
				if($(e.target).parents('#block-shops'+id).length==0 && !$(e.target).is('#block-shops'+id)) close_block('block-shops'+id);
			});
		});
		$('#arrow'+id).addClass("selected");		
		$('#menu'+id).addClass("selected");	
		if($('#loader').html() == null)
		{
			h = document.getElementById('block-shops'+id).clientHeight-52;
			t = (h-30)/2;
			$('#loader'+id).css('height', h);
			$('#loader'+id).find('img').css('top', t);
			$('#loader'+id).show();
		}
			list_for_name(id);
			if(id == 586) {list_for_type(id);}	
		
	}	
}

function hide_hmenu(id) 
{
	$('#block-shops'+id).fadeOut("normal");
	$(".arrows td").removeClass("selected");
	$(".list td").removeClass("selected");
	$('#for_name'+id).hide();
	$('#for_type'+id).hide();	
}

function list_for_name(id)
{
	$('#for_name'+id).load('/include/modules/list_menu.php', {type:'name', id:id}, function(){ $('#for_name'+id).show(); if(id != 586) $('#loader'+id).hide();});
}

function list_for_type(id)
{
	$('#for_type'+id).load('/include/modules/list_menu.php', {type:'type', id:id}, function(){ $('#for_type'+id).show(); $('#loader'+id).hide();});
}

function list_search(id)
{
	word = $("#fast_search"+id).val();
	if(word.length > 2)
	{
		if($('#loader').html() == null)
		{
			h = document.getElementById('block-shops'+id).clientHeight-52;
			t = (h-30)/2;
			$('#loader'+id).css('height', h);
			$('#loader'+id).find('img').css('top', t);
			$('#loader'+id).show();
		}
		$('#for_name'+id).load('/include/modules/list_menu.php', {type:'search', id:id, word:word}, function(){ $('#loader'+id).hide()});
	}else
	{
		list_for_name(id)
	}		
}

function open_gallery(st,img, wg, hg)
{

	h = document.documentElement.scrollHeight;
	w = document.documentElement.clientWidth;
	h1 = document.documentElement.clientHeight;
	p = document.documentElement.scrollTop;
	x = (w-wg)/2;
	y =Math.round((h1-hg)/2)-43+p;
	if($('#img_gallery').html() == null)
	{
		$('#bg_gallery').after('<div id="img_gallery" onclick="return close_gallery();"><div class="close"><a href="#" onclick="close_gallery(); return false;"><img src="/i/close-blue.gif" width="13" height="13" ></a></div><img src="'+img+'" width="'+wg+'" height="'+hg+'" style="border:solid 2px #fff"></div>');
		$('#bg_gallery').show();
	}	
	$('#bg_gallery').css({height:h, width:w});
	$('#img_gallery').css({left:x, top:y});
}

function close_gallery()
{
	h = document.getElementById('img_background').scrollHeight;
	$('#bg_gallery').hide();
	$('#img_gallery').remove();
	document.getElementById('img_background').style.height = h;
	return false;
}
var sss = -1;
function fast_search(e)
{
		if (e.keyCode==38) { // вверх	
			allA = $('#block-search-content a');
			if (sss<1) sss=allA.length-1;
			else sss--;
			t = allA.filter('.selected').removeClass('selected').end().eq(sss).addClass('selected').text();
			$("#search").val(t);
			return false;
		}
		if (e.keyCode==40) { // вниз
			allA = $('#block-search-content a');
			if (sss==allA.length-1) sss=0;
			else sss++;
			t = allA.filter('.selected').removeClass('selected').end().eq(sss).addClass('selected').text();
			$("#search").val(t);
			return false;
		}
		

		text = $("#search").val();
	//document.getElementById("block-search").style.visibility = "hidden";
	if(text.length >= 3 )
	{
		$('#block-search .content').load('/search/', {text:text, catalogue_search:1}, function(){if($('#block-search-content').html() !='' )
			{
				document.getElementById("block-search").style.visibility = "visible";
			}else
			{
				document.getElementById("block-search").style.visibility = "hidden";
			}
		});
	}else{
		document.getElementById("block-search").style.visibility = "hidden";	
	}
	
	return false;

}

function clear_list()
{
	$('#block-search-content a').filter('.selected').removeClass('selected');
}

function chose_search(obj)
{
	$("#search").val(obj);
	document.getElementById("block-search").style.visibility = "hidden";
	return false;

}

function list_floor(obj)
{
	if(obj == ''){flo = location.hash;}else{flo = obj}
	if(flo != ''){fn = flo; }else{ fn = "#level0";}
	$(".inner-page-content h1").eq(0).load('/map/',{fn:fn});
	if(flo != ''){flo = flo.substring(6,7);} else {flo = 0;}
	$("#flash-plan-nav").load('/map/',{floor:flo});
	if(flo != 0){flash_resize(700)}else{flash_resize(960)};
}

function flash_resize(h)
{
	$("object[@id='plan']").attr('height', h);
	$("embed[@name='plan']").attr('height', h);
}

function flash_ico(alias)
{
	if(document.getElementById(alias).checked != true)
	{
		document.getElementById(alias).checked = true;
	}else
	{
		document.getElementById(alias).checked = false;
	}	
	alert(alias);
}

