function preloading() {
	for (i=0;i<arguments.length ;i++) {
		if (document.images) {
			eval(arguments[i]+' = new Image()');
			eval(arguments[i]+'.src ="gfx/'+ arguments[i] +'.jpg"');
			eval(arguments[i]+'r = new Image()');
			eval(arguments[i]+'r.src ="gfx/'+ arguments[i] +'r.jpg"');
		}
	}
}

preloading('btnofirmie','btnlinki','btnkontakt');

function over(iObj) {
	if (document.getElementById) 
		document.getElementById(iObj).src =  eval (iObj+'r.src');
}

function out(iObj) {
	if (document.getElementById)
   		document.getElementById(iObj).src =  eval (iObj+'.src');
}
function preloading_gif() {
	for (i=0;i<arguments.length ;i++) {
		if (document.images) {
			eval(arguments[i]+' = new Image()');
			eval(arguments[i]+'.src ="gfx/'+ arguments[i] +'.gif"');
			eval(arguments[i]+'r = new Image()');
			eval(arguments[i]+'r.src ="gfx/'+ arguments[i] +'r.gif"');
		}
	}
}

preloading_gif('bgmenupro');

function overbg(iObj){
	if (document.getElementById) 
		document.getElementById(iObj).style.backgroundImage = "url('"+ bgmenupror.src +"')"; 
}
function outbg(iObj){
	if (document.getElementById)
   		document.getElementById(iObj).style.backgroundImage = "url('"+ bgmenupro.src +"')" ;
}

function new_window(x,y,fileName){
	var xWin=(screen.availWidth-10);
	var yWin=(screen.availHeight-29);
	var xscrepos=((xWin-x)/2);
	var yscrepos=((yWin-y)/2);
	if (  (xWin<x)&&(yWin>=y)  ){
   	   eval('window.open("' + fileName + '","powiekszenie","menubar=no,status=no,toolbar=no,resizable=no,directories=no,scrollbars=yes,fullscreen=no,top='+yscrepos+',left=0,height='+y+',width='+xWin+'")')
	}
	else if (  (xWin>=x)&&(yWin<y)  ){
   	   eval('window.open("' + fileName + '","powiekszenie","menubar=no,status=no,toolbar=no,resizable=no,directories=no,scrollbars=yes,fullscreen=no,top=0,left='+xscrepos+',height='+yWin+',width='+x+'")')
	}
	else if( (xWin>=x)&&(yWin>=y) )
	{
	   eval('window.open("' + fileName + '","powiekszenie","menubar=no,status=no,toolbar=no,resizable=no,directories=no,scrollbars=no,fullscreen=no,top='+yscrepos+',left='+xscrepos+',height='+y+',width='+x+'")')
	}
}
function check_form()
{
	if (document.contactform.imie.value == "")
	{
		document.contactform.imie.style.background = "#b7cbde";
		alert("Proszę podać imię i nazwisko.");
		return;
	}
	if (document.contactform.email.value == "")
	{
		document.contactform.email.style.background = "#b7cbde";
		alert("Proszę podać adres email.");
		return;
	}
	else 
	{
		if (!check_validEmail(document.contactform.email.value)) 
		{
			 document.contactform.email.style.background = "#b7cbde";
			 alert("Proszę podać prawidłowy adres email.");
	 		 return;
		}
	}
	 if (document.contactform.miasto.value == "")
	{
		document.contactform.miasto.style.background = "#b7cbde";
		alert("Proszę wpisać miasto.");
		return;
	}
	if (document.contactform.nazwa.value == "")
	{
		document.contactform.nazwa.style.background = "#b7cbde";
		alert("Proszę wpisać nazwę firmy.");
		return;
	}
	if (document.contactform.telefon.value == "")
	{
		document.contactform.telefon.style.background = "#b2cef8";
		alert("Proszę wpisać numer telefonu.");
		return;
	}
	else 
	{
		validtel = /^[0-9 \(\)]+$/;
		if ( !validtel.exec(document.contactform.telefon.value) )
		{
			document.contactform.telefon.style.background = "#b7cbde";
			alert("Proszę wpisać poprawny numer telefonu.");
			return;
		}
	}
	document.contactform.sprawdz.value = "wyslij";
	document.contactform.submit();
}

