
//window.onerror = function(desc, page, line, chr) {
//    /* alert('JavaScript error occurred! \n'
//    +'\nError description: \t'+desc
//    +'\nPage address:      \t'+page
//    +'\nLine number:       \t'+line
//    );*/
//}

//$(function() {
//    $('a').focus(function() { this.blur(); });
//    SI.Files.stylizeAll();
//    slider.init();

//    $('input.text-default').each(function() {
//        $(this).attr('default', $(this).val());
//    }).focus(function() {
//        if ($(this).val() == $(this).attr('default'))
//            $(this).val('');
//    }).blur(function() {
//        if ($(this).val() == '')
//            $(this).val($(this).attr('default'));
//    });

//    $('input.text,textarea.text').focus(function() {
//        $(this).addClass('textfocus');
//    }).blur(function() {
//        $(this).removeClass('textfocus');
//    });

//    var popopenobj = 0, popopenaobj = null;
//    $('a.popup').click(function() {
//        var pid = $(this).attr('rel').split('|')[0], _os = parseInt($(this).attr('rel').split('|')[1]);
//        var pobj = $('#' + pid);
//        if (!pobj.length)
//            return false;
//        if (typeof popopenobj == 'object' && popopenobj.attr('id') != pid) {
//            popopenobj.hide(50);
//            $(popopenaobj).parent().removeClass(popopenobj.attr('id').split('-')[1] + '-open');
//            popopenobj = null;
//        }
//        return false;
//    });
//    $('p.images img').click(function() {
//        var newbg = $(this).attr('src').split('bg/bg')[1].split('-thumb')[0];
//        $(document.body).css('backgroundImage', 'url(' + _siteRoot + 'images/bg/bg' + newbg + '.jpg)');

//        $(this).parent().find('img').removeClass('on');
//        $(this).addClass('on');
//        return false;
//    });
//    $(window).load(function() {
//        $.each(css_ims, function() { (new Image()).src = _siteRoot + 'css/images/' + this; });
//        $.each(css_cims, function() {
//            var css_im = this;
//            $.each(['blue', 'purple', 'pink', 'red', 'grey', 'green', 'yellow', 'orange'], function() {
//                (new Image()).src = _siteRoot + 'css/' + this + '/' + css_im;
//            });
//        });
//    });
//    $('div.sc-large div.img:has(div.tml)').each(function() {
//        $('div.tml', this).hide();
//        $(this).append('<a href="#" class="tml_open">&nbsp;</a>').find('a').css({
//            left: parseInt($(this).offset().left) + 864, top: parseInt($(this).offset().top) + 1
//        }).click(function() {
//            $(this).siblings('div.tml').slideToggle();
//            return false;
//        }).focus(function() { this.blur(); });
//    });
//});
//var slider = {
//    num: -1,
//    cur: 0,
//    cr: [],
//    al: null,
//    at: 10 * 1000,
//    ar: true,
//    init: function() {
//        if (!slider.data || !slider.data.length)
//            return false;

//        var d = slider.data;
//        slider.num = d.length;
//        var pos = Math.floor(Math.random() * 1); //slider.num);
//        for (var i = 0; i < slider.num; i++) {
//            $('#' + d[i].id).css({ left: ((i - pos) * 1000) });
//            $('#slide-nav').append('<a id="slide-link-' + i + '" href="#" onclick="slider.slide(' + i + ');return false;" onfocus="this.blur();">' + (i + 1) + '</a>');
//        }

//        $('img,div#slide-controls', $('div#slide-holder')).fadeIn();
//        slider.text(d[pos]);
//        slider.on(pos);
//        slider.cur = pos;
//        window.setTimeout('slider.auto();', slider.at);
//    },
//    auto: function() {
//        if (!slider.ar)
//            return false;

//        var next = slider.cur + 1;
//        if (next >= slider.num) next = 0;
//        slider.slide(next);
//    },
//    slide: function(pos) {
//        if (pos < 0 || pos >= slider.num || pos == slider.cur)
//            return;

//        window.clearTimeout(slider.al);
//        slider.al = window.setTimeout('slider.auto();', slider.at);

//        var d = slider.data;
//        for (var i = 0; i < slider.num; i++)
//            $('#' + d[i].id).stop().animate({ left: ((i - pos) * 1000) }, 1000, 'swing');

//        slider.on(pos);
//        slider.text(d[pos]);
//        slider.cur = pos;
//    },
//    on: function(pos) {
//        $('#slide-nav a').removeClass('on');
//        $('#slide-nav a#slide-link-' + pos).addClass('on');
//    },
//    text: function(di) {
//        slider.cr['a'] = di.client;
//        slider.cr['b'] = di.desc;
//        slider.ticker('#slide-client span', di.client, 0, 'a');
//        slider.ticker('#slide-desc', di.desc, 0, 'b');
//    },
//    ticker: function(el, text, pos, unique) {
//        if (slider.cr[unique] != text)
//            return false;

//        ctext = text.substring(0, pos) + (pos % 2 ? '-' : '_');
//        $(el).html(ctext);

//        if (pos == text.length)
//            $(el).html(text);
//        else
//            window.setTimeout('slider.ticker("' + el + '","' + text + '",' + (pos + 1) + ',"' + unique + '");', 30);
//    }
//};
//// STYLING FILE INPUTS 1.0 | Shaun Inman <http://www.shauninman.com/> | 2007-09-07
//if (!window.SI) { var SI = {}; };
//SI.Files = {
//    htmlClass: 'SI-FILES-STYLIZED',
//    fileClass: 'file',
//    wrapClass: 'cabinet',

