var selected;var submitter=null;function submitFunction(){submitter=1;}
function popupWindow(url){window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')}
function selectRowEffect(object,buttonSelect){if(!selected){if(document.getElementById){selected=document.getElementById('defaultSelected');}else{selected=document.all['defaultSelected'];}}
if(selected)selected.className='moduleRow';object.className='moduleRowSelected';selected=object;if(document.getElementById('payment'[0])){document.getElementById('payment'[buttonSelect]).checked=true;}else{}}
function rowOverEffect(object){if(object.className=='moduleRow')object.className='moduleRowOver';}
function rowOutEffect(object){if(object.className=='moduleRowOver')object.className='moduleRow';}
function popupImageWindow(url){window.open(url,'popupImageWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')}
function setCookie(c_name,value,expiredays)
{var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);document.cookie=c_name+"="+escape(value)+
((expiredays==null)?"":";expires="+exdate.toGMTString());}
function getCookie(c_name)
{if(document.cookie.length>0)
{c_start=document.cookie.indexOf(c_name+"=");if(c_start!=-1)
{c_start=c_start+ c_name.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1)c_end=document.cookie.length;return unescape(document.cookie.substring(c_start,c_end));}}
return"";}
function chowaj(id){if(jQuery("#"+id).is(':hidden'))
{jQuery("#"+id).show("slow");setCookie('id_'+id,'1',365);}
else
{jQuery("#"+id).hide("slow");setCookie('id_'+id,'0',365);}}
var flyingSpeed=20;var url_addProductToBasket='addProduct.php';var shopping_cart_div=false;var flyingDiv=false;var currentProductDiv=false;var shopping_cart_x=false;var shopping_cart_y=false;var slide_xFactor=false;var slide_yFactor=false;var diffX=false;var diffY=false;var currentXPos=false;var currentYPos=false;var ajaxObjects=new Array();function shoppingCart_getTopPos(inputObj)
{var returnValue=inputObj.offsetTop;while((inputObj=inputObj.offsetParent)!=null){if(inputObj.tagName!='HTML')returnValue+=inputObj.offsetTop;}
return returnValue;}
function shoppingCart_getLeftPos(inputObj)
{var returnValue=inputObj.offsetLeft;while((inputObj=inputObj.offsetParent)!=null){if(inputObj.tagName!='HTML')returnValue+=inputObj.offsetLeft;}
return returnValue;}
function addToBasket(productId,nameofDiv)
{if(!shopping_cart_div)shopping_cart_div=document.getElementById('koszyk_top');if(!flyingDiv){flyingDiv=document.createElement('DIV');flyingDiv.style.position='absolute';flyingDiv.style.zIndex=1000;document.body.appendChild(flyingDiv);}
shopping_cart_x=shoppingCart_getLeftPos(shopping_cart_div);shopping_cart_y=shoppingCart_getTopPos(shopping_cart_div);currentProductDiv=document.getElementById(nameofDiv+ productId);currentXPos=shoppingCart_getLeftPos(currentProductDiv);currentYPos=shoppingCart_getTopPos(currentProductDiv);diffX=shopping_cart_x- currentXPos;diffY=shopping_cart_y- currentYPos;var shoppingContentCopy=currentProductDiv.cloneNode(true);shoppingContentCopy.id='';flyingDiv.innerHTML='';flyingDiv.style.left=currentXPos+'px';flyingDiv.style.top=currentYPos+'px';flyingDiv.appendChild(shoppingContentCopy);flyingDiv.style.display='block';flyingDiv.className='slidingProduct';flyingDiv.style.width=currentProductDiv.offsetWidth+'px';flyToBasket(productId);}
function flyToBasket(productId)
{var maxDiff=Math.max(Math.abs(diffX),Math.abs(diffY));var moveX=(diffX/maxDiff)*flyingSpeed;;var moveY=(diffY/maxDiff)*flyingSpeed;currentXPos=currentXPos+ moveX;currentYPos=currentYPos+ moveY;flyingDiv.style.left=Math.round(currentXPos)+'px';flyingDiv.style.top=Math.round(currentYPos)+'px';if(moveX>0&&currentXPos>shopping_cart_x){flyingDiv.style.display='none';}
if(moveX<0&&currentXPos<shopping_cart_x){flyingDiv.style.display='none';}
if(flyingDiv.style.display=='block')setTimeout('flyToBasket("'+ productId+'")',7);else
{ajax_AddProduct(productId);}}
function ajax_AddProduct(productId){var adres="ajax.add_to_basket.php?action=add_product_ajax&BUYproducts_id="+productId;jQuery.ajax({url:adres,success:function(html){jQuery("#koszyk_top").html(html);}});}
function SP_ajax_AddProduct(productId){if($('#goToBasket:checked').val()!==undefined){$("#ajaxAddToCartForm").submit();}
else{$.colorbox.close();qty=jQuery("#products_qty").val();var adres="ajax.add_to_basket.php?action=add_product_ajax&BUYproducts_id="+productId+"&qty="+qty;jQuery.ajax({url:adres,success:function(html){jQuery("#koszyk_top").html(html);}});}}
function ajax_product_tabs(params,tab)
{loading('product_active_tab');var adres="ajax.product_tabs.php?"+params+"&product_tab="+tab;jQuery.ajax({url:adres,success:function(html){$(".active_product_tab").removeClass();$("#"+tab).addClass("active_product_tab");jQuery("#product_active_tab").hide();jQuery("#product_active_tab").html(html);jQuery("#product_active_tab").fadeIn('slow');}});return false;}
function ajax_top_basket_reload(){var adres="ajax.add_to_basket.php";jQuery.ajax({url:adres,success:function(html){jQuery("#koszyk_top").html(html);}});}
function delete_product_from_basket(pID)
{var adres="ajax.shopping_cart.php?remove=1&pID="+pID;loading('order_details');jQuery.ajax({url:adres,success:function(html){ajax_top_basket_reload();jQuery('#order_details').hide();jQuery('#order_details').replaceWith(html);jQuery('#order_details').hide();jQuery('#order_details').fadeIn("slow");}});}
function update_quantity_in_basket(pID)
{var value=jQuery('#product_quantity'+pID).val();var adres="ajax.shopping_cart.php?update=1&pID="+pID+"&value="+value;loading('order_details');jQuery.ajax({url:adres,success:function(html){ajax_top_basket_reload();jQuery('#order_details').hide();jQuery('#order_details').replaceWith(html);jQuery('#order_details').hide();jQuery('#order_details').fadeIn("slow");}});}
function acount_pages_loader(which)
{loading('login_extend');if(which)
var value="account";else
var value="guest";var adres="ajax.account.php?who="+value;jQuery.ajax({url:adres,success:function(html){jQuery('#login_extend').hide();jQuery('#login_extend').html(html);jQuery('#login_extend').fadeIn("slow");}});return false;}
function checkout_shipping(){jQuery('#checkout_shipping_form').post_form('ajax.checkout.php?step=payment&','get',function(data){jQuery('#checkout2').hide();jQuery('#checkout2').html(data);jQuery('#checkout2').fadeIn('slow');})}
function loading(where){jQuery('#'+where).html('<div align="center" valing="middle" style="width: 100%; height:100%; vartical-align:middle; align:center;"><img src="images/loading.gif"></div>');}
function form_action_javascript(){jQuery('#checkout_confirmation').post_form('checkout_process.php','post',function(data){submit();})}
function checkout_payment(){jQuery('#checkout_payment_form').post_form('ajax.checkout.php?step=confirmation&','get',function(data){jQuery('#checkout3').hide();jQuery('#checkout3').html(data);jQuery('#checkout3').fadeIn('slow');})}
function pokazpodkat(which)
{$(".sub-product-menu").each(function(i){$(this).attr("class",'sub-product-menu-hidden');});$(".submenu"+which).attr("class",'sub-product-menu');}
function pokazpodkat2(which)
{$(".submenu"+which).attr("class",'sub-product-menu');}
function toggle(id){if($("#"+id+":hidden").length)
$("#"+id+":hidden").show("slow");else
$("#"+id+":visible").hide("slow");}
function toggle_bebik(id){if($("#"+id+":hidden").length){$("#"+id+":hidden").show("slow");$("#li_"+id).addClass("open");}
else{$("#"+id+":visible").hide("slow");$("#li_"+id).removeClass("open");}}
function toggle_dm(id)
{$(".open").each(function(i){$(this).removeClass("open");});$(".levelTwo").each(function(i){$(this).hide("slow");});$("#"+id+":hidden").show("slow");$("#li_"+id).addClass("open");}
function toggle_tr(id){$('#kategorie li.open ul').each(function(index){$(this).parent().removeClass('open');$(this).hide();});$("#"+id).show();$("#li_"+id).addClass("open");}
function toggle_blingbling(id){if($("#"+id+":hidden").length){$("#"+id+":hidden").show();$("#li_"+id).addClass("open");}
else{$("#"+id+":visible").hide();$("#li_"+id).removeClass("open");}}
function show_shipping_options(id){$(".shippingOptions").hide();$("#shipp"+id).show();}
function SPdeleteAllProductsFromBasket(){jQuery("tbody > tr").each(function(index){SPdeleteProductFromBasket($(this).attr("name"));});}
function SPdeleteProductFromBasket(pID){var adres="ajax.shoppingcart.php?remove=1&pID="+pID;jQuery.ajax({url:adres,success:function(html){ajax_top_basket_reload();jQuery('#product_in_basket'+pID).fadeOut('slow');if(html=='true'){location.reload();}
else{SPupdateTotals();SPupdateMessages();}}});}
function SPupdateQuantityInBasket(pID){var value=jQuery('#product_quantity'+pID).val();var adres="ajax.shoppingcart.php?update=1&pID="+pID+"&value="+value;jQuery.ajax({url:adres,success:function(html){ajax_top_basket_reload();jQuery('#product_in_basket'+pID).replaceWith(html);flashRow('product_in_basket'+pID,6,'add');SPchangeShippingMethod(0);SPupdateTotals();SPupdateMessages();}});}
function flashRow(id,times,action){if(times>0){if(action=='remove')
{$('#'+id).removeClass('SP-flashingRow');setTimeout('flashRow("'+id+'","'+(times-1)+'","add")',140-(times*20));}
else
{$('#'+id).addClass('SP-flashingRow');setTimeout('flashRow("'+id+'","'+(times-1)+'","remove")',140-(times*20));}}}
function SPupdateTotals(){var adres="ajax.shoppingcart.php?totals=1";jQuery.ajax({url:adres,success:function(html){jQuery('#totals').replaceWith(html);flashRow('totals',6,'add');}});}
function SPupdateMessages(){var adres="ajax.shoppingcart.php?messages=1";jQuery.ajax({url:adres,success:function(html){jQuery('#messages').replaceWith(html);}});}
function SPchangeShippingMethod(which){var value=$(which).val();var adres="ajax.shoppingcart.php?shippingMethod=1&value="+value;jQuery.ajax({url:adres,success:function(html){jQuery('#SPshipping').html(html);SPupdateTotals();SPchangePaymentMethod(0);}});}
function SPchangePaymentMethod(which){var value=$(which).val();var adres="ajax.shoppingcart.php?paymentMethod=1&value="+value;jQuery.ajax({url:adres,success:function(html){jQuery('#SPpayment').html(html);}});}
function SPshowChangeShippingMethodBox(module){jQuery('#SP'+module+'Method').hide();jQuery('#SP'+module+'MethodChoose').show();}
function SPchangeQuantityInInput(id,action){var thisValue=$("#"+id).val()
if(action=="plus")thisValue++;if(action=="minus")thisValue--;if(thisValue<0)thisValue=0;$("#"+id).val(thisValue);SPcalculateAjaxCart();}
function SPcalculateAjaxCart(){var qty=jQuery('#products_qty').val();var value=jQuery('#price').val();value=value.replace(',','.');wartosc=parseFloat(qty*value);wartosc=SPZaokraglenie(wartosc);jQuery('#priceValue').html(wartosc);}
function SPchangeSubproductOnAjaxCart(spID,pID){if(spID!=''){jQuery('#SPloader').show();var adres="ajax.addToCart.php?pID="+pID+"&spID="+spID;jQuery.ajax({url:adres,success:function(html){jQuery('#ajaxShoppingCart').replaceWith(html);jQuery('#SPloader').hide('slow');}});}}
function SPZaokraglenie(kvat1){kvat1=kvat1*100;var wynik=Math.round(kvat1)/100;wynik=String(wynik);tab=wynik.split('.');if(!isset(tab[1])){wynik=wynik+'.00';tab[1]='00';}
else if(tab[1].length==1)
wynik=wynik+'0';return wynik.replace(".",",");}
function isset(varname){return eval('typeof('+ varname+') != "undefined"');}
function companyVSPersonal(what){if(what=='personal'){$('#company').hide();$('#nip').hide();}else{$('#company').show();$('#nip').show();}}
