function psPopImg2(obj)
{
	
				var new_chema = window.open(obj.href, "", "resizable=1,HEIGHT=200,WIDTH=200,scrollbar=1");
				with(new_chema.document)
				{
					open();
					write('<ht'+'ml><he'+'ad><ti'+'tle>Схема проезда</ti'+'tle><sc'+'ript 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();}</scr'+'ipt></he'+'ad><bo'+'dy onload="fitPic();" style="margin:0;padding:0;"><img src="'+obj.href+'" border="0" '+' alt="Схема проезда" title="Схема проезда" /></bo'+'dy></ht'+'ml>');
					close();
				}
			
  return false;	
}



// - Windows --------------------------------------------
var currentWindow;

function closeBackGround(){
	if (document.getElementById('closeFonId'))
		return false;
		
	obj = psCreateDiv('closeFonId');
	obj.className='psCloseBackGround';
	obj.style.height=psGetPageSize()[1]+'px';
	obj.style.width=psGetPageSize()[0]+'px';
	//	document.body.style.overflowX="hidden";
}

function psOpenInPopUp (idName,url){
	closeBackGround();

	objWindow =	psCreateDiv('psWindow');
	objWindow.style.position='absolute';
	objWindow.style.zIndex=1100;
	objSrc = document.getElementById(idName);

	if(url){
		psLoadingOn();
		currentWindow = url;		
		reqMain = new JsHttpRequest();
		reqMain.caching = false;
		reqMain.open('GET',url,true);
		var sdata = Array();
		sdata['cmd']='sendlink';
		reqMain.send(sdata);	
		reqMain.onreadystatechange = function(){
			if (reqMain.readyState == 4){
				if (reqMain.responseJS){
					PageContent = reqMain.responseJS.PageContent;
					objWindow.innerHTML = PageContent;
					psPosionPopUp(objWindow);
					psLoadingOff();					
				}
			}
		}		
	}else{
		objWindow.innerHTML = objSrc.innerHTML;
		psPosionPopUp(objWindow);
	}

	return false;
}

function psClosePopUp(){
	psDeleteObj('psWindow');
	psDeleteObj('closeFonId');
	psDeleteObj('psLoader');	
	document.body.style.overflowX="";	
}

function psPosionPopUp(obj){
	var objTop=(((psGetPageSize()[3]-obj.offsetHeight)/2)+psGetPageScroll());
	var objLeft=((psGetPageSize()[0]-obj.offsetWidth)/2);
	obj.style.top = (objTop<=0)?'0px':objTop+'px';
	obj.style.left = (objLeft<=0)?'0px':objLeft+'px';	
}

function psLoadingOn(){
	closeBackGround();
	objLoader = psCreateDiv('psLoader');
	objLoader.innerHTML = 'Загрузка';
	psPosionPopUp(objLoader);
}

function psLoadingOff()
{
	psDeleteObj('psLoader');
}

function psPopImg(obj) {

	if (!document.psImages)
		document.psImages = Array();
	
	psLoadingOn();
	i = new Image();
	i.src = obj.href;
	i.style.cursor = 'pointer';
	i.onload = function(){
		document.psImages[i.src]=true;		
		objWindow =	psCreateDiv('psWindow');
		objWindow.appendChild(i);
		psLoadingOff();
		psPosionPopUp(objWindow);	
		


		var objTop=(((psGetPageSize()[3]-obj.offsetHeight)/2)+psGetPageScroll());
		if ((objWindow.offsetHeight+objTop) >= psGetPageSize()[1]){
			document.getElementById('closeFonId').style.height = (objWindow.offsetHeight + objTop) + 'px';
		}
//		alert(objWindow.offsetHeight+objWindow.offsetTop);
//		alert(psGetPageSize()[1]);		
	}

	if (document.psImages)
		if (document.psImages[i.src]) 
			i.onload();
	
	i.onclick = function(){
		psClosePopUp();		
	}
	return false;
}
// - Windows --------------------------------------------


// - ToolTips Functions --------------------------------------------

function psDrawTooltips(){
	var tags = Array('a','span','img');	
	psCreateDiv('psTooltip')	
	for (var i = 0; i < tags.length; i++){
		el = document.getElementsByTagName(tags[i]);
		for (var e = 0; e < el.length; e++){
			if (el[e].getAttribute('psTitle'))
				psCreateTooltip(el[e])
//			tagTitle = ;				
		}
	}
}

