function ma_naar2(n,d,c){
    nam= n + "@" + d;
    document.write("<\a href='mailto:" +nam +"'>" +c +"<\/a>");
}



function ma_naar(n,d,i){
    nam= n + "@" + d;
    document.write("<\a href='mailto:" +nam +"?"+i+"'>" +nam +"<\/a>");
}

/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


(function(){
    jQuery.fn.formValidation=function(config,filters,errors){
        var form=this;var a="";
        config=jQuery.extend({
            err_class:"f_errorinput",
            err_list:true,
            callback:"",
            mark:true,
            marksymbol:"*",
            frm:'',
            ps:'',
            display_alert:true

        },config);

        filters=jQuery.extend({
            email:{
                test:/^([\w.+%-])+\@(([\w-])+\.)[a-zA-Z0-9]{2,}/,
                mess:"Invalid e-mail"
            },
            domain:{
                test:/^(http:\/\/)([\w]+\.){1,}[A-Z]{2,4}\b/gi,
                mess:"Invalid domain"
            },
            phone:{
                test:/([0-9]){2,3}-([0-9]){5,8}$/,
                mess:"Invalid phone-number"
            },
            postcode:{
                test:/^[0-9]{4}[a-zA-Z]{2}$/gi,
                mess:"Not a zipcode"
            },
            zip:{
                test:/^[0-9]{4,}$/gi,
                mess:"Not a zipcode"
            },
            numeric:{
                test:/^[0-9]+$/gi,
                mess:"Not a number"
            },
            image:{
                test:/[\w]+\.(gif|jpg|bmp|png|jpeg)$/gi,
                mess:"No image file"
            },
            ewvt:{
                test:/[\w]+\.(htm|html|php|txt)$/gi,
                mess:"Invalid file"
            },
            media:{
                test:/[\w]+\.(avi|mov|mpeg|wmv)$/gi,
                mess:"No media-file"
            },
            pdf:{
                test:/[\w]+\.(pdf)$/gi,
                mess:"No pdf"
            },
                  required:{
                test:/[a-zA-Z0-9]+/,
                mess:"Required"
            }
            },filters);
            errors=jQuery.extend({
            error:"Red fields are required or invalid"
        },errors);

            url = form.attr('action')+config.frm+config.ps;
            if(config.mark){
            form.find(".required").prev().after(" <span> "+config.marksymbol+"</span>")
            }
            form.find(".required").blur(function(){e($(this))}).change(function(){e($(this))})

            form.submit(function(){

            config.enable=true;a="";frm=true;
                form.find(".required").filter("input, select, textarea").each(function(){
                e($(this))
                });
                $(".submit-message").remove();

                if(frm){
                wait = $("<img style='border:none;padding:20px;' src='images/loader1.gif'>")
                wait.insertAfter(form);
                form.hide('fast');

                $.post(url,
                $(this).serialize()
            ,
            function(data){
             if (data.status > 0){
                $(data.content).insertBefore(form).show('slow');
                $(form).parent().css('background-color','#75DF6F').animate( {backgroundColor:"#ffffff"}, 2000 );
                $(form).remove();
                wait.remove();
		try{
		pageTracker._trackPageview("/form_ok_"+location.href);
		}
		catch(err) {}
               }
            else {
                $(data.content).insertBefore(form).show('slow');
                $(form).parent().css('background-color','#FF3F3F').animate( {backgroundColor:"#ffffff"}, 2000 );
                 wait.remove();
                  $(form).show('slow');
		try{
		pageTracker._trackPageview("/form_error_"+location.href);
		}
		  catch(err) {}
            }
            }, "json");
            return false;
                }


             else if(config.display_alert&&!frm){
                               $("<div class='submit-message'><p>"+a+"</p></div>").insertAfter(form).show("slow");form.find('.check').addClass(config.err_class);
            }
            return frm

            })


            function e(h){


            h.parents().removeClass(config.err_class);


            if(h.is(":radio") || h.is(":checkbox")){
                if(!h.attr("checked")){
                    h.parent().addClass(config.err_class);a=errors.error;
                    frm=false;
                    return false
                    }
                }
                var g=h.attr("class");
                tests=g.split(" ");

                for(i=0;i<tests.length;i++){
                if(!filters[tests[i]]){
                    continue
                }
                regex=filters[tests[i]].test;if(regex){
                ret=regex.exec(h.val());
                 if(!ret){
                        h.parent().addClass(config.err_class);if(config.err_list){
                            a=errors.error
                            }
                            frm=false;
                            return false
                        }
                    }
                }return true
            }
        }
    })(jQuery);

