// functies fitnessclub

function initialize(dump) {
	menu_hover(0);

	/*
	opencard = window.location.hash;
	if(opencard.indexOf('#unsubscribe') == 0) {
		show_unsubscribe(true);
	} else if(opencard.indexOf('#confirm') == 0) {
		show_confirm(true)
	} else if(opencard.indexOf('#nieuwsbrief') == 0) {
		show_register(true);
	} else if(opencard.indexOf('#ecard') == 0) {
		show_ecard(true);
	}
	*/

	var ahref;
	$(".specialprevent").click(function(e) {
		e.preventDefault();
		ahref = $(this).attr('class');
		ahref= ahref.replace("specialprevent special", "");
		popup(0); waiter(1);
		$.get("ajax/special.php", { id: ahref }, function(data) {
			waiter(0);
			$("#popupContentContent").html(data).fadeIn();
		});
	});

}

// var menu_url = 'http://www.fitnessclubgooimeer.nl/restyle/assets/images/menu_v3/';
var menu_url = 'http://www.fitnessclubgooimeer.nl/assets/images/menu_v3/';
var menuid;

function enlarge_member(target,what) {
	if($("#"+target).hasClass("open")) {
		close_enlarge(0);
	} else {
		close_enlarge(0);
		$("#"+target).html('<a href="javascript:close_enlarge(0);" class="close">[x]</a>'+$("#"+what).html()).show().addClass("open");
		$("#"+what).css({visibility:'hidden'});
	}
}
function close_enlarge(fpp) {
	$(".target").hide().removeClass("open");
	$(".memberimg").css({visibility:'visible'});
}
function opentour() {
	popup(0); waiter(1);
	$.get("/tour/layover.html", function(data) {
		waiter(0);
		$("#popupContentContent").html(data).show();
	});

	/*
	str='/tour/pano.html' ;
	isn = window.open(str,'isn','width=382,height=299,left=200,top=140,statusbar=yes,scrollbars=no');
	isn.opener = self;
	*/
	
}

function menu_hover(goo) {
	$.swapImage(".swapImage");

	/*
	$('#menu a img').hover(function() {
		menuid = $(this).parent().parent().attr("id");
		$(this).attr("src",menu_url+menuid+"_hover.png");
	}, function() {
		menuid = $(this).parent().parent().attr("id");
		$(this).attr("src",menu_url+menuid+".png");
	});
	*/

}


// mag aangepast worden
var carousel_visible = 4; 	// hoeveel berichten zijn zichtbaar
var carousel_speed = 500; 	// 1000 = 1 seconde
var carousel_pause = 3000;	// 1000 = 1 seconde

// niet aanpassen
var carousel_item_height; 	// wordt automatisch berekend
var carousel_num_items;		// wordt automatisch berekend
var carousel_interval;		// niets mee doen
var carousel_active = -1;	// niets mee doen
var carousel_turnpoint;		// niets mee doen
var carousel_direction = '-';		// niets mee doen
var carousel_maxpause;     // niets mee doen

function newsCarousel(v) {
	carousel_maxpause = carousel_speed+((carousel_pause-carousel_speed)/2);	
	carousel_turnpoint = v-1;
	carousel_item_height = $("ul#newsCarousel li:first").height();
	carousel_num_items = $("ul#newsCarousel li").length;
	
	if(carousel_num_items > carousel_visible) {
		// set an interval to repeat the carousel action
		carousel_interval = setInterval("carousel_do_item();",carousel_pause);
		
		// on mouseover clear the interval (pause)
		$("#newsCarousel").mouseover(function(o) {
			clearInterval(carousel_interval);
		});
		
		// on mouseout, re-init the carousel
		$("#newsCarousel").mouseout(function(o) {
			clearInterval(carousel_interval);
			carousel_interval = setInterval("carousel_do_item();",carousel_pause*2);
		});
	}
}

function carousel_do_item(foo) {

	if(carousel_direction == '-') { carousel_active++; } else { carousel_active--; }
	//status(carousel_active);
	
	$("ul#newsCarousel li").animate({ 
		"top": carousel_direction+"="+carousel_item_height+"px"
	}, carousel_speed);
	
	if(carousel_active == carousel_turnpoint) {
		window.setTimeout('$("ul#newsCarousel li").css({ "top": "0px"});',carousel_maxpause);
		carousel_active = -1;
		//status('rewind');
	}
	
}

function status(w) {
	$("#status").append(" "+w);
}
	
function show_confirm(foo) {
	popup(0); waiter(1);
	$.get("ajax/confirm.php", function(data) {
		waiter(0);
		$("#popupContentContent").html(data).fadeIn();
	});
}
function show_unsubscribe(foo) {
	popup(0); waiter(1);
	$.get("ajax/unsubscribe.php", function(data) {
		waiter(0);
		$("#popupContentContent").html(data).fadeIn();
	});
}
function show_register(foo) {
	popup(0); waiter(1);
	$.get("ajax/nieuwsbrief.php", function(data) {
		waiter(0);
		$("#flashslides").hide();
		$("#popupContentContent").html(data).fadeIn();
	});
}

function popup(foo) {
	$("#popupContentContent").hide();
	$("#popup").show();
}
function popupClose(foo) {
	$("#popup").hide();
	$("#popupContentContent").html('').hide();
	$("#flashslides").show();
}

function waiter(trigger) {
	if(trigger == 1) {
		$("#popupContentContent").html('<div align="center"><img style="padding:40px 0 40px 0;" src="assets/images/ecard/loading.gif" alt="" /></div>').show();
	} else {
		$("#popupContentContent").html('').hide();
	}
}

function showRooster(foo) {
	var type = 'normal';
	if(foo == 'pilates') { type = 'pilates'; }
	if(foo == 'zomer') { type = 'zomer'; }
	if(foo == 'automatic') { type = 'automatic'; }
	
	popup(0); waiter(1);
	$.get("ajax/rooster.php", {type:type}, function(data) {
		waiter(0);
		$("#flashslides").hide();
		$("#popupContentContent").html(data).fadeIn();
	});
}

function overlay_close(foo) {
	$("#overlay").hide();
	$("#overlay_back").hide();
	$("#overlay_contents").html('');
}

