function changeLanguage(newLang) {
	var myForm = document.changeLanguageForm;
	if (myForm) {
		if (newLang) {
			myForm.change_language.value = newLang;
		}
		myForm.submit();
	}
}

function viewpix(pic_id, dir_prefix, singleMode, gallery_id) {
	var params = '?id=' + pic_id;
	if (!dir_prefix) {
		dir_prefix = '';
	}
	if (singleMode) {
		params += '&mode=single';
	}
	if (gallery_id) {
		params += '&gallery=' + gallery_id;
	}
	var w = window.open(dir_prefix + 'album.php' + params, 'viewpix', 'top=3,left=3,width=100,height=100,location=0,menubar=0,directories=0,resizable=0,status=1,toolbar=0,scrollbars=0');
	w.focus();
	return w;
}

var opacityArrayShow = new Array(20, 40, 60, 80, 100);
var opacityArrayHide = new Array(80, 60, 40, 20, 0);

var commandsToRunNowShowHideDetails = new Array('setOpacityItemShow', 'setOpacityItemHide');

function showHideMenuItem(time, command, id) {
	removeToDo('showItem');
	runNowToDo('hideItem');
	runNowToDoDetails(commandsToRunNowShowHideDetails);
	addToDo(createCommand(time, command, id));
}

function menuItemOver(id) {
	showHideMenuItem(0, 'showItem', id);
}

function menuItemOut(id) {
	showHideMenuItem(20, 'hideItem', id);
}

function menuItemsOver(id) {
	resetToDo(true);
	addToDo(createCommand(0, 'onItem', id));
}

function menuItemsOut(id) {
	showHideMenuItem(20, 'hideItem', id);
}

function addItemDetails(itemArray, opacArray, command) {
	var itemLength = itemArray.length;
	var opacLength = opacArray.length;
	var i, j;
	for (i = 0; i < itemLength; i++) {
		var itemId = itemArray[i];
		for (j = 0; j < opacLength; j++) {
			addToDoDetails(createCommand(1, command, new Array(itemId, opacArray[j])));
		}
	}
}

function buildAddItemDetails(id, opacArray, show) {
	var submenuItemsCount = submenuItems[id - 1];
	var itemArray = new Array();
	var i;
	var command = show ? 'setOpacityItemShow' : 'setOpacityItemHide';
	opacArray = new Array().concat(opacArray);
	if (show) {
		addToDoDetails(createCommand(0, command, new Array('menu-selected-' + id, 100)));
		for (i = 0; i <= submenuItemsCount; i++) {
			itemArray.push('menu-subitem-' + id + '-' + i);
		}
		addItemDetails(itemArray, opacArray, command);
	} else {
		for (i = submenuItemsCount; i >= 0; i--) {
			itemArray.push('menu-subitem-' + id + '-' + i);
		}
		addItemDetails(itemArray, opacArray, command);
		addToDoDetails(createCommand(0, command, new Array('menu-selected-' + id, 0)));
	}
}

function processTimer(commandArray) {
	var command = commandArray[1];
	var id = commandArray[2];
	if (command == 'showItem') {
		buildAddItemDetails(id, opacityArrayShow, true);
	} else if (command == 'hideItem') {
		buildAddItemDetails(id, opacityArrayHide, false);
	} else if (command == 'onItem') {
		buildAddItemDetails(id, 100, true);
	} else if (command == 'offItem') {
		buildAddItemDetails(id, 0, false);
	} else if ((command == 'setOpacityItemShow') || (command == 'setOpacityItemHide')) {
		setOpacity(id, commandArray[3]);
	}
}

function checkRunNow(commandLine) {
	if (commandLine[1] == 'setOpacityItemHide') {
		if (commandLine[3] != 0) {
			commandLine = false;
		}
	} else if (commandLine[1] == 'hideItem') {
		commandLine[1] = 'offItem';
	}
	return commandLine;
}

/*
	functions "setOpacity..." based on a script from http://brainerror.net/
*/

