var ns6 = (!document.all && document.getElementById);
var ie4 = (document.all);
var ns4 = (document.layers);



var ok;
var blokuj1;
var blokuj2;
var klik1;
var klik2;
var klik3;
var speed;

var topdistace;
var y;

window.onerror = null;
var topMargin = 10;
var slideTime = 700;

function layerObject(id,left) {
if (ns6) {
this.obj = document.getElementById(id).style;
this.obj.left = left;
return this.obj;
}
else if(ie4) {
this.obj = document.all[id].style;
this.obj.left = left;
return this.obj;
}
else if(ns4) {
this.obj = document.layers[id];
this.obj.left = left;
return this.obj;
   }
}
function layerSetup() {
floatLyr = new layerObject('floatLayer',11);
window.setInterval("main()", 10)
}
function floatObject() {
if (ns4 || ns6) {
findHt = window.innerHeight;
} else if(ie4) {
findHt = document.body.clientHeight;
   }
} 
function main() {
if (ns4) {
this.currentY = document.layers["floatLayer"].top;
this.scrollTop = window.pageYOffset;
mainTrigger();
}
else if(ns6) {
this.currentY = parseInt(document.getElementById('floatLayer').style.top);
this.scrollTop = scrollY;
mainTrigger();
} else if(ie4) {
this.currentY = floatLayer.style.pixelTop;
this.scrollTop = document.body.scrollTop;
mainTrigger();
   }
}
function mainTrigger() {
var newTargetY = this.scrollTop + this.topMargin;
if ( this.currentY != newTargetY ) {
if ( newTargetY != this.targetY ) {
this.targetY = newTargetY;
floatStart();
}
animator();
   }
}
function floatStart() {
var now = new Date();
this.A = this.targetY - this.currentY;
this.B = Math.PI / ( 2 * this.slideTime );
this.C = now.getTime();
if (Math.abs(this.A) > this.findHt) {
this.D = this.A > 0 ? this.targetY - this.findHt : this.targetY + this.findHt;
this.A = this.A > 0 ? this.findHt : -this.findHt;
}
else {
this.D = this.currentY;
   }
}
function animator() {
var now = new Date();
var newY = this.A * Math.sin( this.B * ( now.getTime() - this.C ) ) + this.D;
newY = Math.round(newY);
if (( this.A > 0 && newY > this.currentY ) || ( this.A < 0 && newY < this.currentY )) {
if ( ie4 )document.all.floatLayer.style.pixelTop = newY;
if ( ns4 )document.layers["floatLayer"].top = newY;
if ( ns6 )document.getElementById('floatLayer').style.top = newY + "px";
   }
}
function start() {
if(ns6||ns4) {
pageWidth = innerWidth;
pageHeight = innerHeight;
layerSetup();
floatObject();
}
else if(ie4) {
pageWidth = document.body.clientWidth;
pageHeight = document.body.clientHeight;
layerSetup();
floatObject();
   }
}


function reset() {
klik1=true;
klik2=true;
klik3=true;
blokuj1=true;
blokuj2=true;
blokuj3=true
speed=10;
ok=true;
}

function scrollDown(podmenu,co,ile,czas) {
	//alert ("jest w scrollDown");
	obiekt=co;
	obiektpod=podmenu;
	topdistance=ile;
	if ( ie4 ) y=obiekt.style.pixelTop;
	
	moveDown();
	setTimeout("showMenu()",czas);	
}

function moveDown() {
if (y<topdistance) {
	y+=10;	
	if ( ie4 ) obiekt.style.pixelTop = y;
	setTimeout("moveDown()",speed);
	}
}

function scrollUp(podmenu,co,ile,czas) {
		
	obiekt=co;
	obiektpod=podmenu;
	topdistance=ile;
	
	if ( ie4 )
	{
	 obiekt.style.height=ile;
	 y=obiekt.style.pixelTop;
	}
	if ( ns6 )
	{
	 
	 //document.getElementById(co).style.height = ile;
	 y = document.getElementById(obiekt).style.top ;
	 
	}
	
	rightdistance=-180;
	if ( ie4 ) right = obiektpod.style.pixelLeft;
	if ( ns6 ) right = document.getElementById(podmenu).style.left;
	
	moveLeft();
	
	setTimeout("moveUp()",czas);
}
function moveUp() {
if ( ie4 ) obiekt.style.pixelTop = y;
if (y>topdistance) {
	y-=10;	
	
	setTimeout("moveUp()",speed);
	}
}