$(document).ready(function(){
    $('.gallery').atYS_Gallery();

    $("#a_map").click(function(){
        return !$('#map').fadeOut('slow')
         
    })

    $("#a_map2").click(function(){
        $('#map').fadeIn()
        return !$('#map').fadeIn('slow')
    })


    $(".products img").click(function(){
        
        $('.pi').css('display','none')
        $('.pr').hide('');
        $('.d'+$(this).attr('class')).fadeIn();
        
    })
   

    $(window).resize(function(){
        var size = parseFloat((document.documentElement.clientHeight)-550)/2;
        if (size < 0) size = 0;
        if (document.documentElement.clientHeight < 500){
            $("body").css('overflow','scroll')
            }
        else{
            $("body").css('overflow','hidden')
            }
        $('#container').css('marginTop',size+"px");
    })

    var size = parseFloat((document.documentElement.clientHeight)-550)/2;
    if (size < 0) size = 0;
    $('#container').css('marginTop',size+"px");

    setTimeout('$(".t1").fadeIn(1000)',500);
    setTimeout('$(".t2").fadeIn(1000)',1000);


    setTimeout('$("#container1").fadeIn(2000)',200);
    setTimeout('$("#container2").fadeIn(1500)',1200);
 
 
    setTimeout('$("#front").animate({height: "100%"},4000)',1000);

    setTimeout('$(".f3").fadeIn(1000)',2500);




    $("#more").click(function(){
        $("#u_more").show();
        $(this).hide();
        return false;
    });

    $('.p_specs .button').click(function(){
        $('#orderdiv').show('slow');
       // alert('#r'+$(this).attr('id'))
        $('#r'+$(this).attr('id')).show().find('input').val(1).focus().select();
    })

    $('#orderform input').blur(function(){
        var amt = $(this).parents('tr').find('span').html()*$(this).val()
        $(this).parents('tr').find('strong').html(formatTo(amt,2));
        var total = 0;
        $(this).parents('tbody').find('strong').each(function(){
            var amt = parseFloat($(this).html());
            amt = (isNaN(amt)) ? 0 : amt;
            total +=  amt
        })

        $("#total").html(formatTo(total,2));
         var cart='';
         $(this).parents('tbody').find('input').each(function(){
             $(this).val()
         })
        $.cookie('cart','nl',{
            path:'/'
        });
   })
  
});


(function(){
    jQuery.fn.atYS_Gallery=function(config,options){
        var form=this;
        var a="";
        config=jQuery.extend({
            gallery_class:"gallery",
            speed:"3000",
            init_timeout:1000,
            start_img : 1,
            caption_animation : {opacity:1}

        },config);

        options=jQuery.extend({
            error:"Red fields are required or invalid"
        },options);

        var imgs = $("."+config.gallery_class+" img");
        imgs.css('zIndex', 0)
        var x = config.start_img - 1
        imgs.eq(x).css('zIndex',20)

        var tot = imgs.length-1;
        var y=x;
        var cap = $('#caption .content')
        cap.html( imgs.eq(x).attr('title'))
        imgs.css('visibility', 'visible')
      //  setTimeout(capslide2,2000)
        ;


        function capslide(){
            cap.animate({
                opacity:1,height:'20px'
            },1000).animate({
                opacity:1
            }, 2500 ).animate({
                opacity:0,height:0
            },1000)
        }

         function capslide2(){
            cap.animate({
                opacity:1
            },1000,function(){
                setTimeout(function(){cap.animate({
                opacity:0
            },1000)}, 2500)}

        )}

        function slide(){
        
            imgs.eq(y).css('zIndex',0).css('opacity',1)
            y=x
            imgs.eq(x).css('zIndex',20).animate({
                opacity: 0
            }, 2000)
            x = (x == (tot)) ? 0 : x+1;
            cap.html(imgs.eq(x).attr('title'))
            imgs.eq(x).css('zIndex',10)
          //  setTimeout(capslide2,2000)
       
            setTimeout(slide, 6000)
        }


        setTimeout(slide, 6000)
    }
})(jQuery);

 
function formatTo(base, precision)
{
  var a = roundTo(base, precision);
  var s = a.toString();
  var decimalIndex = s.indexOf(".");
  if (precision > 0 && decimalIndex < 0)
  {
    decimalIndex = s.length;
    s += '.';
  }
  while (decimalIndex + precision + 1 > s.length)
  {
    s += '0';
  }
  return s;
}
function roundTo(base, precision)
{
  var m = Math.pow(10, precision);
  var a = Math.round(base * m) / m;
  return a;
}