function setOpacityShowHide(div, opac, visibility, display) {
	if (div) {
		if (opac == 0) {
			if (visibility) {
				div.style.visibility = 'hidden';
			}
			if (display) {
				div.style.display = 'none';
			}
		} else {
			div.style.filter = opac > 50 ? 'none' : 'alpha(opacity=' + opac + ')';
			var opacPercent = opac / 100;
			div.style.opacity = opacPercent;
			div.style.MozOpacity = opacPercent;
			div.style.KhtmlOpacity = opacPercent;
			if (visibility) {
				div.style.visibility = 'visible';
			}
			if (display) {
				div.style.display = '';
			}
		}
	}
}

function setOpacityDiv(div, opac) {
	setOpacityShowHide(div, opac, false, true);
}

function setOpacity(id, opac) {
	setOpacityDiv(document.getElementById(id), opac);
}

function music_change(url, img, mOn) {
	window.parent.zene.location.href = url;
	var i = document.getElementById('speaker_img');
	if (i) {
		i.src = img;
	}
	music_on = mOn;
}

function music_start(imgPathCss) {
	music_change('zene01.php', imgPathCss + 'hang_be.gif', true);
}

function music_stop(imgPathCss) {
	music_change('zene_off.php', imgPathCss + 'hang_ki.gif', false);
}

function swap_music(imgPathCss) {
	if (music_on) {
		music_stop(imgPathCss);
	} else {
		music_start(imgPathCss);
	}
}

function showSpeaker() {
	if (window.parent.zene) {
		var speaker = document.getElementById('speaker');
		if (speaker) {
			speaker.style.display = '';
		}
	}
}

function highlightDesign(show) {
	var design = document.getElementById('design');
	if (design) {
		design.className = show ? 'design design-highlight' : 'design';
	}
}

function validateForm(formName) {
	var myForm = eval('document.' + formName + 'Form');
	var fieldCount = eval(myForm.hidden_field_count.value);
	var i;
	var isOK = true;
	var firstField = false;
	for (i = 1; i <= fieldCount; i++) {
		var requied = myForm.elements['hidden_requied_' + i];
		if (requied) {
			var fieldName = 'input_' + i;
			var field = myForm.elements[fieldName];
			if (field) {
				var fieldType = field.type;
				if (fieldType) {
					switch (fieldType) {
						case 'text': 
						case 'textarea':
						case 'password':
							requied = field.value.replace(/\s/g, '') == '';
							break;
						case 'checkbox':
							requied = !field.checked;
							break;
						case 'select-one':
						case 'select-multiple':
							var options = field.options;
							requied = true;
							for (var j = 0, optionsLength = options.length; requied && (j < optionsLength); j++) {
								var item = options[j];
								requied = item.selected && (item.value != '');
							}
							break;
						default:
							requied = false;
							break;
					}
				} else { // 'radio'
					requied = true;
					for (var j = 0, groupLength = field.length; requied && (j < groupLength); j++) {
						requied = !field[j].checked;
					}
					field = field[0];
				}
				if (requied) {
					if (!firstField) {
						firstField = field;
					}
				}
			} else {
				requied = false;
			}
		} else {
			requied = false;
		}
		var td = document.getElementById(formName + '_form_' + i + '_td');
		if (td) {
			td.style.background = requied ? '#FF0000' : '';
		}
		isOK = isOK && !requied;
	}
	if (!isOK) {
		if (firstField) {
			firstField.focus();
		}
		if (window.alertRequiedFields) {
			alertRequiedFields();
		}
	}
	return isOK;
}

function setFocus(itemSetFocus) {
	if (itemSetFocus) {
		itemSetFocus.focus();
		if (itemSetFocus.type == 'text') {
			itemSetFocus.select();
		}
	}
}

function showGoogleMap(mapId, coord1, coord2, zoom, infoText) {
	var ok = false;
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById(mapId));
		var point = new GLatLng(coord1, coord2);
        map.addControl(new GLargeMapControl());
//        map.addControl(new GOverviewMapControl());
        map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(coord1+0.002, coord2), zoom);
        var marker = new GMarker( new GLatLng(coord1, coord2) );
        map.addOverlay( marker );
        marker.openInfoWindowHtml(infoText);
		ok = true;
	}
	return ok;
}

var subitemShow = false;
var subitemTimeout = false;

