/*
 * Javascripts *
 */
 
 
 /********************
 * Accordinon-nav
 *********************/
$(function() {
    $(".navi_contents h2").hover(function(){
        $(this).css("cursor","pointer");
    },function(){
        $(this).css("cursor","default");
        });
    $(".navi_contents ul").css("display","none");
    $(".navi_contents ul.open").css("display","block");
    $(".navi_contents h2").click(function(){
        $(this).next().slideToggle("100");
    });
});

/********************
 * smartColumns
 *********************/
 
function smartColumns() { //Create a function that calculates the smart columns

        //Reset column size to a 100% once view port has been adjusted
	$("ul.column").css({ 'width' : "100%"});

	var colWrap = $("ul.column").width(); //Get the width of row
	var colNum = Math.floor(colWrap / 200); //Find how many columns of 200px can fit per row / then round it down to a whole number
	var colFixed = Math.floor(colWrap / colNum); //Get the width of the row and divide it by the number of columns it can fit / then round it down to a whole number. This value will be the exact width of the re-adjusted column

	$("ul.column").css({ 'width' : colWrap}); //Set exact width of row in pixels instead of using % - Prevents cross-browser bugs that appear in certain view port resolutions.
	$("ul.column li").css({ 'width' : colFixed}); //Set exact width of the re-adjusted column	

}	

smartColumns();//Execute the function when page loads

$(window).resize(function () { //Each time the viewport is adjusted/resized, execute the function
	smartColumns();
});



 /********************
 * accordion lists
 *********************/
 
 // JavaScript Document

$(document).ready(function() {
	$(".navi dt").hover(function(){
		$(this).css("cursor","pointer"); 
	},function(){
		$(this).css("cursor","default"); 
		});
	$(".navi dd").css("display","none");
	$(".navi dt").click(function(){
		$(this).next().slideToggle("fast");
		});
});

 
 	$(document).ready(function () {
		
		$('#accordion li').click(function () {

			//slideup or hide all the Submenu
			$('#accordion li').children('ul').slideUp('fast');	
			
			//remove all the "Over" class, so that the arrow reset to default
			$('#accordion li > a').each(function () {
				if ($(this).attr('rel')!='') {
					$(this).removeClass($(this).attr('rel') + 'Over');	
				}
			});
			
			//show the selected submenu
			$(this).children('ul').slideDown('fast');
			
			//add "Over" class, so that the arrow pointing down
			$(this).children('a').addClass($(this).children('li a').attr('rel') + 'Over');			

		});
	
	});


 /********************
 * Ameba Blog lists
 *********************/

google.load("feeds", "1");  
function initialize()
{  
 //RSSフィードの取得
 var feed = new google.feeds.Feed("http://feedblog.ameba.jp/rss/ameblo/oita-cworks/rss20.xml");  
 
 //取得するフィード数
 feed.setNumEntries(6)
 
 //実際に読む込む
 feed.load(function(result)
 {  
 
  //読み込めたか判別
  if (!result.error)
  {
   //表示部分を選択
   var container = document.getElementById("feed");
  
   //変数の初期化
   var list = "";
  
   //Feedの処理
   for (var i = 0; i < result.feed.entries.length; i++)
   {  
    //Feedを一つ抽出
    var entry = result.feed.entries[i];
 if(entry.title.match(/^PR:/)) {
 //「PR:」から始まるものがあれば何もしない
 }
 else{
    var div = document.createElement("li");  
    var a = document.createElement("a");
    var strdate = createDateString(entry.publishedDate);
    a.href = entry.link;  
          var list = entry.title + " (" + strdate + ")" ;  
          a.appendChild(document.createTextNode(list));  
          div.appendChild(a);  
          container.appendChild(div);  
        }
  
  }  
     }  
   });  
}

//日付の表示方法を変更
function createDateString(publishedDate)
{
 var pdate = new Date(publishedDate);
 var pday = pdate.getDate();
 var pmonth = pdate.getMonth() + 1;
 var pyear = pdate.getFullYear();
 var phour = pdate.getHours();
 var pminute = pdate.getMinutes();
 var psecond = pdate.getSeconds();
 //var strdate = pyear + "年" + pmonth + "月" + pday + "日" + phour + "時" + pminute + "分" + psecond + "秒";
 var strdate = + pmonth + "-" + pday ;
 return strdate;
}

google.setOnLoadCallback(initialize);  


 /********************
 * FBwall-include
 *********************/

		$(function(){
			$('#choinomiya-oita').fbWall({ id:'choinomiya.oita',accessToken:'236945923026026|2eAumr1rWcGR8ak9fpso0ufWKU0',showGuestEntries:false,showComments:true,max:5,timeConversion:24});
		});

		$(function(){
			$('#oitagenkisakaba').fbWall({ id:'290342910982573',accessToken:'236945923026026|2eAumr1rWcGR8ak9fpso0ufWKU0',showGuestEntries:false,showComments:true,max:5,timeConversion:24});
		}); 
		
		$(function(){
			$('#oitagenkisakaba-funai').fbWall({ id:'119588408144542',accessToken:'236945923026026|2eAumr1rWcGR8ak9fpso0ufWKU0',showGuestEntries:false,showComments:true,max:5,timeConversion:24});
		}); 

		$(function(){
			$('#esquina').fbWall({ id:'258544267489356',accessToken:'236945923026026|2eAumr1rWcGR8ak9fpso0ufWKU0',showGuestEntries:false,showComments:true,max:5,timeConversion:24});
		});

		$(function(){
			$('#mizuyasora').fbWall({ id:'154428867981321',accessToken:'236945923026026|2eAumr1rWcGR8ak9fpso0ufWKU0',showGuestEntries:false,showComments:true,max:5,timeConversion:24});
		});

		$(function(){
			$('#tayutau1').fbWall({ id:'165222780230383',accessToken:'236945923026026|2eAumr1rWcGR8ak9fpso0ufWKU0',showGuestEntries:false,showComments:true,max:5,timeConversion:24});
		});
		
		$(function(){
			$('#carmkitchen').fbWall({ id:'263606010344560',accessToken:'236945923026026|2eAumr1rWcGR8ak9fpso0ufWKU0',showGuestEntries:false,showComments:true,max:5,timeConversion:24});
		});
		
		$(function(){
			$('#tayutau-kokura').fbWall({ id:'204783236255495',accessToken:'236945923026026|2eAumr1rWcGR8ak9fpso0ufWKU0',showGuestEntries:false,showComments:true,max:5,timeConversion:24});
		});
		
