var active_category;var active_buyrow;var map;var mapMarkers=[];var openInfowindow;var ready=false;var initAllH=28;var blockDim=new Array();blockDim['login']=[180,210,120];blockDim['cart']=[180,225,0];blockDim['shops']=[180,155,0];function Scroller()
{var mouseX=0;var focus=false;var to;var ul=$('#thumbbrowser ul');var direction=1;var thumbBrowserWidth=$('#thumbbrowser').width();var maxX=-ul.width()+thumbBrowserWidth+4;function step()
{if(focus)
{step=direction*10;ul.css('left',ul.position().left-step);if(ul.position().left>60)
{focus=false;ul.animate({left:0}),400;}
if(ul.position().left<maxX-60)
{focus=false;ul.animate({left:maxX},400);}}}
this.start=function()
{to=setInterval(step,25);}
this.stop=function()
{clearInterval(to);}
this.setFocus=function(val)
{focus=val;}
this.setMouseX=function(val)
{mouseX=val;}
this.getMouseX=function()
{return mouseX;}
this.getUl=function()
{return ul;}
this.getMaxX=function()
{return maxX;}
this.next=function()
{direction=1;}
this.prev=function()
{direction=-1;}
this.moveToActive=function()
{var activeThumb=$('#thumbbrowser ul li.active');var pos=activeThumb.position().left;var middle=(thumbBrowserWidth-activeThumb.width())/2;if(pos>=0&&pos<middle)
goal=0;else if(pos>ul.width()-middle-activeThumb.width()/2)
goal=maxX;else
{var goal=ul.position().left;goal=-pos+middle;}
ul.animate({left:goal});}
this.showRandomItem=function()
{var rand=this.getRandItem();$('#thumbbrowser ul li:eq('+rand+') a').click();}
this.getRandItem=function()
{var rand=Math.round(Math.random()*($('#thumbbrowser ul li').length-1));if(rand==$('#thumbbrowser ul li').index($('#thumbbrowser ul li.active')))
rand=this.getRandItem();return rand;}}
$.ready=function()
{if(ready)
return;ready=true;initSearchPop();initTopBlocks();initRoundCorners();initCountryDrop();initBreadCrumbMenu();initLoginBox();initNewsletterSubscribe();initActionBanner();switch(pagedata.name)
{case'Home':initHome();break;case'categories':initMainCats();break;case'products':initProductPage();break;case'speedorder':case'prices':case'voorseizoen':initSpeedorderPage();break;case'downloads':initDownloadsPage();break;case'brands':break;case'shop':initShop();initMainCats();break;case'yourdiscounts':initYourDiscounts();break;case'order':initCheckout();break;case'prodreg':initProdreg()
break;case'waranty':initWaranty();break;case'request_folders':initFolders()
case'cataloog':initCataloog();break;case'register':initRegister();break;case'forgot_pass':initForgotPass();break;case'contact':initContact();initDealers();break;case'invoicehistory':initInvoicehistory();break;case'faq':initFaq();break;case'payments':initPayments();break;case'action_italy':initActionItaly();break;case'event':case'event_gemeenten':case'event_pro':initEvent();break;case'dealers':initDealers();break;}};var actionbanner_stop=false;function initActionBanner()
{if(pagedata.name=='action_stock')
$('#banner_action .hide').remove();$('#banner_action').live('click',function()
{if(actionbanner_stop==true)
return false;else
return true;});$('#banner_action .hide').live('click',function()
{actionbanner_stop=true;$(this).parent().slideUp();$.post('/'+url_countrycode+active_language_code+'/action_stock/a/forgetActionBanner');});$('#banner_action .widebutton.dialog').live('click',function()
{actionbanner_stop=true;var dialog=$('<div id="more_info_dialog">');$('body').append(dialog);var dc=$('<div class="content">');dc.appendTo(dialog);dc.load('/'+url_countrycode+active_language_code+'/dealer/voorseizoen_info/v/dc/true');dialog.dialog({width:600,height:500,draggable:true,position:'center',title:$(this).text(),dialogClass:'dealercenter',resizable:false,modal:true,position:'center',zIndex:1800,overlay:{backgroundColor:'#000',opacity:0.2}});dialog.bind('dialogclose',function(event,ui)
{dialog.dialog('destroy');dialog.remove();actionbanner_stop=false;});});}
function loadActionBanner()
{var banner=$('#actionbanner');banner.hide();banner.load('/'+url_countrycode+active_language_code+'/dealer/voorseizoen/action_voorseizoen/a/getbannerhtml',function()
{banner.slideDown();});}
function initNavTabs()
{var p=('div.page');$('#tab_brandnav').click(function(){$(this).addClass('ui-tabs-selected');$('#tab_groupnav').removeClass('ui-tabs-selected');$('#groupnav').hide();$('#brandnav').show();p.attr('id','overview_brands');p.load('/'+url_countrycode+active_language_code+'/shop/brands/a/ajax_brands');return false;});}
function initMainCats()
{$('ul.cats li').mousemove(function(e){var nrPics=$('img',this).length;if(nrPics<2)
return;var mouseX=e.pageX-$(this).offset().left;var imgPartWidth=Math.ceil($(this).width()/nrPics);var showImageIndex=Math.floor(mouseX/imgPartWidth);$('img:visible',this).hide();$('img:eq('+showImageIndex+')',this).show();});}
function initTopBlocks()
{$('#login a.title').click(function()
{return topBlockClick("login");});$('#cart a.title').click(function()
{return topBlockClick("cart");});$('#shops a.title').click(function()
{return topBlockClick("shops");});$('#dealermap a.title').click(function()
{return openDealermap();});$('#login a.close').click(function()
{return topBlockClick("login");});$('#cart a.close').click(function()
{return topBlockClick("cart");});$('#shops a.close').click(function()
{return topBlockClick("shops");});$('#dealercenter a').click(function()
{openDealercenter();return false;});}
function openDealercenter()
{var dc=$('#dealercenter_dialog');if(dc.length>0)
return;dc=$('<div id="dealercenter_dialog">');dc.addClass('dealercenter');$('body').append(dc);dc.load('/'+url_countrycode+active_language_code+'/dealercenter',function()
{$('#dc_nav a',this).live('click',dcOpenPage);$('#dc_nav a',this).first().click();});dc.dialog({width:970,height:500,draggable:true,position:'center',title:'Dealer center',dialogClass:'dealercenter',resizable:false,modal:true,position:'center',zIndex:1800,overlay:{backgroundColor:'#000',opacity:0.2}});dc.bind('dialogclose',function(event,ui)
{dc.dialog('destroy');dc.remove();});}
function dcOpenPage(link)
{$('#dc_nav a').removeClass('active');$(this).addClass('active');$('#dc_content').load($(this).attr('href')+'/v/dc/true',function()
{var frm=$('#dc_content form.ajax');frm.submit(function()
{$('#dc_content').load(frm.attr('action'),frm.serializeArray());return false;});initProdreg();initWaranty();initFolders();initInvoicehistory();initYourDiscounts();initYourWebshop();});return false;}
function openDealermap()
{var dialog=$('<div id="dealermap_dialog">');dialog.addClass('dealercenter');$('body').append(dialog);dialog.load('/'+url_countrycode+active_language_code+'/dealers/a/map',function()
{});dialog.dialog({width:970,height:500,draggable:true,position:'center',title:$('#dealermap .title').html(),dialogClass:'dealercenter',resizable:false,modal:true,position:'center',zIndex:1800,overlay:{backgroundColor:'#000',opacity:0.2}});dialog.bind('dialogclose',function(event,ui)
{dialog.dialog('destroy');dialog.remove();});}
function initSearchPop()
{var searchpop=$('#searchpop');searchpop.hide();$('a.close',searchpop).click(function()
{searchpop.fadeOut('fast');$('#offer_video a').show();});$('#searchpopbutton').click(function()
{openSearchPop('prodlist');$('#offer_video a').hide();});}
function openSearchPop(mode,product_id)
{var searchpop=$('#searchpop');var scontent=$('#searchpop_content');if(mode!='prodlist')
{searchpop.addClass('top');searchpop.css('left',290);var offset=$('#searchpopbutton_'+mode).offset();searchpop.css('top',offset.top-100);}
else
{searchpop.removeClass('top');searchpop.css('top',9);searchpop.css('left',245);}
var data={mode:mode};if(product_id!=undefined)
data.product_id=product_id;scontent.load('/'+url_countrycode+active_language_code+'/shop/products/a/searchpop',data,function()
{searchpop.fadeIn('fast');});}
function initLoginBox()
{$('#logincontent form').submit(function(){$('#topbar').load('/'+url_countrycode+active_language_code+'/admin/dealers/a/loginbox',$(this).serializeArray(),function()
{initLoginBox();updateCart();initTopBlocks();initRoundCorners();topBlockClick('login');if($('#dealercenter').length>0)
{switch(pagedata.name)
{case'prices':document.location='/'+url_countrycode+urls.speedorder_dealer;break;default:location.reload(true);break;}}});return false;});}
function logOut(keepBoxClosed)
{if(keepBoxClosed==undefined)
keepBoxClosed=false;$('#topbar').load('/'+url_countrycode+active_language_code+'/admin/dealers/a/logout',function(){initLoginBox();updateCart();initTopBlocks();initRoundCorners();switch(pagedata.name)
{case'downloads':case'order':document.location='/'+url_countrycode+pagedata.url;break;case'action_stocksale':document.location='/'+url_countrycode+active_language_code;break;}});if(keepBoxClosed==false)
topBlockClick('login');return false;}
function updateTopbar()
{$('#topbar').load('/'+url_countrycode+active_language_code+'/admin/dealers/a/ajax_topbar',function(){initRoundCorners();initTopBlocks();});}
function initBreadCrumbMenu()
{var bcli=$('ul.breadcrumb li');$('a',bcli).mouseover(function()
{var li=$(this).parent();var block=$('div.hoverblock',li);var blockWidth=block.width();var x=li.position().left+(li.width()-blockWidth)/2;block.css({left:x});$('div.arrow',block).css({left:blockWidth/2-9});block.slideDown(200);});bcli.mouseleave(function()
{$('div.hoverblock',this).fadeOut(200);});}
function checkProductTabs()
{var heighest=0;var h;$('#prodtab li').each(function(index)
{h=$('a',this).height();if(h>heighest)
heighest=h;});var item;$('#prodtab li').each(function(index)
{var dif=0;item=$('a',this);item.height(heighest);});var heighest=0;var h;$('table.prodtable thead th[class!="label"]').each(function(index)
{h=$('a',this).height();if(h>heighest)
heighest=h;});var item;$('table.prodtable thead th[class!="label"]').each(function(index)
{var dif=0;item=$('a',this);item.height(heighest);});}
function initRoundCorners()
{$('#topbar .topblock').corner("round bl 3px br 3px");}
function initCountryDrop()
{var pc=$('#pickcountry');pc.hide();$('#dropcountry').click(function(){pc.fadeIn(300);return false;});$('#pickcountry').mouseleave(function(){pc.fadeOut(300);return false;});var pl=$('#picklang');pl.hide();$('#droplang').click(function(){pl.fadeIn(300);return false;});pl.mouseleave(function(){pl.fadeOut(300);return false;});}
function initVideoPlayer(onFinish)
{if(onFinish==undefined)
onFinish=null;var player=$f("focusvideo","/swf/flowplayer-3.2.1.swf",{buffering:false,canvas:{backgroundColor:"transparent"},onError:onFinish,clip:{autoBuffering:false,autoPlay:true,bufferLength:8,scaling:'orig',onFinish:onFinish},plugins:{controls:{volumeSliderGradient:'none',progressGradient:'none',bufferGradient:'none',buttonOverColor:'#A80000',timeBgColor:'#262626',borderRadius:'0px',tooltipTextColor:'#D00000',sliderGradient:'none',timeColor:'#d5d5d5',volumeSliderColor:'#D00000',durationColor:'#ffffff',buttonColor:'#000000',backgroundGradient:'none',tooltipColor:'#C9C9C9',backgroundColor:'#B7B7B7',sliderColor:'#C9C9C9',bufferColor:'#C78F8E',progressColor:'#A80000',height:24,opacity:1.0,playlist:false,volume:false,fullscreen:false,autoHide:'always',hideDelay:1000,tooltips:{scrubber:false}}}});}
function initOrder()
{$('form.addcart').submit(function()
{$(this).parent().load('/'+url_countrycode+active_language_code+'/order/a/cart_add',$(this).serializeArray(),function()
{$(this).css({padding:5});updateCart();if(!$('#cart').hasClass('open'))
topBlockClick("cart");});return false;});}
function showOrderSpectable(button,product_id)
{$(button).parent().load('/'+url_countrycode+active_language_code+'/shop/products/i/'+product_id+'/a/orderbox',null,function(){$('table',this).slideDown('fast');initOrder();});}
function showOrderProductTop(product_code)
{var div=$('<div id="orderpop">');div.hide();div.load('/'+url_countrycode+active_language_code+'/shop/products/a/orderbox',{code:product_code,type:'machine'},function(){$('#prodorder').append(div);div.show();div.css('top',23-$('.largebutton',div).position().top);initOrder();div.mouseleave(function()
{$(this).fadeOut('fast',function()
{$(this).remove();});});});}
function showOrderOption(button,code,type,page)
{if(page==undefined)
page='/'+url_countrycode+active_language_code+'/shop/products/a/orderbox';var buttonPos=$(button).position();var container=$(button).parent().parent();var itemPos=$(button).parent().position();var div=$('div#orderpop');if(div.length==0)
{div=$('<div id="orderpop">');div.appendTo(container);}
div.hide();var open=false;div.load(page,{code:code,type:type},function(){open=true;div.show();div.css('left',itemPos.left+buttonPos.left-$('.largebutton',div).position().left+4);div.css('top',itemPos.top+buttonPos.top-$('.largebutton',div).position().top);initOrder();div.mouseleave(function()
{$(this).fadeOut('fast');});});$(button).mouseleave(function()
{if(!open)
$(div).remove();});}
function hideOrderOption()
{}
function updateOrderbox(amount_select,product_code,update_type,type,page)
{if(page==undefined)
page='/'+url_countrycode+active_language_code+'/shop/products/a/orderbox';var order_amount=$('#orderamount').text();order_amount=parseInt(order_amount);if(update_type=='min')
{if(order_amount>1)
{order_amount-=1;}}
else if(update_type=='plus')
{order_amount+=1;}
$(amount_select).parent().parent().parent().parent().parent().parent().load(page,{amount:order_amount,code:product_code,type:type},function(){initOrder();});return false;}
function updateCart(data)
{if($('#paymentmethod').length>0)
paymentmethod=$('#paymentmethod').val();else
paymentmethod=null;$('#cartcontent').load('/'+url_countrycode+active_language_code+'/order/a/showcart',{paymentmethod:paymentmethod});$('#checkoutcontent').load('/'+url_countrycode+active_language_code+'/order/a/showcheckoutcart',{paymentmethod:paymentmethod},function(){objGifts.init();});}
function removeCartItem(code)
{$.post('/'+url_countrycode+active_language_code+'/order/a/cart_remove',{productcode:code},updateCart);}
function setCartitemAmount(amount,code)
{$.post('/'+url_countrycode+active_language_code+'/order/a/cart_changeamount',{productcode:code,amount:amount},updateCart);}
function addBlankCartItem(blank_article,amount,blank_price)
{$.ajax({url:'/'+url_countrycode+active_language_code+'/order/a/cart_addblankrow',async:false,type:'post',data:{blank_article:blank_article,blank_price:blank_price,amount:amount},success:updateCart});}
function initProductPage()
{$('#prodtab').tabs();$('#optionbutton').click(function()
{$(this).toggleClass('open');$('#optiontable').slideToggle('fast');});$("#imagepop").dialog({autoOpen:false,draggable:false,height:470,width:759,modal:true,position:'center',resizable:false,zIndex:1800,overlay:{backgroundColor:'#000',opacity:0.6}});$("#videopop").dialog({autoOpen:false,draggable:false,height:262,width:482,modal:true,position:'center',resizable:false,zIndex:1800,overlay:{backgroundColor:'#000',opacity:0.6}});$("#textpop").dialog({autoOpen:false,draggable:false,height:$("#textpop div.content").height()+25,width:470,modal:true,position:'center',resizable:false,zIndex:1800,overlay:{backgroundColor:'#000',opacity:0.6}});initOrder();$('#prodorder.dws input.moreinfo').click(function()
{dwsShowMoreInfo();});}
function galleryPop(mediaType,nrThumbs,fileName)
{if(mediaType=="image")
{if(fileName)
{$('#largeimage').css('background-image','url(/skylimit/uploads/normal_'+fileName+')');}
smallerWidth=598;largerWidth=794;largerCount=3;}
else if(mediaType=="video")
{if(fileName)
{$('#focusvideo').attr('href','http://downloads.gardenequipment.be/video/'+fileName);initVideoPlayer();}
smallerWidth=321;largerWidth=497;largerCount=2;}
else if(mediaType=="faqvideo")
{if(fileName)
{$('#focusvideo').attr('href','http://downloads.gardenequipment.be/video/'+fileName);initVideoPlayer();}
smallerWidth=641;largerCount=2;}
if(nrThumbs<2)
{$("#"+mediaType+"pop").dialog('option','width',smallerWidth);}else if(nrThumbs>largerCount){$("#"+mediaType+"pop").dialog('option','width',largerWidth);$("#"+mediaType+"pop ul").css('padding-right',15);}
$("#"+mediaType+"pop").css('display','block');$("#"+mediaType+"pop").dialog('open');return false;}
function topBlockClick(clickedBlock)
{var clickedDiv=$("#"+clickedBlock);if(blockDim[clickedBlock][2]==0)
blockDim[clickedBlock][2]=clickedDiv.width();if(clickedDiv.width()<blockDim[clickedBlock][0])
{$("#"+clickedBlock).addClass('open');clickedDiv.css('width',clickedDiv.width());clickedDiv.css('height','auto');$("#"+clickedBlock+"content").show();$("#"+clickedBlock+"content").slideDown('fast');clickedDiv.animate({width:blockDim[clickedBlock][0]},250,"swing",function(){$("#"+clickedBlock+" .close").show();});}
else
{$("#"+clickedBlock).removeClass('open');clickedDiv.animate({width:blockDim[clickedBlock][2]+1,height:initAllH},250,"swing");$("#"+clickedBlock+"content").slideUp('fast');$("#"+clickedBlock+" .close").hide();}
return false;}
function downloadsLangChooser(el,type)
{var langchooser=$('#'+type+'_langs');var left=15;langchooser.css({left:left});langchooser.fadeIn();$('#'+type+'_link div.hoverblock')
$('#'+type+'_link').mouseleave(function()
{$('div.hoverblock',this).fadeOut(200);});return false;}
function openBuyRow(button,code,id,page)
{if(page==undefined)
page='/topbar/speedorder';closeBuyRow(active_buyrow);var buyRow=$('#'+id);$('td',buyRow).load('/'+url_countrycode+active_language_code+page+'/a/ajax_buyrow',{code:code,type:'part'},function(){initOrder();});buyRow.show();active_buyrow=id;var par=$('#'+id+'_buttons');par.css('backgroundColor','#ccc');$('.closebutton',par).show();$(button).hide();}
function closeBuyRow(id)
{var buyrow=$('#'+id);var buttoncell=$('#'+id+'_buttons');$('.closebutton',buttoncell).hide();$('.buybutton',buttoncell).show();buyrow.hide();buttoncell.css('backgroundColor','#ececec');}
function updateBuyRow(amount_select,code,type,page)
{if(page==undefined)
page='/topbar/speedorder';$('tr.buyrow:visible td.buyrow').load('/'+url_countrycode+active_language_code+page+'/a/ajax_buyrow',{code:code,amount:$(amount_select).val(),type:type},function(){initOrder();});}
function initSpeedorderPage()
{initSearchblock('/'+url_countrycode+pagedata.url+'/a/search');}
function speedorderPage(page)
{var type_index=$('#searchtab').tabs('option','selected');$('#searchtype').val($('#searchtab li:eq('+type_index+') a').attr('href').substr(1));$('#searchresult').html(text.loading);var data=$('div.page div.searchblock form').serializeArray();data.push({name:'searchpage',value:page});$('#searchresult').load('/'+url_countrycode+pagedata.url+'/a/search',data);}
function dump(arr,level){var dumped_text="";if(!level)level=0;var level_padding="";for(var j=0;j<level+1;j++)level_padding+="    ";if(typeof(arr)=='object'){for(var item in arr){var value=arr[item];if(typeof(value)=='object'){dumped_text+=level_padding+"'"+item+"' ...\n";dumped_text+=dump(value,level+1);}else{dumped_text+=level_padding+"'"+item+"' => \""+value+"\"\n";}}}else{dumped_text="===>"+arr+"<===("+typeof(arr)+")";}
return dumped_text;}
function initDownloadsPage()
{initSearchblock('/'+url_countrycode+active_language_code+'/downloads/a/list',initDownloads);}
function initDownloads()
{$('select.doc_langs').change(function(){if($(this).val()=='')
return;var type_index=$('#searchtab').tabs('option','selected');var type_name=$('#searchtab li:eq('+type_index+') a').attr('href').substr(1);var win=window.open();win.location='http://downloads.gardenequipment.be/download/'+type_name+'/'+$(this).val();});$('#videoresults ul li a').click(function(){$('#videopop').attr('title',$(this).attr('title'));$('#focusvideo').attr('href',$(this).attr('href'));$("#videopop").dialog({autoOpen:false,draggable:false,height:262,width:482,modal:true,position:'center',resizable:false,zIndex:1800,overlay:{backgroundColor:'#ccc',opacity:0.5}});$('#ui-dialog-title-videopop').html($(this).attr('title'));initVideoPlayer();galleryPop('video',1);return false;});}
function initSearchblock(url,callback)
{$('#searchtab').tabs();$('#searchtab').bind('tabsshow',function(event,ui){$('div.page div.searchblock form, #dc_content div.searchblock form').submit();});$('#brandselect').change(function(){if($(this).val()!='0')
{$('div.page div.searchblock form input.textfield, #dc_content div.searchblock form input.textfield').val('');$('#catselect').val(0);}
$('div.page div.searchblock form input.textfield, #dc_content div.searchblock form input.textfield').focus();$('div.page div.searchblock form, #dc_content div.searchblock form').submit();});$('#catselect').change(function(){if($(this).val()!='0')
{$('#brandselect').val(0);$('div.page div.searchblock form input.textfield, #dc_content div.searchblock form input.textfield').val('');}
$('div.page div.searchblock form input.textfield, #dc_content div.searchblock form input.textfield').focus();$('div.page div.searchblock form, #dc_content div.searchblock form').submit();});$('div.page div.searchblock form, #dc_content div.searchblock form').submit(function()
{var hastabs=$('#searchtab').length;if(hastabs>0)
{var type_index=$('#searchtab').tabs('option','selected');if(pagedata.name=='speedorder'&&type_index==3)
{location.href=urls.action;return false;}
$('#searchtype').val($('#searchtab li:eq('+type_index+') a').attr('href').substr(1));}
$('#searchresult').html(text.loading);$('#searchresult').load(url,$(this).serializeArray(),callback);return false;});}
function initShop()
{initSearchblock('/'+url_countrycode+active_language_code+'/shop/products/a/search');}
function initYourDiscounts()
{if($('#discountsearch').length>0)
initSearchblock('/'+url_countrycode+active_language_code+'/dealercenter/yourdiscounts/a/search');}
function initHome()
{var activePart=0;var partWidth=656;var nrParts=4;var scroller=new Scroller();scroller.start();scroller.getUl().fadeIn('slow');scroller.getUl().css('left',-$('#thumbbrowser ul li.active').position().left+246);var showRandomItem=function()
{scroller.showRandomItem();}
initVideoPlayer(showRandomItem);$('li:not(.active)',scroller.getUl()).css('opacity',0.3);$('#scroller').mouseleave(function(){scroller.setFocus(false);scroller.moveToActive();});var next=$('#next');var prev=$('#prev');next.bind('mouseover click',function(){if(scroller.getUl().position().left<=-scroller.getUl().width()+699)
return false;scroller.setFocus(true);scroller.next();return false;});prev.bind('mouseover click',function(){if(scroller.getUl().position().left>=0)
return false;scroller.setFocus(true);scroller.prev();return false;});next.mouseleave(function(){scroller.setFocus(false);});prev.mouseleave(function(){scroller.setFocus(false);});var th=$('#thumbbrowser ul li a');th.click(function(){var liactive=$('#thumbbrowser ul li.active');liactive.css('opacity',0.3);liactive.removeClass('active');var par=$(this).parent();par.addClass('active');par.css('opacity',1);$('#offer_info>div:visible').hide();$('#i'+$(this).attr('id').substring(1)).show();$('#focusvideo').attr('href',$(this).attr('href'));initVideoPlayer(showRandomItem);scroller.moveToActive();return false;});th.mousemove(function(){$(this).parent().css('opacity',1);});th.mouseout(function(){if(!$(this).parent().hasClass('active'))
$(this).parent().css('opacity',0.3);});}
function initCheckout()
{$('#order_login form').submit(function(){$.post('/'+url_countrycode+pagedata.url+'/a/login',$(this).serializeArray(),function(data){if(data=='private')
{$('#order_login').slideUp('fast');$('#order_data').load('/'+url_countrycode+pagedata.url+'/a/yourdata_form');}
else if(data=='dealer')
window.location='/'+url_countrycode+pagedata.url;else
$('#order_login div.error').slideDown('fast');});return false;});$('#form_yourdata').submit(function()
{if(webshop_id==undefined&&$('select[name="usertype"]').val()!='dealer'&&$('ul.dealers input[name="dealer"]:checked').length==0)
{$('#dealerchoice .error').remove();var errordiv=$('<div class="error">'+text.choosedealer_env+'</div>');errordiv.hide();$('#dealercontainer').before(errordiv);errordiv.slideDown();return false;}});objGifts.init();}
function setCartitemType(orderType,productcode)
{$.post('/'+url_countrycode+pagedata.url+'/a/cart_changeOrderType',{productcode:productcode,orderType:orderType},updateCart);}
function initWaranty()
{$('#waranty input').keydown(function()
{var tr=$(this).parent().parent();var tbody=tr.parent();if($('tr:last input.nr_replaced_pieces',tbody).val()!=''||$('tr:last input.amount',tbody).val()!=''||$('tr:last input.description',tbody).val()!='')
{var clone=tr.clone();$('input',$(clone)).val('');clone.appendTo(tbody);initWaranty();}});$('#waranty_form').submit(function()
{$.post('/'+url_countrycode+active_language_code+'/dealercenter/waranty/a/submit',$(this).serializeArray(),function(data)
{if(data.error!=undefined)
alert(data.error);else
$('#waranty_container').html('<p>'+data.confirm+'</p>');},'json');return false;});}
function initFolders()
{$('#form_folders').submit(function()
{$.post($(this).attr('action'),$(this).serializeArray(),function(data)
{if(data.error!=undefined)
alert(data.error);else
$('#folders_container').html('<p>'+data.confirm+'</p>');},'json');return false;});}
function initProdreg()
{$('#prodreg_form').submit(function()
{$.post('/'+url_countrycode+active_language_code+'/dealercenter/prodreg/a/submit',$(this).serializeArray(),function(data)
{if(data.error!=undefined)
alert(data.error);else
$('#prodreg_container').html('<p>'+data.confirm+'</p>');},'json');return false;});}
function initCataloog()
{$('#catnavigator .catbutton').click(function()
{$('#catnavigator .catselect').slideDown(200);});$('#catnavigator').mouseleave(function()
{$('#catnavigator .catselect').fadeOut(200);});$('#viewer').load('/'+url_countrycode+pagedata.url+'/a/get_products',{index:0,category_id:0},function()
{$('#viewer_content').hide();$('#viewer_content').fadeIn(300);});$('a.navbutton.left').hide();$('a.navbutton.right').click(function()
{$('#viewer_content').fadeOut(200,function(){$('#viewer').load('/'+url_countrycode+pagedata.url+'/a/get_products',{index:catalog_next_index,category_id:0},function()
{$('#viewer_content').hide();$('#viewer_content').fadeIn(500);$('a.navbutton.left').show();if(catalog_index>=total_products)
$('a.navbutton.right').hide();});});return false;});$('a.navbutton.left').click(function()
{$('#viewer_content').fadeOut(300,function(){$('#viewer').load('/'+url_countrycode+pagedata.url+'/a/get_products',{index:catalog_index-4,category_id:0},function()
{$('#viewer_content').hide();$('#viewer_content').fadeIn(300);$('a.navbutton.right').show();if(catalog_index<4)
$('a.navbutton.left').hide();});});return false;});return false;}
function updateCatalogBrandselect(id)
{var cat_li=$('#cat'+id);$('#catcolor').attr('class',$('div',cat_li).attr('class'));$('#catname').text(cat_li.text());}
function catalogLoadCategory(id)
{$('#catnavigator .catselect').hide();updateCatalogBrandselect(id);$('#viewer_content').fadeOut(300,function(){$('#viewer').load('/'+url_countrycode+pagedata.url+'/a/get_products',{index:0,category_id:id},function()
{$('#viewer_content').hide();$('#viewer_content').fadeIn(300);$('a.navbutton.left').show();$('a.navbutton.right').show();});});}
function initRegister()
{$('#registerform form').submit(function()
{$.post('/'+url_countrycode+pagedata.url+'/a/register_submit',$(this).serializeArray(),function(data)
{if(data.error!=undefined)
alert(data.error);else
$('#registerform').html('<p>'+data.confirm+'</p>');},'json');return false;});}
function initForgotPass()
{$('#form_forgot_pass').submit(function()
{$.post('/'+url_countrycode+pagedata.url+'/a/forgot_pass_submit',$(this).serializeArray(),function(data)
{if(data.error!=undefined)
alert(data.error);else
$('#forgot_pass_container').html('<p>'+data.confirm+'</p>');},'json');return false;});}
function initNewsletterSubscribe()
{$('#form_newsletter').submit(function()
{$.post('/'+url_countrycode+active_language_code+'/admin/newsletter_addresses/a/subscribe',$(this).serializeArray(),function(data)
{if(data.error!=undefined)
alert(data.error);else
$('#newsletter_container').html('<p>'+data.confirm+'</p>');},'json');return false;});}
function initContact()
{$('#form_contact').submit(function()
{$.post('/'+url_countrycode+pagedata.url+'/a/contact_submit',$(this).serializeArray(),function(data)
{if(data.error!=undefined)
alert(data.error);else
$('#contact_container').html('<p>'+data.confirm+'</p>');},'json');return false;});}
function initInvoicehistory()
{$('#invoicesearch form').submit(function()
{$('#searchresult').empty().load('/'+url_countrycode+active_language_code+'/dealercenter/invoicehistory/a/search',$(this).serializeArray());return false;});$('#select-boekjaar').change(function()
{$('#invoicetotals').empty().load('/'+url_countrycode+active_language_code+'/dealercenter/invoicehistory/a/invoicetotals/'+$(this).val());return false;});}
function initFaq()
{$("#faqvideopop").dialog({autoOpen:false,draggable:false,height:501,width:802,modal:true,position:'center',resizable:false,zIndex:1800,overlay:{backgroundColor:'#000',opacity:0.6}});}
function initPayments()
{}
function initActionItaly()
{$('#action_participation form').submit(function()
{var period=$('input:checked',this).attr('id');if(period==undefined||(period!='nopart'&&$('#nr_persons_'+period).val()==0))
{alert(text.contact_wrong);return false;}
$('#action_participation form').load('/'+url_countrycode+pagedata.url+'/a/submit_action_italy_participation',{period:period,persons:$('#nr_persons_'+period).val()});return false;});}
function initEvent()
{$('#action_participation form').submit(function()
{$('#action_participation form').load('/'+url_countrycode+pagedata.url+'/a/submit_event_participation',$(this).serializeArray());return false;});$('#event_tickets form').submit(function()
{$('#event_tickets form').load('/'+url_countrycode+pagedata.url+'/a/submit_event_tickets',$(this).serializeArray());return false;});}
function Gifts()
{var spentAmount;var giftData=new Array();var set;this.init=function()
{$('#gifts .amount_select select').change(objGifts.updateAmount);$('#gifts .pagination a').click(function(){$('#gifts').load('/'+url_countrycode+pagedata.url+'/a/getGiftsSet',{set:$(this).attr('href').substr(1),voorseizoen_total:objGifts.getSpentAmount()},objGifts.init);return false;});objGifts.updateAmounts();};this.updateAmount=function()
{var id=$(this).attr('id');if(giftData[id]==undefined)
giftData[id]={price:Number($('#price_gift_'+id.substr(1)).val()),amount:Number($(this).val())};else
giftData[id].amount=Number($(this).val());objGifts.updateAmounts();};this.updateAmounts=function()
{var rest=objGifts.getSpentAmount()-objGifts.getTotal();var giftID;var giftPrice;var select;$('#gifts .gift').each(function()
{giftID=$('select',this).attr('id');giftPrice=Number($('input.price_gift',this).val());availAmount=Math.floor(rest/giftPrice);if(giftData[giftID]!=undefined)
availAmount+=giftData[giftID].amount;select=$('select',this);select.html('');for(i=0;i<availAmount+1;i++)
{select.append('<option value="'+i+'">'+i+'</option>');}
if(giftData[giftID]!=undefined)
select.val(giftData[giftID].amount);});objGifts.updateForm();};this.updateForm=function()
{var str='';var giftID;for(giftID in giftData)
{if(giftData[giftID].amount>0)
str+=giftID.substr(1)+':'+giftData[giftID].amount+'\n';}
$('#gifts_order').val(str);};this.submitCheck=function()
{if($('#select_order_type').val()=='')
return true;if(this.getTotal()+2500<this.getSpentAmount())
{if(active_language_code=='nl')
alert('U kunt nog gratis geschenken kiezen.');else
alert('Vous pouvez encore choisir des cadeaux gratuites.');return false;}
return true;}
this.getTotal=function()
{var gift;var total=0;for(gift in giftData)
{total+=giftData[gift].price*giftData[gift].amount;}
return total;};this.getSpentAmount=function()
{return spentAmount;};this.setSpentAmount=function(val)
{spentAmount=val;};this.getSet=function()
{return set;};this.setSet=function(val)
{set=val;};}
var objGifts=new Gifts();function initDealers()
{if(dealer){loadMap();}}
function loadMap()
{var start=new google.maps.LatLng(dealer.lat,dealer.lng);var zoomLevel=13;var options={zoom:zoomLevel,center:start,mapTypeId:google.maps.MapTypeId.ROADMAP,navigationControlOptions:{style:google.maps.NavigationControlStyle.SMALL}}
map=new google.maps.Map($('#map')[0],options);var point=new google.maps.LatLng(dealer.lat,dealer.lng);var label=dealer.name;var address=dealer.address;var city=dealer.city;var tel=dealer.tel;var fax=dealer.fax;var email=dealer.email;var website=dealer.website;var marker=createMarker(map,point,label,address,city,tel,fax,email,website);mapMarkers.push(marker);}
createMarker=function(map,latlng,title,address,city,tel,fax,email,website)
{var infoWindowAnchor=new google.maps.Size(23,17);var markerOptions={title:title,position:latlng,map:map}
var marker=new google.maps.Marker(markerOptions);google.maps.event.addListener(marker,"click",function(){var content='<h4>'+title+'</h4>';content+='<br/>';content+=address;content+='<br/>';content+=city;var infowindowOptions={content:content,pixelOffset:infoWindowAnchor}
var infowindow=new google.maps.InfoWindow(infowindowOptions);setInfowindow(infowindow);infowindow.open(map,marker);});return marker;}
function setInfowindow(newInfowindow){if(openInfowindow!=undefined){openInfowindow.close();}
openInfowindow=newInfowindow;}
submitCart=function(){blankRow=$('#checkoutcontent table tr.blankrow');if(blankRow.length!=0){if($('input[name="blank_article[]"]',blankRow).val()!=''){$('#cart_form input[name=blank_article]').val($('input[name="blank_article[]"]',blankRow).val());$('#cart_form input[name=amount]').val($('select[name="blank_amount[]"]',blankRow).val());$('#cart_form input[name=blank_price]').val($('input[name="blank_price[]"]',blankRow).val());}}
return confirm(text.confirm_order_dealer);}
function initYourWebshop()
{$('#yourwebshop').tabs();$('#yourwebshop-offer ul > li input:checkbox').click(function()
{if($(this).is(':checked'))
{$('ul li input:checkbox',$(this).parent().parent()).attr('checked','checked');$('input.discount',$(this).parent().parent()).removeAttr('disabled');}
else
{$('ul li input:checkbox',$(this).parent().parent()).removeAttr('checked');$('input.discount',$(this).parent().parent()).attr('disabled','disabled');}});$('#yourwebshop-offer ul li ul li input:checkbox').click(function()
{if($('input:checkbox:checked',$(this).parent().parent().parent()).length>0)
{$('input:checkbox',$(this).parent().parent().parent().parent()).first().attr('checked','checked');$('input.discount',$(this).parent().parent()).removeAttr('disabled');}
else
{$('input:checkbox',$(this).parent().parent().parent().parent()).first().removeAttr('checked');$('input.discount',$(this).parent().parent()).attr('disabled','disabled');}});$('#yourwebshop-offer ul li ul li input:checkbox:not(:checked)').each(function()
{$('input.discount',$(this).parent().parent()).attr('disabled','disabled');});$('#yourwebshop-offer form').submit(function()
{$('#yourwebshop-offer .confirm').hide();var frm=$(this);$.post(frm.attr('action'),frm.serializeArray(),function(data)
{if(data.confirm!=undefined)
{$('#yourwebshop-offer .confirm').text(data.confirm);$('#yourwebshop-offer .confirm').slideDown();}},'json');return false;});$('#yourwebshop-offer #yourwebshop-offer-changeall .largebutton').click(function()
{$('#yourwebshop-offer form select').val($('#yourwebshop-offer #yourwebshop-offer-changeall select').val());$('#yourwebshop-offer form').submit();return;});$('#yourwebshop-settings form').submit(function()
{$('#yourwebshop-settings .confirm').hide();var frm=$(this);$.post(frm.attr('action'),frm.serializeArray(),function(data)
{if(data.confirm!=undefined)
{$('#yourwebshop-settings .confirm').text(data.confirm);$('#yourwebshop-settings .confirm').slideDown();}},'json');return false;});$('input:radio[name="usebanner"]').click(function()
{$('#yourwebshop-manage-images').toggle();});$('#yourwebshop-manage-images input:button').click(function()
{var bannerManager=$('<div id="bannerManager">');$('body').append(bannerManager);bannerManager.dialog({width:810,height:550,draggable:false,position:'center',title:$(this).val(),dialogClass:'dealercenter',resizable:false,modal:true,position:'center',zIndex:1900,overlay:{backgroundColor:'#000',opacity:0.2}});bannerManager.bind('dialogclose',function(event,ui)
{bannerManager.dialog('destroy');bannerManager.remove();});bannerManager.load('/'+url_countrycode+active_language_code+'/dealerwebshops/a/bannerManager',initBannerManager);});$('#color_selector').ColorPicker({color:$('#yourwebshop-settings input[name="color"]').val(),onShow:function(colpkr){$(colpkr).fadeIn(500);return false;},onHide:function(colpkr){$(colpkr).fadeOut(500);return false;},onChange:function(hsb,hex,rgb){$('#color_selector div').css('backgroundColor','#'+hex);$('#yourwebshop-settings input[name="color"]').val('#'+hex);}});$('#color_bg_selector').ColorPicker({color:$('#yourwebshop-settings input[name="color_bg"]').val(),onShow:function(colpkr){$(colpkr).fadeIn(500);return false;},onHide:function(colpkr){$(colpkr).fadeOut(500);return false;},onChange:function(hsb,hex,rgb){$('#color_bg_selector div').css('backgroundColor','#'+hex);$('#yourwebshop-settings input[name="color_bg"]').val('#'+hex);}});$('#color_detail_selector').ColorPicker({color:$('#yourwebshop-settings input[name="color_detail"]').val(),onShow:function(colpkr){$(colpkr).fadeIn(500);return false;},onHide:function(colpkr){$(colpkr).fadeOut(500);return false;},onChange:function(hsb,hex,rgb){$('#color_detail_selector div').css('backgroundColor','#'+hex);$('#yourwebshop-settings input[name="color_detail"]').val('#'+hex);}});}
function initBannerManager()
{$('#bannerManager-save').click(function()
{var activeBanner=$('#bannerManager-choose input:checked');$('#yourwebshop-manage-images .thumb').html('');var img=$('img',activeBanner.parent()).clone();$('#yourwebshop-manage-images .thumb').append(img);$('#yourwebshop-settings form input[name="banner_id"]').val(activeBanner.val());$('#bannerManager').dialog('close');});}
function updateBanners()
{$('#bannerManager').load('/'+url_countrycode+active_language_code+'/dealerwebshops/a/bannerManager',initBannerManager);}
function profileUploadError(text)
{$('#profile-error').html(text);$('#profile-error').slideDown();}
function profileUploadConfirm(text)
{$('#profile-confirm').html(text);$('#profile-confirm').slideDown();}
