

function imgWinOpen(url, width, height, isScrollable){
    var doScroll = 'yes';
    if(isScrollable == undefined){
        doScroll = 'auto';
    }
    wndW = width + 4 + 12;
    wndH = height + 4 + 14;
    wndX = (screen.availWidth-wndW)/2;
    wndY = (screen.availHeight-wndH)/2;
    this.popupWindow = window.open(url,"img_win","toolbar=no,location=no,status=no,menubar=yes,scrollbars="+doScroll+",resizable,alwaysRaised,dependent,titlebar=no,width="+wndW+",height="+wndH+",left="+wndX+",top="+wndY);
}

function showImagePopup(url, width, height, blockId){
    
    var originalImageWidth = width;
    var originalImageHeight = height;

    var sContent = '';
    if(typeof(blockId) == 'undefined'){
        blockId = '';
    }else if(blockId != ''){
        sContent = document.getElementById(blockId).innerHTML;
    }

    var iFrameSpaceX = 24; // Left + Right
    var iFrameSpaceY = 24; // Top + Bottom
    var iScrollWidth = 16;

    var iTitlePanelHeight = 40;
    var iFrameBorderX = 12;
    var iFrameBorderY = 14;
    
    var picMaxWidth = oSizes.getWindowWidth() - iFrameSpaceX - iFrameBorderX - iScrollWidth;
    var picMaxHeight = oSizes.getWindowHeight() - iFrameSpaceY - iFrameBorderY - iTitlePanelHeight - (sContent != '' ? 16 /* min text height */ : 0);
    
    if(width > picMaxWidth || height > picMaxHeight){
        if(picMaxWidth / width < picMaxHeight / height){
            height = Math.floor(height * picMaxWidth / width);
            width = picMaxWidth;
        }else{
            width = Math.floor(width * picMaxHeight / height);
            height = picMaxHeight;
        }
    }

    var picWidth = width;
    var picHeight = height;

    if(sContent != ''){
        width = Math.max(width, 300);
        height += Math.ceil((sContent.length * 6.3 / width) * 16) + 10;
    }
    
    var wndH = Math.min(height + iFrameBorderY + iTitlePanelHeight, oSizes.getWindowHeight() - iFrameSpaceY);
    var wndW = Math.min(width + iFrameBorderX + (wndH - iFrameBorderY - iTitlePanelHeight  < height ? iScrollWidth : 0), oSizes.getWindowWidth() - iFrameSpaceX);

    var wndX = parseInt((oSizes.getWindowWidth() - wndW) / 2);
    var wndY = parseInt((oSizes.getWindowHeight() - wndH) / 2);

    var imageBlockWidth = wndW - iFrameBorderX;
    var imageBlockHeight = wndH - iFrameBorderY - iTitlePanelHeight + 10;
    
    var oShadow = document.createElement('div');
    oShadow.className = 'imagePopupShadow';
    oShadow = document.body.appendChild(oShadow);

    var oBlock = document.createElement('div');
    oBlock.className = 'imagePopupBlock';
    oBlock.style.left = wndX - 2 + 'px';
    oBlock.style.top = wndY - 2 + (navigator.userAgent.indexOf("MSIE 6") > -1 ? oPositions.getDocumentTop() : 0) + 'px';
    oBlock.style.width = wndW + 'px';
    oBlock.style.height = wndH + 'px';
    oBlock.innerHTML = '<div class="imagePopupBlockContent" style="height: ' + (imageBlockHeight) + 'px"><img src="' + url + '" width="' + picWidth + '" height="' + picHeight + '"' + (originalImageWidth > picWidth || originalImageHeight > picHeight ? ' style="cursor: pointer" title="' + aSpelling.showPicFullSized + '" onClick="this.width=' + originalImageWidth + '; this.height=' + originalImageHeight + '; this.title=\'\'; this.style.cursor=\'default\'"' : '') + '>' + 
                       (sContent != '' ? '<span><br>' + sContent + '</span>' : '') + 
                       '</div>';

    var oClose = document.createElement('a');
    oClose.className = 'imagePopupBlockClose';
    oClose.href = '';
    oClose.innerHTML = aSpelling.showPicCloseButton;
    oClose.onclick = function(_oShadow, _oBlock){return function(){
        _oShadow.parentNode.removeChild(_oShadow);
        _oBlock.parentNode.removeChild(_oBlock);
        return false;
    }}(oShadow, oBlock);
    oBlock.appendChild(oClose);

    var oBar = document.createElement('div');
    oBar.className = 'imagePopupBlockBar';
    oBar.innerHTML = name;
    
    oBlock.appendChild(oBar);
    oBlock = document.body.appendChild(oBlock);
}

var oBase = {
    isIE : document.swapNode,
    isWebKit : /WebKit/.test(navigator.userAgent),
    isFF : this.isWebKit && /Gecko/.test(navigator.userAgent)
} 

/* HTTP Client */

