Prototype.Browser.IE6 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 6;
Prototype.Browser.IE7 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 7;
Prototype.Browser.IE8 = Prototype.Browser.IE && !Prototype.Browser.IE6 && !Prototype.Browser.IE7;

var valid;

var Cart = Class.create({

    initialize: function() {     
        this.url = SHOP_BASE_REL+'front/server_cart.php';  
    }
    ,addRelated: function(div_id){
        var params=$H(
            {
                action: 'addRelated',
                cart_mode: 'simple',
                sid:Math.random()
            }
        ).toQueryString();

        params = params + "&" + $('form_related').serialize();

        $(div_id).ajaxUpdate(
            this.url,
            {
                method: 'post',
                parameters: params,
                onComplete: this.showCompleteCart()
            }    
        );    
    }
    ,addToCart: function(div_id,product_id,quantity){
        
        cart_mode = 'simple';
        if(div_id == 'winkelmand_container')
            cart_mode = 'extended';
    
    
        var params=$H(
            {
                action: 'addToCart',
                product_id:product_id,
                cart_mode: cart_mode,
                quantity:quantity,
                sid:Math.random()
            }
        ).toQueryString();

        if(div_id == 'winkelmand_container'){
            $(div_id).ajaxUpdate(
                this.url,				
                {
                    method: 'get',
                    parameters: params,
				  	evalJS: true,
				  	evalScripts: true					
                }    
            );
        }
        else{
            $(div_id).ajaxUpdate(
                this.url,
                {
                    method: 'get',
                    parameters: params,
				  	evalJS: true,
				  	evalScripts: true					
                }    
            );    
        }
    }
    ,removeFromCart: function(id,product_id,cart_id){
        
        cart_mode = 'simple';
        if(id == 'winkelmand_container')
            cart_mode = 'extended';		
		
        var params=$H(
            {
                action: 'remove',
                product_id: product_id,
				cart_mode: cart_mode,
                cart_id: cart_id,
                sid:Math.random()
            }
        ).toQueryString();

    
        $(id).ajaxUpdate(
            this.url,
            {
                method: 'get',
                parameters: params,
                onComplete: function(){
                    resize();                   
                }          
            }    
        );
    }
    ,updateToCart: function(id,product_id,quantity,cart_id){

        var params=$H(
            {
                action: 'update',
                product_id: product_id,  
                cart_id: cart_id,
                quantity:quantity,
                sid:Math.random()
            }
        ).toQueryString();

    
        $(id).ajaxUpdate(
            this.url,
            {
                method: 'get',
                parameters: params,
                onComplete: function(){
                    resize();             
                }            
            }    
        );
    }
    ,refreshCart: function(id){

        var params=$H(
            {
                action: 'refresh',
                sid:Math.random()
            }
        ).toQueryString();

    
        $(id).ajaxUpdate(
            this.url,
            {
                method: 'get',
                parameters: params
            }    
        );
    }
    ,clearCart: function(){
        
        var params=$H(
            {
                action: 'clearCart',
                sid:Math.random()
            }
        ).toQueryString();

    
        $('winkelmand_container').ajaxUpdate(
            this.url,
            {
                method: 'get',
                parameters: params,
                onComplete: function(){

                    resize(); 
                }
            }    
        );
    }
    ,saveCart: function(id,name){

        var params=$H(
            {
                action: 'save_cart',
                cart_id: id,
                cart_name: name,
                sid:Math.random()
            }
        ).toQueryString();

    
        $('winkelmandje-storebox').ajaxUpdate(
            this.url,
            {
                method: 'get',
                parameters: params,
                onComplete: function(){
                    alert('Bestellijst is opgeslagen');
                }

            }    
        );
    }
    ,loadSavedCart: function(id){
        
        var params=$H(
            {
                action: 'load_saved_cart',
                cart_id: id,
                sid:Math.random()
            }
        ).toQueryString();

    
        $('header_cart').ajaxUpdate(
            this.url,
            {
                method: 'get',
                parameters: params,
                onComplete: function(){
                    showCompleteCart();
                }

            }    
        );
    }
    ,deleteSavedCart: function(id){
        
        var params=$H(
            {
                action: 'delete_saved_cart',
                cart_id: id,
                sid:Math.random()
            }
        ).toQueryString();

    
        $('order_list_overview').ajaxUpdate(
            this.url,
            {
                method: 'get',
                parameters: params
            }    
        );
    }
    ,goto_checkout: function(step,substep,action){
            var form_elements = "";
            f = $('form_winkelmand_cadeau');
            if(f){
                form_elements = f.serialize();
            }
    
    
            var params=$H(
                {
                    action: action,
                    step: step,
                    substep: substep,
                    sid:Math.random()
                }
            ).toQueryString();
            
            if(form_elements){
                params = form_elements + "&" + params;
            }

            
            $('popup_module-resultaat').ajaxUpdate(
                this.url,
                {
                  method: 'POST',
                  parameters: params,
                  onComplete: function(){

                        if($('form_checkout')){
                            valid = new Validation('form_checkout', {immediate : true, onFormValidate : formCallback,useTitles:true});          
                        }
                        else{ 
                            if($('form_user') && $('user_choice_subscribe').visible()){
                                valid = new Validation('form_user', {immediate : true, onFormValidate : formCallback,useTitles:true});          
                                Validation.addAllThese([
                                        ['validate-url', 'Een correcte adres invullen a.u.b.', function (v) {
                                            return Validation.get('IsEmpty').test(v) || v == "http://" || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
                                        }],            
                                        ['validate-postcode', 'Postcode is niet correct', function (v,elm) {

                                            return Validation.get('IsEmpty').test(v) ||  /^[\d]{4,4}\s{0,1}[a-zA-Z]{2,2}$/.test(v) 
                                        }]
                                    ]);                     
                            }
                            else if($('form_login') && $('user_choice_login').visible()){
                                valid = new Validation('form_login', {immediate : true, onFormValidate : formCallback,useTitles:true});          
                            }
                        }
                        resize();  
                  }
                }    
            );  
    }    
    ,checkout_goto: function(step){
        this.goto_checkout(step,'','show');
    }
    ,checkout_confirm_form: function(form,nextstep){

        $(form).request({
            onComplete: function(req){ 
                    //if(dialogCounter == 1) 
                        //hideProcessing();  
                    
                    
                    $('popup_module-resultaat').innerHTML = req.responseText; 
                    
                    if($('form_checkout')){  
                        valid = new Validation('form_checkout', {immediate : true, onFormValidate : formCallback,useTitles:true});
                    }
                    else{
                        if($('form_user') && $('user_choice_subscribe').visible()){ 
                            valid = new Validation('form_user', {immediate : true, onFormValidate : formCallback,useTitles:true});   
                            Validation.addAllThese([
                                    ['validate-url', 'Een correcte adres invullen a.u.b.', function (v) {
                                        return Validation.get('IsEmpty').test(v) || v == "http://" || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
                                    }],            
                                    ['validate-postcode', 'Postcode is niet correct', function (v,elm) {

                                        return Validation.get('IsEmpty').test(v) ||  /^[\d]{4,4}\s{0,1}[a-zA-Z]{2,2}$/.test(v) 
                                    }]
                                ]);                                
                        }
                        else if($('form_login') && $('user_choice_login').visible()){ 
                            valid = new Validation('form_login', {immediate : true, onFormValidate : formCallback,useTitles:true});          
                        }                    
                    }

                    
                    resize();                         
                    
            }
        }); 
        return false;
    }
    ,showCompleteCart: function(action){

        if (action && action == 'payment') {
			action = action;
		}
		else {
			action = 'show';
			if($('header_cart').down('span.empty_cart')){
				
				alert('Winkelmandje is leeg!');
				return false;
			}
			
		}  

        var params=$H(
        {
            action:action,
            sid:Math.random()
        }
        ).toQueryString();

        this.req_parameters = params;

        Lightview.show({
          href: this.url,
          rel: 'ajax',
          viewport:true, 
          options: {
            menubar: false,
            innerPreviousNext:false,
            overflow:'auto',  
            topclose: true,
            autosize: false,
            fullscreen: true,
            ajax: {
              method: 'get',
              parameters: this.req_parameters, 
              onComplete: function(){ 

              }
            }
          }
        });
    }    
    
});

