/*
	window_containers.js
	functions_basic.js
	shop script.js
	shop script_order.js
*/

jQuery(document).ready(function(){function wConsole(o,prop){if(!jQuery("#consoleAct").is(':checked'))return;var p={};jQuery.extend(p,prop);var txt="<b>"+o.find(".n:first").html()+"::  </b>";for(var property in p){var pr=p[property];txt+="<br>"+property+" = "+pr}txt+="<br><hr>";jQuery("#mb_console").append(txt)}jQuery(".containerPlus").buildContainers({containment:"document",elementsPath:"/img/framework/",onResize:function(o){wConsole(o,{resized:true,width:o.outerWidth(),height:o.outerHeight()})},onClose:function(o){wConsole(o,{closed:o.mb_getState("closed")});if(jQuery('#main_menu').exists()){var visible=0;jQuery('.containerPlus').each(function(d,dialog){if(jQuery(this).is(':visible')){visible++}});if(getTinyMceActivated()&&visible==1){hideFade('fade')}else if(visible==1)showMainMenu()}},onCollapse:function(o){wConsole(o,{collapse:o.mb_getState("collapsed")})},onIconize:function(o){wConsole(o,{iconized:o.mb_getState("iconized")})},onDrag:function(o){wConsole(o,{top:o.offset().top,left:o.offset().left})}});jQuery('#main_dialog').mb_close();jQuery('#edit_dialog').mb_close()});var TinyMceActivated=false;var loading_done=false;var showQueue=new Array();jQuery(document).ready(function(){loadSiteMenu('menu');loadPageContent(getCurrentPageName(),'',getCurrentPageID(),getHasChildren(),getCurrentPagePlugin())});jQuery.fn.centerScreen=function(){var obj=this;obj.css('top',jQuery(window).height()/2-this.height()/2);obj.css('left',jQuery(window).width()/2-this.width()/2);jQuery(window).resize(function(){obj.centerScreen()})};jQuery.fn.timeOut=function(time,callback){if(typeof(callback)=="undefined")callback=function(){};var obj=this;obj.queue(function(){setTimeout(function(){obj.dequeue();callback()},time)})};jQuery.fn.exists=function(){return jQuery(this).length>0};function stripslashes(str){return(str+'').replace(/\\(.?)/g,function(s,n1){switch(n1){case'\\':return'\\';case'0':return'\u0000';case'':return'';default:return n1}})}function addslashes(str){return(str+'').replace(/[\\"']/g,'\\$&').replace(/\u0000/g,'\\0')}function setCurrentPageID(PageID){CurrentPageID=PageID}function getCurrentPageID(){return CurrentPageID}function setCurrentPageName(PageName){CurrentPageName=PageName}function getCurrentPageName(){return CurrentPageName}function setCurrentPageParentID(PageParentID){CurrentPageParentID=PageParentID}function getCurrentPageParentID(){return CurrentPageParentID}function setHasChildren(Children){HasChildren=Children}function getHasChildren(){return HasChildren}function setCurrentPagePlugin(Plugin,callback){if(typeof callback=="undefined")callback=function(){};CurrentPagePlugin=Plugin;callback()}function getCurrentPagePlugin(){return CurrentPagePlugin}function setTextPosition(Position){TextPosition=Position}function getTextPosition(){return TextPosition}function setTinyMceActivated(active){TinyMceActivated=active}function getTinyMceActivated(){return TinyMceActivated}function loadDialog(div,content_url,icon,name,callback,login,width){if(typeof callback=="undefined")callback=function(){};if(typeof width=="undefined")width=700;setDialogWidth(div,width);jQuery('#'+div+'_content').empty().load(content_url,'',function(){callback();activateDialogWindow(div,login)});jQuery('#'+div+'_title').html(name);setDialogWindowIcon(div,icon+'.png','/img/framework/dialog_icons/'+icon+'.png')}function setDialogWidth(div,width){jQuery('#'+div).width(width)}function activateDialogWindow(div,login){if(typeof login=="undefined"||login==null){if(jQuery('#main_menu').is(':visible')){hideMainMenu()}}showDialogWindow(div)}function showDialogWindow(div){showFade('fade',0.7);jQuery('#'+div).centerScreen();jQuery('#'+div).mb_open()}function hideDialogWindow(div){jQuery('#'+div).mb_close();jQuery('#'+div).unbind()}function setDialogWindowIcon(div,icon_name,icon_path){jQuery('#'+div).attr('icon',icon_name).find('.icon').attr('src',icon_path)}function showAjaxLoader(position){switch(position){case 1:jQuery('#ajax_loader').css('margin-left','-'+(jQuery('#ajax_loader').width()/2)+'px').show('fast');break;case 2:jQuery('#ajax_loader').css('margin-left','-'+((jQuery('#ajax_loader').width()/2)+107)+'px').show('fast');break}}function showSubmenu(div){var slide_height='30'}function hideSubmenu(div){if(jQuery('#'+div).is(':visible')){}}function showFade(div,transparency){if(jQuery('#'+div).exists()&&jQuery('#'+div).is(':hidden')){jQuery('#'+div).css('display','block').css('opacity',0).fadeTo('fast',transparency)}}function hideFade(div){if(jQuery('#'+div).exists()&&jQuery('#'+div).is(':visible')){jQuery('#'+div).fadeTo('fast',0,function(){jQuery('#'+div).hide()})}}function loadSiteMenu(div){jQuery('#'+div).load('/modules/edit_page/load.php?item=menu','',function(){jQuery('#'+div).ptMenu()})}function loadSiteSubmenu(div,parent_id){jQuery('#'+div).load('/modules/edit_page/load.php?item=submenu&id='+parent_id,'',function(){showSubmenu(div);jQuery('.sub_item').each(function(){jQuery(this).css('font-weight','normal');var split=jQuery(this).attr('id').split('sub_item');if(split[1]==getCurrentPageID()){jQuery(this).css('font-weight','bold')}})})}function loadPageContent(p_name,s_name,id,has_children){showAjaxLoader(2);p_name=URLEncode(p_name);s_name=URLEncode(s_name);jQuery('#normal_content').hide('fast');jQuery('#plugin_top').hide('fast').empty();jQuery('#plugin_bottom').hide('fast').empty();jQuery('#footer').empty();jQuery('#container').css('background-position','-1817px 0px');jQuery('#content_top').css('background-position','0px 0px');jQuery('#permanent_assets').show('fast');if(!getTinyMceActivated()){showQueue[showQueue.length]='#normal_content';if(s_name==""){setCurrentPageID(id);setCurrentPageName(p_name);jQuery('#normal_content').load('/modules/edit_page/load.php?item=page_content&p='+p_name,function(){});loadSiteSubmenu('submenu',id)}else{setCurrentPageID(id);setCurrentPageName(s_name);if(jQuery('#sub_title').attr('class')!=getCurrentPageParentID()){loadSiteSubmenu('submenu',getCurrentPageParentID())}jQuery('#normal_content').load('/modules/edit_page/load.php?item=page_content&p='+p_name+'&s='+s_name,function(){})}}else{showQueue[showQueue.length]='#page_content_tbl';var ed=tinyMCE.get('page_content');if(s_name==""){jQuery.get('/modules/edit_page/load.php?item=page_content&p='+p_name,function(data){setCurrentPageID(id);setCurrentPageName(p_name);ed.setContent(data);loadSiteSubmenu('submenu',id)})}else{jQuery.get('/modules/edit_page/load.php?item=page_content&p='+p_name+'&s='+s_name,function(data){setCurrentPageID(id);setCurrentPageName(s_name);ed.setContent(data);var head_page=jQuery('.sub_title').attr('id').split('sub_title');if(head_page[1]!=getCurrentPageParentID()){loadSiteSubmenu('submenu',getCurrentPageParentID())}else{jQuery('.sub_item').each(function(){jQuery(this).css('font-weight','normal');var split=jQuery(this).attr('id').split('sub_item');if(split[1]==getCurrentPageID()){jQuery(this).css('font-weight','bold')}})}})}handlePluginTab()}if(getCurrentPagePlugin()!=''){jQuery.ajax({type:'GET',url:'/modules/'+getCurrentPagePlugin()+'/index.php',data:'',success:function(data){if(getTextPosition()=='bottom'){showQueue[showQueue.length]='#plugin_top';jQuery('#plugin_top').html(data)}else if(getTextPosition()=='top'){showQueue[showQueue.length]='#plugin_bottom';jQuery('#plugin_bottom').html(data)}else{jQuery('#normal_content').hide('fast');jQuery('#page_content_tbl').hide('fast');showQueue[showQueue.length]='#plugin_top';jQuery('#plugin_top').html(data)}}})}else{jQuery.each(showQueue,function(i,item){jQuery(item).show('fast')});showQueue=[];loading_done=true}}var filterArray=new Array();var vat_rate1=0;var vat_rate2=0;var small_order_charge=4.00;var small_order_limit=45.00;var productsOnPage=10;var statuses=[];var productId=0;var pageCatId=0;var tempAssetsHeight=0;var activeProdPage=1;var activeSearchPage=1;var extra_category_filters=0;var cartLoaded=false;var footer_out=false;var active_filters=false;var back_to='products';var sort_products_by='name~asc';var config_compilations='';var product_stock=0;var set_configs=false;jQuery.getJSON('/modules/shop/load.php?item=vat_rates',function(data){vat_rate1=parseFloat(data[0]);vat_rate2=parseFloat(data[1])});jQuery(document).ready(function(){jQuery('#sort_products_by').change(function(){showAjaxLoader(2);sort_products_by=jQuery(this).val();jQuery.getJSON('/modules/shop/load.php?item=categories&load=single_page&page='+getCurrentPageID(),function(data){activeProdPage=1;activeSearchPage=1;statuses['nieuw']=0;statuses['opruiming']=0;statuses['aanbieding']=0;statuses['populair']=0;pageCatId=data[0].id;filterArray['page']=pageCatId;loadCategories(data,data,0);loadProducts();if(jQuery('#shop_search').is(':visible')){search(jQuery('#search_string').html())}})});jQuery('#products_on_page').change(function(){showAjaxLoader(2);if(jQuery(this).val()!='*')productsOnPage=parseInt(jQuery(this).val());else productsOnPage=1000000000;jQuery.getJSON('/modules/shop/load.php?item=categories&load=single_page&page='+getCurrentPageID(),function(data){activeProdPage=1;activeSearchPage=1;statuses['nieuw']=0;statuses['opruiming']=0;statuses['aanbieding']=0;statuses['populair']=0;pageCatId=data[0].id;filterArray['page']=pageCatId;loadCategories(data,data,0);loadProducts();if(jQuery('#shop_search').is(':visible')){search(jQuery('#search_string').html())}})})});function setup(){filterArray=new Array();productId=0;activeProdPage=1;activeSearchPage=1;extra_category_filters=0;back_to='products';config_compilations='';product_stock=0;if(tempAssetsHeight==0){if(footer_out&&active_filters){jQuery('#permanent_assets').css('height',jQuery('#permanent_assets').height()-120+'px')}else if(footer_out){jQuery('#permanent_assets').css('height',jQuery('#permanent_assets').height()-95+'px')}footer_out=false;active_filters=false}else{jQuery('#permanent_assets').css('height',tempAssetsHeight+'px')}jQuery.getJSON('/modules/shop/load.php?item=categories&load=single_page&page='+getCurrentPageID(),function(data){pageCatId=data[0].id;filterArray['page']=pageCatId;loadCategories(data,data,0);loadProducts();if(!cartLoaded){loadTinyCart();cartLoaded=true}});statuses['nieuw']=0;statuses['opruiming']=0;statuses['aanbieding']=0;statuses['populair']=0}function loadProducts(){back_to='products';jQuery('#product_pages').empty().hide();var listParams='';for(key in filterArray){if(key!='indexOf')listParams+='&arr[]='+filterArray[key]}jQuery('#sort_products_by').attr('disabled','');jQuery('#products_on_page').attr('disabled','');jQuery.getJSON('/modules/shop/load.php?item=products'+listParams+'&sort='+sort_products_by,function(data){jQuery('#producttable tbody').empty();jQuery('#products_holder').remove();if(data.length==0){jQuery('#producttable tbody').append('<tr><td id="shop_message">Er zijn geen producten beschikbaar in deze categorie</td></tr>');jQuery('#ajax_loader').hide('fast')}else{var product_page=1;var edit='';if(HomePage==getCurrentPageID()){jQuery('#sort_products_by').attr('disabled','disabled');jQuery('#products_on_page').attr('disabled','disabled');jQuery('#producttable').after('<div style="width: 100%;" id="products_holder">'+'<div style="clear: both;">'+'<div style="background: #D4EADD url(img/site/head_text.png) no-repeat; width: 100%; height: 27px;">'+'<div style="padding-left: 5px; padding-top: 2px;"></div>'+'</div>'+'<div id="nieuw_col" class="status_col" style="width: 100%; min-height: 10px;"></div>'+'</div>'+'<div style="clear: both;">'+'<div style="background: #D4EADD url(img/site/head_text.png) no-repeat left -54px; width: 100%; height: 27px;">'+'<div style="padding-left: 5px; padding-top: 2px;"></div>'+'</div>'+'<div id="populair_col" class="status_col" style="width: 100%; min-height: 10px;"></div>'+'</div>'+'<div style="clear: both;">'+'<div style="background: #D4EADD url(img/site/head_text.png) no-repeat left -27px; width: 100%; height: 27px;">'+'<div style="padding-left: 5px; padding-top: 2px;"></div>'+'</div>'+'<div id="aanbieding_col" class="status_col" style="width: 100%; min-height: 10px;"></div>'+'</div>'+'<div style="clear: both;">'+'<div style="background: #D4EADD url(img/site/head_text.png) no-repeat left -81px; width: 100%; height: 27px;">'+'<div style="padding-left: 5px; padding-top: 2px;"></div>'+'</div>'+'<div id="opruiming_col" class="status_col" style="width: 100%; min-height: 10px;"></div>'+'</div>'+'</div>');var statuses_length=0;for(key in statuses){if(statuses.hasOwnProperty(key))statuses_length++}jQuery.each(data,function(i,item){var status=(item.status).split('~')[1];statuses[status.toLowerCase()]=statuses[status.toLowerCase()]+1;var status_count=statuses[status.toLowerCase()];edit='<a href="#" onclick="editProduct('+item.id+',\'Edit Product\')" style="margin-left: 5px;"><img src="/img/framework/edit_small.png" alt="edit this product" style="margin-top: 4px;"/></a><a href="javascript:void(0);" onclick="deleteProduct('+item.id+')" style="margin-left: 2px;"><img src="/img/framework/remove_small.png" alt="delete this product" style="margin-top: 4px;"/></a> ';var title=URLDecode(item.name);if(title.length>35){title=title.substring(0,32);title=title+' ...'}var description=URLDecode(item.description);if(description.length>120){description=description.substring(0,117);description=description+' ...'}var prefix='';if(item.combo==true&&!item.constant_price)prefix=' v.a';var temp_vat_rate=item.vat_rate.split('~');jQuery('#'+status.toLowerCase()+'_col').append('<div class="product_wrapper" style="float: left; '+(status_count%2==0?'':'margin-right: 30px;')+'" id="product'+item.id+'">'+'<div class="product_padding">'+'<div class="prod_image">'+'<a href="#" onclick="loadProduct(\''+item.id+'\',\''+str_replace("\"","%22",str_replace("'","",URLDecode(item.name)))+'\')">'+'<img src="/upload/products/'+URLDecode(item.img1).split('~')[0]+'" alt="'+URLDecode(item.name)+'"/>'+'</a>'+'</div>'+'<div class="prod_content_wrapper">'+'<div class="prod_header">'+'<a href="#" onclick="loadProduct(\''+item.id+'\',\''+str_replace("\"","%22",str_replace("'","",URLDecode(item.name)))+'\')">'+title+'</a>'+'</div>'+'<div class="prod_content">'+description+'</div>'+'<span '+(getTinyMceActivated()?'style="margin-left: -15px;"':'')+'>'+(getTinyMceActivated()?edit:'')+'<a href="#" onclick="loadProduct(\''+item.id+'\',\''+str_replace("\"","%22",str_replace("'","",URLDecode(item.name)))+'\')">details</a>'+'<font style="color: #1D4B5E"> | </font>'+'<a href="javascript:void(0);" id="order_prod_'+item.id+'">bestellen</a>'+'<font style="color: #1D4B5E"> | </font>'+'<font style="font-style: italic;">Prijs'+prefix+': &#8364; </font>'+number_format(priceInclusive(temp_vat_rate[1],item.price),2,',','')+'</span>'+'</div>'+'</div>'+'</div>');jQuery('#order_prod_'+item.id).click(function(){var stock=item.in_stock;if(1>stock){addToCart(item.id+'^',1,'',function(){customAlert('Er zijn momenteel 0 stuks voorradig. Het restant wordt zo snel mogelijk nageleverd of pas uw bestelling aan.','button')})}else{addToCart(item.id+'^',1,'',function(){customAlert('Het product is toegevoegd aan uw winkelmandje!')})}})});jQuery('.status_col').each(function(i){jQuery(this).find('.product_wrapper').filter(':last').css('border','0px');if(jQuery(this).length%2==0){jQuery(this).find('.product_wrapper').not(':last').filter(':last').css('border','0px')}})}else{jQuery('#producttable').after('<div id="products_holder" style="width: 100%;"></div>');jQuery.each(data,function(i,item){if(i%2==0){jQuery('#products_holder').append('<div class="product_page'+product_page+' page_product_holder" style="height: 110px; width: 100%; '+(product_page!=1?'display:none;':'')+'"></div>')};edit='<div style="float:left;"><a href="#" onclick="editProduct('+item.id+',\'Edit Product\')" style="margin-left: 5px;"><img src="/img/framework/edit_small.png" alt="edit this product" style="margin-top: 4px;"/></a><a href="javascript:void(0);" onclick="deleteProduct('+item.id+')" style="margin-left: 2px;"><img src="/img/framework/remove_small.png" alt="delete this product" style="margin-top: 4px;"/></a></div>';if((i+1)>productsOnPage*product_page){if(product_page==1){jQuery('#product_pages').html('<a href="javascript:void(0);" onclick="previousProductPage()"><font style="font-size: 16px;">&laquo;</font> vorige<font style="color: #1D4B5E"></a>'+' | </font><span id="page_navigation"></span><font style="color: #1D4B5E"> | </font>'+' <a href="javascript:void(0);" onclick="nextProductPage()">volgende <font style="font-size: 16px;">&raquo;</font></a>');jQuery('#page_navigation').append('<a href="javascript:void(0);" class="product_paging active_page" id="product_page_link1" onclick="showProductPage(1)">1</a>  ');jQuery('#product_pages').fadeIn('fast')}product_page++;jQuery('#page_navigation').append('<a href="javascript:void(0);" class="product_paging" id="product_page_link'+product_page+'" onclick="showProductPage('+product_page+')">'+product_page+'</a>  ')}var prefix='';if(item.combo==true&&!item.constant_price)prefix=' v.a';var temp_vat_rate=item.vat_rate.split('~');jQuery('#products_holder .page_product_holder:last').append('<div id="product'+item.id+'" class="product_wrapper" style="float: left; '+(jQuery('#products_holder .page_product_holder:last .product_wrapper').exists()?'margin-left: 30px;':'')+'">'+'<div class="product_padding">'+'<div class="prod_image">'+'<a href="#" onclick="loadProduct(\''+item.id+'\',\''+str_replace("\"","%22",str_replace("'","",URLDecode(item.name)))+'\')">'+'<img src="/upload/products/'+URLDecode(item.img1).split('~')[0]+'" alt="'+URLDecode(item.name)+'"/>'+'</a>'+'</div>'+'<div class="prod_content_wrapper">'+'<div class="prod_header">'+'<a href="#" onclick="loadProduct(\''+item.id+'\',\''+str_replace("\"","%22",str_replace("'","",URLDecode(item.name)))+'\')">'+URLDecode(item.name)+'</a>'+'</div>'+'<div class="prod_content">'+URLDecode(item.description)+'</div>'+'<div class="prod_footer">'+(getTinyMceActivated()?edit:'')+'</div>'+'<span>'+'<a href="#" onclick="loadProduct(\''+item.id+'\',\''+str_replace("\"","%22",str_replace("'","",URLDecode(item.name)))+'\')">details</a>'+'<font style="color: #1D4B5E"> | </font>'+'<a href="javascript:void(0);" id="order_prod_'+item.id+'">bestellen</a>'+'<font style="color: #1D4B5E"> | </font>'+'<font style="font-style: italic;">Prijs'+prefix+': &#8364; </font>'+number_format(priceInclusive(temp_vat_rate[1],item.price),2,',','')+'</span>'+'</div>'+'</div>'+'</div>');jQuery('#order_prod_'+item.id).click(function(){var stock=item.in_stock;if(1>stock){addToCart(item.id+'^',1,'',function(){customAlert('Er zijn momenteel 0 stuks voorradig. Het restant wordt zo snel mogelijk nageleverd of pas uw bestelling aan.','button')})}else{addToCart(item.id+'^',1,'',function(){customAlert('Het product is toegevoegd aan uw winkelmandje!')})}})})}}jQuery.each(showQueue,function(i,item){jQuery(item).show('fast')});showQueue=[];loading_done=true;jQuery('#ajax_loader').hide('fast');jQuery('#products_holder').find('.product_wrapper').not(':hidden').filter(':last').css('border','0px');if(jQuery('#products_holder').find('.product_wrapper').not(':hidden').length%2==0){jQuery('#products_holder').find('.product_wrapper').not(':hidden').not(':last').filter(':last').css('border','0px')}})}function nextProductPage(){if(jQuery('#products_holder').find('.product_wrapper').filter(':last').is(':hidden')){showProductPage(activeProdPage+1);scroll(0,0)}}function previousProductPage(){if(activeProdPage!=1){showProductPage(activeProdPage-1);scroll(0,0)}}function loadProduct(id,name){showAjaxLoader(2);productId=id;showProduct();jQuery.getJSON('/modules/shop/load.php?item=product&id='+id,function(data){var edit='';jQuery.each(data,function(i,item){jQuery('#product_content').load('/modules/shop/product/product.php','',function(){edit='<a href="#" onclick="editProduct('+item.id+',\'Edit Product\');" style="margin-left: 5px;"><img src="/img/framework/edit_small.png" alt="edit this product"/></a><a href="#" onclick="deleteProduct('+item.id+');hideProduct();" style="margin-left: 2px;"><img src="/img/framework/remove_small.png" alt="delete this product"/></a>';product_stock=item.in_stock;var split=URLDecode(item.img[0]).split('~')[0].split('.');var name=split[0];var extension='.'+split[1];jQuery('#head_image td').html('<img src="/upload/products/'+name+'_small'+extension+'" title="'+addslashes(URLDecode(item.name))+'"/>');var images=0;for(var i=0;i<3;i++){var split=URLDecode(item.img[i]).split('~')[0].split('.');if(split[0]!=''){images++}}for(var j=0;j<3;j++){var split=URLDecode(item.img[j]).split('~')[0].split('.');var name=split[0];var extension='.'+split[1];if(name!=''&&images>1){jQuery('#thumb_images td').append('<div '+(j==0?'class="active_thumb" style="margin-left: 0px !important;"':'')+' onclick="resetZoom(\''+name+'\',\''+extension+'\',\''+addslashes(URLDecode(item.name))+'\');jQuery(this).parent().children().each(function(){jQuery(this).removeClass()});jQuery(this).addClass(\'active_thumb\');">'+'<img src="/upload/products/'+name+'_thumb'+extension+'" class="thumb_img"/>'+'</div>')}}jQuery('#product_details').append('<tr><th colspan="2">'+URLDecode(item.name)+(getTinyMceActivated()?edit:'')+'</th></tr>'+'<tr><td colspan="2">'+nl2br(URLDecode(item.description))+'</td></tr>');jQuery.each(item.info,function(key,info){jQuery('#product_details').append('<tr><td>'+ucwords(info[0])+':</td><td>'+ucwords(info[1])+'</td></tr>')});var temp_vat_rate=item.vat_rate.split('~');jQuery('#product_details').append('<tr><td class="product_price" colspan="2">Prijs &#8364; <span id="detail_prod_price" style="font-weight: bold; font-style: italic;">'+number_format(priceInclusive(temp_vat_rate[1],item.price),2,',','')+'</span></td></tr>');var out_of_stock_split=item.out_of_stock.split('~');if(item.in_stock>0){var stock_text='<div><img src="img/site/in_stock.png" alt="Op voorraad" id="stock_img" style="display: block; float: left;"><div style="float: left; margin-left: 10px; margin-top: 1px; display: none;" id="stock_period">'+out_of_stock_split[1]+'</div></div>'}else{var stock_text='<div><img src="img/site/out_of_stock.png" alt="Geen voorraad" id="stock_img" style="display: block; float: left;"/><div style="float: left; margin-left: 10px; margin-top: 1px;" id="stock_period">'+out_of_stock_split[1]+'</div></div>'}jQuery('#order_product_stock').parent().prepend(stock_text);jQuery('#order_product_stock').val(product_stock);if(item.configs!=''){jQuery.each(item.configs,function(c,config){jQuery('#order_product_now_parent').before('<tr>'+'<td>'+ucwords(URLDecode(config.name))+':</td>'+'<td><select id="product_config'+config.id+'" class="product_config"></select></td>'+'</tr>');jQuery.each(config.children,function(cc,child){jQuery('#product_config'+child.parent_id).append('<option value="'+child.id+'">'+child.name+'</option>')})})}jQuery.getJSON('/modules/shop/load.php?item=product_stock&product_id='+item.id,function(data){config_compilations=data;var config_composition=[];jQuery('.product_config').each(function(){config_composition[config_composition.length]=jQuery(this).val()});jQuery.each(config_compilations,function(j,jtem){if(arrayEqual(config_composition,(jtem.configs).split(','))){jQuery('#detail_prod_price').html(number_format(priceInclusive(temp_vat_rate[1],jtem.price),2,',',''));product_stock=jtem.stock;if(product_stock>0){var stock_src='img/site/in_stock.png';jQuery('#stock_period').hide()}else{var stock_src='img/site/out_of_stock.png';jQuery('#stock_period').text(out_of_stock_split[1]).show()}jQuery('#stock_img').attr('src',(stock_src));jQuery('#order_product_stock').val(product_stock)}})});jQuery('.product_config').change(function(){var config_composition=[];jQuery('.product_config').each(function(){config_composition[config_composition.length]=jQuery(this).val()});jQuery.each(config_compilations,function(j,jtem){if(arrayEqual(config_composition,(jtem.configs).split(','))){jQuery('#detail_prod_price').html(number_format(priceInclusive(temp_vat_rate[1],jtem.price),2,',',''));product_stock=jtem.stock;if(product_stock>0){var stock_src='img/site/in_stock.png';jQuery('#stock_period').hide()}else{var stock_src='img/site/out_of_stock.png';jQuery('#stock_period').show()}jQuery('#stock_img').attr('src',(stock_src));jQuery('#order_product_stock').val(product_stock)}})});jQuery('#order_product_now').click(function(){var cart_id='';jQuery('.product_config').each(function(){cart_id+='~'+jQuery(this).val()});var temp_stock=parseInt(jQuery('#order_product_stock').val());if(parseInt(jQuery('#order_product_quantity').val())!=0){if(parseInt(jQuery('#order_product_quantity').val())>temp_stock){if(parseInt(temp_stock)<0){temp_stock=0}addToCart(item.id+'^'+cart_id,jQuery('#order_product_quantity').val(),'',function(){customAlert('Er zijn momenteel '+temp_stock+' stuks voorradig. Het restant wordt zo snel mogelijk nageleverd of pas uw bestelling aan.','button');hideProduct()})}else{addToCart(item.id+'^'+cart_id,jQuery('#order_product_quantity').val(),'',function(){customAlert('Het product is toegevoegd aan uw winkelmandje!');hideProduct()})}}else{customAlert('Als u het product wilt bestellen, moet het te bestellen aantal minimaal 1 bedragen.')}})})});jQuery('#ajax_loader').hide('fast')})}function arrayEqual(toCompareArray,dbArray){var count=0;jQuery.each(dbArray,function(j,jtem){if(jtem==toCompareArray[j]){count++}});if(count==dbArray.length){return true}else{return false}}function showProductPage(page){showAjaxLoader(2);var last_iteration1=jQuery('.product_page'+activeProdPage).length-1;jQuery('.product_page'+activeProdPage).each(function(i){jQuery(this).hide('fast',function(){if(i==last_iteration1){var last_iteration2=jQuery('.product_page'+page).length-1;jQuery('.product_page'+page).each(function(j){jQuery(this).fadeIn(function(){if(j==last_iteration2){activeProdPage=page;jQuery('.product_paging').removeClass('active_page');jQuery('#product_page_link'+activeProdPage).addClass('active_page');jQuery('#products_holder').find('.product_wrapper').not(':hidden').filter(':last').css('border','0px');if(jQuery('#products_holder').find('.product_wrapper').not(':hidden').length%2==0){jQuery('#products_holder').find('.product_wrapper').not(':hidden').not(':last').filter(':last').css('border','0px')}jQuery('#ajax_loader').hide('fast')}})})}})})}function showProduct(){jQuery('#shop_general').hide();jQuery('#cart_content').hide();jQuery('#shop_checkout').hide();jQuery('#normal_content').hide();jQuery('#shop_search').hide();if(jQuery('#page_content_tbl').exists())jQuery('#page_content_tbl').hide();if(jQuery('#product_content').is(':hidden'))jQuery('#product_content').fadeIn('fast')}function hideProduct(){jQuery('#product_content').hide();jQuery('#cart_content').hide();jQuery('#shop_checkout').hide();if(back_to=='products'){jQuery('#shop_search').hide();if(jQuery('#page_content_tbl').exists()){jQuery('#page_content_tbl').show()}else{jQuery('#normal_content').show()}if(jQuery('#shop_general').is(':hidden'))jQuery('#shop_general').fadeIn('fast')}else if(back_to=='search'){jQuery('#shop_general').hide();if(jQuery('#shop_search').is(':hidden'))jQuery('#shop_search').fadeIn('fast')}}function loadCategories(root,data,iteration){var number_of_cat=4;var number_of_sub_cat=5;var tables=0;var filter_items=0;var table_width=100/number_of_cat;var edit='';if(iteration==0){jQuery('#footer').html('<div id="active_filters">'+'<div id="title">Actieve Filters:</div>'+'</div>'+'<table cellpadding="0" cellspacing="0" id="filtertable" class="filterTable" style="display:none;">'+'<tbody><tr id="filter_content"></tr></tbody>'+'</table>');showQueue[showQueue.length]='#filtertable'}jQuery.each(data,function(i,item){edit='<a href="javascript:void(0);" onclick="editCategory('+item.id+')"><img src="/img/framework/edit_tiny.png" alt="edit this category"/></a><a href="javascript:void(0);" onclick="deleteCategory('+item.id+','+item.parent_id+')" style="margin-left: 2px; margin-right: 2px;"><img src="/img/framework/remove_tiny.png" alt="delete this category"/></a>';if(item.is_page==-1){if(checkIfIsPage(root,item.parent_id)){tables++;if(tables<=number_of_cat){jQuery('#filtertable tbody #filter_content').append('<td valign="top" width="'+table_width+'%">'+'<table id="filter'+item.id+'" class="innerFilter">'+'<tbody><tr><th>'+(getTinyMceActivated()?edit:'')+'Alle '+item.name+'</th></tbody>'+'</table>'+'</td>')}else{if(tables==number_of_cat+1){var last=jQuery('#filter_content').children('td:last').find('th').html().split('Alle');var last_id=jQuery('#filter_content').children('td:last').find('table').attr('id').split('filter')[1];var penultimate=jQuery('#filter_content').children('td').not(':last').filter(':last').find('th').html().split('Alle');var penultimate_id=jQuery('#filter_content').children('td').not(':last').filter(':last').find('table').attr('id').split('filter')[1];jQuery('#filter_content').children('td:last').empty();jQuery('#filter_content').children('td:last').append('<table id="extra_filters" class="innerFilter">'+'<tr><th>Meer opties...</th></tr>'+'<tr><td>'+last[0]+'<a href="javascript:void(0);" onclick="loadExtraCategory(\''+last_id+'\',0)">Alle'+last[1]+'</a></td></tr>'+'<tr><td>'+penultimate[0]+'<a href="javascript:void(0);" onclick="loadExtraCategory(\''+penultimate_id+'\',0)">Alle'+penultimate[1]+'</a></td></tr>'+'</table>')}else{jQuery('#extra_filters').append('<tr><td>'+(getTinyMceActivated()?edit:'')+'<a href="javascript:void(0);" onclick="loadExtraCategory(\''+item.id+'\',0)">Alle '+item.name+'</a></td></tr>')}}}else{filter_items++;if(filter_items>number_of_sub_cat){if(!jQuery('#filter_expand_'+item.parent_id).exists()){jQuery('#filter'+item.parent_id+' tbody tr:last').addClass('hidden_filter');jQuery('#filter'+item.parent_id+' tbody').append('<tr id="filter_expand_'+item.parent_id+'" class="filter_expand"><td><a href="javascript:void(0);" onclick="toggleExpandFilter()" style="font-weight: bold;">meer &#62;&#62;</a></td></tr>')}jQuery('#filter_expand_'+item.parent_id).before('<tr id="category'+item.id+'" class="hidden_filter"><td class="hidden">'+(getTinyMceActivated()?edit:'')+'<a href="javascript:void(0);" onclick="setFilter(\''+item.parent_id+'\',\''+item.id+'\');loadProducts()">'+item.name+'</a></td></tr>')}else{jQuery('#filter'+item.parent_id+' tbody').append('<tr id="category'+item.id+'"><td>'+(getTinyMceActivated()?edit:'')+'<a href="javascript:void(0);" onclick="setFilter(\''+item.parent_id+'\',\''+item.id+'\');loadProducts()">'+item.name+'</a></td></tr>')}}loadCategories(root,item.children,iteration+1)}});if(iteration==0){for(var i=0;i<(number_of_cat-tables);i++){jQuery('#filtertable tbody #filter_content').append('<td valign="top" width="'+table_width+'%"></td>')}jQuery('#filter_content').children('td:last').css('border-right','0px')}}function toggleExpandFilter(){if(jQuery('.hidden_filter .hidden').exists()){jQuery('.hidden_filter td').removeClass('hidden');if(jQuery('#holder').height()<jQuery('#permanent_assets').height()){tempAssetsHeight=0;footer_out=true;jQuery('#permanent_assets').css('height',jQuery('#permanent_assets').height()).animate({height:jQuery('#permanent_assets').height()+95+'px'},'fast')}else{tempAssetsHeight=jQuery('#permanent_assets').height();footer_out=true;jQuery('#permanent_assets').css('height',jQuery('#permanent_assets').height()).animate({height:jQuery('#holder').height()+105+'px'},'fast')}jQuery('#filtertable').css('height','115px').animate({height:'210px'},'fast');jQuery('.filter_expand a').html('minder &#60;&#60;');jQuery('.hidden_filter').show();jQuery('.hidden_filter').children().show()}else{var callback=jQuery('.hidden_filter').length-1;jQuery('.hidden_filter').each(function(i){jQuery(this).fadeOut(function(){if(i==callback){jQuery('.hidden_filter').children().fadeOut();footer_out=false;if(tempAssetsHeight==0){jQuery('#permanent_assets').css('height',jQuery('#permanent_assets').height()).animate({height:jQuery('#permanent_assets').height()-95+'px'},'fast')}else{if(active_filters){jQuery('#permanent_assets').css('height',jQuery('#permanent_assets').height()).animate({height:jQuery('#permanent_assets').height()-105+'px'},'fast')}else{jQuery('#permanent_assets').css('height',jQuery('#permanent_assets').height()).animate({height:tempAssetsHeight+'px'},'fast')}}jQuery('#filtertable').css('height','210px').animate({height:'115px'},'fast');jQuery('.filter_expand a').html('meer &#62;&#62;')}});jQuery(this).find('td').addClass('hidden')})}}function checkIfIsPage(data,category_id){for(var i=0;i<data.length;i++){var item=data[i];if(item.id==category_id&&item.is_page!=-1){return true;break}}return false}function loadExtraCategory(category_id,iteration){var number_of_sub_cat=5;var edit='';jQuery.getJSON('/modules/shop/load.php?item=category&children&id='+category_id,function(data){jQuery.each(data,function(i,item){edit='<a href="javascript:void(0);" onclick="editCategory('+item.id+')"><img src="/img/framework/edit_tiny.png" alt="edit this category"/></a><a href="javascript:void(0);" onclick="deleteCategory('+item.id+','+item.parent_id+')" style="margin-left: 2px; margin-right: 2px;"><img src="/img/framework/remove_tiny.png" alt="delete this category"/></a>';if(iteration==0){extra_category_filters=0;jQuery('#filter_content').children('td').not(':last').filter(':last').html('<table id="filter'+item.id+'" class="innerFilter">'+'<tbody><tr><th>'+(getTinyMceActivated()?edit:'')+'Alle '+item.name+'</th></tbody>'+'</table>')}else{extra_category_filters++;if(extra_category_filters>number_of_sub_cat){var element=jQuery('#filter_content').children('td').not(':last').filter(':last');if(!jQuery('#filter_expand_'+item.parent_id).exists()){element.find('tbody tr:last').addClass('hidden_filter');if(jQuery('.hidden_filter').css('display')!='table-row'){element.find('tbody').append('<tr id="filter_expand_'+item.parent_id+'" class="filter_expand"><td><a href="javascript:void(0);" onclick="toggleExpandFilter()" style="font-weight: bold;">meer &#62;&#62;</a></td></tr>')}else{element.find('tbody').append('<tr id="filter_expand_'+item.parent_id+'" class="filter_expand"><td><a href="javascript:void(0);" onclick="toggleExpandFilter()" style="font-weight: bold;">minder &#60;&#60;</a></td></tr>')}}jQuery('#filter_expand_'+item.parent_id).before('<tr id="category'+item.id+'" class="hidden_filter"><td class="hidden">'+(getTinyMceActivated()?edit:'')+'<a href="javascript:void(0);" onclick="setFilter(\''+item.parent_id+'\',\''+item.id+'\');loadProducts()">'+item.name+'</a></td></tr>')}else{jQuery('#filter_content').children('td').not(':last').filter(':last').find('tbody').append('<tr><td>'+(getTinyMceActivated()?edit:'')+'<a href="javascript:void(0);" onclick="setFilter(\''+item.parent_id+'\',\''+item.id+'\');loadProducts()">'+item.name+'</a>'+'</td></tr>')}}jQuery.each(item.children,function(c,child){loadExtraCategory(child.id,iteration+1)})})})}function setFilter(parent_id,id){removeFilter(parent_id);filterArray[parent_id]=id;jQuery.getJSON('/modules/shop/load.php?item=category&id='+id+'&parent_id='+parent_id,function(data){jQuery.each(data,function(i,item){if(jQuery('#active_filters').find('#'+parent_id).length==0){jQuery('#active_filters').append('<div class="filter" id="'+parent_id+'">'+item.parent_name+': '+item.name+'<a href="javascript:void(0);" onclick="removeFilter('+parent_id+');loadProducts();" style="margin-left: 2px;">'+'<img src="/img/site/remove.png" alt="verwijder deze filter optie" class="remove"/>'+'</a>'+'</div>')}else{jQuery('#'+parent_id).html(item.parent_name+': '+item.name+'<a href="#" onclick="removeFilter('+parent_id+');loadProducts();">'+'<img src="/img/site/remove.png" alt="verwijder deze filter optie" class="remove"/>'+'</a>');if(jQuery('#active_filters').find('#'+parent_id).is(':hidden')){jQuery('#active_filters').find('#'+parent_id).show()}}})});if(jQuery('#active_filters').is(':hidden')){if(jQuery('#holder').height()<jQuery('#permanent_assets').height()){tempAssetsHeight=0;active_filters=true;jQuery('#permanent_assets').css('height',jQuery('#permanent_assets').height()).animate({height:jQuery('#permanent_assets').height()+25+'px'},'fast')}else{tempAssetsHeight=jQuery('#permanent_assets').height();active_filters=true;if(footer_out){jQuery('#permanent_assets').css('height',jQuery('#permanent_assets').height()).animate({height:jQuery('#permanent_assets').height()+25+'px'},'fast')}else{jQuery('#permanent_assets').css('height',jQuery('#permanent_assets').height()).animate({height:jQuery('#holder').height()+35+'px'},'fast')}}jQuery('#active_filters').fadeIn('fast')}}function resetZoom(source,extension,name){jQuery('#head_image td').fadeTo('fast',0.05,function(){jQuery('#head_image td').html('<img src="/upload/products/'+source+'_small'+extension+'" title="'+name+'"/>')}).fadeTo('fast',1)}function removeFilter(parent_id){jQuery('#active_filters').find('#'+parent_id).hide();filterArray=removeKey(filterArray,parent_id)}function search(){showAjaxLoader(2);back_to='search';jQuery('#sort_products_by').attr('disabled','');jQuery('#products_on_page').attr('disabled','');jQuery('#footer').empty();jQuery('#container').css('background-position','-1817px 0px');jQuery('#content_top').css('background-position','0px 0px');jQuery('#permanent_assets').show();jQuery('#search_pages').empty().hide();jQuery('#shop_general').hide();jQuery('#cart_content').hide();jQuery('#shop_checkout').hide();jQuery('#normal_content').hide();jQuery('#product_content').hide();if(jQuery('#page_content_tbl').exists())jQuery('#page_content_tbl').hide();if(jQuery('#shop_search').is(':hidden')){jQuery('#shop_search').fadeIn('fast');jQuery('#submenu').html('<div id="sub_title_search" class="sub_title"><a href="javascript:void(0);">Search results</a></div>')}var search_string=jQuery('#search_field').val();jQuery.getJSON('/modules/shop/load.php?item=search&s='+search_string+'&sort='+sort_products_by,function(data){jQuery('#search_products_holder').empty();jQuery('#search_products_holder').append('<div class="search_header">'+'<div>U heeft gezocht op: "<span id="search_string">'+search_string+'</span>"</div>'+'<div>Er zijn '+data.length+' resultaten gevonden</div>'+'</div>');if(data==""){jQuery('#search_products_holder').append('<div class="search_header">Er zijn helaas geen producten gevonden.</div>');jQuery('#ajax_loader').hide('fast')}else{var search_page=1;var edit='';jQuery.each(data,function(i,item){edit='<div style="display:inline;"><a href="#" onclick="editProduct('+item.id+',\'Edit Product\')" style="margin-left: 5px;"><img src="/img/framework/edit_tiny.png" alt="edit this product" style="margin-top: 4px;"/></a><a href="javascript:void(0);" onclick="deleteProduct('+item.id+')" style="margin-left: 2px;"><img src="/img/framework/remove_tiny.png" alt="delete this product" style="margin-top: 4px;"/></a></div>';if((i+1)>productsOnPage*search_page){if(search_page==1){jQuery('#search_pages').html('<a href="javascript:void(0);" onclick="previousSearchPage()"><font style="font-size: 16px;">&laquo;</font> vorige<font style="color: #1D4B5E"></a>'+' | </font><span id="search_navigation"></span><font style="color: #1D4B5E"> | </font>'+' <a href="javascript:void(0);" onclick="nextSearchPage()">volgende <font style="font-size: 16px;">&raquo;</font></a>');jQuery('#search_navigation').append('<a href="javascript:void(0);" class="search_paging active_page" id="search_page_link1" onclick="showProductPage(1)">1</a>  ');jQuery('#search_pages').fadeIn('fast')}search_page++;jQuery('#search_navigation').append('<a href="javascript:void(0);" class="search_paging" id="search_page_link'+search_page+'" onclick="showSearchPage('+search_page+')">'+search_page+'</a>  ')}var description=URLDecode(item.description);if(description.length>115){description=description.substring(0,112);description=description+' ...'}var prefix='';if(item.combo==true)prefix=' v.a';var split=URLDecode(item.img1).split('~')[0].split('.');var temp_vat_rate=item.vat_rate.split('~');jQuery('#search_products_holder').append('<div class="search_row search_page'+search_page+'"'+(search_page!=1?'style="display:none;"':'')+'>'+'<div style="float:left;">'+'<a href="#" onclick="loadProduct(\''+item.id+'\',\''+str_replace("\"","%22",str_replace("'","",URLDecode(item.name)))+'\')">'+'<img src="/upload/products/'+split[0]+'_tiny.'+split[1]+'" alt="'+URLDecode(item.name)+'" class="head_img"/>'+'</a>'+'</div>'+'<div style="float:right; width: 590px; height: 50px; margin-left: 8px; margin-top: -2px;">'+'<a href="#" onclick="loadProduct(\''+item.id+'\',\''+str_replace("\"","%22",str_replace("'","",URLDecode(item.name)))+'\')">'+URLDecode(item.name)+(getTinyMceActivated()?edit:'')+'</a>'+'<div class="prod_content">'+description+'</div>'+'<div id="search_order">'+'<a href="#" onclick="loadProduct(\''+item.id+'\',\''+str_replace("\"","%22",str_replace("'","",URLDecode(item.name)))+'\')">details</a>'+'<font style="color: #1D4B5E"> | </font>'+'<a href="javascript:void(0);" id="order__search_prod_'+item.id+'">bestellen</a>'+'<font style="color: #1D4B5E"> | </font>'+'<font style="font-style: italic;">Prijs'+prefix+': &#8364; </font>'+number_format(priceInclusive(temp_vat_rate[1],item.price),2,',','')+'</div>'+'</div>'+'</div>');jQuery('#order__search_prod_'+item.id).click(function(){var stock=item.in_stock;if(1>stock){addToCart(item.id+'^',1,'',function(){customAlert('Er zijn momenteel 0 stuks voorradig. Het restant wordt zo snel mogelijk nageleverd of pas uw bestelling aan.','button')})}else{addToCart(item.id+'^',1,'',function(){customAlert('Het product is toegevoegd aan uw winkelmandje!')})}})});jQuery('.search_row').not(':hidden').filter(':last').css('border','0px');jQuery('#ajax_loader').hide('fast')}})}function nextSearchPage(){if(jQuery('.search_row').filter(':last').is(':hidden')){showSearchPage(activeSearchPage+1);scroll(0,0)}}function previousSearchPage(){if(activeSearchPage!=1){showSearchPage(activeSearchPage-1);scroll(0,0)}}function showSearchPage(page){showAjaxLoader(2);var iteration_1=jQuery('.search_page'+activeSearchPage).length-1; var iteration_2=jQuery('.search_page'+page).length-1;jQuery('.search_page'+activeSearchPage).each(function(i){jQuery(this).hide('fast',function(){if(i==iteration_1){jQuery('.search_page'+page).each(function(j){jQuery(this).fadeIn(function(){jQuery(this).children().each(function(k){jQuery(this).show();var iteration_3=jQuery(this).children().length-1;if(i==iteration_1&&j==iteration_2&&k==iteration_3){activeSearchPage=page;jQuery('.search_paging').removeClass('active_page');jQuery('#search_page_link'+activeSearchPage).addClass('active_page');jQuery('.search_row').not(':hidden').filter(':last').css('border','0px');jQuery('#ajax_loader').hide('fast')}})})})}})})}function exitSearch(){jQuery('#shop_search').hide();jQuery('#cart_content').hide();jQuery('#shop_checkout').hide();jQuery('#product_content').hide();if(jQuery('#page_content_tbl').exists()){jQuery('#page_content_tbl').show()}else{jQuery('#normal_content').show()}if(jQuery('#shop_general').is(':hidden'))jQuery('#shop_general').fadeIn('fast')}function newPassword(password_id){jQuery('#plugin_top').hide();jQuery('#plugin_bottom').hide();jQuery('#normal_content').load('/modules/shop/new_password.php',{id:password_id},function(){jQuery('#normal_content').show();jQuery('#submit_new_pass').click(function(){if(jQuery('#new_pass_form').valid()){jQuery.post('/modules/shop/new_password.php',{password:jQuery('#new_password_confirm').val(),hash_id:jQuery('#pass_hash_id').val(),user_id:jQuery('#pass_user_id').val()},function(result){if(result){jQuery('.ctrlHolder').not(':first').hide();jQuery('.buttonHolder').hide();jQuery('#new_pass_label').html("Uw nieuwe wachtwoord is opgeslagen. U kunt nu met uw nieuwe wachtwoord inloggen.")}})}})})}function customAlert(message,fixed,fade){if(typeof fixed=='undefined')fixed=false;if(typeof fade=='undefined')fade=false;jQuery('#alert_message').html(message);if(fade){showFade('site_fade',0.65)}if(!fixed){jQuery('#alert').fadeIn('fast',function(){jQuery(this).timeOut(2000);jQuery(this).fadeOut('fast',function(){hideFade('site_fade')})})}else if(fixed=='button'){jQuery('#alert').find('input').show('fast');jQuery('#alert').fadeIn('fast')}else{jQuery('#alert').fadeIn('fast')}}function closeAlert(){jQuery('#alert').fadeOut('fast',function(){jQuery('#alert').find('input').css('display','none');hideFade('site_fade')})}function priceInclusive(vatRate,price){return((parseFloat(vatRate)/100)*parseFloat(price))+parseFloat(price)}function arrayLength(array){var count=0;for(i in array){count++}return count}function removeKey(arrayName,key){var x;var tmpArray=new Array();for(x in arrayName){if(x!=key){tmpArray[x]=arrayName[x]}}return tmpArray}function in_array(needle,haystack,argStrict){var key='',strict=!!argStrict;if(strict){for(key in haystack){if(haystack[key]===needle){return true}}}else{for(key in haystack){if(haystack[key]==needle){return true}}}return false}function ucwords(str){return(str+'').replace(/^(.)|\s(.)/g,function($1){return $1.toUpperCase()})}function number_format(number,decimals,dec_point,thousands_sep){var n=number,prec=decimals;var toFixedFix=function(n,prec){var k=Math.pow(10,prec);return(Math.round(n*k)/k).toString()};n=!isFinite(+n)?0:+n;prec=!isFinite(+prec)?0:Math.abs(prec);var sep=(typeof thousands_sep==='undefined')?',':thousands_sep;var dec=(typeof dec_point==='undefined')?'.':dec_point;var s=(prec>0)?toFixedFix(n,prec):toFixedFix(Math.round(n),prec);var abs=toFixedFix(Math.abs(n),prec);var _,i;if(abs>=1000){_=abs.split(/\D/);i=_[0].length%3||3;_[0]=s.slice(0,i+(n<0))+_[0].slice(i).replace(/(\d{3})/g,sep+'$1');s=_.join(dec)}else{s=s.replace('.',dec)}var decPos=s.indexOf(dec);if(prec>=1&&decPos!==-1&&(s.length-decPos-1)<prec){s+=new Array(prec-(s.length-decPos-1)).join(0)+'0'}else if(prec>=1&&decPos===-1){s+=dec+new Array(prec).join(0)+'0'}return s}jQuery.fn.ellipsis=function(enableUpdating){var s=document.documentElement.style;if(!('textOverflow'in s||'OTextOverflow'in s)){return this.each(function(){var el=jQuery(this);if(el.css("overflow")=="hidden"){var originalText=el.html();var w=el.width();var t=jQuery(this.cloneNode(true)).hide().css({'position':'absolute','width':'auto','overflow':'visible','max-width':'inherit'});el.after(t);var text=originalText;while(text.length>0&&t.width()>el.width()){text=text.substr(0,text.length-1);t.html(text+"...")}el.html(t.html());t.remove();if(enableUpdating==true){var oldW=el.width();setInterval(function(){if(el.width()!=oldW){oldW=el.width();el.html(originalText);el.ellipsis()}},200)}}})}else return this};function str_replace(search,replace,subject,count){f=[].concat(search),r=[].concat(replace),s=subject,ra=r instanceof Array,sa=s instanceof Array;s=[].concat(s);if(count){this.window[count]=0}for(i=0,sl=s.length;i<sl;i++){if(s[i]===''){continue}for(j=0,fl=f.length;j<fl;j++){temp=s[i]+'';repl=ra?(r[j]!==undefined?r[j]:''):r[0];s[i]=(temp).split(f[j]).join(repl);if(count&&s[i]!==temp){this.window[count]+=(temp.length-s[i].length)/f[j].length}}}return sa?s:s[0]}var checkout_loaded=false;var waitFor=function(params){var condition=params.condition;var callback=params.callback;var interval=params.interval||300;var maxTries=params.maxTries||30;var currentTry=params._currentTry||0;if(condition()===true)return callback();if(currentTry<maxTries){params._currentTry=currentTry+1;var f=function(){return waitFor(params)};setTimeout(f,interval)}else{}};function initCheckout(){checkout_loaded=false;showAjaxLoader(1);jQuery('#shop_checkout').empty().unbind();jQuery('#shop_checkout').append('<div id="checkout_wrapper">'+'<div id="checkout_steps">'+'<div id="steps_holder">'+'<span id="stepLink1" class="stepLink">Stap 1<br/><span class="stepLinksmall">Winkelmandje</span></span>'+'<span id="stepLink2" class="stepLink">Stap 2<br/><span class="stepLinksmall">Uw gegevens</span></span>'+'<span id="stepLink3" class="stepLink">Stap 3<br/><span class="stepLinksmall">Betalen</span></span>'+'<span id="stepLink4" class="stepLink">Stap 4<br/><span class="stepLinksmall">Bevestiging</span></span>'+'</div>'+'<div id="steps_image_holder">'+'<span id="step_image1" class="step_image"></span>'+'<span id="step_image2" class="step_image"></span>'+'<span id="step_image3" class="step_image"></span>'+'<span id="step_image4" class="step_image"></span>'+'</div>'+'</div>'+'<div id="checkout_content">'+'<div id="step1"></div>'+'<div id="step2" style="display:none;"></div>'+'<div id="step3" style="display:none;"></div>'+'<div id="step4" style="display:none;"></div>'+'</div>'+'</div>');jQuery('#shop_general').hide();jQuery('#product_content').hide();jQuery('#normal_content').hide();jQuery('#shop_search').hide();if(jQuery('#page_content_tbl').exists())jQuery('#page_content_tbl').hide();if(jQuery('#shop_checkout').is(':hidden'))jQuery('#shop_checkout').fadeIn();jQuery('#container').css('background-position','-2724px 0px');jQuery('#content_top').css('background-position','-908px 0px');jQuery('#permanent_assets').hide();if(jQuery('#filtertable').exists())jQuery('#filtertable').hide();if(jQuery('#active_filters').exists())jQuery('#active_filters').hide();if(footer_out){if(tempAssetsHeight==0){jQuery('#permanent_assets').css('height',jQuery('#permanent_assets').height()-100+'px')}else{jQuery('#permanent_assets').css('height',tempAssetsHeight+'px')}}if(active_filters){if(tempAssetsHeight==0){jQuery('#permanent_assets').css('height',jQuery('#permanent_assets').height()-25+'px')}}loadStep1()}function exitCheckout(){jQuery('#shop_checkout').hide();jQuery('#product_content').hide();jQuery('#cart_content').hide();if(jQuery('#shop_general').is(':hidden'))jQuery('#shop_general').fadeIn();if(jQuery('#page_content_tbl').exists()){jQuery('#page_content_tbl').show()}else{jQuery('#normal_content').show()}jQuery('#container').css('background-position','-1817px 0px');jQuery('#content_top').css('background-position','0px 0px');if(jQuery('#filtertable').exists())jQuery('#filtertable').fadeIn();if(footer_out){if(tempAssetsHeight==0){jQuery('#permanent_assets').css('height',jQuery('#permanent_assets').height()+100+'px')}else{jQuery('#permanent_assets').css('height',jQuery('#holder').height()+100+'px')}}if(active_filters){if(jQuery('#active_filters').exists())jQuery('#active_filters').fadeIn();jQuery('#permanent_assets').css('height',jQuery('#permanent_assets').height()+25+'px')}jQuery('#permanent_assets').show()}function loadStep1(){showAjaxLoader(1);jQuery('#step2').hide();jQuery('#step1').fadeIn();jQuery('#stepLink2 .stepLinksmall').css('font-size','9px').css('text-decoration','none');jQuery('#stepLink3 .stepLinksmall').css('font-size','9px').css('text-decoration','none');jQuery('#step_image1').css('background-position','0px -466px');jQuery('#step_image2').css('background-position','-150px -486px');jQuery('#step1').html('<table>'+'<thead>'+'<tr>'+'<th>&#32;</th>'+'<th>Product</th>'+'<th>Aantal</th>'+'<th>Optie</th>'+'<th>Prijs</th>'+'<th>Totaal</th>'+'<th></th>'+'</tr>'+'</thead>'+'<tbody></tbody>'+'<tfoot></tfoot>'+'</table>');jQuery.getJSON('/modules/shop/load.php?item=cart&action=load',function(data){jQuery('#stepLink1 .stepLinksmall').css('font-size','11px').css('text-decoration','underline');jQuery('#step1 tbody').html('');jQuery.each(data,function(i,item){var quantity_input='';var quantity_order=0;var unique_id='';jQuery.each(item.selected_config,function(key,value){if(value!=''){unique_id+='-'+value}});quantity_input='<td><input id="cart_quantity'+item.id+unique_id+'" type="text" class="cart_quantity" name="'+item.in_stock+'~'+item.id+'~'+unique_id+'" value="'+item.quantity+'"/></td>';quantity_order=parseInt(item.quantity);var split=URLDecode(item.img1).split('~')[0].split('.');var name=split[0];var extension='.'+split[1];var temp_vat_rate=item.vat_rate.split('~');jQuery('#step1 tbody').append('<tr id="cart'+item.id+'" class="cart_row">'+'<td style="display: none;">'+'<input type="hidden" id="order_vat_rate'+item.id+unique_id+'" value="'+temp_vat_rate[1]+'"/>'+'<input type="hidden" id="cart_prod_vat'+item.id+unique_id+'" value="'+priceInclusive(temp_vat_rate[1],item.price)+'"/>'+'<input type="hidden" class="cart_prod_total cart_prod_sub_total cart_vat'+parseFloat(temp_vat_rate[1])+'" id="cart_prod_vat_total'+item.id+unique_id+'" value="'+(priceInclusive(parseFloat(temp_vat_rate[1]),parseFloat(item.price))*quantity_order)+'"/>'+'<input type="hidden" id="cart_prod_price'+item.id+unique_id+'" value="'+item.price+'"/>'+'<input type="hidden" id="cart_prod_total'+item.id+unique_id+'" value="'+(item.price*quantity_order)+'" class="cart_prod_price'+i+'"/>'+'</td>'+'<td><img class="head_img" src="/upload/products/'+name+'_tiny'+extension+'" alt="'+URLDecode(item.name)+'"/></td>'+'<td>'+URLDecode(item.name)+'</td>'+quantity_input+'<td id="configs_holder'+item.id+unique_id+'"></td>'+'<td>&#8364; '+number_format(priceInclusive(parseFloat(temp_vat_rate[1]),parseFloat(item.price)),2,',','')+'</span></td>'+'<td>&#8364; <span id="cart_prod_visible_total'+item.id+unique_id+'">'+number_format(priceInclusive(parseFloat(temp_vat_rate[1]),parseFloat(item.price)*quantity_order),2,',','')+'</span></td>'+'<td>'+'<img src="img/site/remove.png" alt="" onclick="removeFromCart(\''+item.id+'^'+unique_id.replace(/-/g,'~')+'\',\'cart\')" style="cursor:pointer;"/>'+'</td>'+'</tr>');jQuery.each(item.configs,function(c,config){jQuery('#configs_holder'+item.id+unique_id).append('<select class="cart_config '+item.id+' '+unique_id+'" id="cart_prod_config'+item.id+config.id+unique_id+'"></select>');jQuery.each(config.children,function(cc,child){jQuery('#cart_prod_config'+item.id+child.parent_id+unique_id).append('<option value="'+child.id+'" '+(in_array(child.id,item.selected_config)?'SELECTED':'')+'>'+child.name+'</option>');if(in_array(child.id,item.selected_config)){jQuery('#cart_prod_config'+item.id+child.parent_id+unique_id).addClass('ex'+child.id)}})})});jQuery('#step1 tfoot').append('<tr style="display:none;">'+'<td colspan="4"></td>'+'<td style="border-bottom: 1px solid #ccc;">Subtotaal:</td>'+'<td colspan="2" style="border-bottom: 1px solid #ccc;">&#8364; <span id="cart_sub_total"></span></td>'+'</tr>'+'<tr id="cart_small_order">'+'<td colspan="4"><input type="hidden" value="'+small_order_limit+'"></td>'+'<td>Kleine order <small>(< &#8364; '+parseInt(small_order_limit)+')</small>:</td>'+'<td colspan="2">&#8364; <span class="cart_prod_total">'+number_format(small_order_charge,2,',','')+'</span></td>'+'</tr>'+'<tr id="cart_tr_vat1">'+'<td colspan="4"></td>'+'<td>btw (6%):</td>'+'<td colspan="2">&#8364; <span id="cart_vat1"></span></td>'+'</tr>'+'<tr id="cart_tr_vat2">'+'<td colspan="4"></td>'+'<td style="border-bottom: 1px solid #999;">btw (19%):</td>'+'<td colspan="2" style="border-bottom: 1px solid #999;">&#8364; <span id="cart_vat2"></span></td>'+'</tr>'+'<tr style="font-weight: bold;">'+'<td colspan="4"></td>'+'<td>Te betalen:</td>'+'<td colspan="2">&#8364; <span id="cart_total"></span></td>'+'</tr>');jQuery('#step1').append('<input class="cart_button" type="button" value="Volgende" onclick="loadStep2()"/>'+'<input class="cart_button" type="button" value="Annuleren" onclick="exitCheckout()"/>');calculateTotal('cart');jQuery('#ajax_loader').hide('fast');jQuery('.cart_config').change(function(){var id=jQuery(this).attr('class').split(' ');var conf_ids=id[2].replace(/-/g,'~');jQuery.post('/modules/shop/load.php?item=cart&action=remove&product_id='+id[1]+'^'+conf_ids,'');conf_ids=conf_ids.replace(id[3].replace('ex',''),jQuery(this).val());addToCart(id[1]+'^'+conf_ids,jQuery('#cart_quantity'+id[1]+id[2]).val());loadTinyCart();initCheckout()});jQuery('.cart_quantity').change(function(){var split=jQuery(this).attr('name').split('~');var in_stock=parseInt(split[0]);var product_id=split[1];var config_id=split[2].replace(/-/g,'~');var quantity=parseInt(jQuery(this).val());if(quantity==0){customAlert('Als u het product wilt bestellen, moet het te bestellen aantal minimaal 1 bedragen.');jQuery(this).val(1)}else{if(quantity>in_stock){if(in_stock<0){customAlert('Er zijn momenteel 0 stuks voorradig. Het restant wordt zo snel mogelijk nageleverd of pas uw bestelling aan.','button')}else{customAlert('Er zijn momenteel '+in_stock+' stuks voorradig. Het restant wordt zo snel mogelijk nageleverd of pas uw bestelling aan.','button')}}addToCart(product_id+'^'+config_id,'absolute'+quantity);var tempstring=jQuery('#cart_prod_price'+product_id+split[2]).val();jQuery('#cart_prod_total'+product_id+split[2]).val(quantity*tempstring.replace(',','.'));jQuery('#cart_prod_visible_total'+product_id+split[2]).html(number_format(quantity*jQuery('#cart_prod_vat'+product_id+split[2]).val(),2,',',''));jQuery('#cart_prod_vat_total'+product_id+split[2]).val(quantity*jQuery('#cart_prod_vat'+product_id+split[2]).val());calculateTotal('cart')}});checkout_loaded=true})}function loadStep2(){showAjaxLoader(1);var continue_function=true;jQuery('.cart_quantity').each(function(){var split=jQuery(this).attr('name').split('~');if(split[2]=='none'){continue_function=false;return false}});if(continue_function){jQuery('#step1').hide();jQuery('#step3').hide();jQuery('#step2').fadeIn();jQuery('#step_image3').css('background-position','-300px -486px');jQuery('#step_image2').css('background-position','-150px -466px');jQuery('#stepLink1 .stepLinksmall').css('font-size','9px').css('text-decoration','none');jQuery('#stepLink2 .stepLinksmall').css('font-size','11px').css('text-decoration','underline');if(!jQuery('#order_logged_in').exists()){jQuery('#step2').load('modules/shop/order/customer.php',function(){jQuery('#ajax_loader').hide('fast')})}else{jQuery('#ajax_loader').hide('fast')}}else{jQuery('#ajax_loader').hide('fast');customAlert("Er is een product dat nog geconfigureerd moet worden.");loadStep1()}}function loadStep3(user_id,callback){showAjaxLoader(1);jQuery('#step2').hide();jQuery('#step4').hide();jQuery('#step3').fadeIn();jQuery('#stepLink2 .stepLinksmall').css('font-size','9px').css('text-decoration','none');jQuery('#stepLink4 .stepLinksmall').css('font-size','9px').css('text-decoration','none');jQuery('#stepLink3 .stepLinksmall').css('font-size','11px').css('text-decoration','underline');jQuery('#step_image4').css('background-position','-448px -486px');jQuery('#step_image3').css('background-position','-300px -466px');jQuery.getJSON('/modules/shop/load.php?item=methods',function(data){jQuery.getJSON('/modules/shop/load.php?item=customer&id='+user_id,function(item){if(typeof callback=='undefined'){jQuery('#step3').html('<input id="step3_user_id" type="hidden" value="'+user_id+'"/>'+'<form id="step3_left" class="uniForm" style="width: 49% !important; float: left;">'+'<fieldset class="inlineLabels" style="border-color: #70AFEF;">'+'<div class="ctrlHolder" style="border-color: #70AFEF;">'+'Opmerkingen of alternatief verzendadres:<br/>'+'<textarea id="order_comments" style="color:#0053A6; font-size: 12px; font-family: Arial,Verdena,Helvetica,sans-serif; width: 100%;"></textarea>'+'</div>'+'<div class="ctrlHolder" style="border: none;">'+'<b>Betaal methode:</b> <select id="payment_method_step3" style="color:#0053A6; font-size: 12px;"></select><br/><br/>'+'Voor rembourszendigen wordt &euro; 20,- extra in rekening gebracht. De overige betaalmethoden zijn gratis, u betaalt alleen uw order.'+'</div>'+'</fieldset>'+'</form>'+'<form id="step3_right" class="uniForm" style="width: 49% !important; float: right;">'+'<fieldset class="inlineLabels" style="border-color: #70AFEF;">'+'<div class="ctrlHolder" style="border-color: #70AFEF;">'+'<b>Uw gegevens (<a href="javascript:void(0);" onclick="enableCustomerField();loadStep2();" style="color:#0079F2; text-decoration:none; font-weight:normal;">aanpassen</a>):</b><br/>'+'<div style="padding-left: 10px;">'+stripslashes(URLDecode(item.name))+'<br/>'+ucwords(URLDecode(item.data[0][1]))+'<br/>'+URLDecode(item.data[0][2])+' '+ucwords(stripslashes(URLDecode(item.data[0][3])))+'<br/>'+URLDecode(item.data[0][4])+'<br/>'+item.data[0][5]+'</div>'+'</div>'+'<div class="ctrlHolder" style="border-color: #70AFEF;">'+'<b>Te betalen:</b> &#8364; <span id="pay_meth_total">'+jQuery('#cart_total').html()+'</span>'+'</div>'+'</fieldset>'+'</form>'+'<form class="uniForm" style="width: 100% !important; clear: both;">'+'<fieldset class="inlineLabels" style="border-color: #70AFEF;">'+'<input id="place_order_button" class="cart_button" type="button" value="Plaats Bestelling" onclick="placeOrder('+user_id+');"/>'+'<input class="cart_button" type="button" value="Vorige" onclick="loadStep2()"/>'+'</fieldset>'+'</form>')}else{callback()}jQuery.each(data,function(i,item){if(item.type=='payment_method'){jQuery('#payment_method_step3').append('<option value="'+item.id+'">'+item.name+'</option>')}});var selected_pay_method='ideal';jQuery('#payment_method_step3').change(function(){if((jQuery('#payment_method_step3 option:selected').text()).toLowerCase()=='onder rembours'){jQuery('#pay_meth_total').html(number_format(parseFloat((jQuery('#pay_meth_total').html()).replace(',','.'))+20,2,',',''))}else if(selected_pay_method=='onder rembours'){jQuery('#pay_meth_total').html(number_format(parseFloat((jQuery('#pay_meth_total').html()).replace(',','.'))-20,2,',',''))}selected_pay_method=(jQuery('#payment_method_step3 option:selected').text()).toLowerCase()});jQuery('#ajax_loader').hide('fast')})})}function placeOrder(user_id,proceed,passed_order_id){showAjaxLoader(1);if(typeof proceed=="undefined")proceed=false;if(typeof passed_order_id=="undefined")passed_order_id="";if((jQuery('#payment_method_step3 option:selected').text()).toLowerCase()=='ideal'&&!proceed){var array='';jQuery('.cart_quantity').each(function(){var split=jQuery(this).attr('name').split('~');var order_vat_rate=jQuery('#order_vat_rate'+split[1]+split[2]).val();array+='&prod['+split[1]+'~'+split[2].replace(/-/g,'~')+'~'+order_vat_rate+']='+jQuery(this).val()});var payment_meth=URLDecode(jQuery('#payment_method_step3').val());jQuery.post('/modules/shop/order/save.php?'+array,{order_id:'',customer_id:user_id,payment:payment_meth,extra:(jQuery('.small_order_hidden').exists()?(0):(small_order_charge)),order_comment:jQuery('#order_comments').val()},function(order_id){jQuery('#step3').prepend('<form id="ideal_form" method="post">'+'<div>'+'<input type="hidden" id="merchantID" name="merchantID"/>'+'<input type="hidden" id="subID" name="subID"/>'+'<input type="hidden" id="amount" name="amount"/>'+'<input type="hidden" id="purchaseID" name="purchaseID"/>'+'<input type="hidden" id="language" name="language"/>'+'<input type="hidden" id="currency" name="currency"/>'+'<input type="hidden" id="description" name="description"/>'+'<input type="hidden" id="hash" name="hash"/>'+'<input type="hidden" id="paymentType" name="paymentType"/>'+'<input type="hidden" id="validUntil" name="validUntil"/>'+'<input type="hidden" id="urlSuccess" name="urlSuccess"/>'+'<input type="hidden" id="urlCancel" name="urlCancel"/>'+'<input type="hidden" id="urlError" name="urlError"/>'+'<input type="hidden" id="itemNumber1" name="itemNumber1" value="1"/>'+'<input type="hidden" id="itemDescription1" name="itemDescription1"/>'+'<input type="hidden" id="itemQuantity1" name="itemQuantity1" value="1"/>'+'<input type="hidden" id="itemPrice1" name="itemPrice1"/>'+'</div>'+'</form>');var merchantID='005014636';var subID='0';var purchaseID=order_id;var paymentType='ideal';var amount=(jQuery('#cart_total').html()).replace(',','');var validUntil=0;var language='nl';var currency='EUR';var description='bestelling van de Groef audio';var urlBase='http://webshop.degroefaudio.nl';var urlSuccess=urlBase+'?result=success&oid='+order_id+'&uid='+user_id;var urlCancel=urlBase+'?result=cancel&oid='+order_id+'&uid='+user_id;var urlError=urlBase+'?result=error&oid='+order_id+'&uid='+user_id;var urlPost='https://ideal.secure-ing.com/ideal/mpiPayInitIng.do';var time=(new Date().getTime()/1000)+3600;validUntil=date('Y-m-d',time)+'T'+date('G:i:s',time)+'Z';jQuery('#itemPrice1').val(amount);var hashString=merchantID+subID+amount+purchaseID+paymentType+validUntil+jQuery('#itemNumber1').val()+purchaseID+jQuery('#itemQuantity1').val()+jQuery('#itemPrice1').val();jQuery.get('/modules/shop/order/ideal.php',{hash_string:hashString},function(hash){jQuery('#ideal_form').attr('action',urlPost);jQuery('#merchantID').val(merchantID);jQuery('#subID').val(subID);jQuery('#amount').val(amount);jQuery('#purchaseID').val(purchaseID);jQuery('#itemDescription1').val(purchaseID);jQuery('#language').val(language);jQuery('#currency').val(currency);jQuery('#description').val(description);jQuery('#hash').val(hash);jQuery('#paymentType').val(paymentType);jQuery('#validUntil').val(validUntil);jQuery('#urlSuccess').val(urlSuccess);jQuery('#urlCancel').val(urlCancel);jQuery('#urlError').val(urlError);jQuery('#ideal_form').submit();jQuery('#ajax_loader').hide('fast')})})}else{var array='';jQuery('.cart_quantity').each(function(){var split=jQuery(this).attr('name').split('~');var order_vat_rate=jQuery('#order_vat_rate'+split[1]+split[2]).val();array+='&prod['+split[1]+'~'+split[2].replace(/-/g,'~')+'~'+order_vat_rate+']='+jQuery(this).val()});var payment_meth=URLDecode(jQuery('#payment_method_step3').val());jQuery.post('/modules/shop/order/save.php?'+array,{order:'place',customer_id:user_id,payment:payment_meth,extra:(jQuery('.small_order_hidden').exists()?(0):(small_order_charge)),order_comment:jQuery('#order_comments').val(),id:passed_order_id},function(){jQuery('#ajax_loader').hide('fast');loadStep4(user_id)})}}function loadStep4(user_id,ideal,order_id){if(typeof ideal=='undefined'){ideal=false;order_id=false}showAjaxLoader(1);jQuery('#step3').hide();jQuery('#step4').fadeIn();jQuery('#stepLink3 .stepLinksmall').css('font-size','9px').css('text-decoration','none');jQuery('#stepLink4 .stepLinksmall').css('font-size','11px').css('text-decoration','underline');jQuery('#step_image4').css('background-position','-448px -466px');jQuery('#step4').html('<div style="width: 100%; border: 1px solid #ccc; border-bottom: 0px; padding-top: 5px; padding-bottom: 5px;">'+'<font style="font-size: 13px; font-weight: bold;">Uw bestelling is succesvol verzonden!</font><br/>'+'Hieronder vindt u een overzicht van uw bestelling, ook hebben we u een bevestigings e-mail toegestuurd.'+'</div>'+'<div id="products_block" class="block">'+'<table>'+'<thead>'+'<tr>'+'<th>&#32;</th>'+'<th>Product</th>'+'<th>Aantal</th>'+'<th>Optie</th>'+'<th>Prijs</th>'+'<th>Totaal</th>'+'</tr>'+'</thead>'+'<tbody></tbody>'+'<tfoot></tfoot>'+'</table>'+'</div>'+'<div id="address_block" class="block"><table><tbody></tbody></table></div>'+'<div id="shipping_method_block" class="block" style="display:none;"></div>'+'<div id="payment_method_block" class="block"></div>');jQuery.getJSON('/modules/shop/load.php?item=cart&action=load',function(data){jQuery('#products_block tbody').html('');jQuery.each(data,function(i,item){var split=URLDecode(item.img1).split('~')[0].split('.');var name=split[0];var extension='.'+split[1];var unique_id='';jQuery.each(item.selected_config,function(key,value){if(value!=''){unique_id+=value}});var temp_vat_rate=item.vat_rate.split('~');jQuery('#products_block tbody').append('<tr id="cart'+item.id+'" class="cart_row">'+'<td><img class="head_img" src="/upload/products/'+name+'_tiny'+extension+'" alt="'+URLDecode(item.name)+'"/></td>'+'<td>'+URLDecode(item.name)+'</td>'+'<td>'+item.quantity+'</td>'+'<td id="chk_configs_holder'+item.id+unique_id+'"></td>'+'<td>&#8364; '+number_format(priceInclusive(parseFloat(temp_vat_rate[1]),parseFloat(item.price)),2,',','')+'</td>'+'<td>&#8364; '+number_format((priceInclusive(parseFloat(temp_vat_rate[1]),parseFloat(item.price))*parseInt(item.quantity)),2,',','')+'</td>'+'</tr>');jQuery.each(item.configs,function(c,config){jQuery('#chk_configs_holder'+item.id+unique_id).append('<span id="checkout_prod_config'+item.id+config.id+unique_id+'"></span>');jQuery.each(config.children,function(cc,child){if(in_array(child.id,item.selected_config)){jQuery('#checkout_prod_config'+item.id+child.parent_id+unique_id).append(child.name)}})})});jQuery('#products_block tfoot').append('<tr style="display:none;">'+'<td colspan="4"></td>'+'<td style="border-bottom: 1px solid #ccc;">Subtotaal:</td>'+'<td colspan="2" style="border-bottom: 1px solid #ccc;">&#8364; <span id="checkout_sub_total"></span></td>'+'</tr>'+'<tr id="checkout_small_order">'+'<td colspan="4"><input type="hidden" value="'+small_order_limit+'"></td>'+'<td>Kleine order <small>(< &#8364; '+parseInt(small_order_limit)+')</small>:</td>'+'<td colspan="2">&#8364; <span class="checkout_prod_total">'+number_format(small_order_charge,2,',','')+'</span></td>'+'</tr>'+'<tr id="payment_special" '+((jQuery('#payment_method_step3 option:selected').text()).toLowerCase()=='onder rembours'?'':'style="display:none;"')+'>'+'<td colspan="4"><input type="hidden" value="20"></td>'+'<td>Rembourskosten</td>'+'<td colspan="2">&#8364; <span class="checkout_prod_total">'+number_format(20,2,',','')+'</span></td>'+'</tr>'+'<tr id="checkout_tr_vat1">'+'<td colspan="4"></td>'+'<td>btw (6%):</td>'+'<td colspan="2">&#8364; <span id="checkout_vat1" class="checkout_prod_total"></span></td>'+'</tr>'+'<tr id="checkout_tr_vat2">'+'<td colspan="4"></td>'+'<td style="border-bottom: 1px solid #999;">btw (19%):</td>'+'<td colspan="2" style="border-bottom: 1px solid #999;">&#8364; <span id="checkout_vat2" class="checkout_prod_total"></span></td>'+'</tr>'+'<tr style="font-weight: bold;">'+'<td colspan="4"></td>'+'<td>Te betalen:</td>'+'<td colspan="2">&#8364; <span id="checkout_total"></span></td>'+'</tr>');calculateTotal('checkout')});if(jQuery('#order_comments').val()!=''){jQuery('#products_block').append('<div id="comment_step4">'+'<br/><br/><span style="font-weight:bold; color:#0E3F54;">Opmerkingen:</span><br/>'+'<div id="order_comment_step4" style="width: 460px; border: 1px solid #ccc; margin-top: 3px; padding: 5px; overflow: hidden;">'+jQuery('#order_comments').val()+'</div>'+'</div>')}jQuery.getJSON('/modules/shop/load.php?item=customer&id='+user_id,function(item){jQuery('#address_block').prepend('<span style="font-weight:bold; color:#0E3F54;">Verzend Gegevens:</span>');jQuery('#address_block tbody').html('');jQuery('#address_block tbody').append('<tr><td>'+URLDecode(item.name)+'</td></tr>'+'<tr><td>'+ucwords(URLDecode(item.data[0][1]))+'</td></tr>'+'<tr><td>'+URLDecode(item.data[0][2])+'</td></tr>'+'<tr><td>'+ucwords(URLDecode(item.data[0][3]))+'</td></tr>'+'<tr><td>'+URLDecode(item.data[0][4])+'</td></tr>'+'<tr><td>'+item.data[0][5]+'</td></tr>');emptyCart('empty');jQuery('#ajax_loader').hide('fast')});jQuery('#payment_method_block').html('Betaal methode: <span id="payment_method_step4" style="font-weight:normal;">'+jQuery('#payment_method_step3 :selected').text()+'</span>');jQuery('#step4').append('<div class="buttonHolder" style="border-color: #70AFEF; clear:both;">'+'<a href="/"><input class="cart_button" type="button" value="Afsluiten"/></a>'+'</div>');if(ideal){jQuery('#payment_method_step4').html('iDeal');jQuery.get('/modules/shop/load.php?item=order_comment&id='+order_id+'&customer_id='+user_id,function(order_comment){if(order_comment!=''){jQuery('#order_comment_step4').html(URLDecode(order_comment))}else{jQuery('#comment_step4').hide()}})}}function idealError(){jQuery('#step3').html('<div style="width:100%; text-align:center; font-size:15px; padding:10px;">'+'Er is een fout opgetreden tijdens het afhandelen van uw iDeal betaling.<br/>'+'<a href="/"><input style="float:none;" class="cart_button" type="button" value="Afsluiten"/></a>'+'</div>')}function orderCancel(order_id){jQuery.post('/modules/shop/order/remove.php',{id:order_id},function(){})}function calculateTotal(location){var cart_total=0;var cart_sub_total=0;var vat1=0;var vat2=0;jQuery('.cart_vat'+vat_rate1).each(function(i){var price=jQuery('.cart_prod_price'+i).val();price=price.replace(',','.');var amount=jQuery(this).val().replace(',','.')-parseFloat(price);vat1+=amount});jQuery('#'+location+'_vat1').html(number_format(vat1,2,',',''));if(vat1==0){jQuery('#'+location+'_tr_vat1').hide()}jQuery('.cart_vat'+vat_rate2).each(function(i){var price=jQuery('.cart_prod_price'+i).val();price=price.replace(',','.');var amount=number_format(jQuery(this).val().replace(',','.'),2,'.','')-parseFloat(price);vat2+=amount});jQuery('#'+location+'_vat2').html(number_format(vat2,2,',',''));if(vat2==0){jQuery('#'+location+'_tr_vat2').hide()}jQuery('.cart_prod_sub_total').each(function(){var prodSubTotal=jQuery(this).val();prodSubTotal=prodSubTotal.replace(',','.');cart_sub_total+=parseFloat(prodSubTotal)});jQuery('.cart_prod_total').each(function(){var prodTotal=0;if(jQuery(this).is(':input'))prodTotal=jQuery(this).val();else prodTotal=jQuery(this).html();prodTotal=prodTotal.replace(',','.');cart_total+=parseFloat(prodTotal)});small_order_value=parseFloat(jQuery('#cart_small_order').find('input').val());if(round_float(cart_sub_total,2)>=small_order_value){jQuery('#'+location+'_small_order').hide().addClass('small_order_hidden');cart_total-=small_order_charge}else{jQuery('#'+location+'_small_order').show().removeClass('small_order_hidden')}if(location=='checkout'&&(jQuery('#payment_method_step3 option:selected').text()).toLowerCase()=='onder rembours'){cart_total+=20}jQuery('#'+location+'_total').html(number_format(cart_total,2,',',''));jQuery('#'+location+'_sub_total').html(number_format(cart_sub_total,2,',',''))}function loadTinyCart(){var cart_quantity=0;var cart_total=0;var shipping=0;cart_total_excl=0;jQuery.getJSON('/modules/shop/load.php?item=cart&action=load',function(data){jQuery.getJSON('/modules/shop/load.php?item=methods',function(jdata){var last=jdata.length-1;jQuery.each(jdata,function(j,jtem){if(jtem.type=='shipping_method'&&j==0){}if(j==last){jQuery.each(data,function(i,item){var temp_vat_rate=item.vat_rate.split('~');cart_quantity+=parseInt(item.quantity);cart_total_excl+=parseFloat(item.price)*parseInt(item.quantity);cart_total+=(priceInclusive(temp_vat_rate[1],item.price)*parseInt(item.quantity))});if(round_float(cart_total,2)==false){jQuery('#tiny_total').hide();jQuery('#tiny_total_title').hide();jQuery('#cart_quantity').hide().removeClass().addClass('hidden_q');jQuery('#cart_footer').hide();jQuery('#cart_hidden').show()}else{if(round_float(cart_total,2)<small_order_limit){cart_total+=small_order_charge}cart_total+=shipping;jQuery('#cart_hidden').hide();jQuery('#cart_quantity td:last').html(cart_quantity);jQuery('#tiny_total').html('&#8364; '+number_format(cart_total,2,',',''));if(jQuery('.hidden_q').exists()){jQuery('#tiny_total').show();jQuery('#tiny_total_title').show();jQuery('#cart_quantity').show().removeClass();jQuery('#cart_footer').show()}}}})})})}function addToCart(product_id,quantity,array,callback,proceed){if(typeof callback=="undefined")callback=function(){};if(typeof proceed=="undefined")proceed=false;if(proceed){if(typeof array=="undefined"||array==''){jQuery.post('/modules/shop/load.php?item=cart&action=add&product_id='+product_id+'&quantity='+quantity,'',function(){callback();loadTinyCart()})}else{var url_array='';for(key in array){url_array+='&prod['+key+']='+array[key]}jQuery.post('/modules/shop/load.php?item=cart&action=add_array'+url_array,'',function(){callback();loadTinyCart()})}}else{if(product_id.indexOf('~')==-1){jQuery.getJSON('/modules/shop/load.php?item=configs&id='+product_id.split('^')[0],function(data){jQuery.each(data,function(c,config){var child_config=config.children[0];product_id+='~'+child_config.id});addToCart(product_id,quantity,array,callback,true)})}else{addToCart(product_id,quantity,array,callback,true)}}}function removeFromCart(product_id,location,message){if(typeof message=="undefined")message='Weet u zeker dat u dit product wilt verwijderen?';jQuery.post('/modules/shop/load.php?item=cart&action=remove&product_id='+product_id,'',function(){initCheckout();loadTinyCart()})}function emptyCart(message){if(typeof message=="undefined"){if(confirm('Are you sure you want to empty your shopping cart?')){jQuery.post('/modules/shop/load.php?item=cart&action=empty','',function(){initCheckout();loadTinyCart()})}}else{jQuery.post('/modules/shop/load.php?item=cart&action=empty','',function(){loadTinyCart()})}}function round_float(x,n){if(!parseInt(n))var n=0;if(!parseFloat(x))return false;return Math.round(x*Math.pow(10,n))/Math.pow(10,n)}function date(format,timestamp){var that=this,jsdate=((typeof timestamp==='undefined')?new Date():(timestamp instanceof Date)?new Date(timestamp):new Date(timestamp*1000)),formatChr=/\\?([a-z])/gi,formatChrCb=function(t,s){return f[t]?f[t]():s},_pad=function(n,c){if((n=n+"").length<c){return new Array((++c)-n.length).join("0")+n}else{return n}},txt_words=["Sun","Mon","Tues","Wednes","Thurs","Fri","Satur","January","February","March","April","May","June","July","August","September","October","November","December"],txt_ordin={1:"st",2:"nd",3:"rd",21:"st",22:"nd",23:"rd",31:"st"},f={d:function(){return _pad(f.j(),2)},D:function(){return f.l().slice(0,3)},j:function(){return jsdate.getDate()},l:function(){return txt_words[f.w()]+'day'},N:function(){return f.w()||7},S:function(){return txt_ordin[f.j()]||'th'},w:function(){return jsdate.getDay()},z:function(){return(jsdate-new Date(f.Y(),0,1))/864e5>>0},W:function(){var c=new Date(f.Y(),f.n()-1,f.j()-f.N()+3);return 1+Math.round((c-(new Date(c.getFullYear(),0,4)))/864e5/7)},F:function(){return txt_words[6+f.n()]},m:function(){return _pad(f.n(),2)},M:function(){return f.F().slice(0,3)},n:function(){return jsdate.getMonth()+1},t:function(){return(new Date(f.Y(),f.n()+1,0)).getDate()},L:function(){var y=f.Y();return(!(y&3)&&(y%1e2||!(y%4e2)))?1:0},o:function(){return f.Y()+(f.n()===12&&f.W()<9?-1:(f.n()===1&&f.W()>9?1:0))},Y:function(){return jsdate.getFullYear()},y:function(){return(jsdate.getFullYear()+"").slice(2)},a:function(){return jsdate.getHours()>11?"pm":"am"},A:function(){return f.a().toUpperCase()},B:function(){return _pad(Math.floor(((jsdate.getUTCHours()*36e2)+(jsdate.getUTCMinutes()*60)+jsdate.getUTCSeconds()+36e2)/86.4)%1e3,3)},g:function(){return jsdate.getHours()%12||12},G:function(){return jsdate.getHours()},h:function(){return _pad(f.g(),2)},H:function(){return _pad(f.G(),2)},i:function(){return _pad(jsdate.getMinutes(),2)},s:function(){return _pad(jsdate.getSeconds(),2)},u:function(){return _pad(jsdate.getMilliseconds()*1000,6)},e:function(){return'UTC'},I:function(){},O:function(){var a=jsdate.getTimezoneOffset();return(a>0?"-":"+")+_pad(Math.abs(a/60*100),4)},P:function(){var O=f.O();return(O.substr(0,3)+":"+O.substr(3,2))},T:function(){return'UTC'},Z:function(){return-jsdate.getTimezoneOffset()*60},c:function(){return'Y-m-d\\Th:i:sP'.replace(formatChr,formatChrCb)},r:function(){return'D, d M Y H:i:s O'.replace(formatChr,formatChrCb)},U:function(){return Math.round(jsdate.getTime()/1000)}};return format.replace(formatChr,formatChrCb)}
