// JavaScript (c) Diffuse Interactive

   	$(document).ready(function(){

   		var timeoutlanden = null;
   		var timeout1 = null;
   		var timeout2 = null;
   		var timeout3 = null;

   		//dropdown landen
   		$("#selectlanguage").hide();

		$("#currlanguage").mouseover(function(){
			$("#selectlanguage").slideDown(200);
			$("#currlanguage").css("background-position", "bottom left");
			if(timeoutlanden)
			{

				clearTimeout(timeoutlanden);
			}

		});

		$("#currlanguage").mouseout(function(){

				timeoutlanden = setTimeout(function(){ hideLanguageSelector()}, 500);
		});

		$("#currlanguage img").mouseover(function(){
			if(timeoutlanden)
			{

				clearTimeout(timeoutlanden);
			}
		});

		$("#selectlanguage").mouseover(function(){
			if(timeoutlanden)
			{
				clearTimeout(timeoutlanden);
			}
		});

		$("#selectlanguage a img").mouseover(function(){
			if(timeoutlanden)
			{
				clearTimeout(timeoutlanden);
			}
		});

		$("#selectlanguage a").mouseover(function(){
			if(timeoutlanden)
			{
				clearTimeout(timeoutlanden);
			}
		});

		$("#selectlanguage").mouseout(function(){
			timeoutlanden = setTimeout(function(){ hideLanguageSelector()}, 500);
		});

		//show code example A
		$(".dropdown").hide();

		//dropdown1
		$("a.handle1").mouseover(function(){
			$("#b1").slideDown(300);
			if(timeout1)
			{
				clearTimeout(timeout1);
			}
		});

		$("a.handle1").mouseout(function(){
			timeout1 = setTimeout(function(){$("#b1").slideUp(300)}, 500);
		});

		$("#b1").mouseover(function(){
			if(timeout1)
			{
				clearTimeout(timeout1);
			}
		});

		$("#b1").mouseout(function(){
			timeout1 = setTimeout(function(){$("#b1").slideUp(300)}, 500);
		});

		//dropdown2
		$("a.handle2").mouseover(function(){
			$("#b2").slideDown(300);
			if(timeout2)
			{
				clearTimeout(timeout2);
			}
		});

		$("a.handle2").mouseout(function(){
			timeout2 = setTimeout(function(){$("#b2").slideUp(300)}, 500);
		});

		$("#b2").mouseover(function(){
			if(timeout2)
			{
				clearTimeout(timeout2);
			}
		});

		$("#b2").mouseout(function(){
			timeout2 = setTimeout(function(){$("#b2").slideUp(300)}, 500);
		});

		//dropdown3
		$("a.handle3").mouseover(function(){
			$("#b3").slideDown(300);
			if(timeout3)
			{
				clearTimeout(timeout3);
			}
		});

		$("a.handle3").mouseout(function(){
			timeout3 = setTimeout(function(){$("#b3").slideUp(300)}, 500);
		});

		$("#b3").mouseover(function(){
			if(timeout3)
			{
				clearTimeout(timeout3);
			}
		});

		$("#b3").mouseout(function(){
			timeout3 = setTimeout(function(){$("#b3").slideUp(300)}, 500);
		});

		$("#content ul li img").mouseover(function() {
			$("#link-" + this.id).addClass('hover');
	   	});
	   	$("#content ul li img").mouseout(function() {
				$("#link-" + this.id).removeClass('hover');
	   	});


   		if($("#topimage IMG").length > 1) {
			setInterval("slideShow()", 3000);
		}

	});

function hideLanguageSelector() {
	$("#selectlanguage").hide();
	$("#currlanguage").css("background-position", "top left");
}

function slideShow() {
    var $active = $('#topimage IMG.active');

    if ( $active.length == 0 ) $active = $('#topimage IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#topimage IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function remindCountry(item) {

	if($(item).attr('checked') == true)
	{

		$('#countries li a').each(
			function() {

				var href = $(this).attr('href');

				if(href.substr(href.length-7, 7) != '/remind'){

					$(this).attr('href',  href + '/remind');
				}
			}
		)

	}
	else
	{
		$('#countries li a').each(
			function() {

				var href = $(this).attr('href');

				if(href.substr(href.length-7, 7) == '/remind'){

					href = href.substring(0,href.length-7);

					$(this).attr('href',  href);
				}
			}
		)
	}
}

function newCaptcha() {
	$("#captcha").attr("src","captcha/" + Math.floor(Math.random()*1000000));
}