var Payment = Class.create({   
    initialize: function() {   
    
    }
    ,checkAgree: function(){
        return $('agree2').checked;
        //return true;
    }    
    ,showPaymentDescription: function(){
        pchoice = $RF('pchoice');  
        if (pchoice != null){ 
           switch(pchoice){
                
                case 'Buckaroo_ideal': 
                    $('payment_method_description').innerHTML = $('form_description_buckaroo_ideal').innerHTML;
                    break;
                case 'Buckaroo_incasso':       
                    $('payment_method_description').innerHTML = $('form_description_buckaroo_incasso').innerHTML;                   
                    break;                    
                case 'Vooruitbetalen': 
                    $('payment_method_description').innerHTML = $('form_description_vooruitbetalen').innerHTML;   
                    break;
                case 'OpRekening': 
                    $('payment_method_description').innerHTML = $('form_description_oprekening').innerHTML;       
                    break;                    
                case 'PayPal': 
                    $('payment_method_description').innerHTML = $('form_description_paypal').innerHTML;       
                    break;  
				case 'Incasso':
                    $('payment_method_description').innerHTML = $('form_description_incasso').innerHTML;       
                    break;  					 
                default:
                    $('payment_method_description').innerHTML = $('form_description_'+pchoice).innerHTML;       
                    break; 
           }          
        }
    },
	checkBank:function(nr){
	    checksum = 0;
	    
	    if(nr.length == 9){
	        for (var i=0; i<9; i++){
	            checksum += (nr[i] * (9 - i));
	        } 
	
	        if (checksum > 0 && checksum % 11 == 0){
	            return true;
	        }
	    }	
		return false;
	},
	checkBankAccount:function(nr){
		
		if(nr.length < 3){
			return false;	
		}
		else if (nr.length > 7) {
			return this.checkBank(nr);
		}
		else{
			return true;				
		}		
	},
    pay: function(){
        if(this.checkAgree()){
            checkout_only = false;
            if($('form_payment_checkout_only')){
                checkout_only = true;
            }
                
                

            if(checkout_only){
                var pform = $('form_payment_checkout_only');    
                pform.submit();
            }
            else{
                pchoice = $RF('pchoice');
                
                if (pchoice == null){
                    alert("Kies eerst de gewenste betaalmethode");
                    return;
                }

                switch(pchoice){
                    
                    case 'Buckaroo_ideal': 
                                   
                        var pform = $('form_payment_buckaroo_ideal');
                        
                        $('payment_method_description').innerHTML = $('form_description_buckaroo_ideal').innerHTML;
                        
                        /*if($F('BPE_Issuer') == "" ){
                            alert("Kies eerst de gewenste betaalmethode");
                            return;
                        }                             
                        
                        if($F('BPE_Issuer') == "X" ){
                            alert("U kunt uitsluitend met iDeal betalen\nals u bankiert bij één van de genoemde banken.\nSelecteer andere betaalmethode!");
                            //setRadio('pform','pchoice','incasso');
                            return;
                        } */
                        //self.name = "payopener"; 
                        //prevWin = open('','_pay','toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=800, height=600, top=100, left=150');
                        //if (prevWin && !prevWin.closed)
                            //prevWin.focus();

                        pform.submit();                                
                        //submitFormAfterValidate_project(pform.id,0); 
                    
                        return true;
                        break;

                    case 'Buckaroo_incasso': 
                        
                        var pform = $('form_payment_buckaroo_incasso');           
                        $('payment_method_description').innerHTML = $('form_description_buckaroo_incasso').innerHTML;
                        
                        //self.name = "payopener"; 
                        //prevWin = open('','_pay','toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=800, height=600, top=100, left=150');
                        //if (prevWin && !prevWin.closed)
                           // prevWin.focus();
                        
                        
                        pform.submit();                                
                        //submitFormAfterValidate_project(pform.id,0);
                        return true;                       
                        break;                    
                     
					case 'Incasso':
                        
						
						var pform = $('form_payment_incasso'); 
						var name = $F('payment_incasso_name_temp');
						var account = $F('payment_incasso_account_temp');
						
						
						
						if(name.length > 0 && this.checkBankAccount(account) ){
                        	$('payment_method_description').innerHTML = $('form_description_incasso').innerHTML;   
                        
							$('payment_incasso_name').value = name;
							$('payment_incasso_account').value = account;
							
                        	pform.submit();						
						}
						else{
							alert('Gegevens voor incasso niet compleet of onjuist!');
							return false;
						}
						
					
						break;   
                    case 'Vooruitbetalen': 
                        var pform = $('form_payment_vooruitbetalen'); 
                        $('payment_method_description').innerHTML = $('form_description_vooruitbetalen').innerHTML;   
                        
                        pform.submit();

                        break;
                        
                    case 'OpRekening': 
                        var pform = $('form_payment_oprekening'); 
                        $('payment_method_description').innerHTML = $('form_description_oprekening').innerHTML;       
                        pform.submit();
                        
                        break;                    
                        
                    case 'PayPal': 
                        var pform = $('form_payment_paypal'); 
                        $('payment_method_description').innerHTML = $('form_description_paypal').innerHTML;       
                        pform.submit();
                        
                        // $('paysubscription').submit();
                       //submitFormAfterValidate_project($('paysubscription').id,0);
                        break;   
                    
                    default : 
  
                        if(pchoice.indexOf('MSP_') == 0){
                            var url = SHOP_BASE_REL+'front/server_msp.php';
                            var method = pchoice.substring(4);
                            var params=$H(
                                {
                                    action: 'start_request',
                                    method:  pchoice.substring(4),
                                    session: $F('MSP_'+method+'_session'),
                                    id: $F('MSP_'+method+'_order_id'), 
                                    step: $F('MSP_'+method+'_step'),
                                    sid:Math.random()
                                }
                            ).toQueryString();                            
                            
                            new Ajax.Request(url, {
                              method: 'post',
                              parameters:params,
                              onSuccess: function(transport) {
                                    
                                    var json = transport.responseText.evalJSON();

                                    if(json.success){
                                        window.location = json.url;
                                    }
                                    else{
                                        alert('Er kan geen contact worden gemaakt met de betaal provider. De betaalmethode kan momenteel niet gebruikt worden. Probeer later nog eens of neem contact op met ons.');
                                    }
                              }
                            });
                            
                            
                            
                                        
                        }
                        else{
                            alert("Het is niet mogelijk om te betalen via deze weg. Neem contact op met de eigenaar.");  
                        }
            
                }
            }
        }else{
            alert("U dient alvorens de bevestiging akkoord te gaan met de Algemene Voorwaarden");
        }
        
    }
    ,showGeneralConditions: function(buttons){
    
         if($('general_conditions')){
            
            if($(buttons + '_confirm'))
                $(buttons + '_confirm').toggle();
            if($(buttons + '_previous'))
                $(buttons + '_previous').toggle();                
                
            $('payment_container').toggle();
            $('general_conditions').clonePosition($('lightview'));
            $('general_conditions').setStyle({'width':width-20+'px', 'height':height-100+'px'});
            $('general_conditions').toggle();
        }   
    
    }

});

