//resize popUp окна для схемы проезда 

function psPopImg2(obj){
	var w = window.open(obj.href, "", "resizable=1,HEIGHT=100,WIDTH=100,scrollbar=1");
	with(w.document){
		open();
		var c = [
			'<html><head>',
				'<title>',title,'</title>',
				'<script language="javascript">',
					'function fitPic(){',
						'iWidth = document.body.clientWidth;iHeight = document.body.clientHeight;iWidth = document.images[0].width - iWidth;',
						'iHeight = document.images[0].height - iHeight;window.resizeBy(iWidth, iHeight-1);',
						'var sw=(document.body.clientWidth-iWidth)/2;var sh=(document.body.clientHeight-iHeight)/2;',
						'if (sh<0) sh=0; if (sw<0) sw=0;window.moveTo(sw,sh);self.focus();}',
				'</script></head>',
				'<body onload="fitPic();" style="margin:0;padding:0;">',
					'<img src="',obj.href,'" border="0" alt="',title,'" title="',title,'" />',
				'</body>',
			'</html>'].join('');
		write(c);
		close();
	}
  return false;	
}

function psPrint(obj){
  popupWin = window.open(obj.href, '', 'width=700,height=600,toolbar=no,menubar=yes,location=no,status=yes,resizable=yes,scrollbars=yes,left=50,top=50');
  popupWin.focus();
  return false;	
}

/* --- Put_in_to_cart
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- */
function psAddToCart(obj, id)
	{
		var cartbox = document.getElementById('CartBox');	// id-шник блочка корзины (вверху)
		cartbox.style.display = 'block';
		
		var parent = obj.parentNode;
		obj.parentNode.innerHTML = '<img src="'+psIMG+'_cart_loader.gif" width="16" height="16" alt="Добавление товара" />';
		
		var dCount = $('psCartCount');
		var request = new Request.JSON
			({
				url: obj.href,
				onComplete: function(jsonObj)
					{
						if(this.response.json)
							{
								var d = this.response.json.js;
								parent.innerHTML = (d.cmd_errors) ? d.cmd_errors.join(' ') : d.cmd_messages.join(' ');
								parent.className = 'put-in-cart-full';

								if (dCount && d.cart_count)
									{
										dCount.innerHTML = d.cart_count;
										dCount.nextSibling.innerHTML = Declension(d.cart_count, '&nbsp;товар', '&nbsp;товара', '&nbsp;товаров');
									}				
							}
					}
			}).post({ajax:1});	
	}

/* --- // Put_in_to_cart // --- */


/* --- The correct terminations
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- */
function Declension(count, form1, form2, form5)
	{
		var num = count;
		num = Math.abs(num)%100;
		var nums = num%10;
		if (num > 10 && num < 20)
			{
				return form5;
			}
		if (nums > 1 && nums < 5)
			{
				return form2;
			}
		if (nums == 1)
			{
				return form1;
			}
		return form5;
	}
/* --- // The correct terminations // --- */


