// start config

var VOD = {
	swf : '/Vodafone/wg20/swf/',
	banners : '/Vodafone/wg20/img/banners/',
	flv : '/Vodafone/wg20/swf/'
};

// end config

// start user func

VOD.homebanners = {
	'onze-visie'  : 2,
	'onze-organisatie' : 3,
	'onze-waarden' : 4,
	'onze-mensen' : 5,
	'young-talent-program' : 6
};

VOD.homely = function (id) {
	var banner = VOD.id('overVodafoneHomeBanner');
	banner.style.backgroundImage = 'url(' + VOD.banners + 'home' + VOD.homebanners[id] + '.jpg)';
	if (('onze-mensen' === id) || ('young-talent-program' === id)) {
		VOD.id(id).style.top = '88px';
	}
}

VOD.drop = {
	trigger : null,
	target : null,
	init : function (id) {
		this.trigger = VOD.id(id);
		this.target = VOD.id(this.trigger.href.split('#')[1]);
		this.target.style.top = this.trigger.offsetTop + this.trigger.offsetHeight + 11 + 'px';
		this.target.style.right = '22px';
		this.trigger.onclick = this.toggle;
		this.trigger.onmouseout = this.hide;
		this.target.onmouseover = this.show;
		this.target.onmouseout = this.hide;
	},
	toggle  : function () {
		if (VOD.drop.target.style.display) {
			VOD.drop.show();
		} else {
			VOD.drop.hide();
		}
		return false;
	},
	show : function () {
		VOD.drop.target.style.display = '';
	},
	hide : function () {
		VOD.drop.target.style.display = 'none';
	}
};

VOD.contact = {
	init : function (id) {
		var el = VOD.id(id);
		el.className += ' hide';
		var a = document.createElement('A');
		el.insertBefore(a, el.firstChild);
		a.href = "#" + id;
		a.className = "contactToggle";
		a.appendChild(document.createTextNode('adres en e-mail'));
		a.onclick = VOD.contact.toggle;
	},
	toggle : function () {
		var parent = this.parentNode;
		if (parent.className.indexOf(' hide') != -1) {
			this.innerHTML = '&nbsp;';
			parent.className = parent.className.replace(' hide', '');;
		} else {
			this.innerHTML = 'adres en email';
			parent.className += ' hide';
		}
		return false;
	}
};

VOD.rotate = {
	prev : null,
	init : function (id) {
		var context = VOD.id(id);
		var target = context.childNodes, l = target.length, first;
		for (var i = 0; i < l; i++) {
			if (1 == target[i].nodeType) {
				if (first) {
					target[i].style.display = 'none';
				} else {
					VOD.rotate.prev = target[i];
				}
				if (!first) {
					first = 1;
				}
			}
		}
		var trigger = VOD.gi('A'), l = trigger.length;
		while (l--) {
			if ('buttons' == trigger[l].parentNode.className) {
				trigger[l].onclick = VOD.rotate.toggle;
			}
		}
	},
	toggle : function () {
		var hash = VOD.getFragID(this.href);
		var current = VOD.id(hash);
		current.style.display = '';
		VOD.rotate.prev.style.display = 'none';
		VOD.rotate.prev = current;
		return false;
	}
};

VOD.copyCol = function () {
	var t = window.setInterval(
		function () {
			if (document.body) {
				var body = document.body.className;
				var append = 'over-vodafone-2008';
				document.body.className = (body) ? body + ' ' + append : append;
				window.clearInterval(t);
				t = null, body = null, append = null;
			}
		}, 10
	);
}

VOD.gmt = {
	rel  : {},
	copy : null,
	init  : function (id) {
		VOD.gmt.copy = VOD.id('gmt-copy');
		var farm = VOD.id('gmt-toc');
		if (VOD.gmt.copy && farm) {
			var a = farm.getElementsByTagName('A'), i = a.length, par, img, quote, out;
			while (i--) {
				par = a[i].parentNode;
				quote = par.getElementsByTagName('SPAN')[0];
				quote.style.display = 'none';
				out = '<h2>' + a[i].innerHTML + '</h2>'	+
					'<strong style="color:#008698;">' + par.getElementsByTagName('STRONG')[0].innerHTML + '</strong><br /><br />' +
					quote.innerHTML;
				VOD.gmt.rel[a[i].id] = out;
				a[i].onclick = VOD.gmt.show;
			}
			VOD.gmt.show(id);
		}
	},
	show : function (id) {
		var file = ('string' === typeof id) ? id : this.id;
		VOD.gmt.copy.innerHTML = VOD.gmt.rel[file];
		window.scrollTo(0, 160);
		return VOD.gmt.playFLV(file);
	},
	playFLV : function (file) {
		var swf = VOD.swf;
		var flv = VOD.flv + file + '.flv';
		var so = new SWFObject(swf + "player.swf", "flvPlayer", "285", "206", "8", "#FFFFFF");
		so.addVariable("skinswf", swf + "SteelExternalAll.swf");
		so.addParam("scale", "noscale");
		so.addParam("allowScriptAccess", "always");
		so.addVariable("flvLocatie", flv);
		so.write("player");
		return false;
	}
};


// end user func

// start lib code

VOD.id = function (id) {
    return document.getElementById(id);
};
VOD.gi = function (gi, scope) {
    return (scope || document).getElementsByTagName(gi.toUpperCase());
};

VOD.getFragID = function (uriRef) {
		return uriRef.toString().split('#')[1];
};
VOD.matchFragID = function (id) {
	return (id && (id == this.getFragID(window.location))) ? true : false;
};
VOD.word = function (val) {
    return new RegExp("(^|\\s)" + val + "(\\s|$)");
};

VOD.Tabs = function (id, i, cb) {
    if ((this !== window) && (this.linkFarm = VOD.id(id))) {
        this.union = {};
        this.preset = i - 1 || 0;
        this.select = 'selected';
        this.regex = VOD.word(this.select);
        this.prev = null;
		var a = VOD.gi('A', this.linkFarm), l = a.length, i = 0, hash;
		if (hash = VOD.getFragID(window.location)) {
			for (; i < l; i++) {
				if (hash == VOD.getFragID(a[i].href)) {
					this.preset = i;
				}
			}
			i = 0;
		}
		for (var x, y; i < l; i++) {
			if ((x = VOD.getFragID(a[i].href)) && (y = VOD.id(x))) {
				var o = this, z = a[i];
				this.union[x] = {
					ying : z,
					yang : y
				};
				if (i != this.preset) {
					y.style.display = 'none';
				} else {
					z.parentNode.className += ' ' + this.select;
					this.prev = z;
				}
				z.onclick = function () {
					return o.mangle(this, cb);
				};
			}
		}
		z = null;
    }
};

VOD.Tabs.prototype.mangle = function (o, cb) {
    var id = VOD.getFragID(o.href);
    if ('none' == this.union[id].yang.style.display) {
        for (i in this.union) {
            this.union[i].yang.style.display = (i == id) ? '' : 'none';
            switch (this.union[i].ying) {
                case o:
                    o.parentNode.className += ' ' + this.select;
                    if (!this.prev) {
                        this.prev = o;
                    }
                    break;
                case this.prev:
                    this.prev.parentNode.className = this.prev.parentNode.className.replace(this.regex, '');
                    this.prev = o;
                    break;
            }
        }
		if (cb) {
			cb(id);
		}
		//o.blur();
    }
    return false;
};