var Login = Class.create({
    
    initialize: function() {   
    
    }
    ,password_forgotten: function(form_id,login_box_id,login_box_forgotten_id,name_id,name_forgotten_id){
      
        $$('div.checkout_login_button').invoke('hide');
      
        if($(login_box_id + '_confirm'))
                $(login_box_id + '_confirm').hide();
                    
        $(name_forgotten_id).value = $F(name_id);
        $(login_box_id).toggle(); 
        $(login_box_forgotten_id).toggle(); 
      }
      ,
      send_password: function(form_id,login_box_id,login_box_forgotten_id,name_id,name_forgotten_id){
            f_value = $F(name_forgotten_id);

            var url = SHOP_BASE_REL+'front/server_user.php';
            var params=$H(
                {
                    action: 'send',
                    id:f_value,
                    sid:Math.random()
                }
            ).toQueryString();

    
            $('passwordforgotten_response').ajaxUpdate(
                url,
                {
                  method: 'get',
                  parameters: params,
                  onComplete: function(){

                         $$('div.checkout_login_button').invoke('show');     
                         $(form_id).password.value = '';   
                         $(name_id).value = $F(name_forgotten_id);
                         //this.password_forgotten(form_id,login_box_id,login_box_forgotten_id,name_id,name_forgotten_id);
                         if ($(login_box_id + '_confirm')) {
						 	$(login_box_id + '_confirm').show();
						 } 
                            
                        $(login_box_id).toggle(); 
                        $(login_box_forgotten_id).toggle();               
                  }
                }    
            );
    }
    ,loginEnter: function(e){
        
      if(window.event && e.keyCode == 13){ // IE{
            valid.validate();
      }
      else if(e.which && e.which == 13){ // Netscape/Firefox/Opera{
            valid.validate();
      } 
    }  

});

Array.prototype.removeItems = function(itemsToRemove) {

    if (!/Array/.test(itemsToRemove.constructor)) {
        itemsToRemove = [ itemsToRemove ];
    }

    var j;
    for (var i = 0; i < itemsToRemove.length; i++) {
        j = 0;
        while (j < this.length) {
            if (this[j] == itemsToRemove[i]) {
                this.splice(j, 1);
            } else {
                j++;
            }
        }
    }
};


var ShopRequest = Class.create({
    
    initialize: function(url, options,filters) {     
        this.options = {
            action:'',
            column:'',
            direction:'',
            nav_page:'',
            nr_results:'',
            searchTerms:'',
            exact:''
        };
        Object.extend(this.options, options || { });    
    
		
        this.filters = {
           cat_id: new Array(),
           f_product_v2: new Array(),
		   f_product_bio : new Array(),
           f_product_price_incl: new Array(),
           f_product_administration_discount: new Array()
		   
        };
        Object.extend(this.filters, filters || { });    
        
    
    },
    addParameters: function(options){
        this.options.sid = null;
        Object.extend(this.options, options || { });     
    },
    removeParameters: function(toRemove){
            
            this.options.removeItems(toRemove);

    },
    setParameters: function(options){
        this.options = options;
    },
    setFilter:function(key,value){
        var length = this.filters[key].length;
        this.filters[key][length] = value;  
    },
    removeFilter:function(key,value){

        
        this.filters[key].removeItems(value);     
    },
    removeFilters:function(key){
        this.filters[key] = new Array();
    },
    removeAllFilters:function(){
        for(var filter in this.filters){ 
            this.filters[filter] = new Array();    
        }
    },
    getQueryString: function(){
        var params = $H(this.options).toQueryString();
        
        for(var filter in this.filters){ 

            for(i=0;i<this.filters[filter].length;i++){
                 
                 params = params + '&'+filter + '[]=' + encodeURIComponent(this.filters[filter][i]);
                
            }
        }
        
        return params;
        //var filters = $H(this.filters)
    }
});