function cClient(){
    
    this.oTransport = null;
    this.checkInterval = null;
    this.callbackForData = null;
    
    this.getTransport = function(){
        this.oTransport = null;
        for(var i = 0; i < 3; i++){
            activeXName = (i == 1 ? 'Msxml2.XMLHTTP' : 'Microsoft.XMLHTTP');
            try{
                if(i == 0){
                    this.oTransport = new XMLHttpRequest();
                }else{
                    this.oTransport = new ActiveXObject(activeXName);
                }
            }catch(exception){
                this.oTransport = null;
            }
            if(this.oTransport != null){
                break;
            }
        }
    }
    
    // sData required only for POST request, format: a=value&b=value&...
    this.getContent = function(sMethod, sURL, sData){
        this.getTransport();
        if(this.oTransport != null){
            this.oTransport.open(sMethod, sURL, true);
            if(sMethod != 'POST' || typeof(sData) == 'undefined'){
                sData = null;
            }else if(sMethod == 'POST'){
                this.oTransport.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            }
            if(sMethod == 'GET' && !oBase.isWebKit && !oBase.isFF){
                this.oTransport.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
            }
            this.checkInterval = setInterval(function(_oClient){return function(){_oClient.checkState()}}(this), 50);
            this.oTransport.send(sData);
        }else{
            alert(aSpelling.ajaxRequestError);
        }
    }
    
    this.checkState = function(){
        if(this.oTransport.readyState == 4){
            clearInterval(this.checkInterval);
            if(this.oTransport.status == 200){
                this.callbackForData(this.oTransport.responseText);
            }else{
                alert(aSpelling.ajaxWrongURI);
            }
        }
    }
    
    this.getContentCallback = function(sURL, oCallback, sMethod, sData){
        if(typeof(oCallback) == 'function'){
            this.callbackForData = oCallback;
            if(typeof(sMethod) == 'undefined' || sMethod != 'POST'){
                sMethod = 'GET';
                this.getContent(sMethod, sURL);
            }else{
                if(!sData){
                    sData = '';
                }
                this.getContent(sMethod, sURL, sData);
            }
        }
    }
    
    this.submitFormCallback = function(oForm, oCallback){
        var sURL = oForm.attributes.action.value;
        if(sURL.indexOf('http') != 0){
            sURL = document.location.protocol + '//' + document.location.host + sURL;
        }
        
        var sParameters = '';
        for(i = 0; i < oForm.elements.length; i++){
            if(oForm.elements[i].type == 'checkbox' || oForm.elements[i].type == 'radio'){
                if(oForm.elements[i].checked){
                    sParameters += (sParameters == '' ? '' : '&') + encodeURIComponent(oForm.elements[i].name) + '=' + encodeURIComponent(oForm.elements[i].value);
                }
            }else if(oForm.elements[i].name && oForm.elements[i].name != ''){
                sParameters += (sParameters == '' ? '' : '&') + encodeURIComponent(oForm.elements[i].name) + '=' + encodeURIComponent(oForm.elements[i].value);
            }
        }
        
        if(oForm.attributes.method && oForm.attributes.method.value.toLowerCase() == 'post'){
            this.getContentCallback(sURL, oCallback, 'POST', sParameters);
        }else{
            this.getContentCallback(sURL + '?' + sParameters, oCallback);
        }
    }
}

/* Event manipulation class */

var oEvents = {
    validate : function(oEvent){
        return oEvent ? oEvent : window.event;
    },

    getTarget : function(oEvent){
        oEvent = this.validate(oEvent);
        return oEvent.srcElement || oEvent.target;
    },
    
    send : function(oTarget, sEvent){
        if(document.createEventObject){
            var oEvent = document.createEventObject();
            oTarget.fireEvent('on' + sEvent, oEvent);
        }else if(document.createEvent){
            var oEvent = document.createEvent("HTMLEvents");
            oEvent.initEvent(sEvent, false, false);
            oTarget.dispatchEvent(oEvent);
        }else{
            return false;
        }
        return true;
    },
    
    addHandler : function(oTarget, sEvent, oHandler){
        if(typeof(oTarget.addEventListener) != 'undefined'){
            oTarget.addEventListener(sEvent, oHandler, false);
        }else{
            oTarget.attachEvent('on' + sEvent, oHandler);
        }
    },
    
    removeHandler : function(oTarget, sEvent, oHandler){
        if(typeof(oTarget.removeEventListener) != 'undefined'){
            oTarget.removeEventListener(sEvent, oHandler, false);
        }else if(oTarget.detachEvent){
            oTarget.detachEvent('on' + sEvent, oHandler);
        }
    },
    
    stopProcessing : function(oEvent){
        oEvent = this.validate(oEvent);
        if(typeof(oEvent.stopPropagation) != 'undefined'){
            oEvent.stopPropagation();
        }else if(typeof(oEvent.cancelBubble) != 'undefined'){
            oEvent.cancelBubble = true;
        }
        if(typeof(oEvent.preventDefault) != 'undefined'){
            oEvent.preventDefault();
        }else{
            oEvent.returnValue = false;
        }
    }
}

/* Window, client, object sizes class */

var oSizes = {
    getWindowWidth : function(){
        return document.documentElement.clientWidth || document.body.clientWidth;
    },
    
    getWindowHeight : function(){
        return document.documentElement.clientHeight || document.body.clientHeight;
    },

    getDocumentWidth : function(){
        return Math.max(this.getWindowWidth(), document.documentElement.scrollWidth || document.body.scrollWidth);
    },
    
    getDocumentHeight : function(){
        return Math.max(this.getWindowHeight(), document.documentElement.scrollHeight || document.body.scrollHeight);
    }
}

/* Object coordinates */

var oPositions = {
    getDocumentLeft : function(){
        return document.documentElement.scrollLeft || document.body.scrollLeft;
    },

    getDocumentTop : function(){
        return document.documentElement.scrollTop || document.body.scrollTop;
    },

    getPointerPosition : function(oEvent){
        var aData = new Array(0, 0);
        oEvent = oEvents.validate(oEvent);
        if(oEvent.pageX || oEvent.pageY){
            aData[0] = oEvent.pageX;
            aData[1] = oEvent.pageY;
        }else if(oEvent.clientX || oEvent.clientY){
            aData[0] = oEvent.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
            aData[1] = oEvent.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
        }
        return aData;
    },

    getObjectPosition : function(oObject, isCalculatRelative){
        if(!isCalculatRelative){
            isCalculatRelative = false;
        }
        
        var counter = 0;
        var aData = new Array(0, 0);
        do{
            if(counter > 0 && isCalculatRelative){
                var sParentPositionStyle = oDOM.getStyle(oObject, 'position');
                if(sParentPositionStyle == 'absolute' || sParentPositionStyle == 'relative'){
                    break;
                }
            }
            aData[0] += oObject.offsetLeft;
            aData[1] += oObject.offsetTop;
            counter ++;
        }while((oObject = oObject.offsetParent) != null);
        
        return aData;
    }
}

