var onMouseEl 				= false;
var searchElClicked		= false;


var	offsetX = pageWidth();
var	offsetY = pageHeight();



$(document).ready( function() {
	
if ($("a.hyveslinkimage_module").length)
{
	height = offsetY-120;
	
	$('a.hyveslinkimage_module').attr('href', $('a.hyveslinkimage_module').attr('href')+'&height='+height);
}
	
var oBannerStart 	= document.getElementById('banner-start');

	/* banner rotation */

	if(oBannerStart != null)
	{
		setInterval("nextBanner()", 5000);
	}
	/* end banner rotation */
	
	
//forms - no javascript button
	$('.no_javascript').hide();

	//forms - auto submit
	$(".auto_submit").change(function()
	{
		window.location = $(this).val();
	});
	
	//external window
	$('a[class^="external"]').click(function () {
		this.target = "_blank"
	});

	
	
	//popup window
	$('a[class="popup"]').click(function(){
		window.open(this.href,'Popup','height=580,width=400,scrollTo,resizable=0,scrollbars=0,location=0','false');
		return false;
	});

	//print link
	$('a[class="print"]').click(function() {
		window.print();
		return false;
	});

	//back link
	$('a[class="back"]').click(function() {
		if(BrowserDetect.browser == 'Explorer'){
			//alert(BrowserDetect.browser);
			return true;
		}
		else{
			history.back();
			return false;
		}
	});

	//forms - focus
	$("input[type=password], input[type=text], textarea").focus(function()
	{
		$(this).addClass("focus");
	});
	$("input[type=password], input[type=text], textarea").blur(function()
	{
		if ($(this).find(".focus")) { $(this).removeClass("focus");
		}
	});
if(document.getElementById('landkaart_flash') == true)
{
	//flash objects
	$('#landkaart_flash').flash(
	{ src: '/interactive/flash/landkaart.swf', 
	width: 190,
	height: 260
	});
}
	//forms - hover
	$("input.submit").hover(function()
	{
		$(this).addClass("hover");
	},
	function()
	{
		$(this).removeClass("hover");
	});

	//forms - checkbox
	//$().cssCheckbox();

	//image rollover
	$("img.rollover").hover(
	function() {
		this.src = this.src.replace("_off.","_on.");
	},
	function() {
		this.src = this.src.replace("_on.","_off.");
	});

	//dropdown menu - hover IE6
	$("li.hover").hover(function()
	{
		$(this).addClass("on");
	},
	function()
	{
		$(this).removeClass("on");
	})

	//Tooltip (TEXT in the id)
	if($('.tooltip').length > 0)
	{
		$('.tooltip').tooltip({
			bordercolor: '#6CE26C',
			bgcolor: '#F8F8F8',
			fontcolor: '#006699'
		});
	}

	//forms - multi select
	$('#add').click(function() {
		return !$('#list1 option:selected').remove().appendTo('#list2');
	});
	$('#remove').click(function() {
		return !$('#list2 option:selected').remove().appendTo('#list1');
	});
	$('#add,select#list1 option').dblclick(function() {
		return !$('#list1 option:selected').remove().appendTo('#list2');
	});
	$('#removed,select#list2 option').dblclick(function() {
		return !$('#list2 option:selected').remove().appendTo('#list1');
	});


		/* banner start */
	
	$('div.banner-img a').show();
	$('a.link-image').mouseover(function(){
			var linkid 			= this.id;
			var id 					= linkid.split('-');
			id							= id[1];

			$('div.banner-img a').hide();
			$('div.banner-img a').removeClass('active');
			$('ul.banner-link a').removeClass('active');
			$('a#bannerid-'+id).addClass('active');
			$(this).addClass('active');
			//$('a#bannerid-'+id).fadeIn(1000);
			$('a#bannerid-'+id).show();

			onMouseEl = true;
	});

	
	
	$('a.link-image').mouseout(function(){
			onMouseEl = false;
	});
	/* end banner start */
	

	//slideshow
//		if ($("#slideshow").jCarouselLite != 0)
//		{
//			$('#slideshow').jCarouselLite(
//			{
//				btnNext: ".next",
//				btnPrev: ".prev",
//				scroll: 3
//			});
//		}
	
		if ($("#slideshow_house").length)
		{
			$("#slideshow_house").jCarouselLite(
			{
				btnNext: ".next",
				btnPrev: ".prev",
				visible: 4
			}
			);
		}

	$("div#slideshow_house ul li a").hover(function(){
		var imgHref = $(this).attr('href');
		$('div#large_picture img').attr('src',imgHref);
	},function(){
	});
	$("div#slideshow_house ul li a").click(function(){
		return false;
	});

	//toggle content / link
	$("dd.content").hide();
	$("dt.toggle a").click(function(){
		$(this).parent().next("dd").toggle();
		return false;
	});

	//toggle content / link2
	$("li#go").hide();
	$("li.callback_top a").click(function(){
		$("li.callback_bottom").toggle();
		return false;
	});

	//toggle Personal Producten
	$("tr.product_extrainfo").hide();
	$("tr.toggle_info a").click(function(){
		$(this).parent().parent().next("tr").toggle();
		$(this).toggleClass("close");
		return false;
	});

	//toggle content / link2
	$("div#sitemapbrochures").hide();
	$("a.sitemaptoggle").click(function(){
		$("div#sitemapbrochures").toggle();
		return false;
	});

	$("div.brochurevestiging").hide();
	$("a.sitemaptoggle").click(function(){
		//$("div.brochurevestiging").toggle();
		$(this).parent().next("div").toggle();
		return false;
	});


	//tabs
	$(function () {
		var tabContainers = $('div#tabs > div');
		tabContainers.hide().filter(':first').show();
		$('div#tabs ul.tabs_menu a, dl.details dt a.tab, dl.details dd a.tab, div.house_icons p a.tab').click(function () {
			tabContainers.hide();
			tabContainers.filter(this.hash).show();
			$('div#tabs ul.tabs_menu a').removeClass('selected');
			$(this).addClass('selected');
			return false;
		}).filter(':first').click();
	});


	if($('a[rel*=facebox]').length > 0 )
	{
		$('a[rel*=facebox]').facebox()
	}
	
	
	$(document).ready(function() {
		if ($("a.hyveslink").length)
		{
			$("a.hyveslink").fancybox({
			'frameHeight':420,
			'frameWidth':820,
			'padding':10,
			'hideOnContentClick':false
			});
		}
		
		if ($("a.hyveslinkimage").length)
		{
			$("a.hyveslinkimage").fancybox({
			'frameHeight':420,
			'frameWidth':820,
			'padding':10,
			'hideOnContentClick':false
			});
		}
	});
	
	
	$(document).ready(function() {
		if ($("a.hyveslink_big").length)
		{
			$("a.hyveslink_big").fancybox({
			'frameHeight':720,
			'frameWidth':600,
			'padding':10,
			'hideOnContentClick':false
			});
		}
		if ($("a.hyveslinkimage_big").length)
		{
			$("a.hyveslinkimage_big").fancybox({
			'frameHeight':720,
			'frameWidth':600,
			'padding':10,
			'hideOnContentClick':false
			});
		}
	});
	
	$(document).ready(function() {
		if ($("a.hyveslink_narrow").length)
		{
			$("a.hyveslink_narrow").fancybox({
			'frameHeight':420,
			'frameWidth':600,
			'padding':10,
			'hideOnContentClick':false
			});
		}
		if ($("a.hyveslinkimage_narrow").length)
		{
			$("a.hyveslinkimage_narrow").fancybox({
			'frameHeight':420,
			'frameWidth':600,
			'padding':10,
			'hideOnContentClick':false
			});
		}
	});
	
	$(document).ready(function() {
		if ($("a.hyveslink_module").length)
		{
			$("a.hyveslink_module").fancybox({
			'frameHeight': offsetY - 100,
			'frameWidth': offsetX - 100,
			'padding':10,
			'hideOnContentClick':false
			});
		}
		if ($("a.hyveslinkimage_module").length)
		{
			$("a.hyveslinkimage_module").fancybox({
			'frameHeight': offsetY - 100,
			'frameWidth': offsetX - 100,
			'padding':10,
			'hideOnContentClick':false
			});
		}
			
	});

	//validate forms
	//$("#form_contact_appointment").validate();
	//$("#form_callback").validate();
	//$("#form_request_folder").validate();
	//$("#form_view_house").validate();
	//$("#form_request_brochure").validate();
	//$("#form_contact_mail").validate();
	//$("#form_forward_residence").validate();

	//Google Analytics code
	//var gaTrackCode = "UA-6911197-1";
	//var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");

	//jQuery.getScript(gaJsHost + "google-analytics.com/ga.js", function(){
	//var pageTracker = _gat._getTracker(gaTrackCode);
	//pageTracker._initData();
	//pageTracker._trackPageview();
	//});


}

);

/* banner function */
function nextBanner()
{
	if(onMouseEl == false)
	{
		$('div.banner-img a').hide();
		var activeel 		= 	$('div.banner-img a.active');
		var newActive 	= activeel.next();

		if(activeel.attr('class') == 'img3 active')
		{
			newActive = $('div.banner-img a.img0');
		}

		$('div.banner-img a').removeClass('active');
		$('ul.banner-link a').removeClass('active');
		newActive.addClass('active');
		newId = newActive.attr('id');
		newId = newId.split('-');
		$('ul.banner-link a#linkid-'+newId[1]).addClass('active');
		//newActive.fadeIn(1000);
		newActive.show();
	}
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();



// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} function posRight() {return posLeft()+pageWidth();} function posBottom() {return posTop()+pageHeight();}
                    