var Shop = Class.create({   
    
    initialize: function(options) {     
        this.url = SHOP_BASE_REL+'front/server.php';  
        this.cart = new Cart();
        this.payment = new Payment();
        this.login = new Login();
        this.req_parameters = "";
        this.product_detail_fullscreen = false; 
        this.request = new ShopRequest(this.url,options);
        this.stock = new Array();
        
    }
    ,setParameters: function(params){
        this.request.setParameters(params);
    }
    ,showCompleteCart: function(action){
        this.cart.showCompleteCart(action);
    }
    ,getCart: function(){    
        return this.cart;
    }
    ,getLogin: function(){    
        return this.login;
    }
    ,getPayment: function(){    
        return this.payment;
    }        
    ,showProductDetail: function(){                                         
       
       if($('main_content_detail')){ 
            $('main_content_detail').remove();
       }       
       
        if($('filters'))
            $('filters').hide();
         
        if($('module-resultaat.resultaat'))
            $('module-resultaat.resultaat').hide();
        
        if($('module-resultaat.detail')){

            if($('module-resultaat')){
            
                if(this.product_detail_fullscreen){

                        $('module-resultaat.detail').absolutize(); 
                        $('module-resultaat.detail').style.zIndex = "4999";
                        $('module-resultaat.detail').style.background = "#000000 none repeat scroll 0 0";            
                        $('module-resultaat.detail').clonePosition($('document_body'),{setHeight:false});
                        
                        
                        $('module-resultaat.detail').height = document.viewport.getHeight() + "px";
                        
                }
                else{            
            
            
            
                    if(Prototype.Browser.IE8){
                        el = $('module-resultaat').up('div');
                        $('module-resultaat.detail').style.zIndex = "4999";

                        $('module-resultaat.detail').style.marginTop = "0px";
                        
                        $('module-resultaat.detail').clonePosition(el,{setHeight:false});                    
                    }
                    else{
                    
                        el = $('module-resultaat').up('div');
                 
                        $('module-resultaat.detail').style.zIndex = "4999";

                        $('module-resultaat.detail').style.marginTop = "0px";
                        
                        $('module-resultaat.detail').clonePosition(el,{setHeight:false});
                    }                    
                    
                }
            }            
            $('module-resultaat.detail').show();
            scroll(0,0); 
        }
    }
    ,showProductSearch: function(){

       if($('main_content_detail')){ 
            $('main_content_detail').remove();
       }    
    
        if($('product-details') ){
            if($('product-details') != "undefined" )
                $('product-details').hide();                                                     
        }
    
        if($('filters') ){ 
            $('filters').show();                                                    
        }    
    
        if($('module-resultaat.detail'))
            $('module-resultaat.detail').hide();                                                                                                    
    
        if($('module-resultaat.resultaat'))
            $('module-resultaat.resultaat').show();
    
        scroll(0,0);  
    }
    ,closeProductDetail: function(){
        this.showProductSearch();   
    }
    ,toggleCategory: function(category){
    	opened_el = null;
        $$('div.shop_category_box').each(function(el){
            
            if(el.visible())
                opened_el = el;
        });
    
    
        if(opened_el != null && opened_el.identify() == 'shop_cat_'+category){
            
            new Effect.Move('shop_category_list_0', { x: 200, y: 0, mode: 'relative', duration: 0.5, beforeStart: function(){ 
                $('shop_cat_'+category).hide();                                                                               
                $('shop_category_list_0').show();  
                }
             });    

        }
        else{
            
            new Effect.Move('shop_category_list_0', { x: -200, y: 0, mode: 'relative', duration: 0.5, afterFinish: function(){
                
                $('shop_category_list_0').hide();  
                $('shop_cat_'+category).show();
                
               
                 }  
            });
        }

        return false;
    }      
    ,updateCategory: function(catid){
        if($('module-resultaat.resultaat')){ 
            if(catid == "")
                catid = 0;
            
            if($('module-resultaat.resultaat')){                                     
                this.updateCategoryForElement(catid,'gallery','module-resultaat.resultaat');   
            }

            this.closeProductDetail();   
        
            return false;              

        }
        return true;         
    }
    ,updateCategoryForElement: function(catid,action,elementId){

    
        if(action == 'gallery'){

            if($('f_category_id_'+catid).hasClassName('filter_active')){
                $('f_category_id_'+catid).removeClassName('filter_active');
                
                var parent = $('f_category_id_'+catid).up('.shop_category_list');
                if(parent){
                    parent_el = $('f_'+parent.id);
                    
                    if(parent_el){
                        parent_el.removeClassName('filter_parent_active');
                    }
                }   
                                
                catid = '';
            }
            else{
        
                $$('.shop_category_list a.filter_active').each(function(el){
                    el.removeClassName('filter_active');
                });
                
                $$('.shop_category_list a.filter_parent_active').each(function(el){
                    el.removeClassName('filter_parent_active');
                });                
        
                $('f_category_id_'+catid).addClassName('filter_active');  
             
             
                var parent = $('f_category_id_'+catid).up('.shop_category_list');
                if(parent){
                    parent_el = $('f_'+parent.id);
                    if(parent_el){
                        parent_el.addClassName('filter_parent_active');
                    }
                }   
                
                
            }
            
                params = {
                            action:action,
                            catid:catid,
                            nav_page: 1,    
                            sid:Math.random(),
                            column:'',
                            direction:''
                         };           

      
                this.request.addParameters(
                    params
                );

                $(elementId).ajaxUpdate(
                    this.url,
                    {
                      method: 'get',
				  	  evalJS: true,
				  	  evalScripts: true,					  
                      parameters: this.request.getQueryString(),  
                      onComplete: function(){
                      
                      
                    
                        var container_id = $('f_category_id_'+catid).up('.shop_filters_sub_container').previous(0).id;
                        $$('div.shop_filters_container .shop_filters_sub_title').each(function(el){
                
                            
                            if(el.id != container_id){
                                new Effect.Pulsate(el, { pulses: 2, duration: 1, beforeStart:function(){
                                    el.style.backgroundColor = '#E19400';
                                    el.style.color = '#FFFFFF';
                                },
                                afterFinish:function(){
                                    
                                    new Effect.Highlight(el, {  startcolor: "#E19400", endcolor: "#FFFFFF", duration: 2,
                                        afterFinish:function(){
                                            el.style.backgroundColor = '#FFFFFF';
                                            el.style.color = '#E19400';                                        
                                        }
                                     });  
                 
                                }
                                }); 
                            }
                        });                     
                    
                 
                      
                        Lightview.updateViews();  
                      }
                    }    
                );                
  
        
        
        }
        else{
            var params=$H(
            {
                catid:catid,
                action:action,
                sid:Math.random()
            }
            ).toQueryString();

            this.req_parameters = params; 
            
            $(elementId).ajaxUpdate(
                this.url,
                {
                  method: 'get',
 				  evalJS: true,
				  evalScripts: true,					  
                  parameters: params,
                  onComplete: function(){
                  
                    Lightview.updateViews();  
                  }
                }    
            );
            
        }
    }    
    ,productDetails: function(artikelCode){
    
        return this.productDetail(artikelCode,'',0,0);
    }
    ,productDetail: function(artikelCode,parentArtikelCode,sub,backfromsub){
    
        if($('module-resultaat.detail')){   
            this.showProductDetail();    
            
            var params=$H(
                {
                    action:'details',
                    artikelCode : artikelCode,
                    parentArtikelCode : parentArtikelCode, 
                    sub: sub,
                    backfromsub: backfromsub,
                    sid:Math.random()                                      
                }
            ).toQueryString();
        
            $('module-resultaat.detail').ajaxUpdate(
                this.url,			
                {
                    method: 'get',
					evalJS: true,
					evalScripts: true,						
                    parameters: params,
                    onComplete:function(req){ 
                        Lightview.updateViews()
                        //getProductPrice(req.request.parameters.artikelCode);
                    }
                }    
            );     
        
        return false;    
        } 

        return true;
    }
    ,removeSearch: function(){
            this.request.setParameters(
                {
                    action:'search',
                    searchTerms : '',
                    sid:Math.random()                                      
                }            
            );

            $('module-resultaat.resultaat').ajaxUpdate(
                this.url,
                {
                    method: 'get',
				  	evalJS: true,
				  	evalScripts: true,						
                    parameters: this.request.getQueryString(),
                    onComplete:function(){ 
                        Lightview.updateViews();    
                        $$('.shop_search_list a').each(function(el){
                          el.remove();
                        });
                        $('shop_filters_search_title').hide();
                    }
                }    
            );             
            
    
    }   
    ,searchProducts: function(clean,general){

        this.showProductSearch();
        
        if(general){
            searchTerms = $F('general_searchterms');
            if($('general_exact'))
                exact = $F('general_exact');  
            else
                exact = 0;        
        }
        else{
            searchTerms = $F('searchterms');
            if($('exact'))
                exact = $F('exact');  
            else
                exact = 0;
        }

    
        if(clean){
            this.request.setParameters(
                {
                    action:'search',
                    searchTerms : searchTerms,
                    exact: exact, 
                    sid:Math.random()                                      
                }            
            );
            

        }
        else{
            this.request.setParameters(
                {
                    action:'search',
                    searchTerms : searchTerms,
                    exact: exact, 
                    sid:Math.random()                                      
                }            
            );
        }
        
        this.request.removeAllFilters();
        
        $('module-resultaat.resultaat').ajaxUpdate(
            this.url,
            {
                method: 'get',
				evalJS: true,
				evalScripts: true,				
                parameters:  this.request.getQueryString(),
                onComplete:function(){ 
                    Lightview.updateViews();    
                    $('shop_filters_search_title').show();
                    $$('.shop_filters_container a.filter_active').each(function(el){
                        el.removeClassName('filter_active');
                    });
                    
                    $$('.shop_filters_container a.filter_parent_active').each(function(el){
                        el.removeClassName('filter_parent_active');
                    });     

                    var a = new Element("a", { href : '#', 'class' : 'filter_active'}).update(searchTerms);
                    a.observe("click", function(el){
                       shop.removeSearch();
                       return false;
                    });
                    
                    $$('.shop_search_list li').each(function(el){
                        el.update(a);
                    });
                    
                    
                }
            }    
        );       
    }
    ,updateProductListPage: function(page){

        this.showProductSearch();

        params = {
                    action:'navigate',
                    nav_page:page,  
                    sid:Math.random()
                 };           

        this.request.addParameters(
            params
        );

        $('module-resultaat.resultaat').ajaxUpdate(
            this.url,
            {
              method: 'get',
			  evalJS: true,
			  evalScripts: true,				  
              parameters: this.request.getQueryString(),
              onComplete: function(){
                Lightview.updateViews();  
              }
            }    
        );      
    }

    ,switchPersonal: function(){


        if($('user_choice_subscribe').visible()){
        
            $('user_choice_login').show();
            $('user_choice_subscribe').hide();
            $('tabs_tab_subscribe').removeClassName('active');
            $('tabs_tab_login').addClassName('active');        
            
            valid = new Validation('form_login', {immediate : true, onFormValidate : formCallback,useTitles:true});          
        }
        else if($('user_choice_login').visible()){
        
            $('user_choice_subscribe').show();
            $('user_choice_login').hide();
            $('tabs_tab_subscribe').addClassName('active');
            $('tabs_tab_login').removeClassName('active');
            
            valid = new Validation('form_user', {immediate : true, onFormValidate : formCallback,useTitles:true});          
                Validation.addAllThese([
                        ['validate-url', 'Een correcte adres invullen a.u.b.', function (v) {
                            return Validation.get('IsEmpty').test(v) || v == "http://" || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
                        }],            
                        ['validate-postcode', 'Postcode is niet correct', function (v,elm) {

                            return Validation.get('IsEmpty').test(v) ||  /^[\d]{4,4}\s{0,1}[a-zA-Z]{2,2}$/.test(v) 
                        }]
                    ]);                             
        }
    }
    ,checkout_login: function(button){
        valid = new Validation('form_login', {immediate : true, onFormValidate : formCallback,useTitles:true});          
        
        button.disabled = true; 
        if(!valid.validate()){
            button.disabled = false;
        }
        return false;        
        
    }
    ,checkout_subscribe: function(button){
        valid = new Validation('form_user', {immediate : true, onFormValidate : formCallback,useTitles:true});          
            Validation.addAllThese([
                    ['validate-url', 'Een correcte adres invullen a.u.b.', function (v) {
                        return Validation.get('IsEmpty').test(v) || v == "http://" || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
                    }],            
                    ['validate-postcode', 'Postcode is niet correct', function (v,elm) {

                        return Validation.get('IsEmpty').test(v) ||  /^[\d]{4,4}\s{0,1}[a-zA-Z]{2,2}$/.test(v) 
                    }]
                ]);                                 
        button.disabled = true; 
        if(!valid.validate()){
            button.disabled = false;
        }
        return false;                        
    }
    ,removeFilter: function(key,value){

        this.showProductSearch();
        
        if(value == ''){
            $$("#"+key+" a.filter_active").each(function(el){
                el.removeClassName('filter_active')
            });
        }
        else{
            $(key+'_'+value).removeClassName('filter_active');
        }

        params = {
                    action:'removefilter', 
                    nav_page: 1,    
                    sid:Math.random(),
                    column:'',
                    direction:''
                 };           
        
        if(value == ''){           
            this.request.removeFilters(key);
        }
        else{
            this.request.removeFilter(key,value);
        }

        this.request.addParameters(
            params
        );        

        $('module-resultaat.resultaat').ajaxUpdate(
            this.url,
            {
              method: 'get',
			  evalJS: true,
			  evalScripts: true,				  
              parameters: this.request.getQueryString(),
              onComplete: function(){
                Lightview.updateViews();  
              }
            }    
        );    
    }    
    ,addFilter: function(key,value){
   
        this.showProductSearch();
        
        var id= key +  '_' + value;
        
        
        
        if($(id).hasClassName('filter_active')){
           this.removeFilter(key,value);
        }
        else{
            $(id).addClassName('filter_active');  
            params = {
                        action:'addfilter',
                        nav_page: 1,    
                        sid:Math.random(),
                        column:'',
                        direction:''
                     };           
                     
            this.request.setFilter(key,value);
        
            
            this.request.addParameters(
                params
            );

            $('module-resultaat.resultaat').ajaxUpdate(
                this.url,
                {
                  method: 'get',
				  evalJS: true,
				  evalScripts: true,					  
                  parameters: this.request.getQueryString(),
                  onComplete: function(){
                    Lightview.updateViews(); 

                     
                  }
                }    
            );    
        }
   }
   ,showLargeImage: function(source_el){

       var el = $('img_groot_replace');
       $('img_groot').hide();
       
       if(el){
            el.src = (source_el.src.replace(/.thumb.png/, ""));
            el.show();
            
       }
        
   }
   ,hideLargeImage: function(){
       $('img_groot').show();
       if($('img_groot_replace')){
            $('img_groot_replace').hide();
       }
   },
   tellFriend: function(id){
        
            if($('window_tellfriend')){
                 //$(this.advert_page_detail_id).update(transport.responseText);
                $('window_tellfriend').show(); 
                clone_container = $('window_tellfriend');
            }
            else{
                var clone_container = new Element('div', {'id' : 'window_tellfriend','class' : 'window_tellfriend'});
                Element.extend(clone_container);
                clone_container.innerHTML = '';
                $('module-resultaat.detail').up(0).appendChild(clone_container);
                //clone_container.absolutize();
                //var height = $(this.advert_page_id).getHeight();
                
                clone_container.clonePosition('module-resultaat.detail');
            }           
            
            var params=$H(
            {
                action  :'form',
                id      :id,
                sid:Math.random()
            }
            ).toQueryString();
             

            clone_container.ajaxUpdate(
                 SHOP_BASE_REL+'front/server_tellfriend.php',
                {
                  method: 'get',
                  parameters: params,
                  onComplete: function(transport){

                    if($('form_tellfriend')){   
                        this.valid = new Validation('form_tellfriend', {immediate : true, onFormValidate : this.formCallBackTellFriend.bind(this),useTitles:true});                                    
                    }                  
                  
                  
                  }.bind(this) 
                       
                }
                
            );              
            
            
            scroll(0,0);
            
        
   
   },
   formCallBackTellFriend: function(result, form){   
        form_status = result;

        if (form_status){
           $(form).request({  
           
                onComplete: function(transport){   
                    var json = transport.responseText.evalJSON();
                        
                    if(json.success){    
                        alert(json.message);
                        this.tellFriendClose();
                    }
                    else{
                        alert(json.message);
                    }                
                }.bind(this),
                onException: function(){
               
                },
                onFailure: function(){
  
                }
           
           });
        }   
   
   },
   tellFriendClose: function(){

                                                             
            if($('window_tellfriend')){
                $('window_tellfriend').hide();                                                    
            } 
   
   },
   getStock: function(items,detail){
   	

        var params=$H(
        {
            action:'stock',
			items:items,                                       
            sid:Math.random()                                      
        }
        ).toQueryString();
			  
		var d = '';
		if(detail){
			d = 'detail_' 
		}  
	
		var found = false;
		if(detail && this.stock){
			
			var stock = 0;
			var item;
			for(i=0;i < this.stock.length;i++){     				
 				 item = this.stock[i];

				 if(items == item.id){			 	
				 	found = true;
					stock = item.stock;
					id = item.id;
				 }
			}
			
			if(found){

				if(stock<12){
					$('stock_' + d + id).update('Niet voorradig');
					$('product_ct_buy_'+ d+id).hide();
					if(detail){
						$('number_control').hide();
					}
					
				}
				else{
					$('stock_' + d + id).update('');
				}
			}
			
		}
		if (!found) {
			request = new Ajax.Request(SHOP_BASE_REL + 'front/stock.php', {
				method: 'post',
				parameters: params,
				onComplete: function(transport){
				
					var json = transport.responseText.evalJSON();
					$$('div.stock').each(function(el){
						el.update('');
					});					
					if (json.success && json.total > 0) {
										
						for (i = 0; i < json.total; i++) {
							var data = json.results[i];
							this.stock[i] = data;
							
							if (data.stock < 12) {
						
	
								$('stock_' + d + data.id).update('Niet voorradig');
				
								$('product_ct_buy_' + d + data.id).hide();
	
								if (detail) {
									$('number_control').hide();
								}
								
							}
							else {
							
								$('stock_' + d + data.id).update('');
								
							}
						}
					}
					else {
						this.stock = new Array();
					}
				}
				.bind(this)
			});
		}
   }  
});

