function rewind() {
	$$('img[id=rnd_num]').setProperty('src', '/includes/rnd_image.php?n=' + $random(100000, 999999));
}

function popUpPic(w,h,link) {
	w = parseInt(w);
	h = parseInt(h);
	var new_window = window.open('','name','scrollbars,height=' + (h+70) + ',width=' + (w+50) + ''); 
	new_window.document.write('<html><head><title>Фото</title>');
	new_window.document.write('</head><body>');
	new_window.document.write('<p align=center><img src="' + link + '" border=0 onclick="self.close();" style="cursor:pointer; cursor:hand;" /></p>');
	new_window.document.write('<p align=center><a href=\"javascript:self.close()" style="font-size:12px;color:#0033FF;font-family:Arial">Закрыть окно</a></p>');
	new_window.document.write('</body></html>');
	new_window.document.close();
    return false;
}

/* jQuery Based code */

var NgrTours = (function() {
	
	var ni;
	
	var constants = {
		SRV_SCRIPT: '/ajax/tours.php?ajax'
	};	
	
	function constructor() {
		// Private members.
		
		return { 
			// Public members.
			topic_being_deleted: false,
			turfirmabox_html: null,
			turcountrbox_html: null,
			tourfirma_id: null,
			tourcountr_id: null,
			tourfirma_name: null,
			
			// Public methods
			
			nl2br: function(str, is_xhtml) {
				// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
				var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
				
				return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
			},
			
			trim: function(str, charlist) {
				// http://kevin.vanzonneveld.net
			
				var whitespace, l = 0, i = 0;
				str += '';
				
				if (!charlist) {
					// default list
					whitespace = " \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000";
				} else {
					// preg_quote custom list
					charlist += '';
					whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '$1');
				}
				
				l = str.length;
				for (i = 0; i < l; i++) {
					if (whitespace.indexOf(str.charAt(i)) === -1) {
						str = str.substring(i);
						break;
					}
				}
				
				l = str.length;
				for (i = l - 1; i >= 0; i--) {
					if (whitespace.indexOf(str.charAt(i)) === -1) {
						str = str.substring(0, i + 1);
						break;
					}
				}
				
				return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
			},			
			
			isset: function()
			{
				// discuss at: http://phpjs.org/functions/isset
				// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
				
				var a=arguments, l=a.length, i=0;
				
				if (l===0) {
					throw new Error('Empty isset'); 
				}
				
				while (i!==l) {
					if (typeof(a[i])=='undefined' || a[i]===null) { 
						return false; 
					} else { 
						i++; 
					}
				}
				return true;
			},
			
			in_array: function (needle, haystack, argStrict) {
				// http://kevin.vanzonneveld.net
			
				var key = '', strict = !!argStrict;
			
				if (strict) {
					for (key in haystack) {
						if (haystack[key] === needle) {
							return true;
						}
					}
				} else {
					for (key in haystack) {
						if (haystack[key] == needle) {
							return true;
						}
					}
				}
			
				return false;
			},	
			
			htmlspecialchars_decode: function (string, quote_style) {
				// http://kevin.vanzonneveld.net
			
				var optTemp = 0, i = 0, noquotes= false;
				if (typeof quote_style === 'undefined') {
					quote_style = 2;
				}
				string = string.toString().replace(/&lt;/g, '<').replace(/&gt;/g, '>');
				var OPTS = {
					'ENT_NOQUOTES': 0,
					'ENT_HTML_QUOTE_SINGLE' : 1,
					'ENT_HTML_QUOTE_DOUBLE' : 2,
					'ENT_COMPAT': 2,
					'ENT_QUOTES': 3,
					'ENT_IGNORE' : 4
				};
				if (quote_style === 0) {
					noquotes = true;
				}
				if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags
					quote_style = [].concat(quote_style);
					for (i=0; i < quote_style.length; i++) {
						// Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
						if (OPTS[quote_style[i]] === 0) {
							noquotes = true;
						}
						else if (OPTS[quote_style[i]]) {
							optTemp = optTemp | OPTS[quote_style[i]];
						}
					}
					quote_style = optTemp;
				}
				if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
					string = string.replace(/&#0*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should
					// string = string.replace(/&apos;|&#x0*27;/g, "'"); // This would also be useful here, but not a part of PHP
				}
				if (!noquotes) {
					string = string.replace(/&quot;/g, '"');
				}
				// Put this in last place to avoid escape being double-decoded
				string = string.replace(/&amp;/g, '&');
			
				return string;
			},
			
			strip_tags: function(str, allowed_tags) {
				// http://kevin.vanzonneveld.net
			
				var key = '', allowed = false;
				var matches = [];
				var allowed_array = [];
				var allowed_tag = '';
				var i = 0;
				var k = '';
				var html = '';
			
				var replacer = function (search, replace, str) {
					return str.split(search).join(replace);
				};
			
				// Build allowes tags associative array
				if (allowed_tags) {
					allowed_array = allowed_tags.match(/([a-zA-Z0-9]+)/gi);
				}
			
				str += '';
			
				// Match tags
				matches = str.match(/(<\/?[\S][^>]*>)/gi);
			
				// Go through all HTML tags
				for (key in matches) {
					if (isNaN(key)) {
						// IE7 Hack
						continue;
					}
			
					// Save HTML tag
					html = matches[key].toString();
			
					// Is tag not in allowed list? Remove from str!
					allowed = false;
			
					// Go through all allowed tags
					for (k in allowed_array) {
						// Init
						allowed_tag = allowed_array[k];
						i = -1;
			
						if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+'>');}
						if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+' ');}
						if (i != 0) { i = html.toLowerCase().indexOf('</'+allowed_tag)   ;}
			
						// Determine
						if (i == 0) {
							allowed = true;
							break;
						}
					}
			
					if (!allowed) {
						str = replacer(html, "", str); // Custom replace. No regexing
					}
				}
			
				return str;
			},			
			
			setCookie: function(sName, sValue, oExpires, sPath, sDomain, bSecure) {
				var sCookie = sName + "=" + encodeURIComponent(sValue);
				if (oExpires) {
					sCookie += "; expires=" + oExpires.toGMTString();
				}
				
				if (sPath) {
					sCookie += "; path=" + sPath;
				}
				
				if (sDomain) {
					sCookie += "; domain=" + sDomain;
				}
				
				if (bSecure) {
					sCookie += "; secure";
				}
				
				document.cookie = sCookie;
			},
			
			getCookie: function(sName) {
				var sRE = "(?:; )?" + sName + "=([^;]*);?";
				var oRE = new RegExp(sRE);
				if (oRE.test(document.cookie)) {
					return decodeURIComponent(RegExp["$1"]);
				} else {
					return null;
				}
			},
			
			deleteCookie: function(sName, sPath, sDomain) {
				ni.setCookie(sName, "", new Date(Date.parse("Jan 1, 1980")), sPath, sDomain);
			},
			
			getConstant: function(name) {
				return constants[name];
			},	
			
			hideAlertWindow: function() {
				ngrjQ("#debug_info").remove();
			},
			
			showAlertWindow: function(html,closelink,isloading,autoclose,cssobj) {
				if (ni.isset(closelink) === false) {
					closelink = true;
				}

				if (ni.isset(cssobj) === false) {
					cssobj = {backgroundColor:"#CCCCCC", padding:"10px", border:"2px solid #993300", zIndex:"1000", fontSize:"12px", fontFamily:"Arial"};
				}

				isloading = isloading || false;
				autoclose = autoclose || false;
				ngrjQ("body").append('<div id="debug_info"></div>');
				
				if (isloading) {
					ngrjQ("#debug_info")
					.css({backgroundColor:"#FFF", padding:"10px", border:"1px solid #993300", zIndex:"1000", fontSize:"12px", fontFamily:"Arial"})
					.html('<img src="http://pics.nashgorod.ru/i/is_load.gif" width="16" height="16" align="absmiddle" /> Идет загрузка&hellip;');
				} else {
					ngrjQ("#debug_info")
					.css(cssobj)
					.html(html);
					
					if (autoclose == false && closelink) {
						ngrjQ("#debug_info").append('<div style="margin-top:25px;"><a href="#" id="hidealert">закрыть</a></div>');
						ngrjQ("#hidealert").bind("click", function(e){
							ni.hideAlertWindow();
							return false;
						});
					}
				}
				
				ngrjQ("#debug_info").centerInClient();
				
				if (autoclose) {
					setTimeout(ni.hideAlertWindow,1500);
				}
			},
			
			gi: function(id) {
				return document.getElementById(id);
			},
			
			addObvl: function() {
					
				//var tourfirma_id = ni.getCookie("tourfirma_id");
				var tourfirma_id = ni.tourfirma_id;
				if (tourfirma_id == null) {
					alert('Выберите, пожалуйста, турфирму из выпадающего списка в соответствующем поле.');
					ni.gi('turfirmabox').focus();
					return false;
				}
				
				var tourname = ni.trim(ni.gi('turname').value);
				if (tourname == '') {
					alert('Укажите название тура.');	
					ni.gi('turname').focus();
					return false;
				}
						
				//var tourcountr_id = ni.getCookie("tourcountr_id");
				var tourcountr_id = ni.tourcountr_id;
				if (tourcountr_id == null) {
					alert('Выберите, пожалуйста, страну из выпадающего списка в соответствующем поле.');
					ni.gi('turcountry').focus();
					return false;
				}
										
				var tour_dates = [];
				var inpt = ngrjQ("#obvldates > tbody > tr > td > input.tourdatainput");
				for (var i=0; i<inpt.length; i++) {
					tour_dates.push(inpt[i].value);
				}
				
				if (ni.trim(ngrjQ("#tuda").val()) != '' && ni.trim(ngrjQ("#obratno").val()) != '') {
					if (ni.checkTourData(ngrjQ("#tuda").val(), ngrjQ("#obratno").val(), ngrjQ("#price").val())) {
						tour_dates.push(ngrjQ("#tuda").val() + ':' + ngrjQ("#obratno").val() + ':' + ngrjQ("#price").val() + ':' + ni.gi("obvlcurr").selectedIndex);
					} else {
						return false;	
					}
				}
				
				if (tour_dates.length == 0) {
					alert('Укажите даты тура');
					return false;
				}
				
				tour_dates = tour_dates.join("||");
				
				var tour_descr = tinyMCE.get('dynmce').getContent();
				if (ni.trim(ni.strip_tags(tinyMCE.get('dynmce').getContent())) == '') {
					alert('Укажите описание тура.');	
					return false;
				}				
				
				var rnd = ni.gi('rnd').value;
				if (ni.trim(rnd) == '') {
					alert('Укажите цифры с картинки.');	
					ni.gi('rnd').focus();
					return false;
				}				
				
				ngrjQ.ajax({
					url:    	ni.getConstant('SRV_SCRIPT') + '&addtour',
					success: 	function(responseText) {
									if (ni.isset(responseText.error)) {
										alert(responseText.error);
									} else {
										alert('Тур добавлен.');
										ngrjQ('#hot_tours_ul').prepend('<li><a href="/turpred/?tid=' + responseText.tour_id + '" class="tour_name_link">' + tourname + '</a> <nobr><strong>от ' + responseText.tour_price + ' ' + ni.gi("obvlcurr").options[ni.gi("obvlcurr").selectedIndex].text + '</strong></nobr><br><a class="firm_link" href="/catalog/turisticheskie-agentstva/p' + tourfirma_id + '_107.html">' + ni.tourfirma_name + '</a></li>');
										ni.hideAddObvlForm();
									}
								},
					type: 		"POST",
					dataType: 	"json",
					data:		{'tourfirma_id': tourfirma_id, 'tourname': tourname, 'tourcountr_id': tourcountr_id, 'tour_dates': tour_dates, 'tour_descr': tour_descr, 'rnd': rnd}
				}); 				
			},
			
			hideAddObvlForm: function() {
				tinyMCE.triggerSave();
				tinyMCE.execCommand('mceRemoveControl',true,'dynmce');			
				ngrjQ("#greyback").remove();
				ni.hideAlertWindow();
			},
			
			showAddObvlForm: function() {
				
				var turfirma_name = ni.tourfirma_name =ni.getCookie("tourfirma_name");
				var turfirmabox = '<input type="text" id="turfirma" onclick="{if(this.value==\'начните набирать название турфирмы здесь\'){this.value=\'\'}}" value="начните набирать название турфирмы здесь">';
				if (turfirma_name != null) {
					ni.turfirmabox_html = turfirmabox;
					ni.tourfirma_id = ni.getCookie("tourfirma_id");
					turfirmabox = turfirma_name + ' &nbsp;&nbsp; <a href="javascript:void(0);" title="Изменить турфирму" onclick="ngr_tours.changeTurfirm();return false;"><img src="http://pics.nashgorod.ru/i_news/delete.png" border=0 width=16 height=16 align="absmiddle" /></a>';
				} 				
				
				var tourcountr_name = ni.getCookie("tourcountr_name");
				var turcountrybox = '<input type="text" id="turcountry" onclick="{if(this.value==\'начните набирать название страны здесь\'){this.value=\'\'}}" value="начните набирать название страны здесь" style="width:250px;">';
				if (tourcountr_name != null) {
					ni.tourcountr_id = ni.getCookie("tourcountr_id");
					ni.turcountrbox_html = turcountrybox;
					turcountrybox = tourcountr_name + ' &nbsp;&nbsp; <a href="javascript:void(0);" title="Изменить страну" onclick="ngr_tours.changeCountry();return false;"><img src="http://pics.nashgorod.ru/i_news/delete.png" border=0 width=16 height=16 align="absmiddle" /></a>';
				} 				
				
				var ht = '\
					<div style="font-size:16px; color:#eb3d00;font-family:Tahoma;margin-bottom:10px;">Добавление нового тура</div>\
						<div id="aep_w">\
						<table id="addObvlTable">\
						  <tr>\
							<td class="tdname">Турфирма:</td>\
							<td class="tdinput" id="turfirmabox">' + turfirmabox + '</td>\
						  </tr>\
						  <tr>\
							<td class="tdname">Название тура:</td>\
							<td class="tdinput"><input type="text" id="turname"></td>\
						  </tr>\
						  <tr>\
							<td class="tdname">Страна:</td>\
							<td class="tdinput" id="turcountrybox">' + turcountrybox + '\
						  </tr>\
						  <tr>\
							<td class="tdname">Даты:</td>\
							<td>\
								<table id="obvldates">\
								  <tr>\
									<td class="tdnamedate" nowrap="nowrap" width="130">Туда <input type="text" id="tuda" style="width:70px"></td>\
									<td class="tdnamedate" nowrap="nowrap">Обратно <input type="text" id="obratno" style="width:70px"></td>\
									<td class="tdnamedate" nowrap="nowrap">Цена, от <input type="text" id="price" style="width:60px" onkeyup="ngr_tours.acceptOnly(this,3)"> &nbsp;&nbsp; <select id="obvlcurr"><option value="1">руб.<option value="2">у.е.</select></td>\
									<td align="center" nowrap="nowrap" width="18"><a href="javascript:void(0);" title="Нажимте сюда, чтобы добавить следующую дату тура" onclick="ngr_tours.addNextTourDate();"><img src="/images/link_add.png" width="14" height="14" style="cursor:hand;cursor:point;" border="0" /></a></td>\
								  </tr>\
								</table>\
								</td>\
						  </tr>\
						  <tr>\
							<td class="tdname" colspan=2>Описание:<br>\
							<textarea style="width:580px;height:110px;" id="dynmce"></textarea>\
							</td>\
						  </tr>\
						  <tr>\
							<td class="tdname">Введите цифры с картинки:</td>\
							<td class="tdinput"><input type="text" id="rnd" style="width:40px;" onKeyPress="if((event.keyCode==10)||(event.keyCode==13)) ngr_tours.addObvl(); if (event.keyCode==27) ngr_tours.hideAddObvlForm();">&nbsp;<img src="/includes/rnd_image.php?' + ni.getRandomValue() + '" id="rnd_img">&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onclick="ngr_tours.rndUpdate();" title="Обновить цифры" style="padding:3px;border:1px solid #000000;"><img src="/images/arrow_refresh.png" width="16" height="16" border="0" /></a></td>\
						  </tr>\
						  </table>\
						<div style="margin-top:10px;"><a href="javascript:void(0);" onclick="ngr_tours.addObvl();"><img src="http://pics.nashgorod.ru/i/map/ok_btn.gif" width="37" height="26" border="0" align="absmiddle"  alt="OK" /></a> &nbsp; <a href="#" onclick="ngr_tours.hideAddObvlForm();return false;"><img src="http://pics.nashgorod.ru/i/map/cancel_btn.gif" width="74" height="26" border="0" align="absmiddle" alt="Отмена" /></a>\
							</div>\
						</div>';
				
				ni.showAlertWindow(ht, false, false, false, {backgroundColor:"#FFFFFF", padding:"10px", border:"1px solid #9b9b9b", zIndex:"1000", fontSize:"12px", fontFamily:"Arial"});
				
				ngrjQ("body").append('<div id="greyback"></div>');
				ngrjQ("#greyback")
				.css({backgroundColor:"#000", zIndex:"900", width:"100%", height:ngrjQ(document).height(), cursor:"pointer", top:"0", left:"0", position:"absolute", opacity:"0.5"})
				.bind("click", function(e){
							ni.hideAddObvlForm();
						});
			},
			
			rndUpdate: function() {
				ni.gi('rnd_img').src = '/includes/rnd_image.php?' + ni.getRandomValue();
			},
			
			getRandomValue: function() {
				return Math.round(Math.random()*1000);
			},
			
			addNextTourDate: function() {
				if (ni.checkTourData(ngrjQ("#tuda").val(), ngrjQ("#obratno").val(), ngrjQ("#price").val())) {
					ngrjQ('#obvldates > tbody:last').append('<tr><td colspan="3" align="right" style="padding:4px;"><input type="hidden" class="tourdatainput" value="' + ngrjQ("#tuda").val() + ':' + ngrjQ("#obratno").val() + ':' + ngrjQ("#price").val() + ':' + ni.gi("obvlcurr").selectedIndex + '">' + ngrjQ("#tuda").val() + ' &mdash; ' + ngrjQ("#obratno").val() + ', цена ' + ngrjQ("#price").val() + ' ' + ni.gi("obvlcurr").options[ni.gi("obvlcurr").selectedIndex].text + '</td><td width="18" nowrap="nowrap" align="left"><a href="#" title="Удалить эту дату тура" onclick="ngr_tours.deleteTourDate(this);return false;"><img src="http://pics.nashgorod.ru/i_news/delete.png" border=0 width=16 height=16 align="absmiddle" /></a>&nbsp;</td></tr>');
					
					ngrjQ("#tuda").val('');
					ngrjQ("#obratno").val('');
					ngrjQ("#price").val('');
				}
			},
			
			checkTourData: function(tuda, obratno, price) {
				if (ni.isValidDate(tuda) && ni.isValidDate(obratno)) {
					if ((parseInt(price) * 10) > 10) {
						/* сравним даты */
						
						/* see http://www.hunlock.com/blogs/The_Complete_Javascript_Number_Reference on dates*/
						var tuda_arr = tuda.split(".");
						var obratno_arr = obratno.split(".");
						
						var dTuda = new Date(parseInt(tuda_arr[2]), parseInt(tuda_arr[1],10)-1, parseInt(tuda_arr[0],10));
						var dObratno = new Date(parseInt(obratno_arr[2]), parseInt(obratno_arr[1],10)-1, parseInt(obratno_arr[0],10));
						
						if (dTuda.getTime() > dObratno.getTime()) {
							alert('Дата "Туда" больше, чем дата "Обратно".');
							return false;
						} else if (dTuda.getTime() == dObratno.getTime()) {
							alert('Дата "Туда" такая же, как и дата "Обратно".');
							return false;
						}
						
						return true;
					
					} else {
						alert('Укажите стоимость');	
						return false;
					}
					
				} else {
					alert('Проверьте даты тура.');	
					return false;
				}
			},
			
			isValidDate: function (sText) {
				var reDate = /(?:0[1-9]|[12][0-9]|3[01])\.(?:0[1-9]|1[0-2])\.(?:19|20\d{2})/;
				return reDate.test(sText);
			},	
			
			deleteTourDate: function(aObj) {
				if (confirm('Удалить эту дату у тура?')) {
					tr = aObj;
					while (tr.tagName != 'TR') tr = tr.parentNode;
					tr.parentNode.removeChild(tr);
				}
			},
			
			changeTurfirm: function() {
				ni.deleteCookie('tourfirma_name', "/");
				ni.deleteCookie('tourfirma_id', "/");
				ni.tourfirma_id = null;
				ngrjQ("#turfirmabox").html(ni.turfirmabox_html);
				ni.registerAutocomplete();
			},
			
			changeCountry: function() {
				ni.deleteCookie('tourcountr_name', "/");
				ni.deleteCookie('tourcountr_id', "/");
				ni.tourcountr_id = null;
				ngrjQ("#turcountrybox").html(ni.turcountrbox_html);
				ni.registerAutocomplete();
			},
			
			registerAutocomplete: function() {
				ngrjQ("#turfirma").
				autocomplete(ni.getConstant('SRV_SCRIPT') + '&getturfirms', {
					width: 300,
					selectFirst: false,
					autoFill: false,
					scroll: true,
					max: 30,
					matchContains: false,
					cacheLength: 1, /* no cache*/
					scrollHeight: 220
				}).
				result(function(event, data, formatted) {
					ni.setCookie('tourfirma_name', data[0], new Date(Date.parse("Jan 1, 2020")), "/");
					ni.setCookie('tourfirma_id', data[1], new Date(Date.parse("Jan 1, 2020")), "/");
					ni.turfirmabox_html = ngrjQ("#turfirmabox").html();
					ni.tourfirma_id = data[1];
					ni.tourfirma_name = data[0];
					ngrjQ("#turfirmabox").html(data[0] + ' &nbsp;&nbsp; <a href="javascript:void(0);" title="Изменить турфирму" onclick="ngr_tours.changeTurfirm();return false;"><img src="http://pics.nashgorod.ru/i_news/delete.png" border=0 width=16 height=16 align="absmiddle" /></a>'); 
				});
				
				ngrjQ("#turcountry").
				autocomplete(ni.getConstant('SRV_SCRIPT') + '&getcountries', {
					width: 250,
					selectFirst: false,
					autoFill: false,
					scroll: true,
					max: 30,
					matchContains: false,
					cacheLength: 1, /* no cache*/
					scrollHeight: 220
				}).
				result(function(event, data, formatted) {
					ni.setCookie('tourcountr_name', data[0], new Date(Date.parse("Jan 1, 2020")), "/");
					ni.setCookie('tourcountr_id', data[1], new Date(Date.parse("Jan 1, 2020")), "/");
					ni.turcountrbox_html = ngrjQ("#turcountrybox").html();
					ni.tourcountr_id = data[1];
					ngrjQ("#turcountrybox").html(data[0] + ' &nbsp;&nbsp; <a href="javascript:void(0);" title="Изменить страну" onclick="ngr_tours.changeCountry();return false;"><img src="http://pics.nashgorod.ru/i_news/delete.png" border=0 width=16 height=16 align="absmiddle" /></a>'); 
				});
			},
			
			/**
			 * prevents user to input certain charatcers in textfields
			 * @param {Object} objtextbox - input field or textarea
			 * @param {Integer} what - had to use integer because while parsing 'geometry_html_template.html' ' - causes errors
			 * @usage <input type="text" name="txttest" id="txttest" onkeyup="ngrMapUI.acceptOnly(this)" />
			 */
			acceptOnly: function(objtextbox, what) {
				var what = what || 1;
				
				switch(what) {
					case 3:
						var regExpr = /[^(\d|.|,)]/gi;
					break;
		
					case 2:
						var regExpr = /[^(\d|\/|а|б|в|г|д|е|ё|ж|з|и|й|ё|к|л|м|н|о|п|р|с|т|у|ф|х|ц|ч|ш|щ|ъ|ы|ь|э|ю|я)]/gi;
					break;
		
					default:
						var regExpr = /[^\d]/g;
					break; 			
				}
				
				objtextbox.value = objtextbox.value.replace(regExpr,'');
			}
			
		}
	}	
	
	return {
		initialize: function () {
			if (!ni) {
				ni = constructor();
				
				if (ngrjQ('#addobvllink')) {
					ngrjQ("#addobvllink").bind("click", function(e){
						ni.showAddObvlForm();
						tinyMCE.execCommand('mceAddControl',true,'dynmce');
						ngrjQ("#tuda").datepicker(ngrjQ.datepicker.regional['ru']);
						ngrjQ("#obratno").datepicker(ngrjQ.datepicker.regional['ru']);
						ni.registerAutocomplete();
						return false;
					});
				}
			}
			
			return ni;			
		}
	}
	
})();	

var ngr_tours;	
ngrjQ(function() {
	ngr_tours = NgrTours.initialize();
});	
