/*
 * by Diwa G. Fernandez
 * Date: 2009-12-07 15:45 +8 GMT
 * Revision: 1
 * Dragonica_Theme
 */


/*************************************************
 * Global Helper
 *************************************************/
function DO(domId) {
	return window.document.getElementById(domId);
}

function onNewsTabClick(linkId,url) {
	var source = url;
	var linkId = linkId;
	//$('#newscontent').hide(500) ;
	$("#tab-news-title").animate({
		opacity: 0
      }, 100 );

	$('#newscontent .loading').load( source + '/home-news-data.php?page=' + linkId,
		function() {
            checkNewsTabActive(linkId);
			$("#tab-news-title").animate({
					opacity: 1
			}, 500 );
    })
	
}

function checkNewsTabActive(linkId){
	if (linkId == 'updates') {
		DO('tab-all').className = "tab-all inactive";
		DO('tab-news').className = "tab-news inactive";
		DO('tab-updates').className = "tab-updates active";
	} else if (linkId == 'news'){
		DO('tab-all').className = "tab-all inactive";
		DO('tab-news').className = "tab-news active";
		DO('tab-updates').className = "tab-updates inactive";
	} else {
		DO('tab-all').className = "tab-all active";
		DO('tab-news').className = "tab-news inactive";
		DO('tab-updates').className = "tab-updates inactive";
	}

}

function goto(strURL) {
	location.href = strURL;
}

$(document).ready(function(){
		var btnSkul = '#btn-school-sprite li a';
		var btnDL = '#btn-dl-sprite li a';
		var tabShop = '#shop-tab';
		
		/*For the home school etc tab*/
		$(btnSkul).mouseout( function () {
				$(this).removeClass('hover');
		})
		$(btnSkul).mouseover( function () {
				$(this).addClass('hover');
		})
		$(btnSkul).click( function () {
				$(btnSkul).removeClass('hover');
				$(btnSkul).removeClass('active');
				var $data = $(this).attr("class");
				var $setDiv = '.' + $data + '-content';
				$(this).addClass('active');
				$(this).parent().parent().parent().find('.storycontent').css({'z-index':'1'});
				$(this).parent().parent().parent().find($setDiv).css({'z-index':'999'});
		})
		/*For the home Screenshot tab*/
		$(btnDL).mouseout( function () {
				$(this).removeClass('hover');
		})
		$(btnDL).mouseover( function () {
				$(this).addClass('hover');
		})
		$(btnDL).click( function () {
				$(btnDL).removeClass('hover');
				$(btnDL).removeClass('active');
				var $data = $(this).attr("class");
				var $setDiv = '.' + $data + '-content';
				$(this).addClass('active');
				$(this).parent().parent().parent().find('.storycontent').css({'z-index':'1'});
				$(this).parent().parent().parent().find($setDiv).css({'z-index':'999'});
		})
		$(tabShop).find("li").each(function(){
			$(this).append('<span class="af">&nbsp;</span>');
			$(this).prepend('<span class="bf">&nbsp;</span>');
		});
		$('#shop-tab li').mouseover( function () {
			$(this).addClass('hover');
		})
		$('#shop-tab li').mouseout( function () {
			$(this).removeClass('hover');
		})
/*		$("#sns a").hover(function() {
			var $t = this.title;
			$(this).attr("title", "")
			$(this).append("<em id='tooltip'>"+ $t +"</em>");
			$("#tooltip")
				.fadeIn(500);
			}, function() {
				t = $("#tooltip").text();
				$(this).attr("title",t)
				$("#tooltip").remove();
		});*/

});