var PPage = Class.create({
    
    initialize: function() {   
        this.url = SHOP_BASE_REL+'front/server_ppage.php'; 
    }
    ,changeValidation: function(val){
 
        valid.reset();
        switch(val){
            case 'DE':
                    $('company_btwnummer').removeClassName('required');
                    break;        
            case 'NL':
                    $('company_btwnummer').addClassName('required');
                    break;
            case 'BE':
                    $('company_btwnummer').removeClassName('required');
                    break;        
        }
    }
    ,sameCheckValue: function(){

        var boxStatus;
        boxStatus = eval($('place1').checked);
        if(boxStatus == true){
            if ($('user_infix') && $F('user_infix')) {
				$('user_delivery_name').value = $F('user_firstname') + ' ' + $F('user_infix') + ' ' + $F('user_lastname');
			}
			else {
				$('user_delivery_name').value = $F('user_firstname') + ' ' + $F('user_lastname');
			}
				
				
            $('user_delivery_address').value 		= $F('user_address'); 
            //$('user_delivery_housenumber').value = $F('user_housenumber');      
            $('user_delivery_zipcode').value 		= $F('user_zipcode');    
            $('user_delivery_city').value 			= $F('user_city');      
        }
    }            
    ,submitResultaat: function(form,action){

        $(form).request({
            onComplete: function(req){ 
                    //if(dialogCounter == 1) 
                        //hideProcessing(); 
                        
                    $('module-resultaat.resultaat').innerHTML = req.responseText; 
                   
                        if($('form_ppage_user')){
                            valid = new Validation('form_ppage_user', {immediate : true, onFormValidate : formCallback,useTitles:true});
                        } 
            }
        });    
    
        return false;
    }     
    ,updateResultaatDeleteId: function(action,id){

        if (confirm('Gebruiker verwijderen?')){      
            var params=$H(
            {
                action:action,
                res_id:id,
                sid:Math.random() 
                
            }
            ).toQueryString();

            $('module-resultaat.resultaat').ajaxUpdate(
                this.url,
                {
                  method: 'get',
                  parameters: params,
                  onComplete: function(){
                        
                        if($('form_ppage_user')){
                            valid = new Validation('form_ppage_user', {immediate : true, onFormValidate : formCallback,useTitles:true});
                        } 
                                               
                  }
                  
                }    
            );  
        }
    }
    ,updateResultaatId: function(action,id){

        var params=$H(
        {
            action:action,
            res_id:id,
            sid:Math.random() 
            
        }
        ).toQueryString();

        $('module-resultaat.resultaat').ajaxUpdate(
            this.url,
            {
              method: 'get',
              parameters: params,
              onComplete: function(){
                    
                        if($('form_ppage_user')){
                            valid = new Validation('form_ppage_user', {immediate : true, onFormValidate : formCallback,useTitles:true});
                        }                      
              }
              
            }    
        );  
    }
    ,updateResultaat: function(action){

        if(typeof $('module-resultaat.resultaat') == "undefined" ){
            return true;
        }
        else{

            if($('locatie-informatie'))
                $('locatie-informatie').innerHTML = '<a href=\'index.php?page=70&id=65\'>Vojacek</a><span id="module-resultaat.breadcrumb" style="margin: 0px; padding: 0px; float: left;"></span>'; 
            
            if($('module-resultaat.breadcrumb'))
                $('module-resultaat.breadcrumb').hide();

            var params=$H(
            {
                action:action,
                sid:Math.random() 
                
            }
            ).toQueryString();

            $('module-resultaat.resultaat').ajaxUpdate(
                this.url,
                {
                  method: 'get',
                  parameters: params,
                  onComplete: function(){
                        if($('form_ppage_user')){
                            valid = new Validation('form_ppage_user', {immediate : true, onFormValidate : formCallback,useTitles:true});
                        }                                    
                        
                    
                    if($('module-resultaat.resultaat')){      
                        if(Prototype.Browser.IE8){
                            el = $('module-resultaat').up('div');
                            $('module-resultaat.detail').style.zIndex = "4999";
                            $('module-resultaat.detail').style.background = "#ffffff";
                            $('module-resultaat.detail').style.marginTop = "0px";
                            
                            $('module-resultaat.detail').clonePosition(el);                    
                        }
                        else{
                        
                            el = $('module-resultaat').up('div');
                            $('module-resultaat.detail').absolutize();
                            $('module-resultaat.detail').style.zIndex = "4999";
                            $('module-resultaat.detail').style.background = "#ffffff";
                            $('module-resultaat.detail').style.marginTop = "0px";
                            
                            $('module-resultaat.detail').clonePosition(el);
                        }                           
                    }                           
                  }
                }    
            );  
            return false;
       }
    }
});


