
/* <span style="color:blue;font-weight:bold;">ZALECANY</span> Wybór płatność  - Formularz (order-newpayment - newpayment_form) [53474]*/

function orderpayment(id) {

document.getElementById('idle_payment').style.display = 'none';
    allDivs = document.getElementsByTagName("div");

    for (i = 0; i < allDivs.length; i++) {
        if ((/^newpayment_form_/).test(allDivs[i].id) == true) {
            allDivs[i].style.display = 'none';
        }
    }

    if (document.getElementById('newpayment_form_'+id) ) {
        document.getElementById('newpayment_form_'+id).style.display = 'block';
    }
}
/* Lista adresów dostawy klienta (client-addresses - client_addresses_list) [53417]*/

function client_addresses_list_confirmdelete() {
    return confirm('Are you sure you want to delete the selected delivery address?');
}
/* <b style="font-size:12px;color:red; text-decoration:blink">&gt;</b> Ukrywacz bez img - na grafice tła (projector - projector_components_hiding) [53655]*/

var components = new Array("component_projector_opinions","component_projector_photos","component_projector_ordered","component_projector_associated","component_projector_incategory","component_projector_suggestproduct","component_projector_askforproduct");

function showButtons()
{
    var i = 0;
    var activeButtons = components.length;
    for (i = 0; i < components.length; i++) {
        if (document.getElementById(components[i])) {
            document.getElementById('projector_components_hidding').style.display = 'block';
            if (document.getElementById('hide_'+components[i])) {
                document.getElementById('hide_'+components[i]).style.display = 'block';
            }
        }
    }
    setTimeout("showButtons()", 2000);
}

function components_hidding(component)
{
    if (document.getElementById(component) ) {
        for (i = 0; i < components.length; i++) {
            if (document.getElementById(components[i]) ) {
                document.getElementById(components[i]).style.display = 'none';
            }
        }
        document.getElementById(component).style.display = 'block';
    }
}
showButtons();
/* Lista produktów w koszyku z ilością dla Esensa.pl (basketedit - basketedit_productslist) [53348]*/

