var StatusUchwyt   = 0;
var StatusAktualny = "";
var G__OknoPopupu = "";
var G__MainURL = "http://www.jenerix.com.pl";



//  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/menu1_pos1_off.gif';
  TabImg_[ 1] = 'images/layout/menu1_pos1_off_ov.gif';
  TabImg_[ 2] = 'images/layout/menu1_pos1_on.gif';
  TabImg_[ 3] = 'images/layout/menu1_pos1_on_ov.gif';      
  TabImg_[ 4] = 'images/layout/menu1_pos2_off.gif';
  TabImg_[ 5] = 'images/layout/menu1_pos2_off_ov.gif';
  TabImg_[ 6] = 'images/layout/menu1_pos2_on.gif';
  TabImg_[ 7] = 'images/layout/menu1_pos2_on_ov.gif';      
  TabImg_[ 8] = 'images/layout/menu1_pos3_off.gif';
  TabImg_[ 9] = 'images/layout/menu1_pos3_off_ov.gif';
  TabImg_[10] = 'images/layout/menu1_pos3_on.gif';
  TabImg_[11] = 'images/layout/menu1_pos3_on_ov.gif';
  TabImg_[12] = 'images/layout/menu2_sep.jpg';
  TabImg_[13] = 'images/layout/pasek_menu_tlo_gora.gif';
  TabImg_[14] = 'images/layout/pasek_menu_tlo_dol.gif';
  TabImg_[15] = 'images/layout/pasek_menu_prawy_gora.gif';
  TabImg_[16] = 'images/layout/pasek_menu_lewy.gif';
  TabImg_[17] = 'images/layout/pasek_menu_filar.gif';
  TabImg_[18] = 'images/layout/menu_top_sep.gif';              
}  

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

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

return false;
} // koniec Preloader()




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



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


} // koneic BeforeLoad()




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

objects = document.getElementsByTagName("object");
for (var i = 0; i < objects.length; i++)
  {
  if ( !objects[i].id || objects[i].id.indexOf('_WebMax_Flash_') == -1 )
    {
    objects[i].outerHTML = objects[i].outerHTML;
  }    
}

embeds = document.getElementsByTagName("embed");
for (var i = 0; i < embeds.length; i++)
  {
  embeds[i].outerHTML = embeds[i].outerHTML;
}


return true;
} // koniec LoadAndRun()




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



//  podmienia status
// *****************************************
function StatusZmiana( Text_ )
{
if ( Text_ != "" )
  {
  StatusAktualny = window.status;
	window.status = ""+Text_;
	}
 else
  {
  window.status = 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 SprFormSeekPhrase()
{
OK_ = true;

if ( OK_ && KillAllSpace(document.getElementById('seekPhrase').value).length < 3 )
  {
  alert( 'wyszukiwana fraza musi mieć przynajmniej 3 znaki' );
  document.getElementById('seekPhrase').focus();
  OK_ = false;  
}  

return OK_;
} // koniec SprFormSeekPhrase()






// ********************************************
function SprFormNewsletter()
{
var OK_ = true;

if ( OK_ && KillAllSpace(document.getElementById('newsletter_imie').value).length < 1 )
  {
  alert( "Proszę podać imię" );
  OK_ = false;
  document.getElementById('newsletter_imie').focus();     
}  

if ( OK_ && KillAllSpace(document.getElementById('newsletter_nazwisko').value).length < 1 )
  {
  alert( "Proszę podać nazwisko" );
  OK_ = false;
  document.getElementById('newsletter_nazwisko').focus();     
}  

if ( OK_ && KillAllSpace(document.getElementById('newsletter_email').value).length < 1 )
  {
  alert( "Proszę podać swój adres e-mail" );
  OK_ = false;
  document.getElementById('newsletter_email').focus();     
}  

if ( OK_ && !MailTest( document.getElementById('newsletter_email').value ) )
  {
  alert( "Podany adres e-mail nie jest poprawny" );
  OK_ = false;
  document.getElementById('newsletter_email').focus();     
}  

if ( OK_ )
  { 
  JestZazInter_ = false;
  for ( var Kolejny_ = 1 ; Kolejny_ < document.getElementById('FormNewsletter').elements.length ; Kolejny_ ++ )
    {
    if ( document.getElementById('FormNewsletter').elements[Kolejny_].id.indexOf( 'wsletter_grupa_' ) > 0 && document.getElementById('FormNewsletter').elements[Kolejny_].checked )
      {
      JestZazInter_ = true;
      break;
    }    
  }
  
  if ( !JestZazInter_ )
    {
  	alert( 'Trzeba zaznaczyć przynajmniej jedn± interesuj±c± Cię pozycję' );
  	OK_ = false;   
  }     
}


OK_ = OK_ && confirm( "Dopisać Twoje dane do subskrypcji?" );

if ( OK_ )
  {
  document.getElementById('FormNewsletter_Action').value = 'send';  
}

return OK_;
} // koniec SprFormNewsletter();



// ***************************************
function ProductQuickListSelectKat( Link_ )
{

window.location.href = Link_+';katID='+document.getElementById('ProductQuickListKatID').value;

return false;
} // koniec ProductQuickListSelectKat()


// ***************************************
function ProductQuickListSelectProd( Link_ )
{

window.location.href = Link_+';prodID='+document.getElementById('ProductQuickListProdID').value;

return false;
} // koniec ProductQuickListSelectKat()





// *****************************
function FullTabelka()
{
var G__Navigator   = navigator.userAgent.toUpperCase();
var WysokoscOkna_ = 0;

if ( G__Navigator.indexOf('NETSCAPE') > 0 || G__Navigator.indexOf('FIREFOX') > 0 || G__Navigator.indexOf('GECKO') > 0 )
  {
  WysokoscOkna_ = window.innerHeight;
  }  
 else if ( G__Navigator.indexOf('OPERA') > 0 || G__Navigator.indexOf('MSIE') > 0 )
  {
  WysokoscOkna_ = document.body.clientHeight;
}  

WysokoscTabelki_ = (WysokoscOkna_ - 150); // 150 wysokość nagłówka serwisu

document.getElementById('HeaderTable_Right').style.width = (document.getElementById('MainTable').clientWidth-1025+27)+'px';
//document.getElementById('HeaderTable').style.width = document.getElementById('MainTable').clientWidth+'px';

if ( WysokoscOkna_ > 0 )
  {
 // document.getElementById('MainBody').style.height == ""  
  if ( G__Navigator.indexOf('MSIE 7.0') > 0 )
    {  
    WysokoscOkna_ = Math.max((window.innerHeight || 0), document.body.clientHeight, document.documentElement.clientHeight, document.body.scrollHeight);
    document.getElementById('MainBody').style.height = WysokoscOkna_+'px';
  }    
  document.getElementById('MainTable').style.height = WysokoscTabelki_+'px';
}  

return true;
} // koniec FullTabelka()

