    var curr_set_map = 0;
    var cat_id = '';
    cat_id = '4';

    function send_table(space, city){  // click from Map
        city_id = city;
        get_table(space);
    }

    function get_table(space){

        $('#reg'+curr_set_map).hide()
        showReg(space);
        curr_set_map = space;

        $('#preloader').show();

        $.post('map.php',{'space':space, 'lang':lang}, resp_send_table);
    }

    function resp_send_table(cont){

        $('#table_map').html(cont);
        $('#preloader').hide();

    }


/***************************************************/


function pop(obj, name, width, height) {
    if (!name) {
        name = 'pop';
    }
    if (!width) {
        width = 400;
    }
    if (!height) {
        height = 600;
    }
    popupWin = window.open(obj.href, name, 'width='+width+',height='+height);
    popupWin.focus();
}

function goto_country(){
	box = document.destinations.country;
	destination = box.options[box.selectedIndex].value;
	if (destination>'') {
		window.location.href=destination;
	}
}

function preview_image(img_src) {
    pic = new Image();
    pic.src = img_src;
    setTimeout('view_image(pic.src, pic.width, pic.height);', 500);
}

function view_image(img_src, img_width, img_height){
    if (img_width>screen.availWidth-150 || img_width==0) {
        win_width = screen.availWidth-150;
    } else {
        win_width = img_width+20;
    }
    if (img_height>screen.availHeight-150 || img_height==0) {
        win_height = screen.availHeight-150;
    } else {
        win_height = img_height+20;
    }
    win_top  = Math.abs((screen.availHeight - win_height)/3);
    win_left = Math.abs((screen.availWidth -win_width)/3);
    photoWindow = window.open('', '', "resizable=yes,top=" + win_top + ',left=' + win_left + ",width="+win_width+',height='+win_height+",status=0,menubar=0,toolbar=0,scrollbars=yes");
    photoWindow.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>');
    photoWindow.document.write('<head><title>'+img_src+'</title><style type="text/css"><!-- body {margin:0;padding:0} --></style>');
    photoWindow.document.write('<scr'+'ipt type=text/javascript>');
    photoWindow.document.write('document.onkeypress = function CloseOnEsc(key) { if(document.all) { var keyCode = window.event.keyCode; } else { if (key.which == 0) {window.close();return;}   }  if (keyCode == 27) {window.close();return;} }');
    photoWindow.document.write('</scr'+'ipt>');
    photoWindow.document.write('</head><body style="padding: 10px"><img src="'+img_src+'" ');
    if ( (img_width>1) && (img_height>1) ) {
        photoWindow.document.write('width="'+img_width+'" height="'+img_height+'"');
    }
    photoWindow.document.write(' border=0 onclick="javascript:window.close();">');
    photoWindow.document.write('</body></html>');
    photoWindow.document.bgColor="#f0f0f0";
    photoWindow.document.close()
}

function view_print(img_src, cont_print, img_width, img_height){
    if (img_width>screen.availWidth-150 || img_width==0) {
        win_width = screen.availWidth-150;
    } else {
        win_width = img_width+20;
    }
    if (img_height>screen.availHeight-150 || img_height==0) {
        win_height = screen.availHeight-150;
    } else {
        win_height = img_height+20;
    }
    win_top  = Math.abs((screen.availHeight - win_height)/3);
    win_left = Math.abs((screen.availWidth -win_width)/3);
    photoWindow = window.open('', '', "resizable=yes,top=" + win_top + ',left=' + win_left + ",width="+win_width+',height='+win_height+",status=0,menubar=0,toolbar=0,scrollbars=yes");
    photoWindow.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>');
    
    photoWindow.document.write('<head><title>'+cotn_title+'</title>');
    
    
    photoWindow.document.write('<link rel="stylesheet" type="text/css" href="../../css/main.css"><link rel="stylesheet" type="text/css" href="../../css/style.css">');
    photoWindow.document.write('<scr'+'ipt type=text/javascript>');
    photoWindow.document.write('document.onkeypress = function CloseOnEsc(key) { if(document.all) { var keyCode = window.event.keyCode; } else { if (key.which == 0) {window.close();return;}   }  if (keyCode == 27) {window.close();return;} }');
    photoWindow.document.write('</scr'+'ipt>');
    photoWindow.document.write('</head><body class="print"><div class="logo-pr"><img src="../../img/logo.gif"/></div><h1>'+cotn_title+'</h1><div class="image"><img src="'+img_src+'" ');
    if ( (img_width>1) && (img_height>1) ) {
        photoWindow.document.write('width="'+img_width+'" height="'+img_height+'"');
    }
    photoWindow.document.write(' border=0 onclick="javascript:window.close();"/></div>');
    photoWindow.document.write('<table class="tbl" border="1">'+cont_print+'</table>');
    photoWindow.document.write('<h3><a href="JavaScript:window.print();">Печать страницы</a></h3>');
                                 
    photoWindow.document.write('</body></html>');
    photoWindow.document.bgColor="#f0f0f0";
    photoWindow.document.close()
}

