function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function store_order(){
	var order="";
	$(".column").each(function(){
		order='';
		$(this).children().each(function(){
			if ($(this).attr("id")!="intro"){
				order+=$(this).attr("sort")+"|";
			}
		});
		createCookie($(this).attr('id'),order,99);
	});
	var test= $.get('/personeel/savestate.php');
}
function colapse(obj1,obj2)
{    if (obj1.style.display=="none") //Check if orderlines are expanded or collapsed
     {obj1.style.display=""; //collapse the orderlines
      obj2.src="/images/min.gif" //change the order picture to min
     }
     else
     {obj1.style.display="none"; //collapse the orderlines
      obj2.src="/images/plus.gif"; //change the order picture to min
     }
}
function show_url(uri){
	window.open(uri);
}
function show_route(){
	window.open("/route.php","VanBeekRoute","width=700,height=800,scrollbars=yes");
}

	function setvals(){
		steps=Math.ceil(($("#content").height()/$('#scrolldiv').height()));
		percent=100/steps;
		$('#slider').css("height",percent+"%");
		if (steps==1){$("#scrollbar").hide();}
	}
	var show_agent=function(country){

		switch (country){
			case "NL":{
				$(".agentdetails").slideUp( "slow" );
				$("#agentnetherlands").slideDown("slow");
			break;
			}
			case "NL":{
				$(".agentdetails").slideUp( "slow" );
				$("#agentnetherlands").slideDown("slow");
			break;
			}
			case "CH":{

				$(".agentdetails").slideUp( "slow" );
				$("#euromap").fadeOut("slow");
				$("#agentchina").slideDown("slow");
			break;
			}
			case "MA":{
				$(".agentdetails").slideUp( "slow" );
				$("#euromap").fadeOut("slow");
				$("#agentsingap").slideDown("slow");
			break;
			}
			case "DK":{
				$(".agentdetails").slideUp( "slow" );
				$("#agentdenmark").slideDown("slow");
			break;
			}
			case "FR":{
				$(".agentdetails").slideUp( "slow" );
				$("#agentfrance").slideDown("slow");
			break;
			}
			case "ES":{
				$(".agentdetails").slideUp( "slow" );
				$("#agentspain").slideDown("slow");
			break;
			}
			case "IT":{
				$(".agentdetails").slideUp( "slow" );
				$("#agentitaly").slideDown("slow");
			break;
			}
			case "DE":{
				$(".agentdetails").slideUp( "slow" );
				$("#agentDE1").slideDown("slow");
				break;
			}
			case "PL":{
				$(".agentdetails").slideUp( "slow" );
				$("#agentpoland").slideDown("slow");
			break;
			}
			case "HU":{
				$(".agentdetails").slideUp( "slow" );
				$("#agenthongary").slideDown("slow");
			break;
			}

			case "EU":{
				$("#euromap").fadeIn("slow");
			break;
			}
			case "EU_NO":{
				$("#euromap").fadeOut("slow");
			break;
			}
			default:{

			}
		}
	}
$(document).ready(function(){
	$("#hor-navlist li").mouseover(function(){
      		$(this).addClass("hovernavlist");
    		}).mouseout(function(){
      			$(this).removeClass("hovernavlist");
    		});
	$("#hor-navlist li").click(function(){
			document.location=$(this).attr('href');
			});
	$("#hor-subnavlist li").mouseover(function(){
      		$(this).addClass("hoversubnavlist");
    		}).mouseout(function(){
      			$(this).removeClass("hoversubnavlist");
    		});
    $("#hor-subnavlist li").click(function(){
			document.location=$(this).attr('href');
			});
    $("#ver-navlist li").mouseover(function(){
      		$(this).addClass("hoverdropnavlist");
    		}).mouseout(function(){
      			$(this).removeClass("hoverdropnavlist");
    		});
	$("#ver-navlist li").click(function(){
			document.location=$(this).attr('href');
			});



	$('#down').click(function(){
		/*if (currentstep<(steps-1)){
			$('#scrolldiv').scrollTo('+=500px');
			currentstep+=1;
			slidertop=currentstep*percent;
			if((slidertop+percent)>100){slidertop=100-percent;}
			$('#slider').css("top",slidertop+"%");
		}*/
		var sliderposition=$("#slider").position().top+$("#slider").height();
		if (sliderposition<=$("#sliderback").height()-$("#slider").height()){
			$('#scrolldiv').scrollTo($("#slider").css("top",sliderposition).position().top*steps);
		}else{
			$('#scrolldiv').scrollTo($("#slider").css("top",$("#sliderback").height()-$("#slider").height()).position().top*steps);
		}
	});
	$('#up').click(function(){
		/*if (currentstep>0){
			$('#scrolldiv').scrollTo('-=500px');
			currentstep-=1;
			slidertop=currentstep*percent;
			if((slidertop)<0){slidertop=0;}
			$('#slider').css("top",slidertop+"%");
		}*/
		var sliderposition=$("#slider").position().top-$("#slider").height();
		if (sliderposition>=0){
			$('#scrolldiv').scrollTo($("#slider").css("top",sliderposition).position().top*steps);
		}else{
			$('#scrolldiv').scrollTo($("#slider").css("top",0).position().top*steps);
		}
	});

	$('.productcat').mouseover(function(){
		$(this).addClass('hover');
		//$(this).children('p').addClass('hover');;
	}).mouseout(function(){
      			$(this).removeClass("hover");
    		});

	$('.productcat').click(function(){
		document.location=$(this).attr('href');
	});

	$('#thumbs img').click(function(){
		$('#mainpic img').fadeOut(1000);
		var element=$(this).attr('large');
		$("#"+element).fadeIn(2000);
	});
	$('#agendablock').click(function(){
		document.location="/agenda.php";
	});


	function drag_slider(e, ui){
//			alert(ui.position.top);
			$('#scrolldiv').scrollTo(ui.position.top*steps);
		}
	$("#slider").draggable({
		axis:'y',
		containment:'parent',
		drag:drag_slider
	});
	$(".stipedtable tr").mouseover(function(){$(this).addClass("over");}).mouseout(function(){$(this).removeClass("over");});
   	$(".stipedtable tr:even").addClass("alt");

	setTimeout ("setvals();",100);

	$("#scrollable").prepend("<a class=\"prev\"></a>");
	$("#scrollable").append("<div class=\"navi\"></div>");
	$("#scrollable").append("<a class=\"next\"></a>");
	$("#scrollable").scrollable({items:'.items',horizontal:false,size:4});
	$(".navi").click(function(){
		alert($(this).height());
	});
});

