var
	monthNames 				= new Array("Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"),
	weekdayNames			= new Array("Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота");



	//	Open new window at right side of screen

	function openNewWindow(url, name, width, height, bRandomPosition) {
		try {
			if (typeof(name) == 'undefined') {
				name = url.replace(/\.html$/i, "");
			}
		
			name = name.replace(/[\/\-]/g, "");

			
			if (typeof(width) == 'undefined') {
				width = 380;

			} else if (width > window.screen.availWidth) {
				width = window.screen.availWidth;
			}
		
			
			
			if (typeof(height) == 'undefined') {
				height = 545;
			
			} else if (height > window.screen.availHeight) {
				height = window.screen.availHeight;
			}

			
			var
				wnd = window.open(url, 'newwindow_' + name, 'scrollbars=yes,width=' + width + ',height=' + height + (bRandomPosition == true ? '' : ',top=10,left=' + (window.screen.availWidth - width - 20)));

			wnd.focus();
			return false;
	
		} catch (e) {
			return true;
		}
	}
	
	
	
	//	Check e-mail address validity
	
	function CheckEmail(email) {
		if (email.search(/^[a-z0-9\'\-_]+[a-z\'0-9\-_.]*@[a-z0-9\-_]+[a-z0-9\-_.]*\.[a-z]{2,4}$/i) == -1) {
			return false;
		}

		return true;
	}
	
	
	//	Check phone number validity
	
	function CheckPhoneNumber(phoneNumber) {
		if (phoneNumber.search(/^\+?[\d\(\)\s\-]+$/) == -1) {
			return false;
		}
		
		return true;
	}
	


	function rtrim(str) {
		return str.replace(/\s+$/g,"");
	}

	function ltrim(str) {
		return str.replace(/^\s+/g, "");
	}

	function trim(str) {
		str += '';
		return str.replace(/\s+$|^\s+/g, "");
	}

	function externalLinkOpen(objLink) {
		try {
			window.open(objLink.getAttribute('newhRef'), "newexternawindow", "toolbar=1,location=1,status=1,scrollbars=1,resizable=1");
			return false;
		} catch (ee) {
			return true;
		}
	}


//	Flash detected

var
	requiredVersion					= 5, // Version the user needs to view site (max 7, min 2)
	
	flash2Installed					= false,
	flash3Installed					= false,
	flash4Installed					= false,
	flash5Installed					= false,
	flash6Installed					= false,
	flash7Installed					= false,
	
	maxVersion						= 7,
	actualVersion					= 0,
	
	isIE		= (navigator.appVersion.indexOf("MSIE") != -1)		? true : false,
	isWin		= (navigator.appVersion.indexOf("Windows") != -1)	? true : false,
	
	bFlashPresent					= false;
			
	if(isIE && isWin){
		document.write('<SCR' + 'IPT language="VBScript"\> \n');
		document.write('on error resume next \n');
		document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
		document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
		document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
		document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
		document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
		document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
		document.write('</SCR' + 'IPT\> \n');
	}
	
	function detectFlash() {  
		if (navigator.plugins) {
			if (
				navigator.plugins["Shockwave Flash 2.0"]
				||
				navigator.plugins["Shockwave Flash"]
			) {
				var
					isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "",
					flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description,
					flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
				
				// DEBUGGING: uncomment next line to see the actual description.
				//alert("Flash plugin description: " + flashDescription);
				
				flash2Installed = flashVersion == 2;
				flash3Installed = flashVersion == 3;
				flash4Installed = flashVersion == 4;
				flash5Installed = flashVersion == 5;
				flash6Installed = flashVersion == 6;
				flash7Installed = flashVersion >= 7;
			}
		}
		
		for (var i = 2; i <= maxVersion; i++) {	
			if (eval("flash" + i + "Installed") == true) actualVersion = i;
		}
		
		if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 2;	
		
		//	uncomment next line to display flash version during testing
		//alert("version detected: " + actualVersion);
		
		if (actualVersion >= requiredVersion) {
			bFlashPresent = true;
		}
	}


	detectFlash();


	function WordsBreak(text, width)
	{
		text = text.replace(/\s+/ig," ");
		text = text.replace(/^\s+|\s+$/ig,"");
	
		var words = text.split(" ");
		
		for (i=0; i < words.length;i++)
		{
			if (words[i].length > width)
			{
				words[i] = words[i].replace('/(^|[^&])([^&;]{2})([^&;]{2})([^;]|$)/', '\\1\\2' + '&shy;' + '\\3\\4');
			}
		}

		return words.join(' ');
	}

	function dynamicTranslit()
	{

		//var oJSF = new dynamicTranslit();
		//..
		//<intut onKeyUp="oJSL.strNormalize(this, targetID);" > 

		this.strTranslit = function(el, toID)
		{
			new_el = document.getElementById(toID);
			A = new Array();
			A["Ё"]="YO";A["Й"]="I";A["Ц"]="TS";A["У"]="U";A["К"]="K";A["Е"]="E";A["Н"]="N";A["Г"]="G";A["Ш"]="SH";A["Щ"]="SCH";A["З"]="Z";A["Х"]="H";A["Ъ"]="'";
			A["ё"]="yo";A["й"]="i";A["ц"]="ts";A["у"]="u";A["к"]="k";A["е"]="e";A["н"]="n";A["г"]="g";A["ш"]="sh";A["щ"]="sch";A["з"]="z";A["х"]="h";A["ъ"]="'";
			A["Ф"]="F";A["Ы"]="I";A["В"]="V";A["А"]="A";A["П"]="P";A["Р"]="R";A["О"]="O";A["Л"]="L";A["Д"]="D";A["Ж"]="ZH";A["Э"]="E";
			A["ф"]="f";A["ы"]="i";A["в"]="v";A["а"]="a";A["п"]="p";A["р"]="r";A["о"]="o";A["л"]="l";A["д"]="d";A["ж"]="zh";A["э"]="e";
			A["Я"]="YA";A["Ч"]="CH";A["С"]="S";A["М"]="M";A["И"]="I";A["Т"]="T";A["Ь"]="'";A["Б"]="B";A["Ю"]="YU";
			A["я"]="ya";A["ч"]="ch";A["с"]="s";A["м"]="m";A["и"]="i";A["т"]="t";A["ь"]="'";A["б"]="b";A["ю"]="yu";A[" "]="_";
			new_el.value = el.value.replace(/([\u0410-\u0451 ])/g,
				function (str,p1,offset,s) 
				{
					if (A[str] != 'undefined')
					{
						return A[str];
					}
				}
    		);
		}
	
    	this.strNormalize = function(el,toID)
    	{
	    	if (!el) { return; }
	    	if (!toID) { return; }
	    	this.strTranslit(el,toID);
		}
	}
    