function igallery_image(img_src, img_width, img_height, img_title){
    if (img_width>screen.availWidth-150 || img_width==0) {
        win_width = screen.availWidth-150;
    } else {
        win_width = img_width+20;
    }
    if (img_height>screen.availHeight-150 || img_height==0) {
        win_height = screen.availHeight-150;
    } else {
        win_height = img_height+20;
    }
    win_top  = Math.abs((screen.availHeight - win_height)/3);
    win_left = Math.abs((screen.availWidth -win_width)/3);
    photoWindow = window.open('', '', "resizable=yes,top=" + win_top + ',left=' + win_left + ",width="+win_width+',height='+win_height+",status=0,menubar=0,toolbar=0,scrollbars=yes");
    photoWindow.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>');
    photoWindow.document.write('<head><title>'+img_title+'</title><style type="text/css"><!-- body {margin:0;padding:0} --></style>');
    photoWindow.document.write('<scr'+'ipt type=text/javascript>');
    photoWindow.document.write('document.onkeypress = function CloseOnEsc(key) { if(document.all) { var keyCode = window.event.keyCode; } else { if (key.which == 0) {window.close();return;}   }  if (keyCode == 27) {window.close();return;} }');
    photoWindow.document.write('</scr'+'ipt>');
    photoWindow.document.write('</head><body><img src="'+img_src+'" ');
    if ( (img_width>1) && (img_height>1) ) {
        photoWindow.document.write('width="'+img_width+'" height="'+img_height+'"');
    }
    photoWindow.document.write(' border=0 onclick="javascript:window.close();">');
    photoWindow.document.write('</body></html>');
    photoWindow.document.bgColor="#f0f0f0";
    photoWindow.document.close()
}

function show_obj(obj_id){
obj=document.getElementById(obj_id);
remove_class(obj, 'hide');
add_class(obj, 'show');
}

function hide_obj(obj_id){
obj=document.getElementById(obj_id);
remove_class(obj, 'show');
add_class(obj, 'hide');
}

function add_class(e,c) {
  e.className=e.className+" "+c;
}

function remove_class(e,c) {
  cn=e.className;
  p=cn.indexOf(c);
  if (p>-1){e.className=cn.substr(0,p)+cn.substr(p+c.length);  }
}

function SetCookie(cookieName, cookieValue, nHours) {
 var today = new Date();
 var expire = new Date();
 if (nHours==null || nHours==0) nHours=1;
 expire.setTime(today.getTime() + 3600000*nHours);
 document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}

