function generateFlashMenu(movie, width, height, id, text, sound)
		{
		  document.write('<object type="application/x-shockwave-flash" data="'+movie+'" width="'+width+'" height="'+height+'" id="'+id+'" align="left">');
		  document.write('<param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" />');
		  document.write('<param name="movie" value="'+movie+'" />');
		  document.write('<param name="wmode" value="transparent" />');
		  document.write('<param name="autoStart" value="-1" />');
		  document.write('<embed src="'+movie+'?string=Милые дамы и почтенные господа! Мы рады приветствовать Вас на нашем официальном сайте&soundUrl='+ sound +'" quality="high" bgcolor="#000000" width="'+width+'" height="'+height+'" name="'+id+'" align="left" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		  document.write('</object>');
		}


	


function generateFlash(movie, width, height, id, align, bgUrl, bLink)
{
  document.write('<div class="baner-flash" style="background:url(' + bgUrl + ') no-repeat left top;' + + (height==0 ? '' : ' height:'+height +'px;') + '"' + (width==0 ? '' : ' width="'+width +'"') + '>');
  document.write('<div class="itsflash"><object type="application/x-shockwave-flash" data="'+movie+(width==0 ? '' : '" width="'+width)+(height==0 ? '' : '" height="'+height)+'" id="'+id+'" align="'+align+'">');
  document.write('<param name="movie" value="'+movie+'" />');
  document.write('<param name="wmode" value="opaque" />');
  document.write('<param name="autoStart" value="-1" />');
  document.write('</object><a href="' + bLink + '" style="height: ' + height + 'px;"></a></div>');
  document.write('</div>');
}

function changeFlashSize(h) {
	menuContainer = document.getElementById('menu');
	menuContainer.style.height = h + 'px';
}


function twocolors() {
	var tables = document.getElementsByTagName("table");
	for ( var k = 0; k < tables.length; k++ ) {
		if (tables[k].className == 'twocolors') {
			var rows = tables[k].getElementsByTagName("tr");
			for ( var i = 0; i < rows.length; i += 2 )
			rows[i].className = rows[i].className + " darktr"
			for ( var i = 1; i < rows.length; i += 2 )
			rows[i].className = rows[i].className + " lighttr"
		}
	}			

	var tables = document.getElementsByTagName("ul");
	for ( var k = 0; k < tables.length; k++ ) {
		if (tables[k].className == 'twocolors') {
			var rows = tables[k].getElementsByTagName("li");
			for ( var i = 0; i < rows.length; i += 2 )
			rows[i].className = rows[i].className + " darktr"
			for ( var i = 1; i < rows.length; i += 2 )
			rows[i].className = rows[i].className + " lighttr"
		}
	}			
}



function alertPopup(blockId) {
	popups = getClass ('popup-win');
	for (i = 0; i<popups.length; i++) {
		hidePopup(popups[i]);
	}

	document.getElementById(blockId).style.display = 'block';
}


function hidePopup(block) {
	block.style.display = 'none';
}



function getClass(name,type) {
        var r = [];
        var re = new RegExp("(^| )" + name + "( |$)");

        var e = document.getElementsByTagName(type || "*");
        for ( var i = 0, len = e.length; i < len; i++ )
                if ( re.test(e[i].className) ) r.push( e[i] );
        return r;
}


	function calculateWidth() {
		maxWidth=665;
		bodyWidth = window.document.body.offsetWidth
		leftWidth = Math.round( bodyWidth * 0.37);
		leftFloat = getClass('left-float','div');
		rightFloat = getClass('right-float','div');
		if (leftWidth > maxWidth) {
			for (i=0; i<leftFloat.length; i++) {
				leftFloat[i].style.width= maxWidth + 'px';
			}
			for (i=0; i<rightFloat.length; i++) {
				rightFloat[i].style.marginLeft=maxWidth + 'px';
			}
		} else {
			for (i=0; i<leftFloat.length; i++) {
				leftFloat[i].style.width= '37%';
			}
			for (i=0; i<rightFloat.length; i++) {
				rightFloat[i].style.marginLeft= '37%';
			}
		}
//		alert('maxWidth=' + maxWidth + '; bodyWidth=' + bodyWidth + '; leftWidth=' + leftWidth + '; leftFloat.length=' + leftFloat.length + '; rightFloat.length=' + rightFloat.length)
	}



function showHide(id)
{
    obj = $('div#' + id)[0];
    if (obj.style.display == 'block')  {
        $('div#' + id).hide('fast')
    } else {
        $('div#' + id).show('fast')
    }
    return true;
}

function show(id)
{
    obj = $('div#' + id)[0];
    if (obj.style.display != 'block')  {
        $('div#' + id).show('fast')
    }
}

function popupWindow(fileUrl, winW, winH, winN, scrollB) {
	var winWidth = winW;
	var winHeight = winH;
	var winName = (winN)? winN : 'popupWin'
	var scrollBars = (scrollB)? scrollB : 'auto'
	/*if (nn4 || ie4 || dom) {
		if (screen.width < winWidth + 50) { winWidth = screen.width - 50; scrollbars = 'yes' }
		if (screen.height < winHeight + 100) { winHeight = screen.height - 100; scrollbars = 'yes' }
		posX = Math.round((screen.width - winWidth) / 2);
		posY = Math.round((screen.height - winHeight) / 2);
		posCode = (nn4 || dom)? "screenX="+posX+",screenY="+posY : "left="+posX+",top="+posY;
	} else {*/
		posCode = "";
	//}
	var popupWin = window.open(fileUrl, winName,"menubar=no,toolbar=no,scrollbars=" + scrollBars + ",status=yes,resizable=yes,width=" + winWidth + ",height=" + winHeight + "," + posCode);
	if (popupWin) popupWin.focus();
}

/**
* Обработка поля ввода
*/

function inputController()
{

}

inputController.object = null;
inputController.button = null;
inputController.classActive = '';
inputController.classInactive = '';
inputController.defaultValue = '';
inputController.isSubmitable = ''; 

inputController.prototype.init = function(inputId, buttonId)
{
    // настройки
    this.classInactive = 'inputFieldInactive';
    this.classActive = 'inputFieldActive';
    this.defaultValue = 'Введите поисковый запрос';
    this.isSubmitable = false;

    this.object = document.getElementById(inputId);
    this.button = document.getElementById(buttonId);
    
    this.object.className = this.classInactive;
    this.object.value = this.defaultValue;
    
    
    
}

inputController.prototype.clear = function()
{
    if ( this.object.value == this.defaultValue) {
        this.object.value = '';
    }
    this.object.className = this.classActive;
}

inputController.prototype.lostFocus = function()
{
    if (this.object.value == '' ||  this.object.value == this.defaultValue) {
        this.object.value = this.defaultValue;
        this.object.className = this.classInactive;
    }
}

inputController.prototype.keyPressed = function()
{
    if (this.object.value != '') {
        this.isSubmitable = true;
    } else {
        this.isSubmitable = false;
    }
}

inputController.prototype.submit = function()
{
    if (this.isSubmitable) {
        return true;
    } 
    else return false;
}

function makeNiceOls() {
	var alpha = new Array('a', 'b', 'c', 'd', 'e', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p');
	var ols = document.getElementsByTagName('OL');
	for(i=0; i<ols.length; i++) {
		if (ols[i].parentNode.tagName == 'DIV') {
			for(j=0, k=1; j<ols[i].childNodes.length; j++) {
				if (ols[i].childNodes[j].tagName == 'LI') {
					ols[i].childNodes[j].innerHTML = '<b>' + k++ + '.</b> ' + '<span>' + ols[i].childNodes[j].innerHTML + '</span>';
				}
			}
		} else {
			for(j=0, k=0; j<ols[i].childNodes.length; j++) {
				if (ols[i].childNodes[j].tagName == 'LI') {
					ols[i].childNodes[j].innerHTML = '<b>' + alpha[k%15] + '.</b> ' + '<span>' + ols[i].childNodes[j].innerHTML + '</span>';
					k++;
				}
			}
		}
	}
}


// {{{ IE, please stop flicker
try {
      document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
// }}}

function urldecode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir (http://brettz9.blogspot.com)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brettz9.blogspot.com)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Lars Fischer
    // %          note 1: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urldecode('Kevin+van+Zonneveld%21');
    // *     returns 1: 'Kevin van Zonneveld!'
    // *     example 2: urldecode('http%3A%2F%2Fkevin.vanzonneveld.net%2F');
    // *     returns 2: 'http://kevin.vanzonneveld.net/'
    // *     example 3: urldecode('http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a');
    // *     returns 3: 'http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a'
    
    var histogram = {}, ret = str.toString(), unicodeStr='', hexEscStr='';
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urlencode.
    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A';
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    histogram['\u00DC'] = '%DC';
    histogram['\u00FC'] = '%FC';
    histogram['\u00C4'] = '%D4';
    histogram['\u00E4'] = '%E4';
    histogram['\u00D6'] = '%D6';
    histogram['\u00F6'] = '%F6';
    histogram['\u00DF'] = '%DF'; 
    histogram['\u20AC'] = '%80';
    histogram['\u0081'] = '%81';
    histogram['\u201A'] = '%82';
    histogram['\u0192'] = '%83';
    histogram['\u201E'] = '%84';
    histogram['\u2026'] = '%85';
    histogram['\u2020'] = '%86';
    histogram['\u2021'] = '%87';
    histogram['\u02C6'] = '%88';
    histogram['\u2030'] = '%89';
    histogram['\u0160'] = '%8A';
    histogram['\u2039'] = '%8B';
    histogram['\u0152'] = '%8C';
    histogram['\u008D'] = '%8D';
    histogram['\u017D'] = '%8E';
    histogram['\u008F'] = '%8F';
    histogram['\u0090'] = '%90';
    histogram['\u2018'] = '%91';
    histogram['\u2019'] = '%92';
    histogram['\u201C'] = '%93';
    histogram['\u201D'] = '%94';
    histogram['\u2022'] = '%95';
    histogram['\u2013'] = '%96';
    histogram['\u2014'] = '%97';
    histogram['\u02DC'] = '%98';
    histogram['\u2122'] = '%99';
    histogram['\u0161'] = '%9A';
    histogram['\u203A'] = '%9B';
    histogram['\u0153'] = '%9C';
    histogram['\u009D'] = '%9D';
    histogram['\u017E'] = '%9E';
    histogram['\u0178'] = '%9F';
 
    for (unicodeStr in histogram) {
        hexEscStr = histogram[unicodeStr]; // Switch order when decoding
        ret = replacer(hexEscStr, unicodeStr, ret); // Custom replace. No regexing
    }
    
    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = decodeURIComponent(ret);
 
    return ret;
}
