
/*----------------------------------------------

	Theme Name: design works onside inc.
	http://www.onside.com/
	Description: home JavaScript　06-03-2011 (mm-dd-yyyy)
	Version: ver. 1.0

----------------------------------------------*/

$(document).ready(function() {

	$('a.lightbox').lightBox();

// 背景画像のスライド（jquery.BgImageTransition）
	var bgImages = [ 'home_images_02.jpg', 'home_images_03.jpg', 'home_images_04.jpg', 'home_images_05.jpg', 'home_images_06.jpg', 'home_images_07.jpg', 'home_images_08.jpg' ];
	var currImage = 'home_images_01.jpg';
	setInterval( function(){
		do{
			var randImage = bgImages[Math.ceil(Math.random()*(bgImages.length-1))];
		}while( randImage == currImage )
		currImage = randImage;
		$('#blaf').BgImageTransition( '/img/home/'+currImage );
	}, 5000)

// グローバルメニューのツールチップ
	/*$('#globalNavi li a').hover(function() {
		$(this).next('em').animate({opacity: 'show', top: '-75'}, 'slow');
	}, function() {
		$(this).next('em').animate({opacity: 'hide', top: '-60'}, 'fast');
	});*/

	// initialize tooltip
	$("#globalNavi li a[title]").tooltip({

		// tweak the position
		offset: [12, 0],

		// use the "slide" effect
		effect: 'slide'

	// add dynamic plugin with optional configuration for bottom edge
	}).dynamic({ bottom: { direction: 'down', bounce: true } });



	// This value can be true, false or a function to be used as a callback when the closer is clciked
	$.jGrowl.defaults.closer = function() {
		console.log("Closing everything!", this);
	};
	
	// A callback for logging notifications.
	$.jGrowl.defaults.log = function(e,m,o) {
		$('#logs').append("<div><strong>#" + $(e).attr('id') + "</strong> <em>" + (new Date()).getTime() + "</em>: " + m + " (" + o.theme + ")</div>")
	}

	/*$.jGrowl("<p>Adobe AIR のデスクトップ・アプリケーション（デスクトップ・ウィジェット）をアップしました。</p><p>2010.05.20</p>", { 
		header: '<p>デスクトップ・アプリケーション</p>',
		//sticky: true,
		closer: false,
		life: 5000
	});

	$.jGrowl("<p>iPad でもアニメーションを見ることができるように Flash コンテンツを jQuery にてアニメーションさせました。</p><p>2010.08.20</p>", { 
		header: '<p><a href="http://www.onside.com/blog/archives/2010/08/20/2589.html">iPad でもアニメーション</a></p>',
		//sticky: true,
		closer: false,
		life: 7500
	});

	$.jGrowl("<p>gallery に postcard を追加しました。</p><p>2011.01.01</p>", { 
		header: '<p><a href="http://www.onside.com/gallery/postcard/">ポストカード</a></p>',
		//sticky: true,
		closer: false,
		life: 10000
	});

	$.jGrowl("<p>よろしければ、iPhone、iPod touch、Android 携帯でも一度ご覧くださいませ。</p><p>2011.06.02</p>", { 
		header: '<p>スマートフォンサイトを公開しました</p>',
		//sticky: true,
		closer: false,
		life: 10000
	});*/

	$.jGrowl.defaults.closerTemplate = '<div class="jGrowl-closer">hide all notifications</div>';



/*
	$("#nyc").modal({
		opacity:90,
		overlayCss: {backgroundColor:"#000"},
		overlayClose:true,
		onOpen: function (dialog) {
			dialog.overlay.fadeIn('slow', function () {
				dialog.data.hide();
				dialog.container.fadeIn('slow', function () {
					dialog.data.slideDown('slow');
				});
			});
		},
		onClose: function (dialog) {
			dialog.data.fadeOut('slow', function () {
				dialog.container.hide('slow', function () {
					dialog.overlay.slideUp('slow', function () {
						$.modal.close();
					});
				});
			});
		}
	});
*/



/*
	// select #flowplanes and make it scrollable. use circular and navigator plugins 
	//$("#flowpanes").scrollable({size: 1}).circular().mousewheel(400).navigator({
	$("#flowpanes").scrollable({size: 1}).circular().navigator({ 

		// select #flowtabs to be used as navigator 
		navi: "#flowtabs", 

		// select A tags inside the navigator to work as items (not direct children) 
		naviItem: 'a', 

		// assign "current" class name for the active A tag inside navigator 
		activeClass: 'current' 

	}).autoscroll({

		interval: 7500
	});
*/

	// select #flowplanes and make it scrollable. use circular and navigator plugins
	$("#flowpanes").scrollable({ circular: true}).navigator({

		// select #flowtabs to be used as navigator
		navi: "#flowtabs",

		// select A tags inside the navigator to work as items (not direct children)
		naviItem: 'a',

		// assign "current" class name for the active A tag inside navigator
		activeClass: 'current',

		// make browser's back button work
		history: true

	}).autoscroll({

		autoplay: true,

		interval: 7500
	});

});



