//всплывающие окна
var InfoBlock = {
	defaultClassName : "contextInfo",
	mainMenuId : "MainMenu",
	spacer : "http://img.mail.ru/0.gif",
	itemClassPrefix : "m",
	toggle : false,
	light: "",
	lightItem : "",
	openObject : "",
	opened : "",
	openedGame : "",
	openedGroup : "",	
	host : "",
	PhotoUserID: "",
	ActiveUserID : "",	
	image_id: "",
	album_id: "",
	
	initSMSHelp : function(h,pu,au,i,aid) {
	if(h) this.host = h;
	if(pu) this.PhotoUserID = pu;
	if(au) this.ActiveUserID =	 au;
	if(i) this.image_id = i;
	if (aid) this.album_id = aid;
	},
	
	show : function(id,evt,obj, cn, pos, offsetY, offsetX, toggleMM, item, gameCode, gameParams) { 
		if (this.isOpened(id)) { 
			if(!gameCode) {
				this.hide(); 
				return false;
			}else if(this.openedGame == gameCode) { 
					this.hide(); 
					return false;
			}
		}
			this.hide(); 
			this.openObject = obj;
			
			cancelBubbling(evt);
			
			hideContext();
						
			var targetDiv;
						
			if(gebi(id)) targetDiv = gebi(id); 
			else if(!gameCode) 
					targetDiv = false;
				else
					targetDiv = document.createElement("div"); 

			var coordinates = {};
			targetDiv.className = cn + " " + this.defaultClassName;
			targetDiv.style.zIndex = '100000000';
			targetDiv.onclick = cancelBubbling;
			
			targetDiv.id = id;
			targetDiv.style.position = "absolute";
			if(!gebi(id)) document.body.appendChild(targetDiv);
			
			if(gameCode) { 
				var html = "", gameHTML = "", gameHash = {}, pre;
				targetDiv.innerHTML = '<div class="text-right close"><a href="#" onclick="InfoBlock.hide();return false;"><img src="http://img.mail.ru/r/foto2/ico_close.gif" border="0" alt="Закрыть" title="Закрыть" /></a></div>';
				gameHash = this.getSMSHelp(gameCode, gameParams);
				
				for(var i = 0, j = gameHash.length; i < gameHash.length; i++, j--) {
				gameHTML = "";
				pre = (gameCode == 'all') ? gameHash[i]["id"] : gameCode;
				gameHTML +=	"<span class=\"title\">" + gameHash[i]["name"] + "</span> <a class=\"more\" href=\"" + ((gameHash[i]["gamePage"]) ? gameHash[i]["gamePage"] : "http://" + this.host + "/catalog/static/show_yourself.html#" + gameHash[i]["id"]) + "\">Подробнее</a><br/>";
				if(!this.ActiveUserID && gameCode == 'megavote24') 
				gameHTML += "<p><span class=\"block1\">" + gameHash[i]["descr"] + "</span></p>";
				else {
				gameHTML +=	"<p><span class=\"block1\">" + gameHash[i]["descr"] + "</span></p>";
							if (gameCode == 'all' && pre == 'megavote24' || gameCode == 'megavote24')  gameHTML += "<div class=\"changeGameForm\"><form><select id=\"modeSelect\" onchange=\"InfoBlock.changeGame(this, 'megavote24')\"><option value=\"megavote\">В течение часа</option><option value=\"megavote24\" selected=\"true\">24 часа</option><option value=\"megavote7\">7 дней</option><option value=\"megavote-redir\">месяц</option></select></form></div>";
							if (gameCode == 'squall')  gameHTML += "<div class=\"changeGameForm\"><span class=\"t70\">Чтобы&nbsp;получить</span>&nbsp;<form style=\"display:inline\"><select id=\"modeSelect\" onchange=\"InfoBlock.changeGame(this, 'squall')\"><option value=\"squall\" selected=\"true\">200 оценок</option><option value=\"squall50\">50 оценок</option><option value=\"squall10\">10 оценок</option></select></form>&nbsp;<span class=\"t70\">прямо&nbsp;сейчас,</span></div>";
				gameHTML +=	"<p><span class=\"block2\">" + ((gameCode != "squall") ? "Для участия " : "") + "отправьте SMS</span>"+
							"<div class=\"numberSelectForm\">"+
							"<div class=\"numberSelect\">"+
								"<ins>с кодом</ins>";
								if(gameHash[i]["id"] != 'megavote24') gameHTML += "<div class=\"frame\"><strong><span id=\"gamePrefix_" + gameHash[i]["id"]  + "\">" + gameHash[i]["prefix"] + "</span>+" + this.PhotoUserID + "+" + this.image_id + "</strong></div>";
								else 					   gameHTML += "<div class=\"frame\"><strong><span id=\"gamePrefix_" + gameHash[i]["id"]  + "\">" + gameHash[i]["prefix"] + "</span>+<span id=\"auid\">" + this.ActiveUserID + "</span></strong></div>";
				
				gameHTML +=	"</div>"+
							"<div class=\"numberSelect\" style=\"z-index:"+j+"\">"+
								"<ins>на номер</ins>"+
								"<div class=\"frame\">"+
									"<dl>"+
										"<dt id=\"UserShortNumber_" + gameHash[i]["id"]+ "\">" + SMSInfo.sms_number + "</dt>"+
										"<dd>"+
											"Если вы находитесь в <span class=\"UserCountry\">" + SMSInfo.user_location + "</span><br/><a id=\"numbersOpen_" + gameHash[i]["id"] + "\" onclick=\"SMSInfo.show(this, event); return false;\" href=\"#\" class=\"dashed\">Другая&nbsp;страна</a><br/>";
				
				gameHTML += SMSInfo.getNumbersHTML(pre, gameHash[i]["kat"]);
								
				gameHTML +=				"</dd>"+
									"</dl>"+
								"</div>"+
							"</div>"+
							"</div></p>";
				}				
				gameHTML +=	"<p>"+
							"<span class=\"block3\">Стоимость услуги: <span id=\"gamePrice_" + gameHash[i]["id"] + "\">" + gameHash[i]["price"] + "</span> без НДС.<br/>"+
							"<a href=\"http://rates.mail.ru/\">Условия предоставления услуги</a></span>"+
							"</p>";
							
				if(gameCode == 'megavote24'){
					gameHTML +=		"<div style='padding: 5px 10px 10px 10px; margin: 0 -10px -5px -10px; background-color: rgb(230, 239, 254); font-size: 75%'>"+
							"<a target='_blank' href='http://my.mail.ru/my/megavote-info'><b>Другие способы оплаты</b></a>&nbsp;<sup style='color: red; font-weight: bold'>new</sup>"+
							"<br /><a target='_blank' href='http://my.mail.ru/my/megavote-info'><img src='http://img3.imgsmail.ru/r/foto2/megavote-info.jpg' /></a>"
							"</div>";
					targetDiv.style.width = '270px';
				}



				
				targetDiv.innerHTML += gameHTML;
				
				SMSInfo.getCountry(); 
				SMSInfo.getParams(gameHash[i]["kat"]);
				SMSInfo.setParams(gameHash[i]["id"]);
				
				if(gameHash[i]["group"]) this.openedGroup = gameHash[i]["group"];
				if(gameHash[i]["width"]) targetDiv.style.width = gameHash[i]["width"] + "px";
				}
				
				this.openedGame = gameCode; 
			}
			
			targetDiv.style.display = 'block';	
			pos = (pos) ? pos : 'abs';
			coordinates = this.getPosition(targetDiv, obj, offsetY, offsetX, pos); 

			targetDiv.style.top  = coordinates["top"]  + "px";				
			targetDiv.style.left = coordinates["left"] + "px";	
			
			this.opened = id;
			
			if(toggleMM) {
				this.toggle = true;
				this.toggleMainMenu();
			}
			
			if(item) { 
				this.lightItem = item;
				this.light = true;
				this.lightMenuItem();
				obj.parentNode.style.zIndex = 2; //IE z-index fix
			}
			
			addHandler(document, 'click', function(e) {
			var e = e || window.event;
			if (e.button == 0 )	InfoBlock.hide();
			});
							
			return false;
		
	},
	
	changeGame : function(f, defaultGameCode) { 
		var gameCode = f.options[f.selectedIndex].value; 
		if(gameCode == 'megavote-redir'){
			window.open('http://my.mail.ru/my/megavote-info');
			return;
		}
		var gameHash = this.getSMSHelp(gameCode);
		var id = gameHash[0]["id"];
		var k = gameHash[0]["kat"];
		var prefix = gameHash[0]["prefix"];
		var prefixNode = gebi("gamePrefix_" + defaultGameCode);
		var price = gameHash[0]["price"]; 
		var priceNode = gebi("gamePrice_" + this.openedGroup); 
		var list = gebi("numberList_" + ((this.openedGame == 'all') ? defaultGameCode : this.openedGame));
		var listParent = list.parentNode;
		var userNumber = gebi(SMSInfo.userNumCont + "_" + ((this.openedGame == 'all') ? defaultGameCode : this.openedGame));
		this.openedGame = gameCode;
		
		if(userNumber) userNumber.id = SMSInfo.userNumCont + "_" + gameCode;
		
		priceNode.innerHTML = price;
		prefixNode.innerHTML = prefix;
		
		SMSInfo.getParams(k);
		SMSInfo.setParams(id);
				
		if(list) {
			var numbers = SMSInfo.getNumbersHTML(id,k);
			listParent.removeChild(list);
			listParent.innerHTML += numbers;
		}
	},
	
	changeGameLite : function(f) {
		var gameCode = f.options[f.selectedIndex].value; 
		var prefixNodes = gebc("gamePrefix");
		var gameHash = this.getSMSHelp(gameCode); 
		for(var i = 0; i < prefixNodes.length; i++) {
			prefixNodes[i].innerHTML = gameHash[0]["prefix"];
		}
		
		var list = gebi("numberList_" + this.openedGame); 
		var listParent = list.parentNode;
		var userNumber = gebi(SMSInfo.userNumCont + "_" + this.openedGame);
		this.openedGame = gameCode;
		if(userNumber) userNumber.id = SMSInfo.userNumCont + "_" + gameCode;
		var id = gameHash[0]["id"];
		var k = gameHash[0]["kat"];
		
		
		SMSInfo.getParams(k);
		SMSInfo.setParams(id);
		
		if(list) {
			var numbers = SMSInfo.getNumbersHTML(id,k);
			listParent.removeChild(list);
			listParent.innerHTML += numbers;
		}
	},
	
	getSMSHelp : function(i, p) { 
		var out =[];
		var album_access = 2, vote_access = 1, ero = 0, fav = 0;
		if(typeof p != 'undefined') {
			album_access = p['album_access'];
			vote_access = p['vote_access'];
			ero = p['ero'];
			fav = p['fav'];
		} 
		var games = { 
				'smstop' :
				{ 
					"prefix" : "10",
					"name" : "SMS-топ",
					"descr" : "Размещение фото на главной странице в рубрике «SMS-топ».",
					"price" : "0.99 у.е.",
					"id" : "smstop",
					"kat" : "0"
				},
				'leader' : 
				{ 
					"prefix" : "11",
					"name" : "Фото-Лидер",
					"descr" : "Размещение фото на главной странице в рубрике «Фото-лидер».", 
					"price" : "0.99 у.е.",
					"id" : "leader",
					"kat" : "0"
				},
				'x2': 
				{ 
					"prefix" : "40",
					"name" : "Дайте две!",
					"descr" : "Каждый голос за фото удваивается. Срок действия &mdash; 1 час.",
					"price" : "2.99 у.е.",
					"id" : "x2",
					"kat" : "1"
				},
				'megavote': 
				{
					"prefix" : "28",
					"name" : "Держи десять!",
					"descr" : "Возможность ставить оценку +10",
					"price" : "0.99 у.е.",
					"id" : "megavote", 
					"kat" : "0",
					"group" : "megavote24"
				},
				'megavote24': 
				{
					"prefix" : "63",
					"name" : "Держи десять!",
					"descr" : "Возможность ставить оценку +10",
					"price" : "2.99 у.е.",
					"id" : "megavote24", 
					"kat" : "2",
					"group" : "megavote24"
				},
				'megavote7': 
				{
					"prefix" : "64",
					"name" : "Держи десять!",
					"descr" : "Возможность ставить оценку +10",
					"price" : "4.99 у.е.",
					"id" : "megavote7", 
					"kat" : "3",
					"group" : "megavote24"
				},
				'skinfoto' :
				{
					"prefix" : "46",
					"name" : "Оформить фото",
					"descr" : "",
					"price" : "0.99 у.е.",
					"id" : "skinfoto", 
					"kat" : "4"
				},
				'skinalbum' :
				{
					"prefix" : "47",
					"name" : "Оформить альбом",
					"descr" : "",
					"price" : "2.99 у.е.",
					"id" : "skinalbum", 
					"kat" : "5"
				},
				'squall' : 
				{
					"prefix" : "61",
					"name" : "Шквал оценок!",
					"descr" : "",
					"price" : "4.99 у.е.",
					"id" : "squall", 
					"kat" : "3",
					"group" : "squall",
					"width" : "270"
				},
				'squall50' : 
				{
					"prefix" : "24",
					"name" : "Шквал оценок!",
					"descr" : "",
					"price" : "2.99 у.е.",
					"id" : "squall50", 
					"kat" : "2",
					"group" : "squall"
				},
				'squall10' : 
				{
					"prefix" : "60",
					"name" : "Шквал оценок!",
					"descr" : "",
					"price" : "0.99 у.е.",
					"id" : "squall10", 
					"kat" : "0",
					"group" : "squall"
				}
			};
				
			if (!this.ActiveUserID) games["megavote24"]["descr"]  += '<br/>Для участия в игре вы должны <a href=\"http://' + this.host + '/cgi-bin/login?page=' + encodeURI(window.location.href) + '\">авторизоваться</a>.';

			if(typeof i == 'object') {
				for(var n = 0; n < i.length; n++)  
					out.push(games[i[n]]);
			}
			else if (i != 'all') out = [games[i]];
			else {
					if (fav == 0 && album_access == 2 && ero == 0)  out = [games['leader'],games['smstop']];
					if (vote_access == 1) out.push(games['x2']);
					out.push(games['megavote24']);
			}
		return out;
	},
	
	getPosition: function(target, obj, offsetY, offsetX, pos) {
		var _top = 0, _left = 0, deltaY = 0, deltaX = 0;
		
		if(offsetY != '' && parseInt(offsetY)) deltaY = parseInt(offsetY);  
		if(offsetX != '' && parseInt(offsetX)) deltaX = parseInt(offsetX);
		
		if (getWinSize().h + defScroll().y - absPosition(obj).y - deltaY < target.offsetHeight + 50) deltaY = target.offsetHeight *(-1) - 20;
		if (getWinSize().w + defScroll().x - absPosition(obj).x - deltaX < target.offsetWidth + 50)  deltaX = target.offsetWidth *(-1) - 20;

		if(offsetX == 'left') deltaX = target.offsetWidth *(-1) - 20;
			else if(offsetX == 'right') deltaX = 0;
	
		if(offsetY == 'top') deltaY = target.offsetHeight *(-1) - 20;
			else if(offsetY == 'bottom') deltaY = 0;
			
		
		if(pos == 'abs') {
			_top =  absPosition(obj).y;
			_left = absPosition(obj).x;
		}
		
		_top += deltaY + 20;
		_left+= deltaX + 20;
		
		return {top:_top,left:_left};
	},
	
	isOpened : function(id) {
		if (gebi(id)) {
			if(gebi(id).style.display == 'block') 
				return true; 
			else return false;
		}else return false;
	},
	
	hide : function() { 
		var els = gebc(this.defaultClassName, "div");
		for(var i = 0; i < els.length; i++) 
			if (els[i]) 
				if (els[i].style.display == 'block') {
					if(!this.openedGame) els[i].style.display = 'none';
						else els[i].parentNode.removeChild(els[i]);
					this.opened = "";
				}
		if(this.toggle) {
				this.toggle = false;
				this.toggleMainMenu();
		}

		if(this.light) {
				this.light = false;
				this.lightMenuItem();
				var obj = this.openObject;
				if (obj) obj.parentNode.style.zIndex = ""; //IE z-index fix
				this.openObject = "";
		}
		
		if (this.openedGame) this.openedGame = "";
		
	},
	
	toggleMainMenu : function() { 
					
			var mm = gebi(this.mainMenuId) ? gebi(this.mainMenuId) : false;
			if(!mm) return false;
			var overlay = gebi("__overlay") ? gebi("__overlay") : false;
						
			if (overlay) {
				overlay.parentNode.removeChild(overlay);
				return false;
			}else {
				var overlay = document.createElement("div");
				overlay.id = "__overlay";
				overlay.style.position = "absolute";
				overlay.style.top = "0";
				overlay.style.left = "0";
				overlay.style.width = mm.offsetWidth + "px";
				overlay.style.height = mm.offsetHeight + "px";
				var i = document.createElement("img");
				i.src = this.spacer;
				i.alt = "";
				i.style.width = mm.offsetWidth + "px";
				i.style.height = mm.offsetHeight + "px";
				overlay.appendChild(i);
				mm.appendChild(overlay);
				overlay.style.display = "block";
			}
	},
	
	lightMenuItem : function() {
		if (this.light) { //подсветить
			var _itemClass = this.itemClassPrefix + this.lightItem; 
			var _item = gebc(_itemClass, "li")[0];
			this.defaultClass = _item.className; 
			if(_item.className.indexOf(_itemClass + "-opened") == -1) {
				var pattern = new RegExp("("+ _itemClass + ")(\\s|$)");
				_item.className=_item.className.replace(pattern,"$1-opened$2");
				_item.getElementsByTagName("ul")[0].style.display = "block";
			}
		}else { 
			var _itemClass = this.itemClassPrefix + this.lightItem;
			var _item = gebc(_itemClass + "-opened", "li")[0];
			_item.className = str_replace(_itemClass + "-opened", _itemClass, _item.className);
			_item.getElementsByTagName("ul")[0].style.display = "";
		}
	}
};