function psCreateTooltip(obj){
	
	obj.psTitle = obj.title;
	obj.title = '';	

	obj.onmouseover = function(){
		 obj.psShowTooltip();
	}

	obj.onmouseout = function(){
		obj.Tooltip.style.left = '-1000px';
		obj.Tooltip.style.top = '-1000px';
	}
	
	obj.onmousemove = function(e){
		obj.Tooltip.style.left = psMouse.x + 10 + 'px';
		obj.Tooltip.style.top = psMouse.y + 10 + 'px';
	}
	
	obj.psShowTooltip = function()
	{
		obj.Tooltip = document.getElementById('psTooltip');
		obj.Tooltip.innerHTML = obj.psTitle;		
	}
	
	obj.psHideTooltip = function(){
		psDeleteObj('psTooltip');	
	}
}

function psDeleteTooltip(obj){
	
	
}
// - ToolTips Functions --------------------------------------------

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

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

function psDeleteObj(idName){
	obj = document.getElementById(idName);
	document.body.removeChild(obj);	
}

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

function psGetPageSize(){
	
	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;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

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;
	}
}
//--------------------------------------------------------------------------


// - Old Functions --------------------------------------------




/*var resId=0;
var imgWndw;
function _psPopImg(imgLink, Title) {
  if (typeof(window.resizeBy)=='undefined') return true;
  var sl=(document.body.clientWidth-100)/2;
  var st=(document.body.clientHeight-100)/2;
  imgWndw=window.open(imgLink,'swnd','width=50,height=50,toolbar=no,menubar=no,location=no,status=no,resizable=yes,scrollbars=no,left='+sl+',top='+st);
  imgWndw.focus();
  with (imgWndw.document){
    open();
    write('<ht'+'ml><he'+'ad><ti'+'tle>'+Title+'</ti'+'tle>'+ '</he'+'ad><bo'+'dy leftmargin="0" topmargin="0" '+ 'rightmargin="0" bottommargin="0" marginwidth="0" '+ 'style="margin:0;padding:0;position:fixed;overflow:none;" '+ 'marginheight="0"><img src="'+imgLink+'" border="0" '+ ' alt="'+Title+'" title="'+Title+'" /></bo'+ 'dy></ht'+'ml>');
    close();
  }
  resId=setInterval('imgResize()',100);
  return false
}

function poppage(pageLink,width,height,scrollShow,panelOption){
  width = (width && width !== 'auto')?width:(document.body.clientWidth-100)/1.4;
  height = (height && height !== 'auto')?height:(document.body.clientHeight-100)/1.4;
  scrollShow = (scrollShow == 'no')?'no':'yes';
  if (panelOption == 0 ) panel = 'toolbar=no,menubar=no,location=no';
  else if (panelOption == 2 ) panel = 'toolbar=yes,menubar=yes,location=yes';
  else panel = 'toolbar=no,menubar=yes,location=no';

  popupWin = window.open(pageLink, '', 'width='+width+',height='+height+','+panel+',status=yes,resizable=yes,scrollbars='+scrollShow+',left=50,top=50');
  popupWin.focus();
  return false
}

function imgResize() {
  var w=imgWndw.document.images[0].width;
  if (w>screen.availWidth) w=screen.availWidth;
  var h=imgWndw.document.images[0].height;
  if (h>screen.availHeight) h=screen.availHeight;
  if (w>50 && h>50) {
    var ww=(imgWndw.innerWidth)?imgWndw.innerWidth:((document.body)? imgWndw.document.body.clientWidth:null);
    var wh=(imgWndw.innerHeight)?imgWndw.innerHeight:((document.body)? imgWndw.document.body.clientHeight:null);
    if (ww && wh) {imgWndw.resizeBy(w-ww,h-wh);
    var sw=(document.body.clientWidth-w)/2;
    var sh=(document.body.clientHeight-h)/2;
    if (sh<0) sh=0; if (sw<0) sw=0;
    imgWndw.moveTo(sw,50);
    }
    imgWndw.focus();
    clearInterval(resId)
  }
}*/

//--------------------------------//
// Конструктор класса FlashObject //
//--------------------------------//
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' ] ) {
        /* определяем есть ли у браузера plugin флэшплеера */
        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 ) {
        /* иначе будет создаваться ActiveX объект (IE) */
        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;
    }
  
}

/* Метод вставки в страницу HTML нужного кода */
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;
  
}

/* Метод для генерирования image - кода */
Flash.prototype.GenerateHtmlImage = function( ) {
  
    var imageCode = '<img src="' + this.srcImage + '"/>';
    return imageCode;
  
}

//-- Версия для печати ----------------------------
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;   
}


//-- Версия для печати ----------------------------



function show_hide(id){
	var showObj=document.getElementById(id).style
	if (showObj.display=="none")
		{showObj.display=""}
	else {showObj.display="none"}
	}