// JavaScript Document
$(document).ready(function(){
	var $times =  Math.random();
	var $loader = $('<div class="loading"><img src="images/globe64.gif" style="border:none;" alt=""/></div>'); 
	$("#rss-news").empty().html($loader);
	$.get("update_rss.php?cat=lastest&time="+$times,function(req){		
		$("#rss-news").empty().html(req);
	});
	$("ul.rss li a").live("click",function(){
		$(this).parent().addClass("current").siblings().removeClass("current");
		$("#rss-news").empty().html($loader);
		var cat = $(this).attr("rel");
		$.get("update_rss.php?cat="+cat+"&time="+$times,function(req){		
			$("#rss-news").empty().html(req);
		});
	});	
	
	// tab table
	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
	// tab table
	
	
});



function checkComment(){
	if(document.comment.name.value == ""){
		alert("กรุณากรอกชื่อด้วยค่ะ");
		document.comment.name.focus();
		return false;
	}else if(document.comment.message.value == ""){
		alert("กรุณากรอกข้อความด้วยค่ะ");
		document.comment.message.focus();
		return false;
	}else if(document.comment.security.value == ""){
		alert("กรุณากรอกรหัสการโพสด้วยค่ะ");
		document.comment.security.focus();
		return false;
	}else{
		return true;	
	}	
}