function check_validEmail(adres_email)
{
 	validemail = /^[-^!#$%&'*+\/=?`{|}~.\w]+@[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])*(\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])*)+$/  
	if (validemail.exec(adres_email) )
		return true;
	else
		return false;
}

function checkEnter(e,url_s,item,action)
{
	var characterCode;
	if(e && e.which)
	{
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else
	{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}

	if(characterCode == 13)
	{
	 //if generated character code is equal to ascii 13 (if enter key)
        if (action == "change")
		{
		   change_item(url_s,item)
           return false
		}
		else
		{
		   add_item(url_s,item)
           return false
		} 
	}
	else
	{
		return true 
	}
}

function add_item(url_s,item)
{
   number = document.getElementById("it"+item).value;
   validnumber = /^[0-9]+$/;
   if ( !validnumber.exec(number) )
   {
      alert("Proszę podać liczbę.");
	  return;    
   }
   if ( number==null || number<=0 )
   {
   	  alert("Proszę wprowadzić wartość większą od 0.");
	  return;
   }
   url_add ="http://"+url_s+"/?site=koszyk&action=add&item="+ item +"&q="+number;
   this.document.location.href =url_add;
}

function change_item(url_s,item)
{
   number = document.getElementById(item).value;
   validnumber = /^[0-9]+$/;
   if ( !validnumber.exec(number) && number!='')
   {
      alert("Proszę podać liczbę.");
	  document.getElementById(indeks).value = prev_number
	  return;    
   }
   url_add ="http://"+url_s+"/?site=koszyk&action=change&item="+ item +"&q="+number;
   this.document.location.href =url_add;
}
function aktualizuj(url_s)
{
   url_add ="http://"+url_s+"/?site=logowanie&action=change";
   this.document.location.href =url_add;
}
function aktualizuj_haslo(url_s)
{
   url_add ="http://"+url_s+"/?site=logowanie&action=change_pass";
   this.document.location.href =url_add;
}
function powrot(url_s,site)
{
   if(site)
   {
      url_add ="http://"+url_s+"/?site="+site;
      this.document.location.href =url_add;
   }
   else
   {
      url_add ="http://www."+url_s+"/";
      this.document.location.href =url_add;
   }
}
function zaloguj()
{
   document.logowanie.submit();
}
function wyloguj()
{
   document.logowanie.submit();
}

function zapisz(update)
{
	if (document.zamowienie.nazwa.value == "")
	{
		document.zamowienie.nazwa.style.background = "#b7cbde";
		alert("Proszę podać nazwę firmy.");
		return;
	}
	if (document.zamowienie.imienazw.value == "")
	{
		document.zamowienie.imienazw.style.background = "#b7cbde";
		alert("Proszę podać imię i nazwisko osoby zamawiającej.");
		return;
	}
	if (document.zamowienie.ulica.value == "")
	{
		document.zamowienie.ulica.style.background = "#b7cbde";
		alert("Proszę wpisać nazwę ulicy.");
		return;
	}
	if (document.zamowienie.kod_poczt.value == "")
	{
		document.zamowienie.kod_poczt.style.background = "#b7cbde";
		alert("Proszę wpisać kod pocztowy.");
		return;
	}
	if (document.zamowienie.miasto.value == "")
	{
		document.zamowienie.miasto.style.background = "#b7cbde";
		alert("Proszę wpisać miasto.");
		return;
	}
	if (document.zamowienie.nip.value == "")
	{
		document.zamowienie.nip.style.background = "#b7cbde";
		alert("Proszę wpisać NIP.");
		return;
	}
	if (document.zamowienie.email.value == "")
	{
		document.zamowienie.email.style.background = "#b7cbde";
		alert("Proszę podać adres email.");
		return;
	}
	else 
	{
		if (!check_validEmail(document.zamowienie.email.value)) 
		{
			 document.zamowienie.email.style.background = "#b7cbde";
			 alert("Proszę podać prawidłowy adres email.");
	 		 return;
		}
	}
	if (document.zamowienie.telefon.value == "")
	{
		document.zamowienie.telefon.style.background = "#b7cbde";
		alert("Proszę wpisać numer telefonu.");
		return;
	}
	else 
	{
		validtel = /^[0-9 \(\)]+$/;
		if ( !validtel.exec(document.zamowienie.telefon.value) )
		{
			document.zamowienie.telefon.style.background = "#b7cbde";
			alert("Proszę wpisać poprawny numer telefonu.");
			return;
		}
	}
	if ( (update!=1 && (document.zamowienie.pass.value || document.zamowienie.login.value)) || update ==2 )
	{
       if (document.zamowienie.login.value == "")
	   {
		   document.zamowienie.login.style.background = "#b7cbde";
           alert("Proszę wpisać login.");
           return;
       }
       if (document.zamowienie.login.value.length > 15)
       {
          document.zamowienie.login.style.background = "#b7cbde";
          alert("Login musi się mieć mniej niż 15 znaków.");
          return;
       }
       if (document.zamowienie.pass.value == "")
	   {
		   document.zamowienie.pass.style.background = "#b7cbde";
           alert("Proszę wpisać hasło.");
           return;
       }
       if (document.zamowienie.pass.value.length <= 4 || document.zamowienie.pass.value.length > 15)
       {
          document.zamowienie.ppass.style.background = "#b7cbde";
          alert("Hasło musi się mieć od 5 do 15 znaków.");
          return;
       }
       if (document.zamowienie.ppass.value != document.zamowienie.pass.value)
       {
          document.zamowienie.ppass.style.background = "#b7cbde";
          alert("Hasła muszą być identyczne.");
          return;
       }
	}
	document.zamowienie.sprawdz.value = "wyslij";
	document.zamowienie.submit();
}
function realizuj()
{
   document.zamowienie.sprawdz.value = "wyslij";
   document.zamowienie.submit()
}
function zapisz_login()
{
       if (document.zamowienie.login.value == "")
	   {
		   document.zamowienie.login.style.background = "#b7cbde";
           alert("Proszę wpisać login.");
           return;
       }
       if (document.zamowienie.login.value.length > 15)
       {
          document.zamowienie.login.style.background = "#b7cbde";
          alert("Login musi się mieć mniej niż 15 znaków.");
          return;
       }
       if (document.zamowienie.pass.value == "")
	   {
		   document.zamowienie.pass.style.background = "#b7cbde";
           alert("Proszę wpisać hasło.");
           return;
       }
       if (document.zamowienie.pass.value.length <= 4 || document.zamowienie.pass.value.length > 15)
       {
          document.zamowienie.ppass.style.background = "#b7cbde";
          alert("Hasło musi się mieć od 5 do 15 znaków.");
          return;
       }
       if (document.zamowienie.ppass.value != document.zamowienie.pass.value)
       {
          document.zamowienie.ppass.style.background = "#b7cbde";
          alert("Hasła muszą być identyczne.");
          return;
       }
    document.zamowienie.sprawdz.value = "wyslij";
	document.zamowienie.submit();
}

function przypomnij()
{
   if (document.zamowienie.login.value == "")
   {
      document.zamowienie.login.style.background = "#b7cbde";
      alert("Proszę wpisać login.");
      return;
   }
   if (document.zamowienie.email.value == "")
   {
      document.zamowienie.email.style.background = "#b7cbde";
      alert("Proszę podać adres email.");
      return;
   }
   else 
   {
      if (!check_validEmail(document.zamowienie.email.value)) 
      {
         document.zamowienie.email.style.background = "#b7cbde";
         alert("Proszę podać prawidłowy adres email.");
         return;
      }
   }
   document.zamowienie.submit();
}
function haslo()
{
   url_add ="?site=przypomnij";
   this.document.location.href =url_add;
}
function mail_write(user){
   var domena="acss";
   var suffix="com.pl";
   document.write('<a href="' + 'mailto:' + user + '@' + domena + '.' + suffix + '" >' + user + '@' + domena + '.' + suffix + '<br /></a>');
}
function rejestracja(){
   this.document.location.href = "?site=rejestracja";
}