/* --- Popup_windows
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- */
var psWindows = {
	current:false,
	bg:false,
	loader:false,
	panel:false,
	image:null,
	//psPage.getSize();

	popImg:function(url)	// Full_size_image -->
		{
			this.loadingOn();
			var i = new Image();
			this.image = i;
			i.obj = this;
			i.canceled = false;
			i.onload = function()
				{
					if (this.canceled) return;
					this.obj.current = psCreateDiv('psWindow');
					this.obj.current.appendChild(this);
					this.obj.position();
					this.obj.loadingOff();
/*-------------------вставил вот эту строку-----------------------------*/					
					this.obj.bg.style.height = document.documentElement.scrollHeight;
					/*if(i.offsetHeight > this.obj.bg.offsetHeight)
						{
							this.obj.bg.style.height = i.offsetHeight  + 100+ 'px';
						}*/
				}
			i.onclick = function()
				{
					this.obj.close();		
				}		
			i.src = url.href;
			return false;		
		},




	popImgPreview:function(href, title, reloadPanel)	// Full_size_image_for_photolist -->
		{
			this.loadingOn();
			var i = new Image();
			this.image = i;
			i.obj = this;
			if(title)
				i.title = title;
			else
				i.title = href.title;
			i.canceled = false;
			this.oldUrl = href;
	
			i.onload = function()
				{
					if (this.canceled) return;
					
/*					if((this.obj.oldUrl == this.src) && (reloadPanel == null))
						{
							//this.obj.createPanel(this);
							//this.obj.p = 1;
						}*/
					else if(reloadPanel != null)
						{
							this.obj.currentImg = this;
							this.obj.p = 1;
						}
					else
						{
							this.obj.p = 0;
						}
					this.obj.oldUrl = null;
					this.obj.current = psCreateDiv('psWindow');
					this.obj.current.style.zIndex = 1100;
					this.obj.current.appendChild(this.obj.closeButtonCreate());		
					this.obj.current.appendChild(this);
					this.obj.current.appendChild(this.obj.titleImg(this.title));
					this.obj.current.style.display = 'none';
					if(this.obj.p == 1)
						{
							this.obj.current.p = 1;
						}
					this.obj.position();
					this.obj.loadingOff();
					if(i.offsetHeight > this.obj.bg.offsetHeight)
						{
							this.obj.bg.style.height = i.offsetHeight + 100+ 'px';
						}
				}
			i.onclick = function()
				{
					this.obj.close();		
				}		
			i.src = href;
			return false;		
		},




		

	popDiv:function(id)	// Popup_div_with_rules -->
		{
			this.loadingOn();
			objSrc = $(id);
			if (!objSrc) return false;
			this.current = psCreateDiv('psWindow');	
			//this.current.className = 'psWindow';
			this.current.innerHTML = objSrc.innerHTML;
			this.current.onclick = stopEvent;
			this.position();
			this.loadingOff();
			return false;
		},
	
	
	
	
	
	popUrl:function(url){
		if (!url) return false;
		this.loadingOn();

		this.request = new Request.JSON({
			url: url,
			onComplete: function(jsonObj) {
				if(this.response.json)	{
					this.obj.current =	psCreateDiv('psWindow');	
					//this.obj.current.className = 'psWindow';
					this.obj.current.innerHTML = this.responseJS.PageContent;
					this.obj.current.onclick = stopEvent;
					this.obj.position();
					this.obj.loadingOff();
				}
			}
		}).post({ajax:1});
	},
	
	
	
	
	close:function(){
		if (this.current){
			psDeleteObj(this.current);
			this.current = false;
		}
		if (this.bg){
			psDeleteObj(this.bg);
			this.bg = false;
		}
		if (this.panel){
			psDeleteObj(this.panel);
			this.panel = false;
		}
		if (this.loader){
			psDeleteObj(this.loader);
			this.loader = false;
		}
	},
	
	
	
	
	
	position:function(obj){
		var t, l;
		obj = (obj)?obj:this.current;
		obj.style.display = 'block';
		psPage.getSize();

		t = (psPage.windowHeight - obj.offsetHeight)/2 + psGetPageScroll();
		if(obj.p == 1)	{
			l = ((psPage.windowWidth - 140 - obj.offsetWidth)/2);
		}
		else	{
			l = ((psPage.windowWidth - obj.offsetWidth)/2);
		}
		obj.style.top = (t <= 0) ? '0px' : t + 'px';
		obj.style.left = (l <= 0) ? '0px' : l + 'px';
		if(t < psGetPageScroll())	{
			window.scrollTo(0, t);
		}
		else	{
			window.scrollTo(0, psGetPageScroll());
		}
	},





	loadingOn:function()	// Loading_on/off_block -->
		{
			this.closeBackGround();
			this.loader = psCreateDiv('psLoader');
			this.loader.innerHTML = 'Загрузка';
			this.position(this.loader);
		},
	loadingOff:function()
		{
			if (this.loader)
				{
					psDeleteObj(this.loader);
					this.loader = false;
				}		
		},

	closeBackGround:function()	// Dark_background_display -->
		{
			if (this.bg)
				{
					return false;
				}
			psPage.getSize();
			this.bg = psCreateDiv('psCloseBackGround');
			this.bg.obj = this;
			this.bg.style.height=psPage.pageHeight+100+'px';
			this.bg.style.width=document.body.scrollWidth+'px';
			this.bg.onclick = function()
				{
					this.obj.close();		
				}
		},

	createPanel:function(img)	// Right_switch_images_panel -->
		{
			this.currentImg = img;
			this.panel = psCreateDiv('psPanel');
			this.panel.style.height = parseInt(this.bg.style.height) - 40 +'px';
			this.wrapper = psCreateDiv('psIcoWrapper');
			this.divCenter = psCreateDiv('psCenter');			
			this.table = document.createElement('table');
			this.table.id = 'icoTable';
			this.tbody = document.createElement('tbody');
			this.table.appendChild(this.tbody);
			this.divCenter.appendChild(this.table);
			this.wrapper.appendChild(this.divCenter);
			this.panel.appendChild(this.wrapper);
			this.list = listImg;
			
			for(var i=0;i<this.list.length;i++)
				{
					this.tr = document.createElement('tr');
					this.td = document.createElement('td');
					this.td.id = 'ImgShow'+i;
					this.td.onmouseover = function()
						{
							this.className = (this.className == 'icoTdActive') ? this.className : 'icoTdhover';
						}
					this.td.onmouseout = function()
						{
							this.className = (this.className == 'icoTdActive') ? this.className : 'icoTd';
						}
					this.td.className = 'icoTd';
					this.div = psCreateDiv('DivImgShow'+i);
					this.div.className = 'psIco';
					this.div.listImg = this.list[i];
					this.div.style.background = 'url('+this.div.listImg.ico + this.div.listImg.file+') no-repeat center center';
	
					if((this.div.listImg.img + this.div.listImg.file) == img.src)
						{
							this.td.className = 'icoTdActive';
						}
					this.div.obj = this;
					this.div.td = this.td;
					this.div.onclick = function()
						{
							this.obj.td = this.td;
							this.obj.div = this;
							this.obj.reloadImg();
						}
					this.td.appendChild(this.div);
					this.tr.appendChild(this.td);
					this.tbody.appendChild(this.tr);
					this.div = null;
					this.td = null;
					this.tr = null;
				}
			
			psPage.getSize();
			this.wrapper.style.height = psPage.windowHeight + 'px';
			this.divCenter.style.margin = (this.wrapper.offsetHeight - this.divCenter.offsetHeight)/2 + 'px 0px 0px 0px';		
			
			if(LibBWCheck().ie6)
				{
					this.wrapper.style.top = document.documentElement.scrollTop + (psPage.windowHeight - this.wrapper.offsetHeight)/2 + 'px';
					this.panel.style.position = 'absolute';
					this.panel.style.zIndex = 2000;
					this.panel.style.top = 0;
					this.panel.style.width = '140px';
					this.panel.style.padding = '0px 5px 0px 5px';
					this.panel.style.height = this.bg.style.height;
				}
		},

	closeButtonCreate:function()	// Close_image -->
		{
			this.title = '<img src="'+psIMG+'_close_windows.gif" width="11" height="11" alt="Закрыть" title="Закрыть" />';
			this.button = psCreateDiv('psClose');	
			this.button.obj = this;
			this.button.onclick = function()
				{
					this.obj.close();
				}
			this.button.innerHTML = this.title;
			return this.button;
		},
	
	titleImg:function(title)	// Title_image -->
		{
			this.title = title;
			this.text = psCreateDiv('psTitle');	
			//this.text.className = 'psTitle';
			this.text.obj = this;
			this.text.innerHTML = this.title;
			return this.text;
		},




	reloadImg:function(){
		for(var i=1;i<this.list.length;i++){
			if(this.currentImg.src == (this.list[i].img + this.list[i].file)){
				this.num = i;
				break;
			}
		}
		
		if(this.div)	{
			if(this.currentImg.src != (this.div.listImg.img + this.div.listImg.file))	{
				$('ImgShow'+this.num).className = 'icoTd';
				
				var tUrl = {};
				tUrl.href = this.div.listImg.img + this.div.listImg.file;
				tUrl.title = this.div.listImg.name;
				this.current.removeChild(this.currentImg);
				psDeleteObj(this.current);
				this.popImgPreview(tUrl.href, tUrl.title, 1);
				
				this.td.className = 'icoTdActive';
				this.div = null;
			}
		}
	}
}
/* --- // Popup_windows // --- */






