//Uitklapmenu!

var maxL = 0
var maxContent = 500;

navHover = function() {
	
	var lis = document.getElementById("globalNav").getElementsByTagName("LI");
	
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}


// Flashobject activeX workaround
function makeFlashObj(sID, sPath, sWidth, sHeight, sBG)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="' + sID + '" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + sWidth + '" height="' + sHeight + '">');
	document.write('<param name="movie" value="' + sPath + '">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="bgcolor" value="' + sBG + '">');
	document.write('<embed bgcolor="' + sBG + '" src="' + sPath + '" quality="high" id="' + sID + '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + sWidth + '" height="' + sHeight + '"></embed>');
	document.write('</object>');
}

function openQuestion(id){
	style = document.getElementById(id).style.display;
	
	if(style == "block"){
		document.getElementById(id).style.display = "none";
	}else{
		document.getElementById(id).style.display = "block";
	}
}
function toggleSublist(value,selected,qID){
	
	if(selected == true){
		url = root + "include/generateTag.asp"
		$.get(url,{root:root,tagID:value,qID:qID},function(data){$("#sublist").append(data);})
	}else{
	$("#subtasklist"+value).remove();
	}
}
//if (window.attachEvent) window.attachEvent("onload", navHover);

function shopitem_initCallback(carousel) {
	$(".shopitems .navigation li").each(function(){
		$(this).bind('click', function() {
			carousel.stopAuto();
			carousel.scroll(jQuery.jcarousel.intval($(this).text()));
			$(".shopitems .navigation li").each(function(){
				$(this).css({'color':'#ccc'});
			});
			$(this).css({'color':'#454545'});
			return false;
		});
	});
};

	function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt){
	};


	function mycarousel_after(carousel, item, i, state, evt){

		$(".shopitems .navigation li").each(function(){
				$(this).css({'color':'#ccc'});
			});
		i = i - 1;	
		$(".shopitems .navigation li:eq("+i+")").css({'color':'#454545'});	
	}

jQuery(document).ready(function() {

	if($('#sidebarreactions').size()){
		$('#sidebarreactions').jcarousel({
			wrap: 'both',
			vertical: true,
			auto: 10,
			scroll: 1
		});
	}
	
	$("#searchformNew #q").bind('focus blur', function() {
         toggleInputValue(this);
	});
	
	
	$("#shopitems_carousel").jcarousel({
		scroll: 1,
		auto: 10,
		wrap:'both',
		initCallback: shopitem_initCallback,
		itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback, onAfterAnimation:mycarousel_after},
		buttonNextHTML: null,
		buttonPrevHTML: null
	});
	
	$("#coachicon").smoothDivScroll({
		scrollableArea: "#coachimages",
		scrollWrapper: "#coachiconwrapper",
		scrollingHotSpotLeft: "#coachimagesleft",
		scrollingHotSpotRight: "#coachimagesright",
		scrollingSpeed: 12, 
		mouseDownSpeedBooster: 3, 
		hotSpotsVisibleTime: 9
	});
	
	if ($('.homepage #coach-thnx').length > 0){
		
		
	}
	
	if ($('.homepage #coachquestion').length > 0){
		
		$('#coachquestion-desc').bind('click',function(){
			$('.homepage #coachquestion ul').toggle();
		});
		
		$('#coachquestion ul li a').bind('click',function(){
			id 		= $(this).attr("id");
			desc 	= $(this).attr("title");
			
			$("#coachquestion-labelID").val(id);
			$('#coachquestion-desc').html(desc);
			$('.homepage #coachquestion ul').toggle();
		});
		
	}

	/*
	if ($("#coachicon").length > 0){ 
			
		var iconCount 	= $("#coachicon > a").length;	
		
		$("#coachicon").everyTime(3000,function(p){
			var i	= Math.ceil((iconCount * Math.random()));
			var url = root + "include/returnRandomcoach.asp"
			$.post(url,{},function(data){
				var aData = data.split("@@");
				$('#coachicon > a:nth-child('+i+') > img').fadeOut(1000,function(){
				$('#coachicon > a:nth-child('+i+') > img').attr("src",root+aData[1]);
				$('#coachicon > a:nth-child('+i+')').attr("href",aData[0]);
				$('#coachicon > a:nth-child('+i+') > img').attr("alt",aData[2]);
				$('#coachicon > a:nth-child('+i+') > img').attr("title",aData[2]);
				$('#coachicon > a:nth-child('+i+') > img').fadeIn();
				});
			});
		});
	}
	
	*/
	
	animatedcollapse.addDiv('coachquestion-more','speed=300,fade=0')
	animatedcollapse.addDiv('taglist-more','speed=300,fade=0')
	animatedcollapse.addDiv('errorbox','speed=300,fade=0')
	animatedcollapse.addDiv('coachingvraagError','speed=300,fade=0')
	animatedcollapse.addDiv('reactions','speed=300,fade=0')
	animatedcollapse.addDiv('questionMaster','speed=300,fade=0')
	animatedcollapse.init()
	
});

