var prUrl="http://www.bethelp.gr";

$(document).ready(function() {
	$("div.wcNewsTitle").click(function() {
		$("div.wcNewsAbs").hide();
		$("div.wcNewsTitle").removeClass("wcNewsTitleOn");
		$("div.wcNewsTitle").children("div.wcRelative").addClass("wcContOff");
		$(this).addClass("wcNewsTitleOn");
		$(this).children("div.wcRelative").removeClass("wcContOff");
		$(this).next("div.wcNewsAbs").show();
		$(".wcNewsImg").css("background-image","url("+$(this).children(".imgSrc").val()+")");
	});
});


$(document).ready(function() {
	$("div.wcMenuItem").click(function() {
		
		/// Highlight proper menu button
		$("div.wcMenuItem").removeClass("wcMenuItemOn");
		$(this).addClass("wcMenuItemOn");
		
		/// Loop though buttons. Determine which is clicked and show appropriate content
		var divIndex=0;
		$("div.wcMenuItem").each(function(index) {
			if ( $(this).hasClass("wcMenuItemOn") ) {
				divIndex=index;
			}
		});
		
		/// Loop though content and show appropriate based on index
		$("div.wcCont").each(function(index) {
			if ( divIndex == index ) {
				$(this).removeClass("wcContOff");
				if ( divIndex == 3 ) {
					$("div.wcBack").css("height","900px");
				} else {
					$("div.wcBack").css("height","200px");
				}
			} else {
				$(this).addClass("wcContOff");
			}
		});
		
	});
});

/*
$(function() {
	$(".wcTables").jCarouselLite({
		vertical: true,
		visible: 1,
		start: 1,
		speed: 1000,
		btnGo: [".0", ".1", ".2", ".3", ".4", ".5", ".6", ".7"]
	});
});
*/

function initRoster() {
	$(function() {
		$(".wcRoster").jCarouselLite({
			vertical: true,
			visible: 7,
			scroll: 7,
			speed: 1000,
			circular: false,
			btnNext: ".wcDown",
        		btnPrev: ".wcUp"
		});
	});
}


$(document).ready(function() {
	$("div.wcCont").each(function(index) {
		if ( index > 0 ) {
			$(this).addClass("wcContOff");
		}
	});
});


$(document).ready(function() {
	$("div.groupButton").click(function() {
		$("div.groupButton").removeClass("groupButtonOn");
		$(this).addClass("groupButtonOn");
		$("div.wcTables").hide();
		$("#table_"+$(this).attr("id")).show();
	});
});


$(document).ready(function() {
	$("img.wcImgTeam").click(function() {
		$("img.wcImgTeam").removeClass("wcImgTeamOn");
		$(this).addClass("wcImgTeamOn");
		$(".wcRoster").html("Φορτώνεται η λίστα παικτών...");
		$(".wcUp").show();
		$(".wcDown").show();
		$("div.wcTeamTitle").html($(this).attr("title"));
		$.ajax({
			url: prUrl+"/ajax/roster.php?team="+$(this).attr("id"),
			type: "GET",
			dataType: "text",
			timeout: 5000,
			cache: false,
			error: function(){
				//alert("Error loading XML document");
			},
			success: function(text){
				$(".wcRoster").html(text);
				initRoster();
				$(".wcPlayer").show();
			}
		});
	});
});


$("li.wcRPlayer").live("click", function() {
	$("li.wcRPlayer").removeClass("wcRPlayerOn");
	$(this).addClass("wcRPlayerOn");
	$(".wcPlayer").html("Φορτώνονται τα στοιχεία του παίκτη...");
	$.ajax({
		url: prUrl+"/ajax/player.php?id="+$(this).attr("id"),
		type: "GET",
		dataType: "text",
		timeout: 5000,
		cache: false,
		error: function(){
			//alert("Error loading XML document");
		},
		success: function(text){
			$(".wcPlayer").html(text);
		}
	});
});

