/* switch naar promo/prijzen view */
function switchPromo(id) {
	if ($('box_prijzen') && $('box_promoties')) {
		$('box_prijzen').hide();
		$('box_promoties').hide();
		$(id).show();
	}
}

/* fontsize vergroten/verkleinen */
function setFontSize(size) {
	if(!size)
		size = findFontSize();
	document.getElementById('content_text').style.fontSize = size;
	document.cookie = "fontSize="+size+"; path=/"; 
}
function findFontSize() {
	value	= getCookie("fontSize=");
	if(value == null)
	    return "12px"; 
	else
		return value;
}

/* geluid laten horen of niet */
function setSound() {
	value	= getCookie("sound=");
	if(value == "on")
		value = "off";
	else
		value = "on";
	document.cookie = "sound="+value+"; path=/"; 
	window.location.reload();
}
function findSound() {
	return "off";
	value	= getCookie("sound=");
	if(value == null) {
		setSound();
		return "on";
	} else
		return value;
}

/* cookie waardes ophalen */
function getCookie(nameEQ) {
    var ca = document.cookie.split(';'); 
    for(var i=0;i < ca.length;i++) { 
        var c = ca[i]; 
        while (c.charAt(0)==' ') c = c.substring(1,c.length); 
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 
    } 
	return null;
}

/* history back */
function historyBack() {
	history.back()
}


/* bungalow plattegrond view photo / video */
function switchBungalow(id) {
	$('photo').hide();
	$('video').hide();
	$(id).show();
}

/* rotate plattegrond images */
function Groundplan()
{
	this.pause		= 5000;
	this.teller_1	= 0;
	this.photo_img	= new Array();
	this.teller_2	= 0;
	this.t;

	this.init = function() {
		if(document.getElementById('imgmapphoto')) {
			photo_areas		= document.getElementById('imgmapphoto').getElementsByTagName('area');
			for(i = 0; i < photo_areas.length; i++) {
				this.photo_img[i]	= photo_areas[i].href;
			}
		}
		if(document.getElementById('imgmapvideo')) {
			video_areas		= document.getElementById('imgmapvideo').getElementsByTagName('area');
			for(i = 0; i < video_areas.length; i++) {
				this.videoChange(video_areas[i].href,'video');
			}
		}
	};

	this.stopLoop = function(file,type) {
		clearTimeout(this.t);

		changeOpac(0, type+"_img");
		this.i = 100;
		document.getElementById(type+"_img").src = file;
		document.getElementById(type+"_view").style.backgroundImage = "url(" + document.getElementById(type+"_img").src + ")";

		this.teller_1--;
		this.teller_2--;
	};

	this.goLoop = function() {
		this.teller_1++;
		this.teller_2++;

		if(this.teller_1 > (this.photo_img.length-1))	this.teller_1 = 0;

		if(document.getElementById('photo_view'))
			this.blendimage('photo_view','photo_img',this.photo_img[this.teller_1],700);

		var _self	= this;
		this.t		= setTimeout(function(){_self.goLoop();}, this.pause);
	};

	this.i = 0;
	this.blendimage = function(divid, imageid, imagefile, millisec) {
		var speed = Math.round(millisec / 100);
		var timer = 0;

		document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
		changeOpac(0, imageid);
		document.getElementById(imageid).src = imagefile;

		for(this.i = 0; this.i <= 100; this.i++) {
			setTimeout("changeOpac(" + this.i + ",'" + imageid + "')",(timer * speed));
			timer++;
		}
	}
	
	this.videoChange = function(file,type) {
		tot = file.indexOf(".swf");
		part = file.substr(0,tot);
		src = AC_FL_RunContent1(
			'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width','347',
			'height','232',
			'src', part,
			'type','application/x-shockwave-flash'
		); //end AC code

		document.getElementById('video_view').innerHTML = src;
	}
}
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";	
}



/* slide menu */
function slideMenu() {
	this.left;
	this.leftwidth;
	this.origwidth;

	this.right = new Array();
	this.rightwidth = new Array();

	this.bar;

	this.pause = 50;
	this.interval;
	this.steps = 26;

	this.init = function(left,right) {
		this.left		= document.getElementById(left);
		this.origwidth	= parseInt(this.left.style.width);
		this.leftwidth	= parseInt(this.left.style.width);
		this.left.style.overflow = "hidden";

		for(i=0; i<right.length; i++) {
			if(document.getElementById(right[i])) {
				this.right[i]		= document.getElementById(right[i]);
				this.rightwidth[i]	= parseInt(this.right[i].style.width);
			}
		}
		
		this.bar = document.getElementById('clickbar');
	};

	this.go = function() {
		if(this.leftwidth <= 1 || this.leftwidth >= this.origwidth) {
			this.steps = this.steps * (-1);
			if(this.steps > 0)
				this.leftwidth	= this.leftwidth + this.steps;
		}
		var _self = this;
		this.interval = setInterval(function(){_self.slide();}, this.pause);
	};

	this.slide = function(){
		this.leftwidth	= this.leftwidth + this.steps;
		if(this.leftwidth <= 1 && this.steps < 0) {
			this.bar.style.background = "#FFFFFF url('/default/images/main/clickbar_open.gif') no-repeat";
			clearInterval(this.interval);
			return;
		}
		this.left.style.width	= this.leftwidth + "px";

		for(i=0; i<this.right.length; i++) {
			this.rightwidth[i]			= this.rightwidth[i] - this.steps;
			this.right[i].style.width	= this.rightwidth[i] + "px";
		}

		
		this.bar.style.left = parseInt(this.bar.style.left) + this.steps + "px";

		if(this.leftwidth >= this.origwidth && this.steps > 0) {
			this.bar.style.background = "#FFFFFF url('/default/images/main/clickbar_close.gif') no-repeat";
			clearInterval(this.interval);
			return;
		}
	};
}