/* Document object manipulation functions */

var oDOM = {
    create : function(oParentNode, sTagName, sId, sClassName, sStyles){
        var oObject = document.createElement(sTagName);
        if(typeof(sId) != 'undefined' && sId != ''){
            oObject.id = sId;
        }
        if(typeof(sClassName) != 'undefined' && sClassName != ''){
            oObject.className = sClassName;
        }
        if(typeof(sStyles) != 'undefined' && sStyles != ''){
            oObject.style.cssText = sStyles;
        }
        return oParentNode.appendChild(oObject);
    },
    
    getStyle : function(oObject, sStyleName){
        var sResult = '';
        
        if(window.getComputedStyle){
            var oDeclaration = window.getComputedStyle(oObject, sStyleName);
            sResult = oDeclaration.getPropertyValue(sStyleName);
        }else if(oObject.currentStyle){
            var i;
            while((i = sStyleName.indexOf("-")) != -1){
                sStyleName = sStyleName.substr(0, i) + sStyleName.substr(i+1,1).toUpperCase() + sStyleName.substr(i+2);
            }
            
            if(oObject.currentStyle[sStyleName]){
                sResult = oObject.currentStyle[sStyleName];
            }
        }
        
        return sResult;
    }
}

/* Slider class */

var cSlider = function(oItemList, visibleWidth, scrollWidth, autoScrollTimeout){
    this.itemList = null;
    this.bOverItem = false;
    
    this.autoScrollTimeout = 0;
    this.autoScrollDirection = -1;
    this.autoScrollHandler = null;
    
    this.scrollHandler = null;
    this.isScrolling = false;
    this.nextDirection = 0;
    
    this.visibleWidth = visibleWidth;
    this.currentPosition = 0;
    this.scrollWidth = 0;
    this.fullWidth = 0;
    
    this.oLastItem = null;
    
    this.init = function(){
        this.itemList = oItemList;
        this.scrollWidth = scrollWidth;
        
        var oItem = this.itemList.firstChild;
		
        while(oItem != null){
            if(oItem.tagName && oItem.tagName == 'DIV'){
                this.fullWidth++;
                this.oLastItem = oItem;
				
                oEvents.addHandler(oItem, 'mouseover', function(_oSlider){return function(){_oSlider.bOverItem = true}}(this));
                oEvents.addHandler(oItem, 'mouseout', function(_oSlider){return function(){_oSlider.bOverItem = false}}(this));
            }
            oItem = oItem.nextSibling;
        }
		if (this.fullWidth == 8) {this.fullWidth = 7;}
        this.fullWidth *= this.scrollWidth;
        
        if(typeof(autoScrollTimeout) != 'undefined'){
            this.autoScrollTimeout = autoScrollTimeout;
        }
        
        this.setAutoScrollTimer();
    }
    
    this.doAutoScroll = function(){
        if(!this.bOverItem){
            if(this.autoScrollDirection == -1 && !this.scrollLeft()){
                this.autoScrollDirection = 1;
                this.scrollRight();
            }else if(this.autoScrollDirection == 1 && !this.scrollRight()){
                this.autoScrollDirection = -1;
                this.scrollLeft();
            }
        }else{
            this.setAutoScrollTimer();
        }
    }
    
    this.setAutoScrollTimer = function(){
        if(this.autoScrollTimeout > 0){
            clearTimeout(this.autoScrollHandler);
            this.autoScrollHandler = setTimeout(function(oSlider){return function(){oSlider.doAutoScroll()}}(this), 7000);
        }
    }
    
    this.scrollLeft = function(){
        var result = this.isScrolling;
        clearTimeout(this.autoScrollHandler);
        if(!this.isScrolling && this.visibleWidth + -1 * this.currentPosition < this.fullWidth){
            this.isScrolling = true;
            this.scrollHandler = setInterval(function(oSlider, iDirection, iToPosition){return function(){oSlider.doScroll(iDirection, iToPosition)}}(this, -1, this.currentPosition - this.scrollWidth), 7);
            result = true;
        }else if(this.isScrolling){
            this.nextDirection = -1;
        }else{
            this.setAutoScrollTimer();
			this.scrollRight();
        }
        return result;
    }
    
    this.scrollRight = function(){
        var result = false;
        clearTimeout(this.autoScrollHandler);
        if(!this.isScrolling && this.currentPosition < 0){
            this.isScrolling = true;
            this.scrollHandler = setInterval(function(oSlider, iDirection, iToPosition){return function(){oSlider.doScroll(iDirection, iToPosition)}}(this, 1, this.currentPosition + this.scrollWidth), 7);
            result = true;
        }else if(this.isScrolling){
            this.nextDirection = 1;
        }else{
            this.setAutoScrollTimer();
			this.scrollLeft();
        }
        return this.isScrolling;
    }

    this.doScroll = function(iDirection, iToPosition){
        var isScrolled = false;
        if(iDirection > 0 && this.currentPosition < iToPosition || iDirection < 0 && this.currentPosition > iToPosition){
            var currentStep = 2;
            this.currentPosition += iDirection * Math.min(-iDirection * (this.currentPosition - iToPosition), currentStep);
            this.itemList.style.left = this.currentPosition*2 + 'px';
            isScrolled = true;
        }
        if(!isScrolled){
            this.isScrolling = false;
            clearInterval(this.scrollHandler);
            
            if(this.nextDirection == -1){
                this.scrollLeft();
            }else if(this.nextDirection == 1){
                this.scrollRight();
            }
            
            this.setAutoScrollTimer();
            this.nextDirection = 0;
        }
    }
    
    this.init();
}

var oSlider = null;