var shop = new Shop(); 
var ppage = new PPage();


//ProtoHistoryManager.start();


function checkNumber(elId,afname){
    v = $F(elId);
    
    if(isNaN(v) || /^\s+$/.test(v)){
       $(elId).value = afname;
    }
    else{
        if(v == 0){
            $(elId).value = afname;
            v = afname;
        }
            
        if((v % afname) > 0){
           alert('Minimale afname is ' + afname + '. U kunt alleen hier meervouden van kiezen.');
           $(elId).value = afname;
        }
    }
}

function addQuantity(elId,afname){
    $(elId).value = parseInt($F(elId)) + afname;
    
    checkNumber(elId,afname);
}

function removeQuantity(elId,afname){
    
    
    temp = parseInt($F(elId)) - afname;
    if(temp < afname)
        $(elId).value = afname;
    else
        $(elId).value = temp;
    
    checkNumber(elId,afname);
}

Event.observe(document.onresize ? document : window, "resize", function() {
	
	
	
	
		var height = parseInt(document.viewport.getHeight()) - 80;
		var width = parseInt(document.viewport.getWidth()) - 80;

		Lightview.resize({ width: width, height: height });
		$$('.lv_contentTop')[0].setStyle({'width':(width-4)+'px', 'height':(height-4)+'px'});
		
	
}); 

