// JavaScript Document

//////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// DOCUMENT READY SET UP //////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
$(document).ready(function(){
	
	/*****LOGIN - CLEAR ON CLICK*******************************************************************/
	$("#login .login").click(function(){
		$(this).attr("value", "");
	});
	
	$("#login input").blur(function(){
		if($(this).attr("value") == "") {
			$(this).attr("value", "Username");
		}
	});

	/*****INITIALISE NEWS FEED*********************************************************************/
	var root = $(".scrollable").scrollable({circular: true,speed: 800}).autoscroll({ autoplay: true, interval: 8000 }).navigator({navi:'div.navi', activeClass:'active'});
	
	/*****INITIALISE NEWS TABS*********************************************************************/
	$("ul.tabs").tabs("div.panes > div");
	
	/*****INITIALISE SPONSORS CAROUSEL*************************************************************/
	function mycarousel_initCallback(carousel)
	{
		// Disable autoscrolling if the user clicks the prev or next button.
		carousel.buttonNext.bind('click', function() {
			carousel.startAuto(0);
		});
	 
		carousel.buttonPrev.bind('click', function() {
			carousel.startAuto(0);
		});
	 
		// Pause autoscrolling if the user moves with the cursor over the clip.
		carousel.clip.hover(function() {
			carousel.stopAuto();
		}, function() {
			carousel.startAuto();
		});
	};
	
	$('#mycarousel').jcarousel({
    	wrap: 'circular',
		auto: 4,
		scroll: 1,
		initCallback: mycarousel_initCallback
    });
	
	/*****LOAD RSS FEED*************************************************************/
	$.ajax({
		type:'POST',
		url: '/components/scripts/loadrss.php',
		data:'empty=',
		success: function(data){
				$(".rss").html(data);
		}
	});
	
	/*****TOGGLE SIDE MENU*************************************************************/
	//$(".side-menu").toggle('slide', {}, 1000);
	
	/**** ADMIN TOGGLE FUNCTIONALITY **************************************************/
	$(".toggler").click(function(){
		switch($(this).attr("id")){
			case "toggler1":
				if($("#toggler1 span").html() === "[+]")
					$("#toggler1 span").html("[-]");
				else
					$("#toggler1 span").html("[+]");
				$("#toggle1").toggle('fast');
				break;
			case "toggler2":
				if($("#toggler2 span").html() === "[+]")
					$("#toggler2 span").html("[-]");
				else
					$("#toggler2 span").html("[+]");
				$("#toggle2").toggle('fast');
				break;
			case "toggler3":
				if($("#toggler3 span").html() === "[+]")
					$("#toggler3 span").html("[-]");
				else
					$("#toggler3 span").html("[+]");
				$("#toggle3").toggle('fast');
				break;
			case "toggler4":
				if($("#toggler4 span").html() === "[+]")
					$("#toggler4 span").html("[-]");
				else
					$("#toggler4 span").html("[+]");
				$("#toggle4").toggle('fast');
				break;
			case "toggler5":
				if($("#toggler5 span").html() === "[+]")
					$("#toggler5 span").html("[-]");
				else
					$("#toggler5 span").html("[+]");
				$("#toggle5").toggle('fast');
				break;
			case "toggler6":
				if($("#toggler6 span").html() === "[+]")
					$("#toggler6 span").html("[-]");
				else
					$("#toggler6 span").html("[+]");
				$("#toggle6").toggle('fast');
				break;
		}
	});
	
});


//DELETE PLAYER FUNCTION
function deleteplayer(id)
{
	var agree = confirm('Are you sure you wish to delete this player?');

	var address = '/components/rugby/profiles/delete.php?id=' + id;
	
	if(agree)
	{
		window.location=address;
	}
}

//DELETE ARTICLE FUNCTION
function warning(type, id, url)
{
	var agree = confirm('Are you sure you wish to delete this article?');

	var address = '/admin/delete.php?type=' + type + '&id=' + id + '&url=' + url;
	
	if(agree)
	{
		window.location=address;
	}
}
