var StatusUchwyt   = 0;
var StatusAktualny = "";
var G__MainURL = "http://www.papimi.pl";



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

TabImg_[ 0] = 'images/layout/header.jpg';

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()




//  blokada prawego klawisza
// *****************************************
function LoadAndRun( Text_ )
{
document.body.ondragstart = NieRoobNic;
clearTimeout( StatusUchwyt );
window.status = ""+Text_;

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()




//  drukowanie strony
// *****************************************
function Drukuj()
{
window.print();
return false;
} // koniec Drukuj()



//  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()





/// poprawność formularza kontaktowego
// **********************************************
function SprFormContect()
{
Ok_ = true;

if ( Ok_ && KillAllSpace(document.getElementById('tresc').value).length == 0 )
  {
  alert( 'wprowadź treść wiadomości' );
  Ok_ = false;
  document.getElementById('tresc').focus();
}  

if ( Ok_ && ( KillAllSpace(document.getElementById('osoba').value).length == 0 && KillAllSpace(document.getElementById('firma').value).length == 0 ) )
  {
  alert( 'podpisz wiadomość' );
  Ok_ = false;
  document.getElementById('osoba').focus();
}  

if ( Ok_ && KillAllSpace(document.getElementById('email').value).length == 0 )
  {
  alert( 'podaj kontaktowy adres e-mail' );
  Ok_ = false;
  document.getElementById('email').focus();
}  

if ( Ok_ && (!(/^[^? ]{1,}[@]{1}[^? ]{1,}[.]{1}[^? ]{1,}$/.test(document.getElementById('email').value))))
  {
	alert( 'format adresu e-mail nie jest poprawny' );
	document.getElementById('email').focus();
  Ok_ = false; 
}

if ( Ok_ && confirm( 'chcesz wysłać wiadomość' ) )
  {
	document.getElementById('formContact').submit();
}  

return false;
}  // koniec SprFormContect()