function showMenu() {
leftdistance=29;
left=obiektpod.style.pixelLeft;
moveRight();
}

function moveRight() {
if ( ie4 ) obiektpod.style.pixelLeft = left;
if (left<leftdistance) {
	left+=10;
	setTimeout ("moveRight()", speed);
	}
}

function hideMenu() {
rightdistance=-180;
if ( ie4 ) right=obiektpod.style.pixelLeft;
if ( ns6 ) right = 
moveLeft();
}

function moveLeft() {
if ( ie4 ) obiektpod.style.pixelLeft = right;
if (right>rightdistance) {
	right-=10;
	setTimeout ("moveLeft()", speed);
	}
}
 
function zrob1() {

if (ok&&blokuj1){
   if (klik1) {
	ok=(!ok);
	
	if ( ie4 ) scrollDown(podoferta,oferta,165,150);
	if ( ns6 ) scrollDown('podoferta','oferta',140,550);
	klik1=(!klik1);
	}
      else {
	ok=(!ok);
	if ( ie4 ) scrollUp(podoferta,oferta,25,150);
	if ( ns6 ) scrollUp('podoferta','oferta',25,500);
	klik1=(!klik1);
	}
   setTimeout("ok=true",800);
   
   }
   else
   {
   	   
   }
   
}

function zrob2() {
if (ok&&blokuj2) {
    if (klik2 && blokuj2) {
	ok=(!ok);
	scrollDown(podzapytanie,zapytanie,90,100);
	klik2=(!klik2);
	}
      else {
	ok=(!ok);
	scrollUp(podzapytanie,zapytanie,25,150);
	klik2=(!klik2);
	}
	setTimeout("ok=true",600);
    }
}
function zrob3() {
if (ok&&blokuj3) {
    if (klik3 && blokuj3) {
	ok=(!ok);
	scrollDown(podzapyt,cennik_pod,70,550);
	klik3=(!klik3);
	}
      else {
	ok=(!ok);
	scrollUp(podzapyt,cennik_pod,25,350);
	klik3=(!klik3);
	}
	setTimeout("ok=true",1000);
    }
}

function pokaz1() {
  if ( ie4 )
  {
   document.all.oferta.style.pixelTop +=140;
   document.all.podoferta.style.pixelLeft =29;
  }
  
  if ( ns6 )
  {
   	 document.getElementById('oferta').style.top = 105;
	 document.getElementById('podoferta').style.left =29 ;
	 
  }
  
klik1=(!klik1);
}

function pokaz2() {
  if ( ie4 )
  {
   document.all.zapytanie.style.pixelTop +=70;
   document.all.podzapytanie.style.pixelLeft =29;
  }
  if ( ns6 )
  {
   	 document.getElementById('zapytanie').style.top = 110; ;
	 document.getElementById('podzapytanie').style.left =29 ;
	 
  }

klik2=(!klik2);
}

function pokaz3() {
  if ( ie4 )
  {
   document.all.zapyt.style.pixelTop +=70;
   document.all.podzapyt.style.pixelLeft =29;
  }
  if ( ns6 )
  {
   
  }
klik3=(!klik3);
}


function showKartaProduktu(idproduktu) 
{ 
  KartaProduktu = window.open('/karta_produktu.php?idgrupy='+idproduktu,'VatimComputers','width=500,height=415,resizable=no,scrollbars=yes,location=0,top=50,left=200'); 
  KartaProduktu.focus(); 
} 



function reg_SprawdzMail(pole) 
{
    if (pole.value.search(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/) == -1 )
    {
    	return false;
    }
    else
    {
        return true;
    }
}

function reg_Kieruunkowy(pole) 
{
    if (pole.value.search(/^([0-9]){2,3}$/) == -1 )
    {
    	return false;
    }
    else
    {
        return true;
    }
}
function reg_Telefon(pole) 
{
    if (pole.value.search(/^([0-9]){6,7}$/) == -1 )
    {
    	return false;
    }
    else
    {
        return true;
    }
}

function reg_Tel_kom(pole) 
{
    if (pole.value.search(/^([0-9]){9}$/) == -1 )
    {
    	return false;
    }
    else
    {
        return true;
    }
}