// - Base Functions --------------------------------------------

function addEvent(el, evname, func) {
	if (el.attachEvent) { // IE
		el.attachEvent("on" + evname, func);
	} else if (el.addEventListener) { // Gecko / W3C
		el.addEventListener(evname, func, true);
	} else {
		el["on" + evname] = func;
	}
};
//--------------------------------------------------------------------------
function removeEvent(el, evname, func) {
	if (el.detachEvent) { // IE
		el.detachEvent("on" + evname, func);
	} else if (el.removeEventListener) { // Gecko / W3C
		el.removeEventListener(evname, func, true);
	} else {
		el["on" + evname] = null;
	}
};

function stopEvent(ev) {
	ev || (ev = window.event);
	if (Calendar.is_ie) {
		ev.cancelBubble = true;
		ev.returnValue = false;
	} else {
		ev.preventDefault();
		ev.stopPropagation();
	}
	return false;
};

function psCreateDiv(idName){
	var obj = document.createElement('div');
	document.getElementsByTagName("body")[0].appendChild(obj);
	obj.id=idName;
	return $(idName);
}

function psDeleteObj(obj){
	if (typeof(obj) == 'string'){
		obj = $(obj);
	}
	if (obj){
		document.body.removeChild(obj);
	}
}

function psPreloadImg(url){
    var image = new Image();
    image.src = url;    
}

