// JavaScript Document
function tickInit() {
	
}










ocd = {
	init: function(){
		ocd.minHeight();
		$('#wrapper div.subcontent').append($('li.website ul.menulevel2'));
		
		var placeTimer = setTimeout(function(){
			$('#logo a span').animate({top: 0},2000);
		},1200);
		if (!ua.ie6 && !ua.ie7) ocd.walkingMan();
		
		if (editmode!='content') {
			/*
			$('a.youtube').each(function(){
				var matches = $(this).attr('href').match(/http:\/\/www.youtube.com\/watch\?v=(.*)/);
				
				if (matches && matches[1]) {
					$(this).attr('youtube',matches[1]).click(function(){
						ocd.showMovie(this);
						return false;
					});
				}
			});
			*/
			$('#wrapper a').each(function(){
				var matches = $(this).attr('href').match(/http:\/\/www.youtube.com\/watch\?v=(.*)/);
				
				if (matches && matches[1]) {

					var descr = $(this).text();
					$(this).attr('youtube',matches[1]).addClass('youtubed');
					if ($('img', this).length) {
						$(this).append('<span/>');
					}else {
						$(this).html('<img src="http://i4.ytimg.com/vi/'+matches[1]+'/0.jpg"/><span style="display: block">'+descr+'</span>');
					}
					
					$(this).click(function(){
						ocd.showMovie(this);
						return false;
					});
					/*
					var str='<object width="460" height="280"><param name="movie" value="http://www.youtube.com/v/'+matches[1]+'&hl=en_US&fs=1&autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+matches[1]+'&hl=en_US&fs=1&autoplay=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="460" height="280"></embed></object>';
					$(this).replaceWith(str);
					*/
					
				}
				
				
			
			});

		}
		
		var ul = $('<ul id="city-picker"/>');
		var ul2 = $('<ul id="city-points"/>');
		
		var cities = $('#topmenu ul.menulevel1 > li > a').size();
		$('#topmenu ul.menulevel1 > li > a').each(function(i){
			if (i>0 && i<cities-1) {
				var liid = $(this).parent().attr('id');
				var a = $(this).clone();
				var a2 = $(this).clone();
				a2.append('<em>*</em>');
				
				if ($(this).parent().hasClass('currenttree')) {
					a.addClass('currentlink');
					a2.addClass('currentlink');
				}
				var li = $('<li/>');
				li.append(a);
				ul.append(li);
				var li2 = $('<li/>');
				li2.attr('id',liid.replace('menuitem', 'city'));
				li2.append(a2);
				ul2.append(li2);
			}
		});
		
		

		
		$('.city-map').append(ul2);
		$('.city-map').after(ul);
		
		
		
		$('.pick_city').hover(function(){
			$('#city-picker:hidden').slideDown();
		},function(){
			
		}).click(function(){
			$('#city-picker:hidden').slideDown();
			if ($('#city-picker:visible').size()) {
				$('#city-picker').slideUp();
			}
			return false;
		});
		$('#city-picker').hover(function(){},function(){
			//$('#city-picker').slideUp();
		});
		$(document).click(function(){
			if (!$(this).parents('#city-picker').size()) {
				$('#city-picker').slideUp();
			}
		});
		
		
		
		
	},
	showMovie: function(link) {
		var blackerdiv = document.createElement('div');
		blackerdiv.id = 'blacker';

		document.body.appendChild(blackerdiv);
		$('#blacker').fadeTo('fast',0).css('backgroundColor', '#333333');

		var div = document.createElement('div');
		div.id='moviePlayer';
		str= '<a href="#close" class="close">sluiten [X]</a><br/>';
		str+='<object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/'+$(link).attr('youtube')+'&hl=en_US&fs=1&autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+$(link).attr('youtube')+'&hl=en_US&fs=1&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>';

		$('#blacker').fadeTo(500,0.8,function(){
			$('html').addClass('lightbox');
			div.innerHTML = str;
			document.body.appendChild(div);
			$('#moviePlayer a.close, #blacker').click(function(){
				$('#moviePlayer').remove();
				$('#blacker').fadeTo(500,0,function(){
					$(this).remove();
					$('html').removeClass('lightbox');
				});
			});
		});
		
		
	},
	minHeight: function(){
		//$('#wrapper').css({minHeight: ($('html').height()-110) + 'px'});
	},
	walkingMan: function(){
		pathChecker = setInterval(function(){
			var currentPos = Math.ceil(($('a.concept strong').width()-20)/58);
			if (currentPos!=currentPath) {
				$('a.concept').css({backgroundPosition: '0 '+ (30-(currentPath*120))+'px'});
				currentPath = currentPos;
				$('a.concept span').css({opacity: 0, backgroundPosition: '0 '+ (0-(currentPath*120))+'px'}).fadeTo(500,1,function(){
					
				});
			}
		},100);
		$('a.concept strong').css({opacity: '1', width: '0px'}).animate({width: '232px'},20000,'linear',function(){
			clearInterval(pathChecker);
			$('a.concept strong').fadeTo(500,0,function(){
				ocd.walkingMan();
				
			});
		});
	}
}
var pathChecker;
var currentPath = 1;
$(document).ready(function() {
	ocd.init();
	$('#linked form').each(function(){
		this.onsubmit = function() {}
	});
	
});


var ua = {};
with (ua) {
	ua.toString = function() { return navigator.userAgent; };
	ua.test = function(s) {
		return toString().toLowerCase().indexOf(s.toLowerCase()) > -1;
	};
	ua.gecko = test("gecko") && !test("webkit");
	ua.webkit = test("webkit");
	ua.opera = test("opera");
	ua.ie = test("msie");
	ua.ie6 = test("msie 6");
	ua.ie7 = test("msie 7");
	ua.mac = test("mac");
	ua.win = test("windows");
	ua.iphone = test("iphone");
	ua.ipod = test("ipod");
}

