function initHyperlinks() {
    $("a[rel=external]").each(function() {
        $(this).click(function() { window.open($(this).attr("href")); return false; });
        if ($(this).attr("title") == "") $(this).attr("title", "Deze link wordt in een nieuw venster geopend.")
        else $(this).attr("title", "'" + $(this).attr("title") + "' wordt in een nieuw venster geopend.");
    });
}


function initMainMenu() {

    var el = document.getElementById("nav");

    if (el) {
        sfHover = function() {
            var sfEls = document.getElementById("nav").getElementsByTagName("LI");
            for (var i = 0; i < sfEls.length; i++) {
                sfEls[i].onmouseover = function() {
                    this.className += " sfhover";
                }
                sfEls[i].onmouseout = function() {
                    this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
                }
            }
        }

        if (window.attachEvent) window.attachEvent("onload", sfHover);
    }
}


function initForm() {
    $('#frmContact').validate();
    $('#frmZoek').validate();
}


function initToolTips() {

    if ($("#gebouwen a").length > 0) {
        $("#gebouwen a").tooltip({
            position: "top right",
            offset: [40, -40],
            effect: "fade"
        });
    }

    if ($("#overzicht_architecten a").length > 0) {
        $("#overzicht_architecten a").tooltip({
            position: "top right",
            offset: [5, -65],
            effect: "fade"
        });
    }

    if ($(".overzicht a").length > 0) {
        $(".overzicht a").tooltip({
            position: "top right",
            offset: [40, -40],
            effect: "fade"
        });
    }

    if ($(".gerelateerde a").length > 0) {
        $(".gerelateerde a").tooltip({
            position: "top right",
            offset: [-40, -40],
            effect: "fade"
        });
    }
}

function initScroller() {

	if ($("div.scrollable").length > 0) {
		/*var root = $("div.scrollable").scrollable({ size: 3, vertical: true, speed: 3000 })
			.circular().navigator().mousewheel().autoscroll();
*/
		//var root = $("div.scrollable").scrollable({ easing: 'linear', circular: true, vertical: true, speed: 1000}).autoscroll({ autoplay: true });
		

		// setup api
		//window.api = root.scrollable();

	}


}



$(document).ready(function() {

	var locatie = window.location + '';


	if (locatie.substr(-6) === "thumbs") {
		$('.weergave a.thumb').addClass('active');
	} else if (locatie.substr(-4) === "list") {
		$('.weergave a.lijst').addClass('active');
	};

	var items = 0;

	$('.paging li').each(function() {
		items = items + 1;

	});
	if (items == 1) {
		$('.paging').hide();
	} else {

	}
	// hover fix ie6
	if ($.browser.msie) {
		$('#zoeken form input.submit').hover(function() {
			$(this).css('color', '#fff');
			$(this).css('cursor', 'pointer');
		},
	function() {
		$(this).css('color', '#939393');
	});
	}
	if ($.browser.msie) {
		$('#formcontact  input.submit').hover(function() {
			$(this).css('color', '#fff');
			$(this).css('cursor', 'pointer');
		},
	    function() {
	    	$(this).css('color', '#939393');
	    });
	}
	// einde hover fix IE6
	initHyperlinks();
	initMainMenu();
	initForm();
	initToolTips();
	initScroller();
	$.fn.nyroModal.settings.regexImg = '[^\.]\.(jpg|jpeg|png|tiff|gif|bmp)\s*$|image.aspx';
	$.fn.nyroModal.settings.setWidthImgTitle = false;
	$.fn.nyroModal.settings.title = 'titel';
	$.fn.nyroModal.settings.processHandler = function(settings) {
		var url = settings.url;
		if (url && url.indexOf('http://www.youtube.com/watch?v=') == 0) {
			$.nyroModalSettings({
				type: 'swf',
				height: 355,
				width: 425,
				url: url
			});
		}
	};
	//



	var siebe = '';

	if ($('.scrollable .items').length > 0) {
		siebe = $('.scrollable .items').html().replace(/<br>/g, '<br />').replace(/alt=\"\">/g, 'alt="" />');
	}
	siebe = '<data>' + siebe + '</data>';

	$('#flash').flashembed({
		src: '/lib/flash/architect-scroller.swf'
		, bgcolor: '#000'
		, wmode: 'transparent'
	}, {
		//baseXML: escape(siebe)
		baseXML: '/lib/xml/teams.ashx'
	});
	$('.publicaties .paragraph').addClass('uitklapTxt');
	$('.publicaties .paragraph').addClass('NotCurent');
	$('.publicaties .paragraph:first').removeClass('uitklapTxt');
	$('.uitklapTxt').find('.text').hide();
	$('.uitklapTxt').find('h3').css('cursor', 'pointer');

	$('.uitklapTxt').find('h3').hover(function() {
		$(this).css('text-decoration', 'underline');
	}, function() {
		$(this).css('text-decoration', 'none');
	});

	$('.uitklapTxt').find('h3').click(function() {
		$(this).parent().find('.text').slideToggle();
	});



});