function showSubmenuItems(id) {
	if (subitemShow) {
		hideSubmenuItemsTimeout(subitemShow, 0, -1);
	}
	subitemShow = id;
	var subitemId = 'menu-subitem-' + id;
	var subitemIdRoll = subitemId + '-roll';
	var subitem = document.getElementById(subitemId);
	var subitemRoll = document.getElementById(subitemIdRoll);
	if (subitem && subitemRoll) {
		subitem.style.visibility = 'hidden';
		subitem.style.display = '';
		subitemRoll.style.marginTop = '0px';
		var height = 0 - subitem.clientHeight;
		subitemRoll.style.marginTop = height + 'px';
		subitem.style.display = 'none';
		subitem.style.visibility = 'visible';
		var offset = 5;
		var timeout = 120;
		var more = true;
		while (more) {
			height += offset;
			if (height > -10) {
				height = 0;
				more = false;
			}
			setTimeout('document.getElementById(\'' + subitemIdRoll + '\').style.marginTop = \'' + height + 'px\';', timeout);
			offset = Math.floor(offset * 1.35);
			timeout = Math.floor(timeout * 1.25);
		}
	}
	setOpacity(subitemId, 100);
}

function hideSubmenuItems(id) {
	hideSubmenuItemsTimeout(id, 80, 1000);
}

function hideSubmenuItemsTimeout(id, opac, wait) {
	keepSubitem();
	var divId = 'menu-subitem-'+id;
	if (opac < 0) {
		setOpacity(divId, 0);
	} else {
		if (wait <= 0) {
			setOpacity(divId, opac);
			wait = 100;
			opac -= 20;
		}
		if (opac >= 0) {
			subitemTimeout = setTimeout('hideSubmenuItemsTimeout('+id+', '+opac+', -1)', wait);
		}
	}
}

function keepSubitem() {
	if (subitemTimeout) {
		clearTimeout(subitemTimeout);
	}
}

function initSubitem(subid, id) {
	var item = document.getElementById('menu-item-' + id);
	var subitem = document.getElementById('menu-subitem-' + subid);
	var subitemToCalc = document.getElementById('menu-subitem-' + subid + '-to-calc');
	subitemToCalc.style.display = '';
	var widthSubitem = subitemToCalc.clientWidth;
	subitemToCalc.style.display = 'none';
	var width = item.clientWidth-6;
	subitem.style.width = (widthSubitem < width ? width : widthSubitem) + 'px';
}

function startSlideshow(imgArray) {
	showNextSlideshowImage(imgArray, -1);
}

function showNextSlideshowImage(imgArray, opac) {
	var images = eval(imgArray);
	var img1 = images[2];
	var img2 = images[3];
	if (opac < 0) {
		img1.src = img2.src;
		setOpacityDiv(img1, 100);
		images[0]++;
		if (images[0] == images[1]) {
			images[0] = 4;
		}
		setOpacityDiv(img2, 0);
		img2.src = images[images[0]];
		setTimeout('showNextSlideshowImage(\'' + imgArray + '\', 100)', 5000);
	} else {
		opac -= 10;
		setOpacityDiv(img2, 100-opac);
		setOpacityDiv(img1, opac < 0 ? 0 : opac);
		setTimeout('showNextSlideshowImage(\'' + imgArray + '\', ' + opac + ')', 150);
	}
}

function showTurizmusForm(value) {
	var select = document.turizmusForm.input_1;
	if (select) {
		select.value = value;
		select.focus();
	}
}

function trim(text, toRemove, direction) {
    if (!toRemove) {
        text = trim(text, ' ', direction);
    } else {
        var length = toRemove.length;
        var textLength = text.length;
        if ((length > 0) && (textLength > 0)) {
            if (!direction) {
                direction = 0;
            }
            var doSubstring = false;
            var first = 0;
            var last = textLength;
            var more = direction <= 0;
            for (var firstEnd = first + length; more && (firstEnd <= last); firstEnd += length) {
                if (text.substring(first, firstEnd) == toRemove) {
                    first = firstEnd;
                    doSubstring = true;
                } else {
                    more = false;
                }
            }
            more = direction >= 0;
            for (var lastStart = last - length; more && (lastStart >= first); lastStart -= length) {
                if (text.substring(lastStart, last) == toRemove) {
                    last = lastStart;
                    doSubstring = true;
                } else {
                    more = false;
                }
            }
            if (doSubstring) {
                text = text.substring(first, last);
            }
        }
    }
    return text;
}

