var winkelwagen;
var informatie;
var bestellen;
var verder;
var leuk;

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

soundManager.url = '/inc/flash/'; // path to directory containing SoundManager2 .SWF file
soundManager.flashVersion = 8;
soundManager.debugMode = false;

soundManager.onload = function() {
	bestellen = soundManager.createSound({
		id: 'bestellen',
		url: '/inc/sounds/bestellen.mp3',
		volume: 100
	});
	
	winkelwagen = soundManager.createSound({
		id: 'winkelwagen',
		url: '/inc/sounds/winkelwagen.mp3',
		volume: 100
	});
	
	leuk = soundManager.createSound({
		id: 'leuk',
		url: '/inc/sounds/leuk.mp3',
		volume: 100
	});
	
	informatie = soundManager.createSound({
		id: 'informatie',
		url: '/inc/sounds/informatie.mp3',
		volume: 100
	});
	
	verder = soundManager.createSound({
		id: 'verder',
		url: '/inc/sounds/verder.mp3',
		volume: 100
	});
	
	
	
}

function getFlashVersion(){ 
  // ie 
  try { 
	try { 
	  // avoid fp6 minor version lookup issues 
	  // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ 
	  var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); 
	  try { axo.AllowScriptAccess = 'always'; } 
	  catch(e) { return '6,0,0'; } 
	} catch(e) {} 
	return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; 
  // other browsers 
  } catch(e) { 
	try { 
	  if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){ 
		return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]; 
	  } 
	} catch(e) {} 
  } 
  return '0,0,0'; 
} 

var version = getFlashVersion().split(',').shift(); 

$(document).ready(function() {
	if(version ==0){ 
	  alert("Het is niet leuk, maar voor deze website heb je Flash nodig... Installeer flash en komt snel terug!"); 
	}else{
		$('.bestellen').click(function () { 
			bestellen.play();
			return false;
		});
		
		$('.verder').click(function () { 
			verder.play();
			$('#geefnougewooneenboek').stop();
			$('#geefnougewooneenboek').hide();
			$('#geefnougewooneenboek').css('opacity', '1');
			$(this).addClass('geefnougewooneenboek');
			$(this).parent().before($('#geefnougewooneenboek'));
			$('#geefnougewooneenboek').fadeIn();
			return false;
		});
		
		$('#geefnougewooneenboek').mouseout(function(){
			$('#geefnougewooneenboek').fadeOut(3000);
		});
		
		$('.meer-info').hover(function () { 
				informatie.play();		
				$(this).css('background', 'none');
			},function () { 
				informatie.stop();		
				$(this).css('backgroundImage', 'url(/inc/images/hnl-meerideeen-bg.jpg)');
			});
		
		$('.winkelwagen').hover(function () { 
				winkelwagen.play();	
				if($(this).parent().attr('id')!="tip-vd-week"){
					$(this).css('background', 'none');					
				}
			},function () { 
				winkelwagen.stop();				
				if($(this).parent().attr('id')!="tip-vd-week"){
					$(this).css('backgroundImage', 'url(/inc/images/hnl-winkelwagen-bg.jpg)');				
				}
		});
		
		$('.winkelwagen').click(function () { 
			return false;
		});
		
		$('.item').hover(function(){
				$(this).addClass('hover');
			},function(){
				$(this).removeClass('hover');
		});
		
		$('.item .verder').hover(function(){
				$(this).addClass('hover');
			},function(){
				$(this).removeClass('hover');
		});
		
		$('#tip-vd-week').hover(function(){
				winkelwagen.play();											 
				$(this).addClass('hover');
				$(this).find('img').hide();
				$(this).find('a').hide();
			},function(){
				winkelwagen.stop();	
				$(this).removeClass('hover');
				$(this).find('img').show();
				$(this).find('a').show();
								
			});
		
		$('#nieuwsbrief').hover(function(){
				$(this).attr('src', '/inc/images/hnl-nieuwsbrief-hover-bg.jpg');
				
			},function(){
				$(this).attr('src', '/inc/images/hnl-nieuwsbrief.jpg');
												
			});
		
		$('#onzinnig').hover(function(){
				bestellen.play();											 
				$(this).addClass('hover');
				$(this).find('*').hide();
				$(this).find('a').hide();
			},function(){
				bestellen.stop();	
				$(this).removeClass('hover');
				$(this).find('*').show();
				$(this).find('a').show();
								
			});
		
		
		$('#menu li span').blink();	
	}
});


