var nn=false;
function showSublevel(id)
{
	var el = $("sub_"+id);
	//var els = $("subs_"+id);
	if(el){
		if(el.offsetHeight<1){
			//if(els)els.style.display = "none";
			//new Effect.BlindDown(el);
			Element.show(el);
			//if((id==33 || id==5) && !nn){
			if(id==33 && !nn){
				nn=true;
				if(navigator.appName=="Microsoft Internet Explorer"){
					$('rul').style.position="absolute";
					$('rul').style.top=(document.documentElement.scrollTop*1+100)+"px";
				}
				$('rul').show();
			}
			
		} else {
			//if(els)els.style.display = "";
			//new Effect.BlindUp(el);
			Element.hide(el);
		}
	}
}
function getGallery(id)
{
	new Ajax.Request
    (
        homePart+"/admin/modules/includes/fotogallery/design/front.php",
	    {
	        method: 'post',
	        parameters: 'ajax=ok&id='+id,
	        onComplete : function(req) {
				$('galss').innerHTML=req.responseText;
				new Effect.Opacity($('gallery'),{duration:2, from:0, to:1});
				setTimeout("$('gallery').show()",200);
				setTimeout("myLightbox.updateImageList()",1000);
			}
		}

    );
}
function subscrible(event)
{
	Event.stop(event);
	$("subscribleform").request({
	        onComplete : function(req) {
				switch(req.responseText){
					case "ok":alert("Вы удачно подписались на рассылку");
						break;
					case "deleted":alert("Вы удачно отписались от рассылки");
						break;
					case "error":alert("Вы указали не верный E-mail");
						break;
					default: alert("Ошибка соединения с сервером "+req.responseText);
						break;
				}
			}
		}
    );
    //$("subscribleform").reset();
}
function goLink(link,id){
	setSettings("subMenu",id);
	window.location.href=link;
}
Event.observe(window,"load",function(){
	updateBasket();
	Event.observe("subscribleform","submit",subscrible);
});
Event.observe(window,"resize",resizeUpdate);
function resizeUpdate(){
}
function addToBasket(id,count){
	$('basket_list').update('<center><img src="/js/lightbox/images/loading.gif"></cente>');
	$$(".sButton, .button").invoke("hide");
	new Ajax.Updater('basket_list', homePart+'/basket.php?operation=add', {
	  parameters: {id:id,count:count},onComplete:function(){$$(".sButton, .button").invoke("show");}
	});
}
function deleteFromBasket(id){
	$('basket_list').update('<center><img src="/js/lightbox/images/loading.gif"></cente>');
	$$(".sButton, .button").invoke("hide");
	new Ajax.Updater('basket_list', homePart+'/basket.php?operation=delete', {
	  parameters: {id:id},onComplete:function(){$$(".sButton, .button").invoke("show");}
	});
}
function updateBasket(){
	$('basket_list').update('<center><img src="/js/lightbox/images/loading.gif"></cente>');
	$$(".sButton, .button").invoke("hide");
	new Ajax.Updater('basket_list', homePart+'/basket.php',{onComplete:function(){$$(".sButton, .button").invoke("show");}});
}
function sortE(s,m){
	$('sortIn').value=s;
	$('sortMode').value=m?"DESC":"ASC";
	setTimeout(function(){$('pagerForm').submit()},10);
}
var setSettings = function(name, value)
{
	document.cookie = name + "=" + escape(value) +
      	"; expires=Mon, 01-Jan-2017 00:00:00 GMT" +
      	"; path=/";
}
var getSettings = function(name)
{
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
   	var offset = 0;
    var end = 0;
    if (cookie.length > 0)
	{
		offset = cookie.indexOf(search);
		if (offset != -1)
		{
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1)
			{
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}
function printWin(id) 
{
	myWin= open("", "printWindow",
	"status=no,toolbar=no,menubar=yes");
	myWin.document.open();
	myWin.document.write("<html><head><title>Print version");
	myWin.document.write("</title></head><link type='text/css' rel='stylesheet' href='/images/style.css'><body style='padding:20px'>");
	var a=$(id).innerHTML;
	myWin.document.write(a);
	myWin.document.write("</body></html>");
	myWin.document.close();
}
function closeBigImage(){
	$("bigImg").hide();
}
function showBigImage(){
	$("bigImg").show();
}
function getTimes()
{
	var curDateTime = new Date()
	var curHour = curDateTime.getHours();
	var curMin = curDateTime.getMinutes();
	var curSec = curDateTime.getSeconds();
	if(curMin<10)curMin="0"+curMin;
	$("time").innerHTML = curHour+":"+curMin;
	setTimeout("getTimes()",3000);
}
function bg(cl){
	$$("."+cl)[0].className+=" bg"+Math.round(1+Math.random());
}