var psPage = {
	pageWidth:0,
	pageHeight:0,
	windowWidth:0,
	windowHeight:0,
	
	getSize:function(){
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		if (self.innerHeight) {	// all except Explorer
			this.windowWidth = self.innerWidth;
			this.windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			this.windowWidth = document.documentElement.clientWidth;
			this.windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			this.windowWidth = document.body.clientWidth;
			this.windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < this.windowHeight){
			this.pageHeight = this.windowHeight;
		} else { 
			this.pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < this.windowWidth){	
			this.pageWidth = this.windowWidth;
		} else {
			this.pageWidth = xScroll;
		}
	}
//	
//	return arrayPageSize;
}

// временная функция
function psGetPageSize(){
	return [psPage.pageWidth,psPage.pageHeight,psPage.windowWidth,psPage.windowHeight];
}

function psGetPageScroll(){
	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	return yScroll;
}
//--------------------------------------------------------------------------
// Browser Check
//--------------------------------------------------------------------------
function LibBWCheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	this.ieTrueBody = function(){
		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}
	
	return this
}
//--------------------------------------------------------------------------
// Mouse
//--------------------------------------------------------------------------
function _psMouse(){
	this.move = function(e){
		psMouse.x=(psBW.ns4 || psBW.ns6)?e.pageX:event.clientX + psBW.ieTrueBody().scrollLeft;
		psMouse.y=(psBW.ns4 || psBW.ns6)?e.pageY:event.clientY + psBW.ieTrueBody().scrollTop;
	}
}

//--- Flash --------------------------------------------------
function Flash( ) {

    this.transparent = true;
    this.needFlashVerion = 8;          
    this.flashvars = "xml_source=/ixml/&menuselid=0";
    this.BrowserInfo( );

}


Flash.prototype.BrowserInfo = function( ) { 
 
    var userAgent = navigator.userAgent.toLowerCase( );
       this.browserIE = ( userAgent.indexOf( 'msie' ) != -1 );

}

Flash.prototype.CheckVersionFlash = function( needVersion ) {
 
    if ( navigator.plugins[ 'Shockwave Flash' ] ) {
        matchStr = new RegExp ( '^[A-Za-z ]*(.*) .*$' );
        this.flashVerion = parseInt( navigator.plugins[ 'Shockwave Flash' ].description.replace( matchStr, '$1' ) );
        return ( needVersion <= this.flashVerion );
    }
    else if ( this.browserIE ) {
        for( var i = needVersion; i < needVersion + 10; i++ ) {
            try {
                    flashPlayer = new ActiveXObject( 'ShockwaveFlash.ShockwaveFlash.' + i );
                    this.flashVerion = i;
                    return true;
            }
            catch( e ) {
                continue;
            }
        }
        return false;     
    }
    else {
        this.flashVerion = 0;
        return false;
    }
 
}

Flash.prototype.Insert = function( ) {
	if ( this.CheckVersionFlash( this.needFlashVerion ) ) { 
		document.write( this.GenerateHtmlFlash( ) );
	}else{
		document.write( this.GenerateHtmlImage( ) );
	}
}