function trimBatch(text, partsToRemove, direction) {
    for (var i = 0, length = partsToRemove.length; i < length; i++) {
        text = trim(text, partsToRemove[i], direction);
    }
    return text;
}

var lightboxImagesLength = 0;

function setLightboxImagesLength(length) {
    lightboxImagesLength = length;
}

var lightboxImagesDelay = 30;

function displayLightboxImage(id, src) {
    var img = document.getElementById(id);
    if (img.src != src) {
        img.src = src;
    }
}

function showLightboxImage(index) {
    if (index < lightboxImagesLength) {
        setTimeout(lightboxImages[index] + ' showLightboxImage(' + (index + 1) + ');', lightboxImagesDelay);
    }
}

function showLightboxImage0() {
    showLightboxImage(0);
}

var lightboxImagesPerPage = 20;

function setLightboxImagesPerPage(imagesPerPage) {
    lightboxImagesPerPage = imagesPerPage;
}

var pageShowLightbox = 1;
var defaultPagerId = 'galeria-pix-pager';
var pagerProperties = new Array();

function initPager(pagerId, maxPage, pageNumberBlockInfo) {
    pagerProperties[pagerId] = new Array(maxPage, pageNumberBlockInfo);
}

function showLightboxPage(pageToShow, pagerId, relative) {
    if (!pagerId) {
        pagerId = defaultPagerId;
    }
    var properties = pagerProperties[pagerId];
	if (properties) {
	    var maxPage = properties[0];
	    var pageNumberBlockInfo = properties[1];
	    if (relative) {
	        pageToShow += pageShowLightbox;
	        if (pageToShow > maxPage) {
	            pageToShow = maxPage;
	        } else if (pageToShow < 1) {
	            pageToShow = 1;
	        }
	    }
	    pageShowLightbox = pageToShow;
	    var nextPageFirst = pageToShow * lightboxImagesPerPage;
	    var index =  nextPageFirst - lightboxImagesPerPage;
	    if (nextPageFirst > lightboxImagesLength) {
	        nextPageFirst = lightboxImagesLength;
	    }
		showLightboxImageInterval(index, nextPageFirst);
	    var pagerTd;
	    pagerTd = document.getElementById(pagerId + '-prev');
	    if (pagerTd) {
	        pagerTd.className = pageToShow == 1 ? 'disabled' : '';
	    }
	    pagerTd = document.getElementById(pagerId + '-next');
	    if (pagerTd) {
	        pagerTd.className = pageToShow == maxPage ? 'disabled' : '';
	    }
	    var firstTdToShow = 1;
	    var lastTdToShow = maxPage;
	    if (pageNumberBlockInfo) {
	        var isLeftSlide = pageToShow <= pageNumberBlockInfo[3];
	        var isRightSlide = pageToShow >= pageNumberBlockInfo[4];
	        pagerTd = document.getElementById(pagerId + '-block-spacer-left');
	        if (pagerTd) {
	            pagerTd.className = isLeftSlide ? 'hidden' : '';
	        }
	        pagerTd = document.getElementById(pagerId + '-block-spacer-right');
	        if (pagerTd) {
	            pagerTd.className = isRightSlide ? 'hidden' : '';
	        }
	        if (isLeftSlide) {
	            lastTdToShow = pageNumberBlockInfo[5];
	        } else if (isRightSlide) {
	            firstTdToShow = pageNumberBlockInfo[6];
	        } else {
	            firstTdToShow = pageToShow - pageNumberBlockInfo[1];
	            lastTdToShow = pageToShow + pageNumberBlockInfo[2];
	        }
	    }
	    var pageIndex = 1;
	    var morePage = true;
	    while (morePage) {
	        var showTr = pageIndex == pageToShow;
	        pagerTd = document.getElementById(pagerId + '-' + pageIndex);
	        if (pagerTd) {
	            pagerTd.className = showTr ? 'selected' : (pageIndex >= firstTdToShow) && (pageIndex <= lastTdToShow) ? '' : 'hidden';
	        }
	        var prefix = 'galeria-pix-row-' + pageIndex + '-';
	        var rowIndex = 1;
	        var moreRow = true;
	        while (moreRow) {
	            var tr = document.getElementById(prefix + rowIndex);
	            if (tr) {
	                if (showTr) {
	                    if (tr.style.display == 'none') {
	                        tr.style.display = '';
	                    }
	                } else {
	                    if (tr.style.display != 'none') {
	                        tr.style.display = 'none';
	                    }
	                }
	                rowIndex++;
	            } else {
	                moreRow = false;
	                if (rowIndex == 1) {
	                    morePage = false;
	                } else {
	                    pageIndex++;
	                }
	            }
	        }
		}
    } else {
		showLightboxImageInterval(0, lightboxImagesLength);
	}
}

