// perform JavaScript after the document is scriptable.


function ajax_will_paginate(s){
 $.ajax({
		 type: "POST",
		 url: "index/blog_paginate?page="+s,
		 success: function(msg){
			 $("div.blog[style='display: block;']").html(msg);
			 replace_paginate_links();
		 }
	 });
}


function replace_paginate_links(){
	$('div.pagination a').each(function(){
		var new_attr = "ajax_will_paginate"
		var get_href_a = $(this).attr('href').split('=');
		var get_href = get_href_a[get_href_a.length-1]
		
		$(this).attr('href',"#")
		$(this).attr('onclick',"ajax_will_paginate('"+get_href+"'); return false;")
	})
}

$(function() {
	// setup ul.tabs to work as tabs for each div directly under div.panes
	$("ul.tabs").tabs("div.panes > div");
	
  $('#gallery a.gall').lightBox();
	
	replace_paginate_links()
	
	
	
	

	
	//~ $('div.pagination a').click(function(){
	
		//~ var obj = {
			//~ 'page':$(this).attr('href')
		//~ }
		
		
		
		
		 //~ $.ajax({
		 //~ type: "POST",
		 //~ url: "index/blog_paginate"+$(this).attr('href'),
		 //~ success: function(msg){
			 //~ $('div.blog').html(msg);
			 
		 //~ }
	 //~ });
	 
	 //~ return false;
	//~ })
	 
	
	var t3 = $("ul.tabs li");
	$(t3[2]).css('border-right','1px solid gray');
	
	function checkCurrent(){
		$("ul.tabs li a").each(function(){
				
				if($(this).hasClass('current')){

						var cssObj = {
								'border-bottom' : 'none',
								'background-color' : 'white'
						};

						$(this).parent().css(cssObj);
				}else{
				
						var cssObj = {
								'border-bottom' : '1px solid gray',
								'background-color' : '#ccc'
						};
						$(this).parent().css(cssObj);
				}
		})
	}
	
	
	$("ul.tabs li a").live('click',checkCurrent);
	checkCurrent();
	//slider
	

	$("#slider").easySlider({
		auto: true,
		continuous: true,
		orientation: 'horizontal',
		speed: 800,
		pause: 12000,
		numeric : 'true',
		numericId: 		'controls'
	});

});