// wait until document is fully scriptable
$(function() {


});



jQuery(window).bind('load ', function() {

	$('.cycleImages').cycle({ 
		fx:     'fade',
		timeout: 4500,
		cleartype:  1 // enable cleartype corrections 
	});

});

function Ref_home(){
	xx = escape(document.referrer);
	yy = "";
	for (i = 0; i < xx.length; i++) {
		zz = xx.charAt(i);
		yy += (zz == "+") ? "%2B" : zz;
	}
	document.write('<img width="63px" height="22px" border="0" alt="counter" ');
	document.write('src="/cgi-local/wwwcount/wwwcount.cgi?gif"');
	document.write('+ref+', yy, '">');
	document.close();
}

/*function Pic(){

	var isiPad = navigator.userAgent.match(/iPad/i) != null;
	var isiPhone  = navigator.userAgent.match(/iPhone /i) != null;
	var isiPod = navigator.userAgent.match(/iPod/i) != null;

	var num;
	num = 3;
	number = Math.floor(Math.random() * num);

	if (isiPad) {
		document.write('<div id="slideshowHolder">');
		document.write('<img src="img/home/gallery_01.jpg" alt="イメージ01" />');
		document.write('<img src="img/home/gallery_02.jpg" alt="イメージ02" />');
		document.write('<img src="img/home/gallery_03.jpg" alt="イメージ03" />');
		document.write('<img src="img/home/gallery_04.jpg" alt="イメージ04" />');
		document.write('<img src="img/home/gallery_05.jpg" alt="イメージ05" />');
		document.write('</div>');
		document.close();
	} else if (isiPhone) {
		document.write('<div id="slideshowHolder">');
		document.write('<img src="img/home/gallery_01.jpg" alt="イメージ01" />');
		document.write('<img src="img/home/gallery_02.jpg" alt="イメージ02" />');
		document.write('<img src="img/home/gallery_03.jpg" alt="イメージ03" />');
		document.write('<img src="img/home/gallery_04.jpg" alt="イメージ04" />');
		document.write('<img src="img/home/gallery_05.jpg" alt="イメージ05" />');
		document.write('</div>');
		document.close();
	} else if (isiPod) {
		document.write('<div id="slideshowHolder">');
		document.write('<img src="img/home/gallery_01.jpg" alt="イメージ01" />');
		document.write('<img src="img/home/gallery_02.jpg" alt="イメージ02" />');
		document.write('<img src="img/home/gallery_03.jpg" alt="イメージ03" />');
		document.write('<img src="img/home/gallery_04.jpg" alt="イメージ04" />');
		document.write('<img src="img/home/gallery_05.jpg" alt="イメージ05" />');
		document.write('</div>');
		document.close();
	} else {
		document.write('<script type="text/javascript">Pic_'+number+'()</script>');
		//document.write(number);
		document.close();
	}

}*/

function Pic(){
	var num;
	num = 3;
	number = Math.floor(Math.random() * num);
	document.write('<script type="text/javascript">Pic_'+number+'()</script>');
	//document.write(number);
	document.close();
}

function Pic_0() {
	document.write('<script type="text/javascript" src="/js/home/jquery.canimate.js"></script>');
	document.write('<script type="text/javascript">$(document).ready(function(){$(".canimation").canimate({totalFrames: 30,imagePrefix: "ino",fps: 15,preload:true});});</script>');
	document.write('<div class="canimation">');
	document.write('<img src="/img/home/ino0000.png"/>');
	document.write('</div>');
	document.close();
}