var SMSInfo = {
	numbers : [//sms топ, лидер, 10 на час, оформить фото, шквал10 - 0.99уе
		{ 
		'4446' : [
					{"country" : "Россия" , "location" : "России", "id" : "rus"},
					{"country" : "Беларусь" , "location" : "Беларуси", "id" : "bel"}, 					
					{"country" : "Украина" , "location" : "Украине", "id" : "ukr"}, 
					{"country" : "Молдова" , "location" : "Молдове", "id" : "mol"}, 
					{"country" : "Армения" , "location" : "Армении", "id" : "arm"}, 
					{"country" : "Грузия" , "location" : "Грузии", "id" : "geo"}, 
					{"country" : "Таджикистан" , "location" : "Таджикистане", "id" : "taj"}, 
					{"country" : "Азербайджан" , "location" : "Азербайджане", "id" : "aze"},
					{"country" : "Узбекистан" , "location" : "Узбекистане", "id" : "uzb"}
				],
		'3350'  :  {"country" : "Казахстан" , "location" : "Казахстане", "id" : "kaz"}, 
		'1824'  :  {"country" : "Латвия" , "location" : "Латвии", "id" : "lat" },
		'1624'  :  {"country" : "Литва" , "location" : "Литве", "id" : "lit" },
		'1302'  :  {"country" : "Эстония" , "location" : "Эстонии", "id" : "est" },
		'82300' :  {"country" : "Германия" , "location" : "Германии", "id" : "ger" },
		'4070'  :  {"country" : "Израиль" , "location" : "Израиле", "id" : "izr" }
		},
	 
		{//x2, оформить альбом - 2.99 у.е.
		'4449' : [
					{"country" : "Россия" , "location" : "России", "id" : "rus"},
					{"country" : "Беларусь" , "location" : "Беларуси", "id" : "bel"}, 
					{"country" : "Молдова" , "location" : "Молдове", "id" : "mol"}, 
					{"country" : "Армения" , "location" : "Армении", "id" : "arm"}, 
					{"country" : "Таджикистан" , "location" : "Таджикистане", "id" : "taj"}, 
					{"country" : "Азербайджан" , "location" : "Азербайджане", "id" : "aze"},
					{"country" : "Узбекистан" , "location" : "Узбекистане", "id" : "uzb"}
				],
		'3352'  :  {"country" : "Казахстан" , "location" : "Казахстане", "id" : "kaz"}, 
		'4161'  :  {"country" : "Украина" , "location" : "Украине", "id" : "ukr"}, 
		'4107'  :  {"country"  : "Грузия" , "location" : "Грузии", "id" : "geo"}, 
		'1824'  :  {"country" : "Латвия" , "location" : "Латвии", "id" : "lat" },
		'1624'  :  {"country" : "Литва" , "location" : "Литве", "id" : "lit" },
		'1206'  :  {"country" : "Эстония" , "location" : "Эстонии", "id" : "est" },
		'82300' :  {"country" : "Германия" , "location" : "Германии", "id" : "ger" },
		'4070'  :  {"country" : "Израиль" , "location" : "Израиле", "id" : "izr" }
		},
	
		{//+10 на 24часа, шквал50 - 2.99 у.е.
		'4449' : [
					{"country" : "Россия" , "location" : "России", "id" : "rus"},
					{"country" : "Беларусь" , "location" : "Беларуси", "id" : "bel"}, 
					{"country" : "Украина" , "location" : "Украине", "id" : "ukr"},
					{"country" : "Молдова" , "location" : "Молдове", "id" : "mol"}, 
					{"country" : "Армения" , "location" : "Армении", "id" : "arm"}, 
					{"country" : "Таджикистан" , "location" : "Таджикистане", "id" : "taj"}, 
					{"country" : "Азербайджан" , "location" : "Азербайджане", "id" : "aze"},
					{"country" : "Узбекистан" , "location" : "Узбекистане", "id" : "uzb"}
				],
		'3352'  :  {"country" : "Казахстан" , "location" : "Казахстане", "id" : "kaz"}, 
		'4107'  :  {"country" : "Грузия" , "location" : "Грузии", "id" : "geo"}, 
		'1824'  :  {"country" : "Латвия" , "location" : "Латвии", "id" : "lat" },
		'1624'  :  {"country" : "Литва" , "location" : "Литве", "id" : "lit" },
		'1204'  :  {"country" : "Эстония" , "location" : "Эстонии", "id" : "est" },
		'82300' :  {"country" : "Германия" , "location" : "Германии", "id" : "ger" },
		'4070'  :  {"country" : "Израиль" , "location" : "Израиле", "id" : "izr" }
		},
		
		{//+10 на 7дней, шквал 200 - 4.99 у.е.
		'4161' : [
					{"country" : "Россия" , "location" : "России", "id" : "rus"},
					{"country" : "Беларусь" , "location" : "Беларуси", "id" : "bel"}, 
					{"country" : "Украина" , "location" : "Украине", "id" : "ukr"}, 
					{"country" : "Молдова" , "location" : "Молдове", "id" : "mol"}, 
					{"country" : "Казахстан" , "location" : "Казахстане", "id" : "kaz"},
					{"country" : "Грузия" , "location" : "Грузии", "id" : "geo"}, 					
					{"country" : "Таджикистан" , "location" : "Таджикистане", "id" : "taj"}

				],
		'8161'  :  {"country" : "Армения" , "location" : "Армении", "id" : "arm"},
		'8171'	:  {"country" : "Азербайджан" , "location" : "Азербайджане", "id" : "aze"},
		'1824'  :  {"country" : "Латвия" , "location" : "Латвии", "id" : "lat" },
		'1624'  :  {"country" : "Литва" , "location" : "Литве", "id" : "lit" },
		'1206'  :  {"country" : "Эстония" , "location" : "Эстонии", "id" : "est" },
		'82300' :  {"country" : "Германия" , "location" : "Германии", "id" : "ger" },
		'4070'  :  {"country" : "Израиль" , "location" : "Израиле", "id" : "izr" }
		},
		
		{//оформить фото 0.99уе
		'4446' : [
					{"country" : "Россия" , "location" : "России", "id" : "rus"}, 
					{"country" : "Беларусь" , "location" : "Беларуси", "id" : "bel"}, 
					{"country" : "Украина" , "location" : "Украины", "id" : "ukr"}, 
					{"country" : "Молдова" , "location" : "Молдовы", "id" : "mol"}, 
					{"country" : "Армения" , "location" : "Армении", "id" : "arm"}, 
					{"country" : "Грузия" , "location" : "Грузии", "id" : "geo"}, 
					{"country" : "Таджикистан" , "location" : "Таджикистана", "id" : "taj"}, 
					{"country" : "Азербайджан" , "location" : "Азербайджана", "id" : "aze"}
				],
		'3350'  :  {"country" : "Казахстан" , "location" : "Казахстане", "id" : "kaz"}, 
		'1824'  :  {"country" : "Латвия" , "location" : "Латвии", "id" : "lat" },
		'1624'  :  {"country" : "Литва" , "location" : "Литвы", "id" : "lit" },
		'1302'  :  {"country" : "Эстония" , "location" : "Эстонии", "id" : "est" },
		'82300' :  {"country" : "Германия" , "location" : "Германии", "id" : "ger" },
		'4070'  :  {"country" : "Израиль" , "location" : "Израиля", "id" : "izr" }
		},
	 
		{//оформить альбом 2.99уе
		'4449' : [
					{"country" : "Россия" , "location" : "России", "id" : "rus"},
					{"country" : "Беларусь" , "location" : "Беларуси", "id" : "bel"}, 
					{"country" : "Молдова" , "location" : "Молдовы", "id" : "mol"}, 
					{"country" : "Армения" , "location" : "Армении", "id" : "arm"}, 
					{"country" : "Таджикистан" , "location" : "Таджикистана", "id" : "taj"}, 
					{"country" : "Азербайджан" , "location" : "Азербайджана", "id" : "aze"},
					{"country" : "Узбекистан" , "location" : "Узбекистана", "id" : "uzb"}
				],
		'3352'  :  {"country" : "Казахстан" , "location" : "Казахстана", "id" : "kaz"}, 
		'4161'  :  {"country" : "Украина" , "location" : "Украины", "id" : "ukr"}, 
		'4107'  :  {"country" : "Грузия" , "location" : "Грузии", "id" : "geo"}, 
		'1824'  :  {"country" : "Латвия" , "location" : "Латвии", "id" : "lat" },
		'1624'  :  {"country" : "Литва" , "location" : "Литвы", "id" : "lit" },
		'1206'  :  {"country" : "Эстония" , "location" : "Эстонии", "id" : "est" },
		'82300' :  {"country" : "Германия" , "location" : "Германии", "id" : "ger" },
		'4070'  :  {"country" : "Израиль" , "location" : "Израиля", "id" : "izr" }
		}
	],
	id: "",
	opened : false,
	cookie :  "",
	cookieEnabled : navigator.cookieEnabled,
	userNumCont : "UserShortNumber",
	userCountryCont: "UserCountry",
	user_country : "",
	sms_number : "",
	user_location : "",
	default_sms_numbers : ["4446", "4449", "4449", "4161", "4446" ,"4449"],
	default_user_location : "России",
	default_user_country : "Россия",
	defaultClassName : "numberList",
	
	getCountry: function() { 
		this.user_country = getCookie("country_id"); 
		if (!this.user_country) this.user_country = this.default_user_country ;
	},
	
	setCountry: function(c,n,l,id) { 
		setCookie("country_id",c);
		this.user_country = c;
		this.setParams(id,n,l);
		//InfoBlock.changeGame(gebi("modeSelect"), InfoBlock.openedGroup);
		this.hide();
	},
	
	getParams : function(k) { 
	this.sms_number = this.default_sms_numbers[k];
	this.user_location = this.default_user_location;
		for(var i in this.numbers[k]) 
			if(this.numbers[k][i].length) {
				for (var j=0 ; j< this.numbers[k][i].length; j++){
				if (this.numbers[k][i][j]["id"] == this.user_country) { 
						this.sms_number = i; 
						this.user_location = this.numbers[k][i][j]["location"];
						break;
				}}
			}else{
				if (this.numbers[k][i]["id"] == this.user_country) {  
						this.sms_number = i; 
						this.user_location = this.numbers[k][i]["location"];
						break;
				}
			}
	},
			
	setParams: function(id,n,l) { 
		n = (typeof n == 'undefined') ? this.sms_number : n;
		l = (typeof l == 'undefined') ? this.user_location : l; 
		var uc = gebc(this.userCountryCont, "span"); 
		InfoBlock.openedGame = id;
		if (InfoBlock.openedGame != 'all') {
		var nc = gebi(this.userNumCont + "_" + id); 
		if (nc) nc.innerHTML = n; 
				
		}else {
			var gameHash = InfoBlock.getSMSHelp('all'); 
			for(var i = 0 ; i < gameHash.length; i++) {
			var nc = gebi(this.userNumCont + "_" + gameHash[i]["id"]); 
			this.getParams(gameHash[i]["kat"]); 
			if (nc) nc.innerHTML = this.sms_number;
		}
		}
		
		if (uc) for (var i = 0; i < uc.length; i++) if (uc[i]) uc[i].innerHTML = l;
	},
	
	getNumbersHTML : function(code, kat) { 
		var html = "";
		
html = "<div id=\"numberList_" + code + "\" class=\"smsgame contextInfo numberList\">\
			<div class=\"text-right close\"><a href=\"#\" onclick=\"SMSInfo.hide();return false;\"><img src=\"http://img.mail.ru/r/foto2/ico_close.gif\" border=\"0\" alt=\"Закрыть\" title=\"Закрыть\" /></a></div>\
			<div class=\"head\">\
				<span>Номер</span>\
				<span>Страна</span>\
			</div>\
			<ul class=\"ShortNumbers\">";
			for (var i in this.numbers[kat]) {
			if(i != "toJSONString") {
				if(this.numbers[kat][i].length > 1) {
					html += "<li class=\"group\">\
								<div class=\"num\">" + i + "</div>\
									<ul>";
					for (var j=0 ; j < this.numbers[kat][i].length; j++) 
						html += "<li onclick=\"SMSInfo.setCountry('" + this.numbers[kat][i][j]["id"] + "', '" + i + "', '" + this.numbers[kat][i][j]["location"] + "', '" + code + "')\">" + this.numbers[kat][i][j]["country"] + "</li>";
					
					html += "		</ul>\
								<div class=\"t\" ></div>\
								<div class=\"b\" ></div>\
							</li>\
							<li class=\"space\"></li>";
				}else {
					html += "<li>" + i ;
					html += "	<ul>\
									<li onclick=\"SMSInfo.setCountry('" + this.numbers[kat][i]["id"] + "', '" + i + "', '" + this.numbers[kat][i]["location"] + "', '" + code + "')\">" + this.numbers[kat][i]["country"] + "</li>\
								</ul>\
							</li>";
					}
			}
			}
		html += "</ul>\
		</div>";
														
		return html;
	},
	
	show: function(obj,evt) { 
		
		while(obj = obj.nextSibling) {  
			if (obj.nodeType == 1) if(obj.className.indexOf(this.defaultClassName) != -1) break;
		}
		id = obj.id; 
		
		if(this.opened == id) {
			this.hide();
			return false;
		}
		this.hide();
		cancelBubbling(evt);
		if(obj) {
			obj.style.display = "block";
			obj.style.visibility = "visible"; /*IE fix who knows why?*/
		}
		this.opened = id;
		this.id = id;
		addHandler(document, 'click', function(e) {
			var e = e || window.event;
			if (e.button == 0 )	SMSInfo.hide();
		});
		
		return false;
	},

	hide: function() {
		var els = gebc(this.defaultClassName, "div");
		for(var i = 0; i < els.length; i++) 
			if (els[i]) 
				if (els[i].style.display == 'block') {
					els[i].style.display = 'none';
					els[i].style.display.visibility = "hidden"; /*IE fix who knows why?*/
				}
		this.opened = false;
	},
	
	init : function(id, k) {
		this.getCountry();
		this.getParams(k);
		this.setParams(id);
		document.write(this.getNumbersHTML(id,k));
	}

}