function showLightboxImageInterval(startIndex, length) {
	var timeout = 0;
	for (var i = startIndex; i < length; i++) {
		setTimeout(lightboxImages[i], timeout);
		timeout += lightboxImagesDelay;
	}
}

function showLightboxPage1() {
    showLightboxPage(1);
}

function showLightboxPageByLastViewedImage(lastViewedImage) {
    var pageToShow = Math.floor((lastViewedImage - 1)/ lightboxImagesPerPage) + 1;
    showLightboxPage(pageToShow);
}

function showMonth(month) {
	var myForm = document.calendarForm;
	if (myForm) {
		myForm.month.value = month;
		myForm.submit();
	}
}

function merulesColor(merulesIds, highlight) {
	var merulesIdArray = merulesIds.split(',');
	var length = merulesIdArray.length;
	var i;
	for (i = 0; i < length; i++) {
		merulesId = merulesIdArray[i];
		var index = 0;
		var more = true;
		while (more) {
			var tdId;
			if (index == 0) {
				tdId = merulesId;
			} else {
				tdId = 'td_' + merulesId + '_' + index;
			}
			var td = document.getElementById(tdId);
			if (td) {
				td.style.backgroundColor = highlight ? '#0099FF' : '';
				td.style.fontWeight = highlight ? 'bold' : '';
			} else {
				if (index != 0) {
					more = false;
				}
			}
			index++;
		}
	}
}

function hideShowElements(container, toHide, toShow) {
	var elementsToHideToShow = new Array(false, false);
	if (container) {
		if (toHide) {
			var elements = container.getElementsByTagName(toHide);
			elementsToHideToShow[0] = elements;
			for (var i = 0, length = elements.length; i < length; i++) {
				elements[i].style.display = 'none';
			}
		}
		if (toShow) {
			var elements = container.getElementsByTagName(toShow);
			elementsToHideToShow[1] = elements;
			for (var i = 0, length = elements.length; i < length; i++) {
				elements[i].style.display = '';
			}
		}
	}
	return elementsToHideToShow;
}

function hideButtonShowDiv(divId) {
	var div = document.getElementById(divId);
	hideShowElements(div, 'a', 'div')
}

function mouseOnLabel(td, over) {
	td.parentNode.style.background = over ? '#CCCCFF' : '';
}

function guestbook_action(id, action_name, guide) {
	var myform = document.guestbook_admin;
	myform.id.value = id;
	myform.action_name.value = action_name;
	myform.guide.value = guide;
	myform.submit();
}

function guestbook_reply(id) {
	guestbook_action(id, 'reply', '');
}

function guestbook_cancel() {
	guestbook_action('', '', '');
}

function setInnerHtml(container, text) {
	var jsCode = '';
	var p;
	while ((p = text.indexOf('<!--CALLBACK--script type="text/javascript">')) != -1) {
		var p2 = text.indexOf('</script--CALLBACK-->');
		if (p2 > p) {
			jsCode += text.substring(p + 44, p2);
			text = text.substring(0, p) + text.substring(p2 + 21);
		} else {
			text = text.substring(0, p) + text.substring(p + 44);
		}
	}
	if (container) {
		container.innerHTML = text;
	}
	if (jsCode != '') {
		while ((p = jsCode.indexOf("Event.observe(window, 'load', ")) != -1) {
			var jsCodePrefix = jsCode.substring(0, p);
			var jsCodePostfix = jsCode.substring(p + 30);
			var p2 = jsCodePostfix.indexOf(',');
			var p3 = jsCodePostfix.indexOf(');');
			if ((p2 != -1) && (p3 > p2)) {
				jsCode = jsCodePrefix  + jsCodePostfix.substring(0, p2) + '();\n' + jsCodePostfix.substring(p3 + 2);
			} else {
				jsCode = '// ' + jsCodePostfix;
			}
		}
		eval(jsCode);
	}
}