function Pic_1() {
	document.write('<script type="text/javascript" src="/js/home/jquery.canimate.js"></script>');
	document.write('<script type="text/javascript">$(document).ready(function(){$(".canimation").canimate({totalFrames: 30,imagePrefix: "hiyo",fps: 15,preload:true});});</script>');
	document.write('<div class="canimation">');
	document.write('<img src="/img/home/hiyo0000.png"/>');
	document.write('</div>');
	document.close();
}

function Pic_2() {
	document.write('<div id="slideshowHolder">');
	document.write('<img src="img/home/gallery_01.jpg" alt="イメージ01" />');
	document.write('<img src="img/home/gallery_02.jpg" alt="イメージ02" />');
	document.write('<img src="img/home/gallery_03.jpg" alt="イメージ03" />');
	document.write('<img src="img/home/gallery_04.jpg" alt="イメージ04" />');
	document.write('<img src="img/home/gallery_05.jpg" alt="イメージ05" />');
	document.write('</div>');
	document.close();
}

/*function Pic_0() {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="316" height="180" id="hiyoko">');
	document.write('<param name="movie" value="/fla/hiyoko.swf" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="scale" value="exactfit" />');
	document.write('<param name="bgcolor" value="#606A74" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="/fla/hiyoko.swf" menu=false quality=autohigh scale=exactfit bgcolor="#606A74" width="316" height="180" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" />');
	document.write('</object>');
	document.close();
}

function Pic_1() {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="316" height="180" id="ino">');
	document.write('<param name="movie" value="/fla/ino.swf" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="scale" value="exactfit" />');
	document.write('<param name="bgcolor" value="#606A74" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="/fla/ino.swf" menu=false quality=autohigh scale=exactfit bgcolor="#606A74" width="316" height="180" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" />');
	document.write('</object>');
	document.close();
}

function Pic_2() {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="316" height="180" id="ino">');
	document.write('<param name="movie" value="/fla/homeillust.swf" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="scale" value="exactfit" />');
	document.write('<param name="bgcolor" value="#606A74" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="/fla/homeillust.swf" menu=false quality=autohigh scale=exactfit bgcolor="#606A74" width="316" height="180" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" />');
	document.write('</object>');
	document.close();
}*/

function jgrowlFirebug() {
		// In case you don't have firebug...
		if (!window.console || !console.firebug) {
			var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
			window.console = {};
			for (var i = 0; i < names.length; ++i) window.console[names[i]] = function() {};
		}
}



$(function(){
	$.getFeed({
		//ここにRSSのURLを指定する。
		url: 'proxy.php?url=http://feeds.feedburner.com/onside',
		success: function(feed){
			var html = '';
			for(var i = 0; i < feed.items.length && i < 10; i++){
				var item = feed.items[i];
				html += '<li><a href="' + item.link + '">' + item.title + '<\/a> ' + dateChanger(item.updated) + '<\/li>';
			}
			$('#recententries').append(html);
			$('#recententries li').wrapAll('<ul><\/ul>');
		}
	});
	//月表示を数字表示に変換する
	var dateChanger = function(str){
		var changerM = {
			Jan: '01',
			Feb: '02',
			Mar: '03',
			Apr: '04',
			May: '05',
			Jun: '06',
			Jul: '07',
			Aug: '08',
			Sep: '09',
			Oct: '10',
			Nov: '11',
			Dec: '12'
		};
		//dateをスペースで区切り、2番目から5番目を抜き出し、逆順に変更
		str = str.split(" ").slice(1,4).reverse();
		//月の表示を英語表記から数字表記へ変換
		str[1] = str[1].replace(str[1],changerM[str[1]]);

		str[0] = str[0] + ".";
		str[1] = str[1] + ".";
		str[2] = str[2] + "";
		str = str.join("");
		return str;
	};
});

function plusoneHome() {
	document.write('<g:plusone href="http://www.onside.com" size="tall" count="false"></g:plusone>');
	document.close();
}
