window.addEvent('domready', function(){

	/************** SUBPRODUCT CHANGE ***************/

	if( $('product_table') ){
		var Product_ObjSelects = $$('#product_table .product_select');
		$$(Product_ObjSelects).addEvent('change', function(){
			this.getParent('tr').addClass('HIDE');
			var ObjToShow = $('product_table').getElement('tr.'+this.value);
			ObjToShow.removeClass('HIDE');
		});
	}

})


function PoliczRate(koszyk,shopNo,wariantSklepu) {
window.open('https://www.eraty.pl/symulator/oblicz.php?numerSklepu='+shopNo+'&wariantSklepu='+wariantSklepu+'&typProduktu=0&wartoscTowarow='+koszyk, 'Policz_rate', 'width=630,height=500,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
//window.open('https://www.zagiel.com.pl/kalkulator/index_smart.php?action=getklientdet_si_rata&shopNo='+shopNo+'&goodsValue='+koszyk, 'Policz_rate', 'width=630,height=500,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}

function nowe_okno_Zagiel() {
  window.open('https://www.zagiel.com.pl/kalkulator/jak_kupic.html', 'nowe_okno',
  'width=600,height=500,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
  }

function validate_Zagiel() {
  if (document.frZagiel.zagiel_agree.checked==false){
    alert ("Zanim złożysz zamówienie, zapoznaj sie z procedura udzielenia kredytu ratalnego eRaty Żagiel.");
    return false;
    }
  else {
    return true;
    }
  }

/*************/

function koszyk_sprawdz_stan(Input, InBasket, Max){
	if( Math.abs(Input.value)+Math.abs(InBasket)>Max ){
		Input.value = Max-InBasket;
		alert('Mamy tylko '+Max+' szt na magazynie.');
	}
}

function dokoszyka (plik){
var ilosc5 = prompt ("Podaj ilość produktów dodanych do koszyka","1");
if(ilosc5>0)
{
var plik2;
plik2=plik+'&ilosc='+ilosc5;
parent.location.href=plik2;
}

}



function amenu(div)
{
 div1= document.getElementById(div);
 div1.style.top= 100;
}

function amenu2(div)
{
 div1= document.getElementById(div);
 div1.style.top= -1000;
}



function pasek(txt)
{
   window.status = txt;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function otworz(plik) {

window.location=plik;

}


function produkt_popup(url, displayWindow ){
var Win = window.open(url, displayWindow ,'width=100,height=100,top=30,left=100,resizable=yes,scrollbars=yes,menubar=no');
}
function intro_popup(url, width, height){
var Win = window.open(url,"intro_popup1",'width=' + width + ',height=' + height + ',top=30,left=100,resizable=yes,scrollbars=no,menubar=no');
}


function popup(url ){
var Win = window.open(url, 'mapa' ,'width=100,height=100,top=30,left=100,resizable=yes,scrollbars=yes,menubar=no');
}

function displayWindow(url, width, height){
var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',top=30,left=100,resizable=no,scrollbars=no,menubar=no');
}

function displayWindow1(url, width, height){
var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',top=20,left=250,resizable=no,scrollbars=no,menubar=no');
}

function displayWindow2(url, width, height){
var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',top=220,left=380,resizable=no,scrollbars=no,menubar=no');
}


function test(){
var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
if (!re_mail.test(emailform.email.value)) {
alert('Podałeś błędny adres email !!!');
}
else { emailform.submit(); }
}
function moveover(txt) {
   window.status = txt;
   setTimeout("erase()",1300);
}
function erase() {
   window.status="";
}


function test1()
{
var re_mail=logowanie_55.email_h.value;
if(logowanie_55.email_h.value=='')
{
alert('Podaj adres e-mail !!!');
}
else
{
logowanie_55.submit();
}



}
function otworz(plik)
{
parent.location.href=plik;
}



function pasek(txt)
{
   window.status = txt;
}

function pasek1(txt)
{
   window.status = txt;

   setTimeout("erase()",1500);
}



 function edit_kat( object0, object1, object2 )
 {

 obiekt0= document.getElementById(object0);
 obiekt1= document.getElementById(object1);
 obiekt2= document.getElementById(object2);

 obiekt0.style.display = '';
 obiekt1.style.display = '';
 obiekt2.style.display = 'none';

  }


 function edit_kat_n( object0, object1, object2 )
 {

 obiekt0= document.getElementById(object0);
 obiekt1= document.getElementById(object1);
 obiekt2= document.getElementById(object2);

 obiekt0.style.display = 'none';
 obiekt1.style.display = 'none';
 obiekt2.style.display = '';

  }

function do_koszyka_p(nowyURL,ip)
{
var ilosc5= document.getElementById('ilosc.'+ ip).value
if(ilosc5<0)ilosc5=1;
nowyURL=nowyURL+'&ilosc='+ilosc5;
document.location.href=nowyURL;
alert ('Dodałeś produkt do koszyka');

}

function aktualizujParent(nowyURL)
{
var ilosc5= document.form_wybor.ilosc_sztuk.value;
if(ilosc5<0)ilosc=1;
nowyURL=nowyURL+'&ilosc='+ilosc5;
window.document.location= nowyURL;
alert ('Dodałeś produkt do koszyka!');
}