function callAjaxContent(id, dontGoToTop) {
	var iframe = document.getElementById('hotspot-callback-iframe');
	if (iframe) {
		var src =  'hotspot_details_ajax.php?id=!' + id;
		if (dontGoToTop) {
			src += '&dontGoToTop=true';
		}
		iframe.src = src;
	}
}

function showAjaxContentText(content, goToTop) {
	var div = document.getElementById('hotspot-details-text-container');
	if (div) {
		setInnerHtml(div, content);
	}
	if (goToTop && window.goVerticalMenuTop) {
		goVerticalMenuTop();
	}
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSizeLB(w){

	var xScroll, yScroll;
	if (!w) {
		w = window;
	}
	var doc = w.document;
	var b = doc.body;
	
	if (w.innerHeight && w.scrollMaxY) {
		xScroll = w.innerWidth + w.scrollMaxX;
		yScroll = w.innerHeight + w.scrollMaxY;
	} else if (b.scrollHeight > b.offsetHeight){ // all but Explorer Mac
		xScroll = b.scrollWidth;
		yScroll = b.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = b.offsetWidth;
		yScroll = b.offsetHeight;
	}

	var windowWidth, windowHeight;

//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(doc.documentElement.clientWidth){
			windowWidth = doc.documentElement.clientWidth;
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else {
        var bodyElement = doc.getElementsByTagName('body')[0];
        if (bodyElement) { // all browsers (IEs)
            windowWidth = bodyElement.scrollWidth;
            var bottommost = doc.getElementById('bottommost');
            if (bottommost) {
                windowHeight = bottommost.offsetHeight;
                while (bottommost != bodyElement) {
                    windowHeight += bottommost.offsetTop;
                    bottommost = bottommost.parentNode;
                }
            } else {
                windowHeight = bodyElement.scrollHeight;
            }
        } else {
            windowHeight = 0;
        }
        if (windowHeight == 0) {
            if (doc.documentElement && doc.documentElement.clientHeight) { // Explorer 6 Strict Mode
                windowWidth = doc.documentElement.clientWidth;
                windowHeight = doc.documentElement.clientHeight;
            } else if (b) { // other Explorers
                windowWidth = b.clientWidth;
                windowHeight = b.clientHeight;
            }
		}
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

var hotspotIframe = false;

function showHotspotFrame(id, width, height, marginTop) {
	var w = window;
	while (w.parent && (w.parent != w)) {
		w = w.parent;
	}
	var sizes = getPageSizeLB(w);
	var doc = w.document;
	var div = doc.createElement('div');
	div.className = 'hotspot-frame-background';
	var fullWidth = sizes[0];
	div.style.width = fullWidth + 'px';
	div.style.height = sizes[1] + 'px';
	div.onclick = function() { this.parentNode.removeChild(this.nextSibling); this.parentNode.removeChild(this); return false; };
//	height += 5;
	var marginLeft = Math.floor((fullWidth - width) / 2);
	iframe = doc.createElement('iframe');
	iframe.className = 'hotspot-frame';
	iframe.style.width = width + 'px';
	iframe.style.height = height + 'px';
	iframe.style.marginTop = marginTop + 'px';
	iframe.style.marginLeft = marginLeft + 'px';
	iframe.setAttribute('scrolling', 'no');
	hotspotIframe = new Array(iframe, width, height, marginLeft, marginTop, div);
	iframe.src = './hotspot.php?id=' + id + '&ts=' + (new Date()).getTime();
	var bodyElement = doc.getElementsByTagName('body')[0];
	bodyElement.appendChild(div);
	setHotspotFrameBackgroundHeight(div, height + marginTop);
	bodyElement.appendChild(iframe);
	w.scrollTo(0, marginTop > 10 ? marginTop - 10 : 0);
}

function setWideDesign() {
	var contentColumns = document.getElementById('content-columns');
	if (contentColumns) {
		contentColumns.className = 'content-columns content-columns-wide';
	}
}

function goToAnchor(name) {
	var url = location.href;
	var p = url.indexOf('#');
	if (p != -1) {
		url = url.substring(0, p);
	}
	url += '#' + name;
	location.replace(url);
}

function resizeHotspotContainer(hotspotContaier, clear) {
	if (hotspotIframe) {
		var iframe = hotspotIframe[0];
		var hotspotDetails = hotspotContaier.parentNode;
		var hotspotImage = hotspotDetails.parentNode;
		while (hotspotImage && (hotspotImage.className != 'hotspot-image')) {
			hotspotImage = hotspotImage.nextSibling;
		}
		if (clear) {
			var width = hotspotIframe[1];
			iframe.style.width = width + 'px';
			iframe.style.height = hotspotIframe[2] + 'px';
			iframe.style.marginLeft = hotspotIframe[3] + 'px';
			hotspotDetails.style.width = width + 'px';
			hotspotImage.style.paddingLeft = '0px';
		} else {
			var iframeWidth = iframe.clientWidth;
			var width = hotspotContaier.clientWidth;
			var imgs = hotspotContaier.getElementsByTagName('img');
			for (var i in imgs) {
				var imgWidth = imgs[i].clientWidth;
				if (imgWidth) {
					imgWidth += 32;
					if (imgWidth > width) {
						width = imgWidth;
					}
				}
			}
			if (width > iframeWidth) {
				var offsetWidth = Math.floor((width - iframeWidth) / 2);
				iframe.style.width = width + 'px';
				iframe.style.marginLeft = (iframe.offsetLeft - offsetWidth) + 'px';
				hotspotDetails.style.width = 'auto';
				hotspotImage.style.paddingLeft = offsetWidth + 'px';
			}
			var height = hotspotContaier.clientHeight + 20;
			var iframeHeight = iframe.clientHeight;
			if (height > iframeHeight) {
				iframe.style.height = height + 'px';
				var div = hotspotIframe[5];
				setHotspotFrameBackgroundHeight(div, height + hotspotIframe[4]);
			}
		}
	}
}

function setHotspotFrameBackgroundHeight(div, heightWithMargin) {
	var divHeight = div.clientHeight;
	heightWithMargin += 16;
	if (heightWithMargin > divHeight) {
		div.style.height = heightWithMargin + 'px';
		var contentMainPadding = document.getElementById('content-main-padding');
		if (contentMainPadding) {
			var offsetHeight = heightWithMargin - divHeight;
			contentMainPadding.style.height = (contentMainPadding.clientHeight + offsetHeight) + 'px';
		}
	}
}

function isDiversStatusChangedLeader() {
	var leader = document.getElementById('user_leader_1');
	var leader = leader ? leader.checked : false;
	return leader;
}

function diversStatusChanged(radio) {
	var leader = isDiversStatusChangedLeader();
	var className = 'login-form-details';
	if (!leader) {
		className += ' login-form-details-diver';
	}
	radio.form.className = className;
}

function submitLoginForm(actionName) {
	var myForm = document.loginForm;
	if (myForm) {
		myForm.loginAction.value = actionName;
		myForm.submit();
	}
}

function changeLoginFormType(formType, selectName) {
	var myForm = document.loginForm;
	if (myForm) {
		if (formType) {
			myForm.formType.value = 'login';
		} else {
			formType = 'base';
			myForm.formType.value = '';
			selectName = false;
		}
			myForm.className = 'login-form-' + formType;
		if (selectName) {
			var loginName = myForm.login_name;
			if (loginName) {
				loginName.focus();
			}
		}
	}
}

function showLightboxImage(id) {
	var hiddenImages = false;
	var w = window;
	var more = true;
	while (more) {
		hiddenImages = w.document.getElementById('hidden-images');
		if (hiddenImages) {
			more = false;
		} else {
			if (w == w.parent) {
				more = false;
			} else {
				w = w.parent;
			}
		}
	}
	if (hiddenImages) {
		hiddenImages.innerHTML = '<a id="hidden-lightbox-image" rel="lightbox" href="../images/galeria/11/' + id + '_11.jpg">&nbsp;</a>';
		var lbImage = w.document.getElementById('hidden-lightbox-image');
		w.myLightbox.start(lbImage);
	}
}
