// JavaScript Document
$(document).ready(function() {		
	
		//Execute the slideShow
		//slideShow();
		$('#registration').click(function(){
                    $('#overlay').fadeIn('fast',function(){
                        $('#box').animate({'top':'75px'},500);
                    });
                });
                $('#boxclose').click(function(){
                    $('#box').animate({'top':'-1000px'},500,function(){
                        $('#overlay').fadeOut('fast');
						 $('#formRegister').fadeOut('fast');
                    });
                });
		
		var headline_count;
		 var headline_interval;
		 var old_headline = 0;
		 var current_headline = 0;
		 
		 

		// $(document).ready(function(){
		   headline_count = $("div.headline").size();
		   $("div.headline:eq("+current_headline+")").css('top','5px');
		 
		   headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
		   $('#scrollup').hover(function() {
			 clearInterval(headline_interval);
		   }, function() {
			 headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
			 headline_rotate();
		   });
		 
		 
		 function headline_rotate() {
		   current_headline = (old_headline + 1) % headline_count; 
		   $("div.headline:eq(" + old_headline + ")").animate({top: -255},"slow", function() {
			 $(this).css('top','210px');
		   });
		   $("div.headline:eq(" + current_headline + ")").show().animate({top: 5},"slow");  
		   old_headline = current_headline;
		 	}
		
	   $("#topnews").click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?type=news&sid="+Math.random(),hideLoader);  
	   });
	    $("#moreNews").click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?type=news&sid="+Math.random(),hideLoader);  
	   });
	   $(".news").click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?type=news&sid="+Math.random(),hideLoader);  
	   });
	   $(".bulletin").click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?type=bulletin&sid="+Math.random(),hideLoader);  
	   });
	   $(".blogs").click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?type=blogs&sid="+Math.random(),hideLoader);  
	   });
	   $("#moreblogs").click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?type=blogs&sid="+Math.random(),hideLoader);  
	   });
	   $("#moretrivia").click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?type=trivia&sid="+Math.random(),hideLoader);  
	   });
	   $("#topArticles").click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?type=article&sid="+Math.random(),hideLoader);  
	   });
	   $("#topblogs").click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?type=blogs&sid="+Math.random(),hideLoader);  
	   });
	   $(".sntpost").click(function(){ 
		  	$("#side").load("process.php?type=publication&side=1&sid="+Math.random(),hideLoader);  
	   });
	   $(".dostdigest").click(function(){ 
		  	$("#side").load("process.php?type=publication&side=2&sid="+Math.random(),hideLoader);  
	   });
	   $('#health').click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?sidetitle=Health+/+Medical+Sciences&type=categories&cat=54&sid="+Math.random(),hideLoader);  
	   });
	   $('#basic').click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?sidetitle=Basic+Sciences&type=categories&cat=46&sid="+Math.random(),hideLoader);  
	   });
	   $('#forest').click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?sidetitle=Forest+Products&type=categories&cat=45&sid="+Math.random(),hideLoader);  
	   });
	   $('#textile').click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?sidetitle=Textile&type=categories&cat=39&sid="+Math.random(),hideLoader);  
	   });
	   $('#agriculture').click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?sidetitle=Agriculture+Natural+Resources&type=categories&cat=40&sid="+Math.random(),hideLoader);  
	   });
	    $('#ndm').click(function(){ 
			showLoader();
		  	$("#side").load("process.php?sidetitle=Natural+Disaster+en+Mitigation&type=categories&cat=41/35&i=multi&sid="+Math.random(),hideLoader);  
	   });
	   $('#industry').click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?sidetitle=Industry+and+Business&type=categories&cat=44/42/39/43&i=multi&sid="+Math.random(),hideLoader);  
	   });
	   $('#technology').click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?sidetitle=ICT&type=categories&cat=52&sid="+Math.random(),hideLoader);  
	   });
	   $('#food').click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?sidetitle=Food+en+Nutrition&type=categories&i=categories&cat=58&sid="+Math.random(),hideLoader);  
	   });
	   $('#pagasa').click(function(){ 
	   		showLoader();
		  	$("#side").load("process.php?sidetitle=Weather+Bulletins&type=categories&i=categories&cat=35&sid="+Math.random(),hideLoader);  
	   });

		$('#logout').click(function(){ 
			showLoader();
		  	$("#wrapper").load("includes/logout.php?ac=logout&sid="+Math.random(),hideLoader);  
	   });
	   
	   $("ul.thumb li").hover(function() {
		$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
		$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
			.animate({
				marginTop: '-210px', /* The next 4 lines will vertically align this image */ 
				marginLeft: '-130px',
				top: '100%',
				left: '100%',
				width: '440px', /* Set new width */
				height: '529px'/* Set new height */
			//	padding: '20px'
			}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
	
		} , function() {
		$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
		$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
			.animate({
				marginTop: '0', /* Set alignment back to default */
				marginLeft: '0',
				top: '5px',
				left: '0',
				width: '100px', /* Set width back to default */
				height: '130px', /* Set height back to default */
				padding: '5px'
			}, 400);
		});

	   //show loading bar
		function showLoader(){
			document.getElementById("loading").style.display='';
			$('#loading').fadeIn(200);
		}
		//hide loading bar
		function hideLoader(){
			document.getElementById("loading").style.display='none';
			$('#loading').fadeOut(200);
		};
		
	});
