var G__StatusUchwyt   = 0;
var G__StatusAktualny = "";
var G__OknoPopupu = "";
var G__MainURL = "http://www.aikido.webmax.pl";
var G__Navigator = navigator.userAgent.toUpperCase();
var G__BGColor = '';


//  wstępne ładowanie obrazków itp
// ********************************
function Preloader( Text_ , tImg_ )
{
var TabImg_ = new Array();
var TabObr_ = new Array();

if ( typeof tImg_ == "array" )
  {
  TabImg_ = tImg_;
  }
 else
  { 
  TabImg_[ 0] = '/images/layout/panel_body_01.gif';
  TabImg_[ 1] = '/images/layout/panel_body_02.gif';
  TabImg_[ 2] = '/images/layout/panel_body_03.gif';
  TabImg_[ 3] = '/images/layout/panel_body_04.gif';
  TabImg_[ 4] = '/images/layout/panel_body_05.gif';
  TabImg_[ 5] = '/images/layout/panel_body_06.gif';
  TabImg_[ 6] = '/images/layout/panel_body_07.gif';
  TabImg_[ 7] = '/images/layout/panel_body_08.gif';
  TabImg_[ 8] = '/images/layout/panel_body_09.gif';
  TabImg_[ 9] = '/images/layout/panel_body_10.gif';
  TabImg_[10] = '/images/layout/main_bg.gif';
  TabImg_[11] = '/images/layout/header.jpg';
  TabImg_[12] = '/images/layout/panel_menu_01.gif';
  TabImg_[13] = '/images/layout/panel_menu_02.gif';
  TabImg_[14] = '/images/layout/panel_menu_03.gif';
  TabImg_[15] = '/images/layout/panel_menu_04.gif';
  TabImg_[16] = '/images/layout/panel_menu_05.gif';
  TabImg_[17] = '/images/layout/panel_menu_06.gif';
  TabImg_[18] = '/images/layout/panel_menu_07.gif';
  TabImg_[19] = '/images/layout/panel_menu_08.gif';
  TabImg_[20] = '/images/layout/panel_menu_09.gif';
  TabImg_[21] = '/images/layout/panel_menu_10.gif';
  TabImg_[22] = '/images/layout/content_header_01.gif';
  TabImg_[23] = '/images/layout/content_header_02.gif';
  TabImg_[24] = '/images/layout/content_header_03.gif';
}  

if ( Text_ != '' )
  {
  PodmieniajStatus( Text_ );
}  

for ( var Kolejny_=0 ; Kolejny_ < TabImg_.length ; Kolejny_ ++ )
  {
  TabObr_[Kolejny_] = new Image();
  TabObr_[Kolejny_].src = TabImg_[Kolejny_];    
}   

return false;
} // koniec Preloader()




//  status
// *****************************************
function PodmieniajStatus( Text_ )
{
window.status = Text_;
G__StatusUchwyt  = setTimeout( "PodmieniajStatus( '"+Text_+"' )", 100 );
return true;
} // koniec PodmieniajStatus()



//  przed załadowaniem sewrisu ....
// *****************************************
function BeforeLoad()
{


return true;
} // koniec BeforeLoad()




//  po załadowaniu sewrisu ....
// *****************************************
function LoadAndRun( Text_ )
{
document.body.ondragstart = NieRoobNic;
clearTimeout( G__StatusUchwyt );
window.status = ""+Text_;

FixPNG();

TestRamek();

return true;
} // koniec LoadAndRun()




//  zwraca nic
// *****************************************
function NieRoobNic()
{
return false;
} // koniec NieRoobNic()



//  podmienia status
// *****************************************
function StatusZmiana( Text_ )
{
if ( Text_ != "" )
  {
  G__StatusAktualny = window.status;
	window.status = ""+Text_;
	}
 else
  {
  window.status = G__StatusAktualny;
}	

return true;
} // koniec StatusZmiana()




//  nowe okno z serwisem .....
// *****************************************
function NoweOkno( URL_ )
{
window.open( 'http://'+URL_ );
return false;
} // koniec StatusZmiana()




//  nowe okno lokalne z serwisem .....
// *****************************************
function NoweOknoLok( URL_ ,Nazwa_,Param_)
{
Nazwa_ = ( Nazwa_==null ) ? "" : Nazwa_;
Param_ = ( Param_==null ) ? "" : Param_;

window.open( URL_ , Nazwa_ , Param_ );

return false;
} // koniec NoweOknoLok()




//  testowanie ramek
//  jak kto odpala serwis w ramce to wyłazi na wierzch :))
// ******************************************************
function TestRamek()
{
if ( top.window.location != self.window.location )  
  {
	top.window.location.replace( G__MainURL );
}
} // koniec TestRamek()




//  sprawdza czy nie otworzyno popupu w nowym oknie
// ****************************************************
function SprImgWindow()
{
if ( window.name == '' )
  {
	window.location.replace( G__MainURL );
}
} // koniec SprImgWindow()




//  wycina wszystkie spacje
// *****************************
function KillAllSpace( Ciag_ )
{

while ( Ciag_.indexOf( " " ) >= 0 )
  {
	Ciag_ = Ciag_.replace( ' ' , '' );	
}	

return Ciag_
} // koniec KillAllSpace()




/// testowanie poprawności maila
// ****************************************
function MailTest( Mail_ )
{

return ( KillAllSpace(Mail_).length > 0 && (/^[^? ]{1,}[@]{1}[^? ]{1,}[.]{1}[^? ]{1,}$/.test(Mail_) ) )
} // koniec MailTest()



// ******************************************
function OtworzPopup( Plik_ , Szer_ , Wys_, DodParam_, ZmienRozm_ )
{
DodParam_  = ( DodParam_ == null ) ? "" : DodParam_;
ZmienRozm_ = ( ZmienRozm_ == null ) ? true : ZmienRozm_;

if ( ZmienRozm_ )
  {
  if ( Wys_>600 )
    {
    Szer_ += 16;
    Wys_   = 600;  
    DodParam_ += ',scrollbars=yes';  
  }
  if ( Szer_>800 )
    {
    Wys_ += 16;
    Szer_   = 800;  
    DodParam_ += ',scrollbars=yes';  
  }
}  

PozTop_  = Math.ceil( ( screen.height - Wys_ ) / 2 );
PozLeft_ = Math.ceil( ( screen.width - Szer_ ) / 2 );

if ( G__OknoPopupu )
  {
  G__OknoPopupu.close();
}
G__OknoPopupu = window.open( Plik_, 'popup','width='+Szer_+',height='+Wys_+',top='+PozTop_+',left='+PozLeft_+''+DodParam_);

return false;
} // koniec OtworzPopup()




// ******************************************
function FixPNG()
{

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

if ((version >= 5.5) && (document.body.filters)) 
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}

return false;
} // koniec FixPNG()