Flash.prototype.GenerateHtmlFlash = function( ) {
 
    var flashCode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
    flashCode += 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version= ' + this.flashVerion + ',0,0,0"' + ' width="' + this.width + '" height="' + this.height + '" align="middle">';
    flashCode += '<param name="allowScriptAccess" value="always"/>';
    flashCode += '<param name="movie" value="' + this.srcFlash + '"/>';
    flashCode += '<param name="quality" value="high"/>';
    if ( this.base ) {
        flashCode += '<param name="base" value="' + this.base + '"/>';
    }
    if ( this.background ) {
        flashCode += '<param name="bgcolor" value="' + this.background + '"/>';
    }
    if ( this.transparent ) {
        flashCode += '<param name="wmode" value="transparent"/>';
    }
    if ( this.flashvars ) {
        flashCode += '<param name="flashvars" value="' + this.flashvars + '"/>';
    }
 
    flashCode += '<embed quality="high" allowScriptAccess="always" type="application/x-shockwave-flash"' + ' pluginspage="http://www.macromedia.com/go/getflashplayer" ';
    flashCode += 'src="' + this.srcFlash+'" ' + '" width="' + this.width + '" height="' + this.height + '" ';
    if ( this.base ){
        flashCode += ' base="' + this.base + '"';
    }
    if ( this.background ){
        flashCode += ' bgcolor="' + this.background + '"';
    }
    if ( this.transparent ){
        flashCode += ' wmode="transparent"'
    }
    if ( this.flashvars ){
        flashCode += ' flashvars="' + this.flashvars + '"';
    }
    flashCode += '></embed>';
 
    flashCode += '</object>';
    return flashCode;
 
}

Flash.prototype.GenerateHtmlImage = function( ) {
 
    var imageCode = '<img src="' + this.srcImage + '"/>';
    return imageCode;
 
}
//--- Flash --------------------------------------------------













































/* --- If_we_have_'voting'
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- */
function setVotingResult(div, href, block, form)	// Results_on_the_home_page_without_rebooting -->
	{
		var sdata = {};
		vForm = $(form);
		theGroup = vForm.send_vote;
		for (i=0; i<=theGroup.length; i++)
			{
				if(theGroup[i] && theGroup[i].type == "radio" && theGroup[i].checked)
					{
						sdata['value'] = theGroup[i].value;
						break;
					}		
			}
		if(!sdata['value'])
			{
				alert('Выберите вариант ответа!');
				return false;
			}
		sdata['cmd'] = vForm.cmd.value;
		sdata['id'] = vForm.voteid.value;
		sdata['ajax'] = 1;
		
		this.request = new Request.JSON
			({
					url: href,
					onComplete: function(jsonObj)
						{
							if(this.response.json)
								{				
									$('voteMsg').innerHTML = this.response.json.js.msg;
									$('voteMsg').style.display = 'block';
									if(this.response.json.js.vote)
										{
											$('voteMsg').className = 'voting-message-ok';
											href = href + '?cmd=popup&id='+sdata['id'];
											getVotingResult(div, href, block);
										}
									else
										{
											$('voteMsg').className = 'voting-message-err';
										}
								}
						}
			}).get(sdata);
	}

function getVotingResult(div, href, block, goBack) // Results_on_the_inner_page_with_a_link_'back' -->
	{
		this.request = new Request.JSON
			({
				url: href,
				onComplete: function(jsonObj)
					{
						if(this.response.json)
							{
								$('vName').innerHTML = this.response.json.js.vName;
								$('vVotes').innerHTML = 'Всего голосов:&nbsp;<strong>'+this.response.json.js.vVotes+'</strong>';
								
								var msg = '';
								for(i=1;i<this.response.json.js.vItems;i++)
									{
										doc_vote = 0;
										doc_vote_percent = 0;
										msg = msg + '<div class="voting-items">'+this.response.json.js['value'+i]+'&nbsp;<img src="'+psIMG+'0.gif" width="'+this.response.json.js['width'+i]+'%" height="6" alt="'+this.response.json.js['percent'+i]+'%" title="'+this.response.json.js['percent'+i]+'%" />&nbsp;'+this.response.json.js['percent'+i]+'%&nbsp;<strong>('+this.response.json.js['vote'+i]+')</strong></div>';
									}				
								msg = msg + '';
								$('vItems').innerHTML = msg;
								$(div).style.display  = "block";//временно
								if(block)
									{
										$(block).style.display  = "none";//временно
									}
								if(goBack)
									{
										$('goBack').style.display  = "block";
									}
							}
					}
			}).get();
	}