//    fini: false,
//    able: false,
//    init: function() {
//        this.fini = true;
//    },
//    stylize: function(elem) {
//        if (!this.fini) { this.init(); };
//        if (!this.able) { return; };

//        elem.parentNode.file = elem;
//        elem.parentNode.onmousemove = function(e) {
//            if (typeof e == 'undefined') e = window.event;
//            if (typeof e.pageY == 'undefined' && typeof e.clientX == 'number' && document.documentElement) {
//                e.pageX = e.clientX + document.documentElement.scrollLeft;
//                e.pageY = e.clientY + document.documentElement.scrollTop;
//            };
//            var ox = oy = 0;
//            var elem = this;
//            if (elem.offsetParent) {
//                ox = elem.offsetLeft;
//                oy = elem.offsetTop;
//                while (elem = elem.offsetParent) {
//                    ox += elem.offsetLeft;
//                    oy += elem.offsetTop;
//                };
//            };
//        };
//    },
//    stylizeAll: function() {
//        if (!this.fini) { this.init(); };
//        if (!this.able) { return; };
//    }
//};

function laadGoogleMaps(mapID, arrMarkers) {
    if (mapID != undefined) {
        $(function() {
            // init map
            $("#" + mapID).goMap({
                address: arrMarkers[0].adres,
                zoom: 15,
                scrollwheel: false,
                maptype: 'ROADMAP',
                icon: 'imgsite/marker.png' 
            });
            $("#" + mapID).resize();
            // plaatsen van markers
            var iAantalMarkers = arrMarkers.length;
            var i = 0;
            for (i = 0; i < iAantalMarkers; i++) {
                $.goMap.createMarker({
                    address: arrMarkers[i].adres
                });
            }
            // centreren van de markers
        });
    }
}

//function() {
//    var slider_area;
//    var slider_buttons;

//    // Which slider
//    if ($('#slider_area').length > 0) {

//        // Home Page Slider
//        slider_area = "#slider_area";
//        slider_buttons = "#numbers";


//        $(slider_area).cycle({
//            fx: 'fade',
//            timeout: 4000,
//            pager: slider_buttons,
//            cleartype: 1,
//            pagerAnchorBuilder: function(idx) {
//                return '<a href="#" title=""><img src="images/pixel.gif" width="14" heigth="14"></a>';
//            }
//        });
//    }

//}


//home page slider

$(document).ready(function() {
    var slider_area;
    var slider_buttons;

    // Which slider
    if ($('#slider_area').length > 0) {

        // Home Page Slider
        slider_area = "#slider_area";
        slider_buttons = "#numbers";


        $(slider_area).cycle({
            fx: 'fade',
            timeout: 11000,
            pager: slider_buttons,
            cleartype: 1,
            pagerAnchorBuilder: function(idx) {
                return '<a href="#" title=""><img src="images/pixel.gif" width="14" heigth="14"></a>';
            }
        });
    }

    // portfolio slider
    if ($('.portfolio_slides').length > 0) {

        slider_area = ".portfolio_slides";

        $(slider_area).cycle({
            fx: 'fade',
            timeout: 11000,
            prev: '.left',
            next: '.right'
        });

    }




});



//pretty photo
//	$(document).ready(function(){
//		$("a[rel^='prettyPhoto']").prettyPhoto();
//	});


//image effects 
$(document).ready(function() {
    var image_e = $(".image.portfolio, .image.product_image");
    image_e.mouseover(function() {
        $(this).stop().animate({ opacity: 0.6
        }, 400);
    }).mouseout(function() {
        image_e.stop().animate({
            opacity: 1
        }, 400);
    });
});

//validate contact form
//$(document).ready(function(){

//		// show a simple loading indicator
//		var loader = jQuery('<img src="images/loading.gif" alt="loading..." />')
//			.appendTo(".loading")
//			.hide();
//		jQuery().ajaxStart(function() {
//			loader.show();
//		}).ajaxStop(function() {
//			loader.hide();
//		}).ajaxError(function(a, b, e) {
//			throw e;
//		});
//		
//		jQuery.validator.messages.required = "";
//		var v = jQuery("#validate_form").validate({
//			submitHandler: function(form) {
//				jQuery(form).ajaxSubmit({
//					target: "#result"
//				});
//			}
//		});
//		
//		jQuery("#reset").click(function() {
//			v.resetForm();
//		});
// });


//preloading 
$(function() {
    //$('.preload').hide();//hide all the images on the page
    $('.play,.magnifier').css({ opacity: 0 });
    $('.preload').css({ opacity: 0 });
    $('.preload').addClass("animated");
    $('.play,.magnifier').addClass("animated_icon");
});


var i = 0; //initialize
var cint = 0; //Internet Explorer Fix
$(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
    var cint = setInterval("doThis(i)", 70); //500 is the fade in speed in milliseconds

});

function doThis() {
    var images = $('.preload').length; //count the number of images on the page
    if (i >= images) {// Loop the images
        clearInterval(cint); //When it reaches the last image the loop ends
    }
    //$('.preload:hidden').eq(i).fadeIn(500);//fades in the hidden images one by one
    $('.animated_icon').eq(0).animate({ opacity: 1 }, { "duration": 500 });
    $('.animated').eq(0).animate({ opacity: 1 }, { "duration": 500 });
    $('.animated').eq(0).removeClass("animated");
    $('.animated_icon').eq(0).removeClass("animated_icon");
    i++; //add 1 to the count
}

