function getKeys(hash)
{
	var keys = []

	for (var i in hash)
		keys.push(i)

	return keys
}



function fullMap(imgId, zoom)
{
	var imgs	= new Array('map_big.jpg', 'map.gif')
   	var imgObj	= document.getElementById(imgId)

	if (imgObj)
		imgObj.src = imgPath + '/' + imgs[zoom]

	return false
}


function chm(elId, imgId)
{
	var imgs		= new Array('arrow.gif', 'spacer.gif')
	var elName		= 'mi' + elId
	var activeMenu	= 'mi' + activeMenuId

	var elObj		= document.getElementById(elName)
	var activeObj	= document.getElementById(activeMenu)

	elObj.src		= imgPath + '/' + imgs[imgId]

	if (activeObj) {
		if(elId != activeMenuId)
			activeObj.src = imgPath + '/' + imgs[imgId ? 0 : 1]
		else
			activeObj.src = imgPath + '/' + imgs[0]
	}
}


function hm(sid, idx)
{
	var colors		= ['#0079C6', '#FC9917']
	var arrows		= ['arrow_l1_a.gif', 'arrow_l1.gif']
	var titles		= ['a.gif', '.gif']

	var row_id		= 'mr' + sid
	var arrow_id	= 'ma' + sid
	var title_id	= 'mi' + sid

	// change bg color
	document.getElementById(row_id).style.backgroundColor = colors[idx]

	// change arrow img
	document.getElementById(arrow_id).src = menu_img_url + '/' + arrows[idx]

	// change title img
	document.getElementById(title_id).src = menu_img_url + '/' + sid + titles[idx]
}

function floors(idx)
{
	if (idx == 1) {
		document.getElementById('floors').innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="100%" height="540" align="left">'+
											'<param name="allowScriptAccess" value="sameDomain" />'+
											'<param name="movie" value="/design/img/user/floors/1floor.swf?path=/design/img/user/floors/" />'+
											'<param name="quality" value="best" />'+
											'<param name="salign" value="ct" />'+
											'<param name="wmode" value="transparent" />'+
											'<param name="bgcolor" value="#6fcaf6" />'+
											'<embed src="/design/img/user/floors/1floor.swf?path=/design/img/user/floors/" quality="best" salign="ct" wmode="transparent" bgcolor="#6fcaf6" width="100%" height="540" name="floors" align="left" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';

		document.getElementById('levnav').innerHTML = '<img src="/design/img/user/tour/level1a.gif" alt="Этаж 1" width="113" height="25" /><a href="#1" title="Посмотреть Этаж №2" onclick="floors(2);"><img src="/design/img/user/tour/level2.gif" alt="Этаж 2" width="114" height="25" /></a><a href="#3" title="Посмотреть Этаж №3" onclick="floors(3);"><img src="/design/img/user/tour/level3.gif" alt="Этаж 3" width="115" height="25" /></a>';

	};

	if (idx == 2) {
		document.getElementById('floors').innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="100%" height="540" align="left">'+
											'<param name="allowScriptAccess" value="sameDomain" />'+
											'<param name="movie" value="/design/img/user/floors/2floor.swf?path=/design/img/user/floors/" />'+
											'<param name="quality" value="best" />'+
											'<param name="salign" value="ct" />'+
											'<param name="wmode" value="transparent" />'+
											'<param name="bgcolor" value="#6fcaf6" />'+
											'<embed src="/design/img/user/floors/2floor.swf?path=/design/img/user/floors/" quality="best" salign="ct" wmode="transparent" bgcolor="#6fcaf6" width="100%" height="540" name="floors" align="left" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';

		document.getElementById('levnav').innerHTML = '<a href="#1" title="Посмотреть Этаж №1" onclick="floors(1);"><img src="/design/img/user/tour/level1.gif" alt="Этаж 1" width="113" height="25" /></a><img src="/design/img/user/tour/level2a.gif" alt="Этаж 2" width="114" height="25" /><a href="#3" title="Посмотреть Этаж №3" onclick="floors(3);"><img src="/design/img/user/tour/level3.gif" alt="Этаж 3" width="115" height="25" /></a>';

	};

	if (idx == 3) {
		document.getElementById('floors').innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="100%" height="540" align="left">'+
											'<param name="allowScriptAccess" value="sameDomain" />'+
											'<param name="movie" value="/design/img/user/floors/3floor.swf?path=/design/img/user/floors/" />'+
											'<param name="quality" value="best" />'+
											'<param name="salign" value="ct" />'+
											'<param name="wmode" value="transparent" />'+
											'<param name="bgcolor" value="#6fcaf6" />'+
											'<embed src="/design/img/user/floors/3floor.swf?path=/design/img/user/floors/" quality="best" salign="ct" wmode="transparent" bgcolor="#6fcaf6" width="100%" height="540" name="floors" align="left" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';

		document.getElementById('levnav').innerHTML = '<a href="#1" title="Посмотреть Этаж №1" onclick="floors(1);"><img src="/design/img/user/tour/level1.gif" alt="Этаж 1" width="113" height="25" /></a><a href="#1" title="Посмотреть Этаж №2" onclick="floors(2);"><img src="/design/img/user/tour/level2.gif" alt="Этаж 2" width="114" height="25" /></a><img src="/design/img/user/tour/level3a.gif" alt="Этаж 3" width="115" height="25" />';
	};

}