function resize(){

	return;
    if($('lightview')){                     
   
       // $('lightview').style.marginTop = '0px';
        //$('lightview').scrollTop = '0px';
    
        height = $('lightview').getHeight(); 
        width  = $('lightview').getWidth(); 
        $$('.lv_contentTop')[0].setStyle({'width':width+'px', 'height':height+'px'});
        
        
        //resize winkelmandje
        if($('winkelmandje-overzicht')){
 
            if(Prototype.Browser.IE)    
                $('winkelmandje-overzicht').setStyle({'width':width-18+'px','height':(height*0.45)-5+'px'});          
            else
                $('winkelmandje-overzicht').setStyle({'width':width-25+'px','height':(height*0.45)-5+'px'});          
        }     
        
        //resize subscription form
        
        if($('checkout-subscribe.content')){   
            subscribe_height = ((height*0.8)-5);
            if(Prototype.Browser.IE)    
                    $('checkout-subscribe.content').setStyle({'overflow':'hidden','width':width-15+'px', 'height':subscribe_height+'px'});  
            else
                    $('checkout-subscribe.content').setStyle({'overflow':'hidden','width':width-15+'px', 'height':subscribe_height+'px'});  
        }
        
        if($('subscription_wrapper')){
           
           if($('checkout-subscribe.content')){
                
                if($('button_checkout_subscribe')){       
                    subscribe_height = ($('checkout-subscribe.content').getHeight() - 20); 
                }
                else{
                    subscribe_height = $('checkout-subscribe.content').getHeight(); 
                }
                    
                if($('user_choice_login'))
                    subscribe_width  = ($('checkout-subscribe.content').getWidth()*0.6);            
                else    
                    subscribe_width  = ($('checkout-subscribe.content').getWidth()*0.98);            
                if(Prototype.Browser.IE){
                    $('subscription_wrapper').setStyle({'overflow':'hidden','width':subscribe_width+'px','height':(subscribe_height-10)+'px'});          
                    $('subscription_content').setStyle({'overflow':'auto','width':$('subscription_wrapper').style.width+'px','height':$('subscription_wrapper').style.height+'px'});          
                }
                else{
                    $('subscription_wrapper').setStyle({'overflow':'hidden','width':subscribe_width+'px','height':(subscribe_height-10)+'px'});                    
                    $('subscription_content').setStyle({'overflow':'auto','width':$('subscription_wrapper').style.width+'px','height':($('subscription_wrapper').style.height-15)+'px'});          
                }         
                scroll(0,0);   
           }
           else{
            if(Prototype.Browser.IE){
                $('subscription_wrapper').setStyle({'overflow':'auto','width':width-18+'px','height':(height*0.80)-5+'px'});          
                $('subscription_content').setStyle({'overflow':'auto','width':$('subscription_wrapper').style.width+'px','height':$('subscription_wrapper').style.height+'px'});          
            }
            else{
                $('subscription_wrapper').setStyle({'overflow':'auto','width':width-25+'px','height':(height*0.80)-5+'px'});                  
                $('subscription_content').setStyle({'overflow':'auto','width':$('subscription_wrapper').style.width+'px','height':($('subscription_wrapper').style.height-15)+'px'});          
            }
            
           }
        }   
    }

}


