// - 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';	
//	obj.onclick = function(){
//		psClosePopUp();
//	}
	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="auto";	
}

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) {
	psLoadingOn();
	i = new Image();
	i.src = obj.href;
	i.style.cursor = 'pointer';
	i.onload = function(){
		objWindow =	psCreateDiv('psWindow');
		objWindow.appendChild(i);
		psLoadingOff();
		psPosionPopUp(objWindow);		
	}
	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'; //((psBW.ns4 || psBW.ns6)?e.pageX:event.clientX + psBW.ieTrueBody().scrollLeft)+ 10 + 'px';
		obj.Tooltip.style.top = psMouse.y + 10 + 'px';//((psBW.ns4 || psBW.ns6)?e.pageY:event.clientY + psBW.ieTrueBody().scrollTop) + 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 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 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;
	}
}
//--------------------------------------------------------------------------


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

// -Show Horoscope --------------------------------------
function show_rrr(name,obj)
{
var arr = new Array('hor','wea','fin');
var arrs = new Array('a1','a2','a3');
var a;
var d;
var d1;
var d2;
	for(i=0;i<3;i++)
	{
		a = document.getElementById(arr[i]).style;
		if(arr[i] == name){a.display = 'block';}
		else{a.display='none';}
		
		
	}
	
		 d = document.getElementById('a1');
		
		  d1 = document.getElementById('a2');
		 
		   d2 = document.getElementById('a3');
		    
	
		d.style.color = '#003EA5';
		d1.style.color = '#003EA5';
		d2.style.color = '#003EA5';
	
	
	obj.style.color = '#0060FF';

return false;
}



//--------------------------------//
// Конструктор класса FlashObject //
//--------------------------------//
function Flash( ) {

	this.transparent = true;
	this.needFlashVerion = 6;           
	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;
  
}