function hideFloor(floorId)
{
   	document.getElementById('floor-pics-' + floorId).style.display = 'none'
}


function hideAllFloors()
{
	for (var i = 0; i < all_floors.length; i++)
		hideFloor(all_floors[i])
}


function showFloor(floorId)
{
	hideAllFloors()

   	document.getElementById('floor-pics-' + floorId).style.display = 'block'

	curent_cid = floorId

   	showItem(floors_with_items[floorId].items[0].iid)
}


function showItem(iid)
{
   	document.getElementById('large-photo').src = galary_img_url + '/' + all_items[iid].src
   	document.getElementById('img-title').innerHTML = all_items[iid].img_title

	curent_iid = iid
}

function getNextPrevId(needNext)
{
	var curent_floor_items	= floors_with_items[curent_cid].items
	var keys				= getKeys(curent_floor_items)

	for (var i = 0; i < keys.length; i++)
	{
		if (curent_floor_items[i].iid == curent_iid)
		{
			// is last item
			if (keys.length - 1 == i)
				return needNext	? 0 : i - 1
			// is first item
			else if (i == 0)
				return needNext	? i + 1 : keys.length - 1
			else
				return needNext	? i + 1 : i - 1
		}
	}
}


function showPrevItem()
{
	showItem(floors_with_items[curent_cid]['items'][getNextPrevId(0)]['iid'])
}


function showNextItem()
{
	showItem(floors_with_items[curent_cid]['items'][getNextPrevId(1)]['iid'])
}

//-----„«п б¬Ґ­л а §аҐиҐ­Ёп----------------------------------------
function getScreenSize()
{
	var swidth = 0;
	var sheight = 0;

	if ( self.screen ) {			// for NN4 and IE4
		swidth = screen.width;
		sheight = screen.height
	} else if ( self.java ) {		// for NN3 with enabled Java
		var jkit = java.awt.Toolkit.getDefaultToolkit();
		var scrsize = jkit.getScreenSize();

		swidth = scrsize.width;
		sheight = scrsize.height;
	}
	
	var ret = new Array(swidth, sheight);

	return ret;	
}


function getWindowSize()
{
	var wwidth=(window.innerWidth)?window.innerWidth:
	  ((document.all)?document.body.offsetWidth:null);
	var wheight=(window.innerHeight)?window.innerHeight:
	  ((document.all)?document.body.offsetHeight:null);

	var ret = new Array(wwidth, wheight);

	return ret
}

function getWindowWidth()
{
	var windowSize = getWindowSize();

	return windowSize[0];
	
}

