 jQuery(document).ready(function(){
	 
	 	// set ajax cache
	 	jQuery.ajaxSetup ({  
    		cache: false
		 }); 
	 
	/*  find block to add corner */
	jQuery(".art-Block").each(function(index){
		if(jQuery(this).find(".art-BlockHeader").length){
			jQuery(this).find(".art-BlockContent-body").corner("bottom");	
			
		}else{
			jQuery(this).find(".art-BlockContent-body").corner();	
			
		}
	});
	
	jQuery("#mod_search_searchword ").focus(function(){
		jQuery(this).css("color","black");
	});
		
	/* round corner  */
		 jQuery(".art-Footer-background").corner("bottom"); 
	 
	/*resize panel*/
	
	var td1 = jQuery("#yoo-carousel-1 .slide").eq(0).find(".moduletable td").height();
	var td2 = jQuery("#yoo-carousel-1 .slide").eq(1).find(".moduletable td").height();
	td1 = td1+40;
	td2 = td2+40;
	jQuery("#yoo-carousel-1 .button a").eq(0).click(function(){
		jQuery("#yoo-carousel-1 .panel").animate({"height":(td1+"px")},"slow");
	})
	jQuery("#yoo-carousel-1 .button a").eq(1).click(function(){
		
		jQuery("#yoo-carousel-1 .panel").animate({"height":(td2+"px")},"slow");
	})
	
	/* 	 left menu  */
		/* add class for each row */
       jQuery(".leftNostyle").find("tr:eq(0)").addClass("menuTr1");
       jQuery(".leftNostyle").find("tr:eq(1)").addClass("menuTr2");
       jQuery(".leftNostyle").find("tr:eq(2)").addClass("menuTr3");
       jQuery(".leftNostyle").find("tr:eq(3)").addClass("menuTr4");
       jQuery(".leftNostyle").find("tr:eq(4)").addClass("menuTr5");
       jQuery(".leftNostyle").find("tr:eq(5)").addClass("menuTr6");
       
     /*  left menu effect hover*/
       jQuery("tr[class^=menuTr]").hover(
       function () {
       		jQuery(this).css("background-position","-207px");
      	}, 
      	function () {
      	  jQuery(this).css("background-position","0");
     	 }
		);
		
		/* add class for new magazine */
		jQuery(".art-sidebar1").find("div.art-Block-body:first").addClass("newMagazine");
		
		/* this script add color for Knowledge and Industrial spanding in firstpage */
		jQuery(".position h2:eq(0)").addClass("purpleCenter1").corner("top 7px");
		jQuery(".position h2:eq(1)").addClass("purpleCenter2").corner("top 7px");
		
		
		jQuery(".position .list:eq(0) li:even").css("background","#A1A8E0");
		jQuery(".position .list:eq(0) li:odd").css("background","#CCD0E7");
		jQuery(".position .list:eq(1) li:even").css("background","#C6B7E4");
		jQuery(".position .list:eq(1) li:odd").css("background","#DCCDE8");
		
		
	/* first page tab */
		/* add curve and background color for heading tab*/
		jQuery("#yoo-carousel-2").find(".slide:eq(0)").find(".name").css("color","#2E1F73");
		jQuery("#yoo-carousel-2").find(".slide:eq(1)").find(".name").css("color","#6E2E72");
		jQuery("#yoo-carousel-2").find(".slide:eq(2)").find(".name").css("color","blue");
		
		
		/* li button eq 0 mean first li of id yoo-carousel-2 */
		
		/* blue one */
		jQuery("#yoo-carousel-2 li.button:eq(0) span span").addClass("centerTab1");
		jQuery("#yoo-carousel-2 li.button:eq(0) span").corner("top");
		
		/* purple one */
		jQuery("#yoo-carousel-2 li.button:eq(1) span span").addClass("centerTab2");
		jQuery("#yoo-carousel-2 li.button:eq(1) span").corner("top");
				
		/* red one */
		jQuery("#yoo-carousel-2 li.button:eq(2) span span").addClass("centerTab3");
		jQuery("#yoo-carousel-2 li.button:eq(2) span").corner("top");
			
		/*  fade when mouse over link for whole page */
		jQuery(".zoo-item li").hover(
			function(){
				jQuery(this).fadeTo("fast", 0.85);

			},
			function(){
				jQuery(this).fadeTo("fast", 1);
			});		
			
	jQuery(".sub-category").hover(function(){
	jQuery(this).css({"background-color":"#E3E3E2"});
	},
	function(){
		jQuery(this).css({"background-color":"#FFFFFF"});
	});		

				
 });
 
/*  end document ready  */
     
    /* ajax paging function */
    
	 /*
		urlInput = current url
	    montval = month for show start from 1
	    total page = total page count get form last month - first month
	*/
	function changePage ( urlInput , page , totalpage) {
		var  remoteUrl = urlInput+"&page="+page;
		var html_out = "";
		var thispage = page;
		  jQuery.ajax({
		    type: "POST",
		    url: remoteUrl,
		    
		    contentType: "application/json; charset=utf-8",
		    success: function(responseHtml) {
		      // Render the resulting data, via template.
		      
		     /*  if success load data under .zoo-item-list only , not load all page */
		      jQuery(".zoo-item-list").load(remoteUrl+" .list .zoo-item-list");
    		}
    	});	
    	
    		/* paging logic */
    		if(thispage > 1){
    			html_out+="&laquo; <a href=javascript:changePage('"+urlInput+"',"+(thispage-1)+","+totalpage+")>Prev</a>";
    		}
    		if(thispage > 5)
    		{
    			html_out+=" <a href=javascript:changePage('"+urlInput+"',"+1+","+totalpage+") id='navig_"+1+"'>"+1+"</a>...";
    		}
			var count = 0;
			for(var i = (thispage-5) ; i <= totalpage ; i ++ )
			{
				if(i<1)
					continue;	
					
				count ++;
				if (i == thispage) {
				html_out += " ["+i+ "] ";
				}
				else {
					html_out += " <a href=javascript:changePage('" + urlInput + "'," + (i) + "," + totalpage + ") id='navig_" + (i) + "'>" + (i) + "</a>";
				}
				if(i >= thispage)
				{
					break;
				}	
			}
			
			var count = 0;
			
    		for(var i = 1 ; i < 5; i++ )
			{
				if((thispage+i) > totalpage){
					
					break;
				}
				
				count ++;
				html_out+=" <a href=javascript:changePage('"+urlInput+"',"+(thispage+i)+","+totalpage+") id='navig_"+(thispage+i)+"'>"+(thispage+i)+"</a>";
				if(count > 5)
				{
					break;
				}	
				
			}


    		if(totalpage - thispage > 5 ) {
    			html_out+="...<a href=javascript:changePage('"+urlInput+"',"+totalpage+","+totalpage+") id='navig_"+i+"'>"+totalpage+"</a>";
    		}
    		if(thispage < totalpage ) {
    			html_out+=" <a href=javascript:changePage('"+urlInput+"',"+(thispage+1)+","+totalpage+")>Next</a> &raquo;"
    		}
    		/* end paging logic */
    		jQuery(".paging_list").html(html_out);    	
    			

  		
	}
	