/* Popup menu object */

/* Создание ветки children в Mozille для идентичного отображения выдвигающегося меню во всех браузерах*/
if (window.Node)
{
Node.prototype.__defineGetter__("children", function()
{
l = this.childNodes.length; list = []; z = 0;

for ( var i = 0 ; i < l ; i++ )

if ( this.childNodes[i].nodeType == 1 )
list[z++] = this.childNodes[i];

return list;
});
}
/* Конец функции для Mozilla*/

var oStart = {
	
	definedHandlers : {},
    currentOpened : {
        oLink : null,
        oPopup : null
    },
	
	start : function(oPopup,oLink,iCustomTopOffset,hei,wid,sPopupId,step,width,heiStroki,ki2,ki3,ki4,ki5,ki6,ki7,ki8,ki9,ki10,ki11) {
		wid = parseInt(wid);
		oPopup.style.height = wid+'px';
		oPopup.style.width = width+'px';
		
		if(typeof(iCustomTopOffset) == 'undefined'){
            iCustomTopOffset = 0;
        }
		if(wid>=hei) {
			step = 0;
			clearTimeout(this.stopTimeout);
		}
        if(oPopup != null && oPopup.innerHTML != ''){
            var linkSId = oLink.href ? oLink.href : '';
            if(!this.definedHandlers['link' + linkSId]){
                oEvents.addHandler(oLink, 'mouseout', function(_this){return function(){_this.hideMenu(oPopup,oLink,hei,width)}}(this));
                this.definedHandlers['link' + linkSId] = true;
            }
            if(!this.definedHandlers['popup' + sPopupId]){
                oEvents.addHandler(oPopup, 'mouseover', function(_this){return function(){_this.disableHideMenu()}}(this));
                oEvents.addHandler(oPopup, 'mouseout', function(_this){return function(){_this.hideMenu(oPopup,oLink,hei,width)}}(this));
                this.definedHandlers['popup' + sPopupId] = true;
            }
		}

				if (wid>=(ki2+16)) {oPopup.getElementsByTagName("a")[1].style.display = 'block';
					if (wid>=(ki3+ki2+16)) {oPopup.getElementsByTagName("a")[2].style.display = 'block';
						if (wid>=(ki4+ki3+ki2+16)) {oPopup.getElementsByTagName("a")[3].style.display = 'block';
							if (wid>=(ki5+ki4+ki3+ki2+16)) {oPopup.getElementsByTagName("a")[4].style.display = 'block';
								if (wid>=(ki6+ki5+ki4+ki3+ki2+16)) {oPopup.getElementsByTagName("a")[5].style.display = 'block';
									if (wid>=(ki7+ki6+ki5+ki4+ki3+ki2+16)) {oPopup.getElementsByTagName("a")[6].style.display = 'block';
										if (wid>=(ki8+ki7+ki6+ki5+ki4+ki3+ki2+16)) {oPopup.getElementsByTagName("a")[7].style.display = 'block';
											if (wid>=(ki9+ki8+ki7+ki6+ki5+ki4+ki3+ki2+16)) {oPopup.getElementsByTagName("a")[8].style.display = 'block';
												if (wid>=(ki10+ki9+ki8+ki7+ki6+ki5+ki4+ki3+ki2+16)) {oPopup.getElementsByTagName("a")[9].style.display = 'block';
													if (wid>=(ki11+ki10+ki9+ki8+ki7+ki6+ki5+ki4+ki3+ki2+16)) {oPopup.getElementsByTagName("a")[10].style.display = 'block';
														if (wid>=(ki12+ki11+ki10+ki9+ki8+ki7+ki6+ki5+ki4+ki3+ki2+16)) {oPopup.getElementsByTagName("a")[11].style.display = 'block';
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}


				oPopup.style.visibility = 'visible';
			   	oLink.className = oLink.className + ' activePopup';
            	oPopup.style.display = 'block';
            	var linkPosition = oPositions.getObjectPosition(oLink, true);
            	oPopup.style.left = linkPosition[0] + 'px'; // linkPosition[0] - координаты слева, [1] - координаты сверху
            	oPopup.style.top = linkPosition[1] + oLink.offsetHeight + iCustomTopOffset + 'px';
            	this.currentOpened.oLink = oLink;
            	this.currentOpened.oPopup = oPopup;	
		this.stopTimeout = setTimeout(function(_this){return function(){_this.start(oPopup,oLink,iCustomTopOffset, hei, wid+step, sPopupId, step, width, heiStroki,ki2,ki3,ki4,ki5,ki6,ki7,ki8,ki9,ki10,ki11)}}(this), 2);
	},
	
    hideCurrentOpenedPopup : function(oPopup,oLink,hei){
        if(this.currentOpened.oPopup != null){
            this.currentOpened.oLink.className = this.currentOpened.oLink.className.replace(' activePopup', '');
            this.currentOpened.oPopup.style.display = 'none';
			oPopup.style.height = hei+'px';
			clearTimeout(this.stopTimeout);
            this.currentOpened.oLink = null;
            this.currentOpened.oPopup = null;
        }
    },
	
    hideMenu : function(oPopup,oLink,hei){
        	oPopupMenu.currentOpened.yes = 'yes';
			oPopupMenu.currentOpened.oLink = oLink;
			oPopupMenu.currentOpened.oPopup = oPopup;
			oPopupMenu.currentOpened.hei = hei;
            this.hideTimeout = setTimeout(function(_this){return function(){_this.hideCurrentOpenedPopup(oPopup,oLink,hei)}}(this), 50);
    },
    
    disableHideMenu : function(){
        clearTimeout(this.hideTimeout);
    }
}

var oPopupMenu = {
    definedHandlers : {},
    currentOpened : {
		yes : null,
        oLink : null,
        oPopup : null,
		hei : null
    },
    
    showMenu : function(oLink, sPopupId, iCustomTopOffset){
		clearTimeout(oStart.stopTimeout);
		clearTimeout(oStart.hideTimeout);
		
		
		if(this.currentOpened.yes == 'yes'){
			this.currentOpened.oLink.className = this.currentOpened.oLink.className.replace(' activePopup', '');
            this.currentOpened.oPopup.style.display = 'none';
			var hei = this.currentOpened.hei;
			this.currentOpened.oPopup.style.height = hei+'px';
			this.currentOpened.yes = null;
			this.currentOpened.oLink = null;
			this.currentOpened.oPopup = null;
			this.currentOpened.hei = null;
		}
        if(typeof(iCustomTopOffset) == 'undefined'){
            iCustomTopOffset = 0;
        }
        var oPopup = document.getElementById(sPopupId);
        if(oPopup != null && oPopup.innerHTML != ''){
			
		
			oPopup.style.display = 'block';
			oPopup.style.visibility = 'hidden';
			var hei = oPopup.clientHeight;
			var width = oPopup.clientWidth;			
			hei=parseInt(hei);
			hei = hei - 17;
			width = width - 26;
			step = 6;
			var ki2=250;var ki3=250;var ki4=250;var ki5=250;var ki6=250;var ki7=250;var ki8=250;var ki9=250;var ki10=250;var ki11=250;var ki12=250; var ki13=250; var ki14=250; var ki15=250;
			childNum = oPopup.children.length;
			for (var i = 0; i < childNum; i++) {oPopup.getElementsByTagName("a")[i].style.display = 'inline-block';}
			var ki1=oPopup.getElementsByTagName("a")[0].clientHeight;;
			for (var i = 1; i < childNum; i++) {
				if(i==1){ki2=oPopup.getElementsByTagName("a")[1].clientHeight;}
				if(i==2){ki3=oPopup.getElementsByTagName("a")[2].clientHeight;}
				if(i==3){ki4=oPopup.getElementsByTagName("a")[3].clientHeight;}
				if(i==4){ki5=oPopup.getElementsByTagName("a")[4].clientHeight;}
				if(i==5){ki6=oPopup.getElementsByTagName("a")[5].clientHeight;}
				if(i==6){ki7=oPopup.getElementsByTagName("a")[6].clientHeight;}
				if(i==7){ki8=oPopup.getElementsByTagName("a")[7].clientHeight;}
				if(i==8){ki9=oPopup.getElementsByTagName("a")[8].clientHeight;}
				if(i==9){ki10=oPopup.getElementsByTagName("a")[9].clientHeight;}
				if(i==10){ki11=oPopup.getElementsByTagName("a")[10].clientHeight;}
				if(i==11){ki12=oPopup.getElementsByTagName("a")[11].clientHeight;}
				if(i==12){ki13=oPopup.getElementsByTagName("a")[12].clientHeight;}
				if(i==13){ki14=oPopup.getElementsByTagName("a")[13].clientHeight;}
				if(i==14){ki15=oPopup.getElementsByTagName("a")[14].clientHeight;}
			}
			for (var i = 1; i < childNum; i++) {oPopup.getElementsByTagName("a")[i].style.display = 'none';}
			
			heiStroki = (hei+17)/childNum;
			heiStroki=Math.floor(heiStroki);

			oPopup.style.height = 1+'px';
			oStart.start(oPopup,oLink,iCustomTopOffset,hei,10,sPopupId,step,width,heiStroki,ki2,ki3,ki4,ki5,ki6,ki7,ki8,ki9,ki10,ki11);
			
        }
    }
}

var oDiv_map = {map : function(){document.getElementById("div_map").style.background='url(/images/pages/toch_small.png)';}}
var cDiv_map = {map : function(){document.getElementById("div_map").style.background='url(/images/pages/toch_small_out.png)';}}

var oPopupMenu1 = {
    
    definedHandlers : {},
    currentOpened : {
        oLink : null,
        oPopup : null,
		oMap : null
    },
    
    showMenu : function(oLink, sPopupId, iCustomTopOffset){
        clearTimeout(this.hideTimeout);
		if(this.currentOpened.oMap == "map" || this.currentOpened.oMap == "map1" || this.currentOpened.oMap == "map2" || this.currentOpened.oMap == "map3" || this.currentOpened.oMap == "map4" || this.currentOpened.oMap == "map5" || this.currentOpened.oMap == "map6" || this.currentOpened.oMap == "map7" || this.currentOpened.oMap == "map8" || this.currentOpened.oMap == "map9" || this.currentOpened.oMap == "map10" || this.currentOpened.oMap == "map11" || this.currentOpened.oMap == "map12" || this.currentOpened.oMap == "map13" || this.currentOpened.oMap == "map14" || this.currentOpened.oMap == "map15" || this.currentOpened.oMap == "map16" || this.currentOpened.oMap == "map17" || this.currentOpened.oMap == "map18" || this.currentOpened.oMap == "map19" || this.currentOpened.oMap == "map20" || this.currentOpened.oMap == "map21" || this.currentOpened.oMap == "map22"){
		/*document.getElementById("sandiego").style.display = 'block';*/
		document.getElementById("london").style.display = 'block';
		/*document.getElementById("bruxells").style.display = 'block';
		document.getElementById("minsk").style.display = 'block';
		document.getElementById("tallin").style.display = 'block';
		document.getElementById("praga").style.display = 'block';
		document.getElementById("isfahan").style.display = 'block';*/
		document.getElementById("dubai").style.display = 'block';
		/*document.getElementById("johannesburg").style.display = 'block';*/
		document.getElementById("novosibirsk").style.display = 'block';
		document.getElementById("moscow").style.display = 'block';
		document.getElementById("krasnoyarsk").style.display = 'block';
		document.getElementById("piter").style.display = 'block';
                document.getElementById("anaheim").style.display = 'block';
                document.getElementById("ontario").style.display = 'block';
                document.getElementById("newwestminster").style.display = 'block';
                document.getElementById("randburg").style.display = 'block';
                document.getElementById("hongkong").style.display = 'block';
                document.getElementById("lima").style.display = 'block';
                /*document.getElementById("krefeld").style.display = 'block';
                document.getElementById("worms").style.display = 'block';
                document.getElementById("felizzano").style.display = 'block';
                document.getElementById("bucheonsi").style.display = 'block';*/}



		this.currentOpened.oMap = sPopupId;
        this.hideCurrentOpenedPopup();
        
        if(typeof(iCustomTopOffset) == 'undefined'){
            iCustomTopOffset = 0;
        }
        
        var oPopup = document.getElementById(sPopupId);
		if(oPopup != null && oPopup.innerHTML != ''){
            var linkSId = oLink.name ? oLink.name : '';
            if(!this.definedHandlers['link' + linkSId]){
                oEvents.addHandler(oLink, 'mouseout', function(_this){return function(){_this.hideCurrentOpenedPopup()}}(this));
                this.definedHandlers['link' + linkSId] = true;
            }
            if(!this.definedHandlers['popup' + sPopupId]){
                oEvents.addHandler(oPopup, 'mouseover', function(_this){return function(){_this.disableHideMenu()}}(this));
                oEvents.addHandler(oPopup, 'mouseout', function(_this){return function(){_this.hideMenu()}}(this));
                this.definedHandlers['popup' + sPopupId] = true;
            }

            oLink.className = oLink.className + ' activePopup';
            
            var linkPosition = oPositions.getObjectPosition(oLink, true);


			if(this.currentOpened.oMap == "map8" || this.currentOpened.oMap == "map4" || this.currentOpened.oMap == "map19") {
            oPopup.style.left = linkPosition[0] + 'px';
            oPopup.style.top = linkPosition[1] + oLink.offsetHeight + iCustomTopOffset + -75 + 'px';
			}
			else {
				if(this.currentOpened.oMap == "map3") {
            		oPopup.style.left = linkPosition[0] + 5 + 'px';
            		oPopup.style.top = linkPosition[1] + oLink.offsetHeight + iCustomTopOffset + 24 + 'px';
				} else {
            		oPopup.style.left = linkPosition[0] + 5 + 'px';
            		oPopup.style.top = linkPosition[1] + oLink.offsetHeight + iCustomTopOffset + 6 + 'px';
				}
			}
            oPopup.style.display = 'block';

            this.currentOpened.oLink = oLink;
            this.currentOpened.oPopup = oPopup;
        }
    },
    
    hideCurrentOpenedPopup : function(){
		/*if(this.currentOpened.oMap == "map"){document.getElementById("sandiego").style.background='url(/images/pages/sandiego_red.png)';}*/
		if(this.currentOpened.oMap == "map1"){document.getElementById("london").style.background='url(/images/pages/london_red.png)';}
		/*if(this.currentOpened.oMap == "map2"){document.getElementById("bruxells").style.background='url(/images/pages/bruxells_red.png)';}
		if(this.currentOpened.oMap == "map3"){document.getElementById("minsk").style.background='url(/images/pages/minsk_red.png)';}
		if(this.currentOpened.oMap == "map4"){document.getElementById("praga").style.background='url(/images/pages/praga_red.png)';}
		if(this.currentOpened.oMap == "map5"){document.getElementById("tallin").style.background='url(/images/pages/tallin_red.png)';}
		if(this.currentOpened.oMap == "map6"){document.getElementById("isfahan").style.background='url(/images/pages/isfahan_red.png)';}*/
		if(this.currentOpened.oMap == "map7"){document.getElementById("dubai").style.background='url(/images/pages/dubai_red.png)';}
		/*if(this.currentOpened.oMap == "map8"){document.getElementById("johannesburg").style.background='url(/images/pages/johannesburg_red.png)';}*/
		if(this.currentOpened.oMap == "map9"){document.getElementById("novosibirsk").style.background='url(/images/pages/novosibirsk_red.png)';}
		if(this.currentOpened.oMap == "map10"){document.getElementById("moscow").style.background='url(/images/pages/moscow_red.png)';}
		if(this.currentOpened.oMap == "map11"){document.getElementById("krasnoyarsk").style.background='url(/images/pages/krasnoyarsk_red.png)';}
		if(this.currentOpened.oMap == "map12"){document.getElementById("piter").style.background='url(/images/pages/piter_red.png)';}
                if(this.currentOpened.oMap == "map13"){document.getElementById("ontario").style.background='url(/images/pages/ontario_red.png)';}
                if(this.currentOpened.oMap == "map14"){document.getElementById("anaheim").style.background='url(/images/pages/anaheim_red.png)';}
                if(this.currentOpened.oMap == "map15"){document.getElementById("lima").style.background='url(/images/pages/lima_red.png)';}
                if(this.currentOpened.oMap == "map16"){document.getElementById("newwestminster").style.background='url(/images/pages/new-westminster_red.png)';}
                if(this.currentOpened.oMap == "map17"){document.getElementById("bucheonsi").style.background='url(/images/pages/bucheon-si_red.png)';}
                if(this.currentOpened.oMap == "map18"){document.getElementById("hongkong").style.background='url(/images/pages/hong-kong_red.png)';}
                if(this.currentOpened.oMap == "map19"){document.getElementById("randburg").style.background='url(/images/pages/randburg_red.png)';}
                if(this.currentOpened.oMap == "map20"){document.getElementById("krefeld").style.background='url(/images/pages/krefeld_red.png)';}
                if(this.currentOpened.oMap == "map21"){document.getElementById("worms").style.background='url(/images/pages/worms_red.png)';}
                if(this.currentOpened.oMap == "map22"){document.getElementById("felizzano").style.background='url(/images/pages/felizzano_red.png)';}
        
		if(this.currentOpened.oPopup != null){
            this.currentOpened.oLink.className = this.currentOpened.oLink.className.replace(' activePopup', '');
            this.currentOpened.oPopup.style.display = 'none';
			/*if(this.currentOpened.oMap == "map"){document.getElementById("sandiego").style.background='url(/images/pages/sandiego.png)';}*/
			if(this.currentOpened.oMap == "map1"){document.getElementById("london").style.background='url(/images/pages/london.png)';}
			/*if(this.currentOpened.oMap == "map2"){document.getElementById("bruxells").style.background='url(/images/pages/bruxells.png)';}
			if(this.currentOpened.oMap == "map3"){document.getElementById("minsk").style.background='url(/images/pages/minsk.png)';}
			if(this.currentOpened.oMap == "map4"){document.getElementById("praga").style.background='url(/images/pages/praga.png)';}
			if(this.currentOpened.oMap == "map5"){document.getElementById("tallin").style.background='url(/images/pages/tallin.png)';}
			if(this.currentOpened.oMap == "map6"){document.getElementById("isfahan").style.background='url(/images/pages/isfahan.png)';}*/
			if(this.currentOpened.oMap == "map7"){document.getElementById("dubai").style.background='url(/images/pages/dubai.png)';}
			/*if(this.currentOpened.oMap == "map8"){document.getElementById("johannesburg").style.background='url(/images/pages/johannesburg.png)';}*/
			if(this.currentOpened.oMap == "map9"){document.getElementById("novosibirsk").style.background='url(/images/pages/novosibirsk.png)';}
			if(this.currentOpened.oMap == "map10"){document.getElementById("moscow").style.background='url(/images/pages/moscow.png)';}
			if(this.currentOpened.oMap == "map11"){document.getElementById("krasnoyarsk").style.background='url(/images/pages/krasnoyarsk.png)';}
			if(this.currentOpened.oMap == "map12"){document.getElementById("piter").style.background='url(/images/pages/piter.png)';}
                        if(this.currentOpened.oMap == "map13"){document.getElementById("ontario").style.background='url(/images/pages/ontario.png)';}
                        if(this.currentOpened.oMap == "map14"){document.getElementById("anaheim").style.background='url(/images/pages/anaheim.png)';}
                        if(this.currentOpened.oMap == "map15"){document.getElementById("lima").style.background='url(/images/pages/lima.png)';}
                        if(this.currentOpened.oMap == "map16"){document.getElementById("newwestminster").style.background='url(/images/pages/new-westminster.png)';}
                        if(this.currentOpened.oMap == "map17"){document.getElementById("bucheonsi").style.background='url(/images/pages/bucheon-si.png)';}
                        if(this.currentOpened.oMap == "map18"){document.getElementById("hongkong").style.background='url(/images/pages/hong-kong.png)';}
                        if(this.currentOpened.oMap == "map19"){document.getElementById("randburg").style.background='url(/images/pages/randburg.png)';}
                        if(this.currentOpened.oMap == "map20"){document.getElementById("krefeld").style.background='url(/images/pages/krefeld.png)';}
                        if(this.currentOpened.oMap == "map21"){document.getElementById("worms").style.background='url(/images/pages/worms.png)';}
                        if(this.currentOpened.oMap == "map22"){document.getElementById("felizzano").style.background='url(/images/pages/felizzano.png)';}

            this.currentOpened.oLink = null;
            this.currentOpened.oPopup = null;
        }
    },
    
    hideMenu : function(isDoHide){
		if(!isDoHide){
            this.hideTimeout = setTimeout(function(_this){return function(){_this.hideMenu(true)}}(this), 50);
        }else{
            this.hideCurrentOpenedPopup();
        }
    },
    
    disableHideMenu : function(){
        clearTimeout(this.hideTimeout);
    }
}

function setBlockHeights(){
    var oBlockLeft = document.getElementById('idPageLeft');
    var oBlockContent = document.getElementById('idPageContent');
    var iLeftHeight = oBlockLeft.offsetHeight;
    var iContentHeight = oBlockContent.offsetHeight;
    if(iContentHeight < iLeftHeight - 56){
        if(window.navigator.userAgent.indexOf('MSIE 6.0') > 0){
            oBlockContent.style.height = iLeftHeight - 56 + 'px';
        }else{
            oBlockContent.style.minHeight = iLeftHeight - 56 + 'px';
        }
    }
}

var leftPolls = {
    isRequestInProgress : false,
    
    set : function(idVariant, oLink){
        var aLinks = oLink.parentNode.parentNode.getElementsByTagName('A');
        for(var i = 0; i < aLinks.length; i ++){
            if(aLinks[i] != oLink){
                aLinks[i].className = '';
            }else{
                document.forms.leftPoll.id_variant.value = idVariant;
                aLinks[i].className = 'leftPollsActiveChoice';
            }
        }
        return false;
    },
	
	set1 : function(idVariant, oLink){
        var aLinks = oLink.parentNode.parentNode.getElementsByTagName('input');
        for(var i = 0; i < aLinks.length; i ++){
            if(aLinks[i] != oLink){
                aLinks[i].className = '';
            }else{
                document.forms.leftPoll.id_variant.value = idVariant;
                aLinks[i].className = 'leftPollsActiveChoice';
            }
        }
        return false;
    },
    
    doAction : function(doSubmitForm){
        if(document.forms.leftPoll.id_variant.value == ''){
            alert(aSpelling.pollsCheckVariant);
            return;
        }
        if(this.isRequestInProgress){
            alert(aSpelling.ajaxProcessing);
            return;
        }
        this.isRequestInProgress = true;
        
        if(doSubmitForm){
            document.forms.leftPoll.submit();
        }else{
            var oClient = new cClient();
            oClient.submitFormCallback(document.forms.leftPoll, function(_this){return function(sContent){_this.onResponse(sContent)}}(this));
        }
    },
    
    onResponse : function(sContent){
        this.isRequestInProgress = false;
        var oPollsBlock = document.getElementById('idLeftPolls');
        if(oPollsBlock != null){
            oPollsBlock.innerHTML = sContent;
        }
        setBlockHeights();
    }
}

function submitFaqForm(oForm){
    if(oForm.name.value == ''){
        alert(aSpelling.faqCheckName);
        oForm.name.focus();
        return false;
    }
    re = new RegExp("^[a-zA-Z0-9\\_\\.\\-]+@([a-zA-Z0-9\\-]+\\.)+[a-zA-Z]{2,5}$");
    if(oForm.email.value == '' || !re.test(oForm.email.value)){
        alert(aSpelling.faqCheckEmail);
        oForm.email.focus();
        return false;
    }
    if(oForm.question.value == ''){
        alert(aSpelling.faqCheckAnswer);
        oForm.question.focus();
        return false;
    }
    oForm.submit();
}

var oOrders = {
    isRequestInProgress : false,
    
    addToCart : function(sId){
        if(this.isRequestInProgress){
            alert(aSpelling.ajaxProcessing);
            return;
        }
        this.isRequestInProgress = true;

        var oQuantity = document.getElementById('idCatItem' + sId);
        if(oQuantity != null){
            var iQuantity = parseInt(oQuantity.value);
            if(!isNaN(iQuantity) && iQuantity > 0){
                var oClient = new cClient();
                oClient.getContentCallback(document.location.protocol + '//' + document.location.host + '/cart/?action=add&id=' + encodeURIComponent(sId) + '&quantity=' + iQuantity, function(_this){return function(sContent){_this.onResponse(sContent)}}(this)); 
            }else{
                alert(aSpelling.addToCartCheck);
            }
        }else{
            alert(aSpelling.addToCartError);
        }
    },
    
    onResponse : function(sContent){
        this.isRequestInProgress = false;
        
        var aResult = null;
        eval('aResult = ' + sContent);
        if(typeof(aResult) == 'object'){
            var oCartNumber = document.getElementById('leftCartNumber');
            if(oCartNumber != null){
                oCartNumber.innerHTML = aResult['quantity'];
            }

            if(aResult['status'] == 'ok'){
                alert(aSpelling.addToCartAdded);
            }else{
                alert(aSpelling.addToCartNotAdded);
            }
        } 
    },
    
    goToOrders : function(sModuleLink,togo){
        var oCartNumber = document.getElementById('leftCartNumber');
        if(oCartNumber != null){
            var iQuantity = parseInt(oCartNumber.innerHTML);
            if(!isNaN(iQuantity) && iQuantity > 0){
                document.location.href = sModuleLink;
            }else{
                alert(aSpelling.orderEmptyCart);
            }
        }
		
    },
    
    showOrderForm : function(){
        document.getElementById('idOrderLink').style.display = 'none';
        document.getElementById('idOrderTitle').style.display = 'block';
        document.getElementById('idOrderForm').style.display = 'block';
    },
    
    submitOrderForm : function(){
        oForm = document.forms.orderForm;

        if(oForm.user_name.value == ''){
            alert(aSpelling.orderCheckName);
            oForm.user_name.focus();
            return false;
        }
        re = new RegExp("^[a-zA-Z0-9\\_\\.\\-]+@([a-zA-Z0-9\\-]+\\.)+[a-zA-Z]{2,5}$");
        if(oForm.user_email.value == '' || !re.test(oForm.user_email.value)){
            alert(aSpelling.orderCheckEmail);
            oForm.user_email.focus();
            return false;
        }
        if(oForm.phone.value == ''){
            alert(aSpelling.orderCheckPhone);
            oForm.phone.focus();
            return false;
        }
        if(oForm.city.value == ''){
            alert(aSpelling.orderCheckCity);
            oForm.city.focus();
            return false;
        }
        if(oForm.address.value == ''){
            alert(aSpelling.orderCheckAddress);
            oForm.address.focus();
            return false;
        }
        
        oForm.submit();
    }
}

oEvents.addHandler(window, 'load', function(){
    if(navigator.userAgent.match(/MSIE (5|5\.5|6)/i) && !navigator.userAgent.match(/Opera/i)){
        var aImages = document.images;
        for(var i = 0; i < aImages.length; i++){
            if(aImages[i].src.match(/\.png$/i)){
                aImages[i].src = '/images/pix.gif';
            }
        }
    }
});

function adjustCartNumber(id, oArrows, evt){
    evt = evt ? evt : window.event;

    var mousePos = oPositions.getPointerPosition(evt);
    var elementPos = oPositions.getObjectPosition(oArrows);
    elementHalfY = oArrows.offsetHeight / 2;
    iPlus = (mousePos[1] > elementPos[1] + elementHalfY) ? -1 : 1;
    
    var oInput = document.getElementById('idCatItem' + id);
    if(oInput != null){
        var currentValue = parseInt(oInput.value);
        if(isNaN(currentValue)){
            currentValue = 0;
        }
        oInput.value = Math.max(1, currentValue + iPlus);
    }
    
    return true;
}

function adjustCartNumberKey(oInput, evt){
    evt = evt ? evt : window.event;

    iPlus = 0;
    if(evt.keyCode == 38){
        iPlus = 1;
    }else if(evt.keyCode == 40){
        iPlus = -1;
    }
    
    if(iPlus != 0 && oInput != null){
        var currentValue = parseInt(oInput.value);
        if(isNaN(currentValue)){
            currentValue = 0;
        }
        oInput.value = Math.max(1, currentValue + iPlus);
    }
    
    return true;
}

function checkSearchForm(obj){
    if(obj.phrase.value == ''){
        alert(aSpelling.searchCheck);
        obj.phrase.focus();
        return false;
    }
    return true;
}