function getVotingResultArchive(div, obj, id)	// Results_on_the_inner_page_withuot_a_link_'back' -->
	{
		if($(div+id).style.display == "block")
			{
				$(div+id).style.display = "none";
			}
		else if($('vVotes'+id).innerHTML != "")
			{
				$(div+id).style.display = "block";
			}
		else if($('vVotes'+id).innerHTML == "")
			{
				this.request = new Request.JSON
					({
						url: obj.href,
						onComplete: function(jsonObj)
							{
								if(this.response.json)
									{
										$('vVotes'+id).innerHTML = 'Всего голосов:&nbsp;' + this.response.json.js.vVotes;
										var msg = '';
										for(i=1;i<this.response.json.js.vItems;i++)
											{
												doc_vote = 0;
												doc_vote_percent = 0;
												msg = msg + '<div class="voting-items">'+this.response.json.js['value'+i]+'&nbsp;<img src="'+psIMG+'0.gif" width="'+this.response.json.js['width'+i]+'%" height="6" alt="'+this.response.json.js['percent'+i]+'%" title="'+this.response.json.js['percent'+i]+'%" />&nbsp;'+this.response.json.js['percent'+i]+'%&nbsp;<strong>('+this.response.json.js['vote'+i]+')</strong></div>';
											}				
										msg = msg + '';
										$('vItems'+id).innerHTML = msg;
										$(div+id).style.display  = "block";//временно
									}
							}
					}).get();
			}
	}

function backToVoting()	// 	Back_to_the_'voting'_function -->
	{
		$('portalVResultIndex').style.display  = "none";
		$('goBack').style.display  = "none";
		$('voteIndex').style.display  = "block";
	}
/* --- // If_we_have_'voting' // --- */



/* --- If_we_have_'subscribe'
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- */
function setButton(button, num1, name)	// A_function_that_changes_the_picture_on_chekbox -->
	{
		var class1 = ($(button+num1).className == 'unsubscribe') ? 'subscribe' : 'subscribe';
		var class2 = (class1 == 'subscribe') ? 'unsubscribe' : 'subscribe';
		var num2 = (num1 == 0) ? 1 : 0;
		if (name == 'doc_sub')
			{
				$(name).value = (num1 == 0) ? 'unsubscribe' : 'subscribe';
			}
		$(button+num1).className = class1;
		$(button+num2).className = class2;
	}

function checkAction() // A_function_that_changes_action -->
	{
		var form = $('fSub');
		var sdata = {};
		var d = $('subscribe_messages');
		
		sdata['doc_name'] = form['doc_name'].value;
		sdata['doc_email'] = form['doc_email'].value;
		sdata['doc_sub'] = form['doc_sub'].value;
		sdata['cmd'] = 'process';
		sdata['ajax'] = 1;
		
		if (!sdata['doc_sub'])
			{
				alert('Выберите действие!');	
				return false;
			}
		else
			{
				form.action = (sdata['doc_sub'] == 'subscribe') ? sub : unsub;
				if (!sdata['doc_email'] || !sdata['doc_sub'] || !sdata['doc_name'])
					{
						var msg = '';
						if (!sdata['doc_sub'] && (!sdata['doc_email'] || !sdata['doc_name']))
							{
								msg += 'Выберите действие и заполните следующие поля:';
							}
						else if (!sdata['doc_sub'])
							{
								msg += 'Выберите действие!';
							}
						else if (!sdata['doc_email'] || !sdata['doc_name'])
						{
							msg += 'Заполните следующие поля:';
						}	
						
						if (!sdata['doc_email'])
							msg += '\n -Ваш email';
						
						if (!sdata['doc_name'])
							msg += '\n -Ваше имя';
							
						alert(msg);	
						return false;
					}
			
				$('subscribe_hide').style.display = 'block';
				this.request = new Request.JSON
					(
						{
							url: form.action,
							onComplete: function(jsonObj)
								{
									if (this.response.json)
										{
											$('subscribe_hide').style.display = 'none';
											if (this.response.json.js.cmd_errors)
												{
													d.innerHTML = this.response.json.js.cmd_errors.join('<br />');
													d.className = 'subscribe_messages_err';
												}
											else
												{
													d.innerHTML = (sdata['doc_sub'] == 'subscribe') ? 'На Ваш E-mail отправлено письмо с активацией.' : 'Ваш E-mail удален из списка рассылки.';
													d.className = 'subscribe_messages_ok';
													form.reset();
													$('sub0').className = 'unsubscribe';
													$('sub1').className = 'unsubscribe';
												}
										}
								}		
						}	
					).post(sdata);
			}
	}
/* --- // If_we_have_'subscribe' // --- */



/* --- If_we_have_hide_element_function
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- */
function show(name)
	{
		var objStyle = $(name).style;
		if (objStyle.display == "none")
			{
				objStyle.display = "";
			}
		else
			{
				objStyle.display = "none";
			}
		return false;
	}
/* --- // If_we_have_hide_element_function // --- */