function GetCookie(name){
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else  {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)  {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}


function DeleteCookie(name, path, domain) {
    if (getCookie(name))  {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}





/*****************************************************/


var preview = 1;
function previewIcon(id, src_big) {
	if (preview != id) {
        //aki
        curr_src_big = src_big;
        //aki end
		document.getElementById('ic' + preview).className = "ic";
		document.getElementById('ic' + id).className = "ic a";
		document.getElementById('ic_img' + preview).style.display = "none";
		document.getElementById('ic_img' + id).style.display = "block";
		preview = id;
	}
}



function clickImgFull() { 
    $('#big_img_full_div').html('<img src="../../img/loading.gif">');
	document.getElementById('switchFull').style.display = "block";
    //aki 
    var image = document.createElement('img');
    image.title = curr_src_title;
    image.alt = curr_src_title;
    //alert(0);
    image.onload = function () {
        $('#big_img_full_div').html(image);
    };      
    image.src = curr_src_big;
    //aki end
}

function hideImgFull() {
	document.getElementById('switchFull').style.display = "none";
}

var nowShowedImg = new Array();
function showCatalogImg(id, key) {
	if(!key) key = nowShowedImg[id];

	imgSmT = imgSm[id];

	obj = document.getElementById("prevImg_"+id);
	if(obj) {
		if(nowShowedImg[id] == 0) {
			obj.style.display="none";
		}
		else {
			obj.style.display="block";
		}
	}
	obj = document.getElementById("nextImg_"+id);
	if(obj) {
		if(nowShowedImg[id] == (imgSmT.length-1)) {
			obj.style.display="none";
		}
		else {
			obj.style.display="block";
		}
	}
	var obj = document.getElementById("linkZoom_"+id);
	if(obj) obj.href = imgSmT[key]["img"];

	var obj = document.getElementById("linkImg_"+id);
	if(obj) obj.href = imgSmT[key]["img"];
	
//	alert(imgSmT[key]["title"]);
	var obj = document.getElementById("imgSm_"+id);
	if(obj) obj.src = imgSmT[key]["img_sm"];

	var obj = document.getElementById("img_descr_"+id);
	if(obj) obj.innerHTML = imgSmT[key]["img_descr"];

	var obj = document.getElementById("imgTitle_"+id);
	if(obj) obj.innerHTML = "<a href='"+imgSmT[key]["url"]+"' class='goodTitle'>"+imgSmT[key]["title"]+"</a>";
}
function prevCatalogImg(id) {
	if(nowShowedImg[id] >= 0) {
		nowShowedImg[id]--;
	}
	else {
		nowShowedImg[id] = 0;
	}
//	alert(nowShowedImg);
	showCatalogImg(id);
}
function nextCatalogImg(id) {
	var imgSmT = imgSm[id];
	if(nowShowedImg[id] < imgSmT.length-1) {
		nowShowedImg[id]++;
	}
	else {
		nowShowedImg[id] = imgSmT.length-1;
	}
//	alert(nowShowedImg);
	showCatalogImg(id);
}

function showHideZoom(id, action) {
	obj = document.getElementById('zoom_'+id);
	if(obj) {
		if(action == 1) obj.style.display = "block";
		else obj.style.display = "none";
	}
}

function setActiveTab(id) {
	if(!id) id = nowShow;
	var lastObj = document.getElementById(nowShow);
	if(lastObj) lastObj.style.display = 'none';

	if(document.getElementById('head_'+nowShow+'_Active')) document.getElementById('head_'+nowShow+'_Active').style.display = 'none';
	if(document.getElementById('head_'+nowShow+'_Deactive')) document.getElementById('head_'+nowShow+'_Deactive').style.display = 'block';
	if(document.getElementById('content_'+nowShow)) document.getElementById('content_'+nowShow).style.display = 'none';

	var nowObj = document.getElementById(id);
	if(nowObj) nowObj.style.display = 'block';

	if(document.getElementById('head_'+id+'_Active')) document.getElementById('head_'+id+'_Active').style.display = 'block';
	if(document.getElementById('head_'+id+'_Deactive')) document.getElementById('head_'+id+'_Deactive').style.display = 'none';
	if(document.getElementById('content_'+id)) document.getElementById('content_'+id).style.display = 'block';

	nowShow = id;
}

function formOrderFocus(obj, value, value1) {
//	if(obj.value==value) {
//		obj.value='';
//	}
}
function formOrderBlur(obj, value, value1) {
	if(obj.value=='') {
		obj.value=value
	}
}

var requestAjax = new Array();
var alertUrl = false;

function setImgGallery(id) {
	objInner = document.getElementById("imgsGallery_"+id);
	if(!objInner) {
		alert("Не найден контейнер "+id+" для отображения элементов!\nРабота системы ограничена");
		return false;
	}
	if(!showElementsAjaxUrl) {
		if(alertUrl===false) alert("Не найдена ссылка для AJAX объекта!\nРабота системы ограничена");
		alertUrl = true;
		return false;
	}
	if(objInner.style.display == "block") {
		objInner.style.display = "none";
	}
	else {
		requestAjax[id] = createAjax();
		if(!requestAjax[id]) {
			alert("Невозможно отобразить список элементов!\nAJAX объект не существует\nРабота системы ограничена");
			return false;
		}
		var url = showElementsAjaxUrl+"&category_id="+id;
//		alert(url);
		requestAjax[id].open("GET", url, true);
		requestAjax[id].stateHandler = 0;
		requestAjax[id].actionAjax = "show";
		requestAjax[id].onreadystatechange = getSrcSubItems;
		requestAjax[id].send(null);
	}
}
function getSrcSubItems() {
	for(id in requestAjax) {
		if (requestAjax[id].actionAjax=="show" && requestAjax[id].stateHandler==0 && requestAjax[id].readyState == 4) {
			requestAjax[id].stateHandler = 1;
			if(requestAjax[id].status == 200) {
				objInner = document.getElementById("imgsGallery_"+id);
				if(!objInner) return false;
				responseText = requestAjax[id].responseText;
				responseTextArr = responseText.split('~|~|~');
				if(responseTextArr[0]) objInner.innerHTML = responseTextArr[0];
				if(responseTextArr[1]) eval(responseTextArr[1]);
			}
		}
	}
}


var galleryImg = new Array();
var nowShowedImgGallery = new Array();
var galleryImgSize = new Array();
var galleryScrollSize = new Array();

function showGalleryImg(id, key) {
//	if(!key) key = nowShowedImgGallery[id];

	if(!galleryImg[id]) return;

	imgSmT = galleryImg[id];

	obj = document.getElementById("divPrevGallery_"+id);
	if(obj) {
		if(nowShowedImgGallery[id] == 0) {
			obj.style.display="none";
		}
		else {
			obj.style.display="block";
		}
	}
	obj = document.getElementById("divNextGallery_"+id);
	if(obj) {
		if(nowShowedImgGallery[id] == (imgSmT.length-1)) {
			obj.style.display="none";
		}
		else {
			obj.style.display="block";
		}
	}
	var obj = document.getElementById("imgGallery_"+id+"_"+nowShowedImgGallery[id]);
	if(obj) obj.className = "item_a";

	var obj = document.getElementById("imgGallery_"+id+"_"+key);
	if(obj) obj.className = "item";

	var obj = document.getElementById("linkZoom_"+id);
	if(obj) obj.href = imgSmT[nowShowedImgGallery[id]]["img"];

	var obj = document.getElementById("aImgGallery_"+id);
	if(obj) obj.href = imgSmT[nowShowedImgGallery[id]]["img"];
	
//	alert(imgSmT[key]["title"]);
	var obj = document.getElementById("imgGallerySm_"+id);
	if(obj) obj.src = imgSmT[nowShowedImgGallery[id]]["img_sm"];


//	var obj = document.getElementById("img_descr_"+id);
//	if(obj) obj.innerHTML = imgSmT[key]["img_descr"];

//	var obj = document.getElementById("imgTitleGallery_"+id);
//	if(obj) obj.innerHTML = ""+imgSmT[key]["title"]+"";
}

function prevGalleryImg(id) {
	if(!galleryImg[id]) {
		return;
	}
	var now = nowShowedImgGallery[id];
	if(nowShowedImgGallery[id] > 0) {
		nowShowedImgGallery[id]--;
	}
	else {
		nowShowedImgGallery[id] = 0;
	}
	moveContentImgs(id, now);
	showGalleryImg(id, now);
}
function nextGalleryImg(id) {
	if(!galleryImg[id]) return;

	imgT = galleryImg[id];

	var now = nowShowedImgGallery[id];

	if(nowShowedImgGallery[id] < imgT.length-1) {
		nowShowedImgGallery[id]++;
	}
	else {
		nowShowedImgGallery[id] = imgT.length-1;
	}
	moveContentImgs(id, nowShowedImgGallery[id]);

	showGalleryImg(id, now);
}
function showThisGalleryImg(id, counter) {
	if(!galleryImg[id]) return;

	imgT = galleryImg[id];

	var now = nowShowedImgGallery[id];

	nowShowedImgGallery[id] = counter;

	moveContentImgs(id, nowShowedImgGallery[id]);

	showGalleryImg(id, now);
}
var imgsWidth;
var imgsVisWidth;
var nowPosition = 0;
var padGallery = 4;
function moveContentImgs(id, now) {
	var obj = document.getElementById("imgsGallery_"+id);
	var objTd = document.getElementById("td_"+id+"_0");
	if(obj) {
		padGallery = galleryImgSize[id][0]["summWidth"] - objTd.offsetWidth;
	}
	if(obj) {
		padGallery += 4;
		nowPosition = padGallery/2 + galleryImgSize[id][now]["summWidth"];
		imgsWidth = (obj.scrollWidth > obj.offsetWidth) ? obj.scrollWidth : obj.offsetWidth;
		imgsVisWidth = obj.offsetWidth;
//		alert(padGallery+" "+nowPosition);
		if(imgsVisWidth/2-nowPosition<0) {
			obj.scrollLeft = Math.abs(Math.ceil(imgsVisWidth/2-nowPosition));
		}
		else {
			obj.scrollLeft = 0;
		}
	}
}

function showReg (id){
    //aki: переписал на jQuery потому что баги лезли - id иногда null был
    //document.getElementById("reg"+id).style.display = "block";
    $('#reg'+id).show();
}
function hideReg (id){
    //aki: переписал на jQuery  потому что баги лезли - id иногда null был
    //document.getElementById("reg"+id).style.display = "none";
    if(id != curr_set_map)
        $('#reg'+id).hide(); 
}


catIndCur1 = 1;
catIndCur2 = 1;
function catIndOver (id, sec){
	document.getElementById("nm" + "1" + sec).className = "name";
	if (sec == 1)	{
		document.getElementById("im" + catIndCur1 + sec).style.display = "none";
		document.getElementById("im" + id + sec).style.display = "block";

		document.getElementById("nm" + catIndCur1 + sec).className = "name";
		document.getElementById("nm" + id + sec).className = "name a";

		catIndCur1 = id;
	} else {
		document.getElementById("im" + catIndCur2 + sec).style.display = "none";
		document.getElementById("im" + id + sec).style.display = "block";

		document.getElementById("nm" + catIndCur2 + sec).className = "name";
		document.getElementById("nm" + id + sec).className = "name a";

		catIndCur2 = id;
	}
}

/////////////////////////////////////////////////////////////////////////////////////    
//empty      
/////////////////////////////////////////////////////////////////////////////////////
    var basketTimer;
    
    function empty_hi(){
        var basket_win = document.getElementById('empty_hi'); 
        //closeCompareInfo();
        var centerX = parseInt(getClientWidth() / 2) + getBodyScrollLeft();
        var centerY = parseInt(getClientHeight() / 2) + getBodyScrollTop();
        var left = centerX - 150; 
        var top = centerY - 50;    
        left +='px';
        top +='px';
        
        basket_win.style.left =left; 
        basket_win.style.top = top; 
        basket_win.style.display = 'block'; 
        /*
        if(basketTimer) {
            clearTimeout(basketTimer);   
        }
        basketTimer = setTimeout(empty_hi, 1);
        */
        
    }
    
    function closeCompareInfo() {   
        clearTimeout(basketTimer);
        var compare_win = document.getElementById('empty_hi'); 
        compare_win.style.display = 'none';  
    }
    
    
    function getClientWidth() {
		return iecompattest().clientWidth;
      return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
    }

    function getClientHeight() {
		return iecompattest().clientHeight;
      return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
    }
	function iecompattest(){
		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

    function getBodyScrollTop() {
        return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
    }

    function getBodyScrollLeft() {
        return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
    }

/////////////////////////////////////////////////////////////////////////////////////    
//  END empty      
/////////////////////////////////////////////////////////////////////////////////////

//name_tovar
