/*-------------------------------------------------------------------
	GLOBAL VARIABLES
-------------------------------------------------------------------*/

var fkkcCurUrl = '';
var fkkcCurWaar = '';
var openFaq = '';
var openWaar = '';
var openCollectionText = '';


addEvent(window, 'load', checkUrl);
addEvent(window, 'load', checkWaar);


function $() {
	var elements = new Array();
	for (var i=0; i<arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string') {
			element = document.getElementById(element);
		}
		if (arguments.length == 1) {
			return element;
		}
		elements.push(element);
	}
	return elements;
}

function overMenu(obj) {
		var languagesUL = document.getElementById('languages');
		languagesUL.style.display = 'block';
		languagesUL.style.position = 'absolute';
		languagesUL.style.top = '27px';
		languagesUL.style.backgroundColor = '#C0B6AA';
		languagesUL.style.height = '23px';

}

function outMenu(obj) {
	var languagesUL = document.getElementById('languages');
	languagesUL.style.display = 'none';
}

function addEvent(obj, evType, fn) {
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}


function checkUrl(){
	var theUrl = window.location.href;
	if (theUrl != fkkcCurUrl) {
		swapFaq(theUrl);
	}
	window.setTimeout('checkUrl();', 200);
}
function checkWaar(){
	var theUrl = window.location.href;
	if (theUrl != fkkcCurWaar) {
		swapWaar(theUrl);
	}
	window.setTimeout('checkWaar();', 200);
}

function swapFaq(theUrl) {
	var fid = '';
	if (theUrl.search('#') > 0) {
		var theVar = theUrl.split('#')[1];
		if (theVar.substr(0,4) == 'faq-') {
			var displaystyle = 'block';
			var fid = 'faq' + theVar.split('-')[1];
		}
	}
	if (fid != openFaq) {
		if (fid == ''){
			$(openFaq).style.display = 'none';
		} else {
			if (openFaq != ''){
				$(openFaq).style.display = 'none';
			}
			if ((document.all) && (navigator.userAgent.indexOf('Opera')== -1)) {
				$(fid).style.display = 'block';
			} else {
				$(fid).style.display = 'block';
			}
		}
		openFaq = fid;
	}
}

function swapWaar(theUrl) {
	var fid = '', theVar = false;
	if (theUrl.search('#') > 0) {
		var theVar = theUrl.split('#')[1];
		if (theVar.substr(0,7) == 'dealer-') {
			var displaystyle = 'table-row';
			var fid = 'dealer' + theVar.split('-')[1];
		}
	}
	if (fid != openWaar) {
		if (fid == ''){
			$(openWaar).style.display = 'none';
		} else {
			if (openWaar != ''){
				$(openWaar).style.display = 'none';
				var temp = openWaar.substr(6);
				$('dealerH'+temp).className = '';
			}
			if ((document.all) && (navigator.userAgent.indexOf('Opera')== -1)) {
				$(fid).style.display = 'block';
			} else {
				$(fid).style.display = 'table-row';
			}
			var temp = fid.substr(6);
			$('dealerH'+temp).className = 'selected';
			if('pageTracker' in window && theVar){
				pageTracker._trackPageview('/waar-te-koop/'+theVar);
			}

		}
		openWaar = fid;
	}
}

function swapColectionText(id,text) {

	if (openCollectionText > 0) {

		var intro = 'fullText'+openCollectionText;
		$(intro).style.display = 'none';
		var intro = 'intro'+openCollectionText;
		$(intro).style.display = '';
	}

	var intro = 'intro'+id;
	$(intro).style.display = 'none';

	var intro = 'fullText'+id;
	$(intro).style.display = '';

	openCollectionText = id;
}