function countAnnuityZagiel(account, amount)
{ 
window.open('http://www.zagiel.com.pl/kalkulator/index_smart.php?action=getklientdet_si_rata&shopNo=' + account + '&goodsValue=' + amount, 'count_zagiel', 'width=630,height=500,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}
function validate_Zagiel()
{
var zagielconfirm = document.getElementById('zagiel_confirm');
  if (zagielconfirm.checked) {
    return true;
  } else {
    alert(zagielnotconfirmed)
    return false;
  }
}

/*eraty*/
function countAnnuityEraty(account, version, amount)
{ 
window.open('https://www.eraty.pl/symulator/oblicz.php?numerSklepu=' + account + '&wariantSklepu=' + version+ '&typProduktu=0&wartoscTowarow=' + amount, 'count_zagiel', 'width=630,height=500,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}
function validate_eraty()
{
  var zagielconfirm = document.getElementById('zagiel_confirm');
  if (!zagielconfirm) {
    return false;
  }
  if (zagielconfirm.checked) {
    return true;
  } else {
    alert(zagielnotconfirmed)
    return false;
  }
}
/* Detale produktu Sklep luksor (projector - projector_details) [53676]*/

function projector_button_switch(cont) {
     if (cont == 'component_projector_suggestproduct') {
            if (document.getElementById('component_projector_askforproduct')) {
                document.getElementById('component_projector_askforproduct').style.display = 'none';
            }
            if (document.getElementById('component_projector_suggestproduct')) {
                document.getElementById('component_projector_suggestproduct').style.display = 'block';
            }
     }
     if (cont == 'component_projector_askforproduct') {
            if (document.getElementById('component_projector_suggestproduct')) {
                document.getElementById('component_projector_suggestproduct').style.display = 'none';
            }
            if (document.getElementById('component_projector_askforproduct')) {
                document.getElementById('component_projector_askforproduct').style.display = 'block';
            }
     }
}
/**
  Popup
*/

var ns6=document.getElementById&&!document.all;
var html = document.getElementsByTagName("html");
var Popup = {
	link   : '',
	width  : 0,
	height : 0,
        loaded : 0,
	show : function (link,x,y) {
		Popup.link = link;
		Popup.width = x;
		Popup.height = y;
                Popup.loaded = 1;
		if (document.getElementById('big_photo')) {
			document.getElementById('big_photo').style.display = "none";
			document.getElementById('big_photo').src = Popup.link;
		}
		if (!ns6) {Popup.hideSelects(1);}
		Popup.creatLayers();
	},
        reload : function () {
              if (Popup.loaded) {
                     Popup.show(Popup.link,Popup.width,Popup.height);
              }
        },
	hide : function () {
		var edit = document.getElementById('show_popup_photo');
		var cover = document.getElementById('cover');
		edit.style.display = "none";
		cover.style.display = "none";
                Popup.loaded = 0;
		if (!ns6) {Popup.hideSelects(0);}
	},
	creatLayers : function () {
		var edit = document.getElementById('show_popup_photo');
		edit.style.position = 'absolute';
	        edit.style.display = "block";
		edit.style.width = (Popup.width + 10) + "px";
		edit.style.height = (Popup.height + 40) + "px";
	    edit.style.left = ns6? (Popup.pageSizes()[2] - (Popup.width + 10))/2 + html[0].scrollLeft +"px" : (Popup.pageSizes()[2] - (Popup.width + 10))/2 + "px";
            if (ns6) {
                  edit.style.top = ((((Popup.pageSizes()[3] - (Popup.height + 10))/2) - 100  + html[0].scrollTop) < 0) ? "0px" : (((Popup.pageSizes()[3] - (Popup.height + 10))/2) - 100  + html[0].scrollTop) + "px"
            } else {
                  edit.style.top = (((Popup.pageSizes()[3] - (Popup.height + 10))/2 - 100) < 0) ? "0px" : (Popup.pageSizes()[3] - (Popup.height + 10))/2 - 100 + "px";
            }

	    //edit.style.top =  ns6? ((Popup.pageSizes()[3] - (Popup.height + 10))/2) - 100  + html[0].scrollTop + "px": (Popup.pageSizes()[3] - (Popup.height + 10))/2 - 100 + "px";


            edit.style.zIndex = 1000;
		edit.style.Background = '#FFFFFF';

	    //'cover'- div do blokowania elementow innych niz edit
	    var cover = document.getElementById('cover');
	    cover.style.display = "block";
            cover.style.position = "absolute";
	    cover.style.zIndex = 900;
	    ns6? cover.style.opacity = .5 :  cover.style.filter = "alpha(opacity=50)";
	    if (window.opera) {
			cover.style.opacity = .5;
		}
		cover.style.left = "0px";
	    cover.style.top = "0px";
            offsetX = 0;
            if (!ns6 && !window.opera) {
                  offsetX = 20;
            }
	    cover.style.width = ns6? (Popup.pageSizes()[0] - 16) + "px" : Popup.pageSizes()[0] - offsetX + "px"; //ns6? html[0].offsetWidth +"px" : document.body.offsetWidth + "px";
	    cover.style.height = Popup.pageSizes()[1] + "px" //ns6? html[0].offsetHeight +"px" : document.body.offsetHeight + "px";
	},
	pageSizes : function () {
		var xScroll, yScroll;
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else {
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		if (self.innerHeight) {
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) {
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
		if(xScroll < windowWidth){	
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
		return arrayPageSize;
	},
	hideSelects : function (flag) {
		var selects = document.getElementsByTagName('SELECT');
		if (flag == 1) {
			for (i = 0; i < selects.length; i++) {
				selects[i].style.display = 'none';
			}
		} else {
			for (i = 0; i < selects.length; i++) {
				selects[i].style.display = '';
			}
		}
	}
}
window.onresize = function() {if (Popup.loaded == 1) {Popup.reload();}}
/* <b style="font-size:12px;color:red; text-decoration:blink">&gt;</b>Formularz dodawania nowego klienta 3.5 (client-new - client_new_form) [53700]*/

function clientnew_delivery_addr() {
    if (document.getElementById('deliver_to_billingaddr').checked) {
        document.getElementById('delivery_address_form').style.display = 'none';
    } else {
        document.getElementById('delivery_address_form').style.display = 'block';
    }
}

function clientnew_firm() {
    if (document.getElementById('firm_data').checked) {
        document.getElementById('firm_data_inputs').style.display = 'block';
    } else {
        document.getElementById('firm_data_inputs').style.display = 'none';
    }
}
/* <b style="font-size:12px;color:red; text-decoration:blink">&gt;</b>  Order 1 NEW z wyborem płatności ver 3.5   (order1 - order1) [53692]*/

function order1_shop_payformdiv(show)
{
    if (show) {
        document.getElementById('payform_div').style.display = 'block';
    } else {
        document.getElementById('payform_div').style.display = 'none';
        document.getElementById('payform_id').selectedIndex = 0;

        allDivs = document.getElementsByTagName("div");
        for (i = 0; i < allDivs.length; i++) {
            if ((/^newpayment_form_/).test(allDivs[i].id) == true) {
                allDivs[i].style.display = 'none';
            }
        }
    }
}

function order1_changepayform()
{
    selVal = document.getElementById('payform_id').value;
    allDivs = document.getElementsByTagName("div");

    for (i = 0; i < allDivs.length; i++) {
        if ((/^newpayment_form_/).test(allDivs[i].id) == true) {
            allDivs[i].style.display = 'none';
        }
    }

    if (document.getElementById('newpayment_form_'+selVal) ) {
        document.getElementById('newpayment_form_'+selVal).style.display = 'block';
    }
}
/* menu kategorii 3.5 teleskop.pl (layout_left - menu_categories) [53510]*/

function menu_categories_toggle(id) {
if(document.getElementById(id)){
     if (document.getElementById(id).style.display == 'block') {
           document.getElementById(id).style.display='none';
return false;
     } else {
           document.getElementById(id).style.display='block';
return false;
     }
}else{return true;}
}
/* Newsletter (contact - contact_newsletter) [44013]*/

if (typeof(newstxt) == "undefined") {

} 




function newsletter_blur(x) {
         if (x.value == '') {
                 x.value = contact_newstxt;
         }
}
function newsletter_focus(x) {
         if (x.value == contact_newstxt) {
                 x.value = '';
         }
}
/* Zadaj pytanie o produkt 3.0 (projector - projector_askforproduct) [53316]*/

function askforproduct()
{
    if (document.getElementById("askforproduct_email") ) {
        if ((/^[0-9a-zA-Z.-_]+@[0-9a-zA-Z.-_]+.[0-9a-zA-Z]+$/).test(document.getElementById("askforproduct_email").value) == false || document.getElementById("email").value.length == 0){
            alert('Nie wpisałeś poprawnie adresu e-mail na który mielibyśmy wysłać Ci odpowiedź.');
            return false;
        } else {
            return true;
        }
    }
}
function hideaskforproduct()
{
    if (document.getElementById('projector_askforproduct_table').style.display == 'none') {
        document.getElementById('projector_askforproduct_table').style.display = 'block';
    } else {
        document.getElementById('projector_askforproduct_table').style.display = 'none';
    }
}