function toggleInputValue(o) {
	if(o.value == o.title) o.value = "";
    else if($.trim(o.value) == "") o.value = o.title;
}


function fillCoachCat(cat){
	aCat = cat.split('||');
			
	if (aCat.length == 2){
		$("#coachquestion-desc").html(aCat[1]);
		$("#coachquestion-labelID").val(aCat[0]);
		animatedcollapse.toggle('coachquestion-more');
		}
}
		
function fillCoachCatNoAnime(cat){
	aCat = cat.split('||');
	
	if (aCat.length == 2){
		$("#coachquestion-desc").html(aCat[1]);
		$("#coachquestion-labelID").val(aCat[0]);
	}
}
		
function clearArea(text){
	currenttext = jQuery.trim($("#coachingvraag-q").html());
	if (currenttext == text){$("#coachingvraag-q").html("");}
	if( currenttext == "" ){ $("#coachingvraag-q").html(text);}
}

function clearTextArea(fieldid){
	var text 		= jQuery.trim($("#"+fieldid).attr("title"));
	var currenttext	= jQuery.trim($("#"+fieldid).html());
	if (currenttext == text){$("#"+fieldid).html("");}
	if( currenttext == "" ){ $("#"+fieldid).html(text);}
}

	function objectContentQuestion(obj){

		if ( maxL == 0){
		maxL  = Number(maxContent)
		}

		var length 	= Number(obj.value.length)
		var n 		= Number(maxL-length)

		if (length<=(maxL-2)){
			
			animatedcollapse.hide('coachingvraagError');	
			
		}else{
			var value = (String(obj.value).substring(0,maxL));
			obj.value = value;
			animatedcollapse.show('coachingvraagError');
		}
	}
								
	function submitBox(){
		
		boxSubmit 	= true;
		questionFrm = document.coachingvraag
		var sError 	= "";
		
		var x = $("#coachquestion-labelID").val();
		var q = $("#coachingvraag-q").val();
		var filter  = /^([0-9])/;

		if (filter.test(x) == false || isEmptyValue(x) == true){
			boxSubmit = false;
			sError = "Je hebt geen rubriek gekozen.";
		}
		
		if (q == "Stel hier jouw coachingsvraag..." || isEmptyValue(q) == true){
			boxSubmit = false;
			sError = "Je hebt geen vraag ingevuld.<br>" + sError;
		}
		
		
		if(isEmptyValue(sError) == false){
			$("#errorbox").html(sError);
			animatedcollapse.show('errorbox');
		}
		
		if(boxSubmit == true){
			document.coachingvraag.submit();
		}
	}

	function isEmptyValue(s){
		if ( null == s || "" == s ){
			return true; 
		} 
		return false; 
	}
	
	function submitcoach(){
					
		boxSubmit 	= true;
		questionFrm = document.coachingvraag
		var sError 	= "";
		
		var x = $("#coachquestion-labelID").val();
		var q = $("#coachingvraag-q").val();
		var filter  = /^([0-9])/;

		if (filter.test(x) == false || isEmptyValue(x) == true){
			boxSubmit = false;
			sError = "Je hebt geen coach gekozen.";
		}
		
		if (q == "Jouw bedankje..." || isEmptyValue(q) == true){
			boxSubmit = false;
			sError = "Je hebt geen vraag ingevuld.<br>" + sError;
		}
		
		
		if(isEmptyValue(sError) == false){
			$("#errorbox").html(sError);
			animatedcollapse.show('errorbox');
		}
		
		if(boxSubmit == true){
			
			//ajax post aanmaken
			url 	= root + "include/coach_thanks.asp";
			$.post(url,{q:q,cID:x},
			function(){
			$("#coachquestion").hide();
			$("#coachbedankt").show();
			});

			
		}
	}