function chgWidth(elName)
{
	var elObj = document.getElementById(elName);

	if (elObj)
		elObj.style.width = getWindowWidth() > 1024 ? '770px' : '100%';
}

function chgWidthCommon(elName)
{
	chgWidth(elName)

	document.getElementById('topflash').style.display = getWindowWidth() >= 1024 ? 'block' : 'none';
}

//-------------------------------------------------------------

/* Fonts download */

var hasFlash=function(){var a=6;if(navigator.appVersion.indexOf("MSIE")!=-1&&navigator.appVersion.indexOf("Windows")>-1){document.write('<script language="VBScript"\> \n');document.write('on error resume next \n');document.write('hasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & '+a+'))) \n');document.write('</script\> \n');if(window.hasFlash!=null){return window.hasFlash;};};if(navigator.mimeTypes&&navigator.mimeTypes["application/x-shockwave-flash"]&&navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){var b=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;var c=parseInt(b.charAt(b.indexOf(".")-1));return c>=a;};return false;}();String.prototype.normalize=function(){return this.replace(/\s+/g," ");};if(Array.prototype.push==null){Array.prototype.push=function(){for(var i=0;i<arguments.length;i++){this[this.length]=arguments[i];};return this.length;};};if(!Function.prototype.apply){Function.prototype.apply=function(d,e){var a=[];var b,c;if(!d)d=window;if(!e)e=[];for(var i=0;i<e.length;i++){a[i]="e["+i+"]";};c="d.__applyTemp__("+a.join(",")+");";d.__applyTemp__=this;b=eval(c);d.__applyTemp__=null;return b;};};var parseSelector=function(){var a=/^([^#\.>\`]*)(#|\.|\>|\`)(.+)$/;function parseSelector(b,c,d){b=b.replace(" ","`");var e=b.match(a);var f,g,h,j;var k=[];if(e==null){e=[b,b]};if(e[1]==""){e[1]="*"};if(d==null){d="`"};if(c==null&&(e[2]==null||e[2]!=">")){c=document;};switch(e[2]){case "#":j=e[3].match(a);if(j==null){j=[null,e[3]]};f=document.getElementById(j[1]);if(f==null||(e[1]!="*"&&f.nodeName.toLowerCase()!=e[1].toLowerCase())){return k;};if(j.length==2){k.push(f);return k;};return parseSelector(j[3],f,"#");case ".":if(d=="`"){g=l(c,e[1]);}else{g=c.childNodes;};for(var i=0;i<g.length;i++){f=g[i];if(f.nodeType!=1){continue;};j=e[3].match(a);if(j!=null){if(f.className.match("\\b"+j[1]+"\\b")==null){continue;};h=parseSelector(j[3],f,j[2]);k=k.concat(h);}else if(f.className.match("\\b"+e[3]+"\\b")!=null){k.push(f);};};return k;case ">":if(d=="`"){g=l(c,e[1]);}else{g=c.childNodes;};for(var i=0;i<g.length;i++){f=g[i];if(f.nodeType!=1){continue;};if(f.nodeName.toLowerCase()!=e[1].toLowerCase()){continue;};h=parseSelector(e[3],f,">");k=k.concat(h);};return k;case "`":g=l(c,e[1]);for(var i=0;i<g.length;i++){f=g[i];h=parseSelector(e[3],f,"`");k=k.concat(h);};return k;default:g=l(c,e[0]);for(var i=0;i<g.length;i++){k.push(g[i]);};return k;};};function l(c,m){if(m=="*"&&c.all!=null){return c.all;};return c.getElementsByTagName(m);};return parseSelector;}();function named(oArgs){return new named.Arguments(oArgs);};named.Arguments=function named_Arguments(oArgs){this.oArgs=oArgs;};named.Arguments.prototype.constructor=named.Arguments;named.extract=function named_extract(a,b){var c,d;for(var i=0;i<a.length;i++){d=a[i];if(d!=null&&d.constructor!=null&&d.constructor==named.Arguments){c=a[i].oArgs;break;};};if(c==null){return};for(var e in c){if(b[e]!=null){b[e](c[e]);};};return;};var sIFR=function(){if(window.hasFlash==false||!document.createElement||!document.getElementById){return false;};var a="http://www.w3.org/1999/xhtml";var b=false;var c=false;var d=[];var UA=function(){var sUA=navigator.userAgent.toLowerCase();var e={bIsWebKit:sUA.indexOf("applewebkit")>-1,bIsKHTML:sUA.indexOf("applewebkit")>-1||sUA.indexOf("konqueror")>-1,bIsOpera:sUA.indexOf("opera")>-1,bIsXML:document.contentType!=null&&document.contentType.indexOf("xml")>-1,bHasTransparentSupport:true};e.bIsIE=sUA.indexOf("msie")>-1&&!e.bIsOpera&&!e.bIsKHTML&&!e.bIsGecko;e.bIsGecko=!e.bIsKHTML&&navigator.product!=null&&navigator.product.toLowerCase()=="gecko";if(e.bIsOpera){e.nOperaVersion=new Number(sUA.match(/.*opera(\s|\/)(\d+\.\d+)/)[2])};if(e.bIsGecko){e.nGeckoBuildDate=new Number(sUA.match(/.*gecko\/(\d{8}).*/)[1])};if(e.bIsWebKit){e.nWebKitVersion=new Number(sUA.match(/.*applewebkit\/(\d+).*/)[1])};if(sUA.match(/.*(windows|mac).*/)==null||(e.bIsOpera==true&&e.nOperaVersion<7.6)||(e.bIsWebKit==true&&e.nWebKitVersion<124)||(e.bIsGecko==true&&e.nGeckoBuildDate<20020523)){e.bHasTransparentSupport=false;};return e;}();function sIFR(e){if((!self.bAutoInit&&(window.event||e)!=null)||!f(e)){return;};b=true;for(var i=0;i<d.length;i++){replaceElement.apply(null,d[i]);};d=[];};var self=sIFR;function f(e){if(c==false||((UA.bIsXML&&UA.bIsGecko||UA.bIsKHTML)&&e==null&&b==false)||document.getElementsByTagName("body").length==0){return false;};return true;};function g(h,j,k,l,m){var n="";var o=h.firstChild;var p,q,r;if(l==null){l=0};if(m==null){m=""};while(o){if(o.nodeType==3){switch(k){case "lower":n+=o.nodeValue.toLowerCase();break;case "upper":n+=o.nodeValue.toUpperCase();break;default:n+=o.nodeValue;};}else if(o.nodeType==1){if(o.nodeName.toLowerCase()=="a"&&!o.getAttribute("href")==false){if(o.getAttribute("target")){m+="&sifr_url_"+l+"_target="+o.getAttribute("target");};m+="&sifr_url_"+l+"="+o.getAttribute("href").replace(/&/g,"%26");n+='<a href="asfunction:_root.launchURL,'+l+'">';l++;}else if(o.nodeName.toLowerCase()=="br"){n+="<br/>";};if(o.hasChildNodes){r=g(o,null,k,l,m);n+=r.n;l=r.l;m=r.m;};if(o.nodeName.toLowerCase()=="a"){n+="</a>";};};p=o;o=o.nextSibling;if(j!=null){q=p.parentNode.removeChild(p);j.appendChild(q);};};return{"n":n,"l":l,"m":m};};function s(t){if(document.createElementNS&&!UA.bIsOpera){return document.createElementNS(a,t);}else{return document.createElement(t);};};function u(v,w,x){var node=s("param");node.setAttribute("name",w);node.setAttribute("value",x);v.appendChild(node);};function replaceElement(y,z,aa,ab,ac,ad,ae,af,ag,ah,ai,k,aj){if(!f()){return d.push(arguments);};named.extract(arguments,{sSelector:function(value){y=value},sFlashSrc:function(value){z=value},sColor:function(value){aa=value},sLinkColor:function(value){ab=value},sHoverColor:function(value){ac=value},sBgColor:function(value){ad=value},nPaddingTop:function(value){ae=value},nPaddingRight:function(value){af=value},nPaddingBottom:function(value){ag=value},nPaddingLeft:function(value){ah=value},sFlashVars:function(value){ai=value},sCase:function(value){k=value},sWmode:function(value){aj=value}});if(ai!=null){ai="&"+ai.normalize();}else{ai="";};if(ae==null){ae=0};if(af==null){af=0};if(ag==null){ag=0};if(ah==null){ah=0};if(aj=="transparent"){if(!UA.bHasTransparentSupport){aj="opaque";}else{ad="transparent";};};if(aj==null){aj=""};var ak,al,am,an,ao,ap,aq,ar;var as=parseSelector(y);if(as.length==0){return false};for(var i=0;i<as.length;i++){ak=as[i];if(ak.className.match(/\bsIFR\-replaced\b/)!=null){continue;};al=ak.offsetWidth-ah-af;am=ak.offsetHeight-ae-ag;ap=s("span");ap.className="sIFR-alternate";ar=g(ak,ap,k);an=ar.n;if(UA.bIsIE){an=an.replace(new RegExp("%\d{0}","g"),"%25");}else{an=an.replace(new RegExp("%(?!\d)","g"),"%25");};an=an.replace(/\+/g,"%2B");an=an.replace(/&/g,"%26");an=an.replace(/\"/g, "%22");an=an.normalize();ao="txt="+an+ai+"&w="+al+"&h="+am+ar.m;if(aa!=null){ao+="&textcolor="+aa};if(ab!=null){ao+="&linkcolor="+ab};if(ac!=null){ao+="&hovercolor="+ac};ak.className=ak.className.normalize()+(ak.className==""?"":" ")+"sIFR-replaced";if(UA.bIsOpera){if(UA.nOperaVersion<7.60){ak.innerHTML=['<object class="sIFR-flash" type="application/x-shockwave-flash" data="',z,'" quality="best" wmode="',aj,'" bgcolor="',ad,'" flashvars="',ao,'" width="',al,'" height="',am,'"></object>'].join("");}else{aq=s("object");aq.setAttribute("type","application/x-shockwave-flash");aq.setAttribute("data",z);u(aq,"quality","best");u(aq,"wmode",aj);u(aq,"bgcolor",ad);u(aq,"flashvars",ao);};}else{aq=s("embed");aq.setAttribute("src",z);aq.setAttribute("quality","best");aq.setAttribute("flashvars",ao);aq.setAttribute("type","application/x-shockwave-flash");aq.setAttribute("wmode",aj);aq.setAttribute("bgcolor",ad);};if(!UA.bIsOpera||UA.nOperaVersion>=7.60){aq.className="sIFR-flash";aq.setAttribute("width",al);aq.setAttribute("height",am);aq.style.width=al+"px";aq.style.height=am+"px";ak.appendChild(aq);};ak.appendChild(ap);if(UA.bIsKHTML||UA.bIsIE){ak.innerHTML+="";};};};function setup(){c=true;if(document.documentElement){document.documentElement.className=document.documentElement.className.normalize()+(document.documentElement.className==""?"":" ")+"sIFR-hasFlash";};if(window.attachEvent){window.attachEvent("onload",sIFR);}else if(document.addEventListener||window.addEventListener){if(document.addEventListener){document.addEventListener("load",sIFR,false);};if(window.addEventListener){window.addEventListener("load",sIFR,false);};}else{if(typeof window.onload=="function"){var fOld=window.onload;window.onload=function(){fOld();sIFR();};}else{window.onload=sIFR;};};};self.UA=UA;self.bAutoInit=true;self.replaceElement=replaceElement;self.setup=setup;return self;}();if(sIFR != false){sIFR.setup();};