function trigger(name){

    var element=$('subcat_'+name);
    var hrefElement = $('href_'+name);

    if(trim(hrefElement.innerHTML) == "+"){
        hrefElement.innerHTML = "-";
        element.style.display='block';
    }
    else{
        hrefElement.innerHTML = "+";
        element.style.display='none';
    }
}


function submitForm(form,action){


    //dialogCounter = 0;
    //showProcessing();

        
    if(form ==  'form_checkout' || form ==  'form_login' || form ==  'form_user')
        shop.getCart().checkout_confirm_form(form,action);
    else 
        ppage.submitResultaat(form,action);
}

function formCallback(result, form) 
{   form_status =  result;
   /* include the ajax httprequest here */
   
  
   
    if (form_status){
        //submitFormAfterValidate_project(form.id,0);

        if(form.id ==  'form_checkout' || form.id ==  'form_login' || form.id ==  'form_user') 
            submitForm(form.id,$F('step'));
        else
            submitForm(form.id,$F('action'));
    }
}   

document.observe('lightview:opened', function(event) {
    

    if(!event.target.href){  
		
		var body = document.body;
		body = $(body); 		
		body.down('div.website').hide();

        /*resize();
        Event.observe(window, "resize", function() {   
            resize(); 
        });*/  
    }


});

document.observe('lightview:hidden', function(event) {
  if(!event.target.href){
  
		var body = document.body;
		body = $(body); 		
		body.down('div.website').show();  
  
    if($('header_cart'))
        shop.getCart().refreshCart('header_cart');   
                                
    if($('order_list_overview') != null ){ 
       ppage.updateResultaat('order_list_overview'); 
    }  
  }
});


/*window.dhtmlHistory.create({
    toJSON: function(o) { return Object.toJSON(o); },
    fromJSON: function(s) { return s.evalJSON(); } 
});

var  = function(newLocation, historyData) {
    
    var historyMsg = (typeof historyData == "object" && historyData != null ? historyStorage.toJSON(historyData) : historyData);

    var msg = "A history change has occured:\n oldLocation=" + oldLocation + "\n historyData=" + historyMsg ;

    // myRestorePage(oldLocation, historyData)

    alert(msg); 
} */



/*var load = function(newLocation, historyData) {
    alert(newLocation);
    var historyMsg = (typeof historyData == "object" && historyData != null ? historyStorage.toJSON(historyData) : historyData);

    var msg = "A history change has occured:\n oldLocation=" + oldLocation + "\n historyData=" + historyMsg ;

    // myRestorePage(oldLocation, historyData)

    alert(msg)
     
  new Ajax.Updater('main', newLocation, { method: 'get', evalScripts: true }); 
  dhtmlHistory.add(newLocation); 
  return false; 
 };*/

//load = function(page) {
  //new Ajax.Updater('main', page, { method: 'get', evalScripts: true }); 
  //dhtmlHistory.add(page); return false; 
 //};

  
