<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs
	title="Jolie-horloge by bijin-tokei"
	title_url="__MSG_module_url__"
	description="__MSG_module_description__"
	screenshot="http://www.ig.gmodules.com/gadgets/proxy/refresh=3600&amp;container=ig&amp;gadget=http%3A%2F%2Fbijint.com%2Fgadget%2Fparis%2FFgadget.xml/http://www.bijint.com/gadget/paris/assets/img/screenshot.jpg"
	thumbnail="http://www.ig.gmodules.com/gadgets/proxy/refresh=3600&amp;container=ig&amp;gadget=http%3A%2F%2Fbijint.com%2Fgadget%2Fparis%2FFgadget.xml/http://www.bijint.com/gadget/paris/assets/img/thumbnail.png"
	scrolling="false"
	singleton="false"
	height="320"
	author_email="cc@bijint.com"
	author="__MSG_author_name__"
	author_affiliation="__MSG_author_affiliation__"
	author_location="__MSG_author_location__"
	author_aboutme="__MSG_author_aboutme__"
	author_link="http://www.bijint.com/"
	author_photo="http://www.bijint.com/img/logo70x100.jpg">

	<Locale messages="http://www.bijint.com/gadget/paris/assets/locale/ALL_ALL.xml" />
	<Locale messages="http://www.bijint.com/gadget/paris/assets/locale/ja_ALL.xml" lang="ja" />
	<Locale messages="http://www.bijint.com/gadget/paris/assets/locale/fr_ALL.xml" lang="fr" />
	<Require feature="dynamic-height"/>
	<Require feature="views"/>
	<Require feature="opensocial-0.9"/>
	<Require feature="analytics"/>
	<Icon mode="base64" type="image/gif">R0lGODlhEAAQALMKAERERFVVVREREczMzHd3d6qqqmZmZt3d3YiIiAAAAP///wAAAAAAAAAAAAAA
AAAAACH5BAEAAAoALAAAAAAQABAAAAQ5UMlJKx02q5AyrkgHIlYIJsZxcsSUkOdxJKrylqIA36ek
S6/aJCQT2RCwSYEAACSbSY10Sq1ar5MIADs=</Icon>

</ModulePrefs>

<Content type="html"><![CDATA[
<div id="wrapper">
	<a target="_blank" id="photo" href="__MSG_module_url__"><span class="dummy">&nbsp;</span></a>
</div>
<style type="text/css">/*<!--*/
	body { margin:0; padding:0; color:#333; background:#fff; }
	#wrapper { padding:0; text-align:center; }
	#photo { width:240px; height:320px; margin:0 auto; display:block; position:relative; top:0; left:0; text-decoration:none; }
	.canvas #photo { width:590px; height:450px; margin:0; }
	#photo .dummy { display:block; width:100%; height:100%; z-index:9; position:absolute; top:0; left:0; }
	#photo img { position:absolute; top:0; left:0; width:100%; }
	img { border:0; }
/*-->*/</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<script type="text/javascript">/*<!--*/
;(function($){

var wrapper, photoDiv, currentPhoto;
var
	usedRandom = {},
	isMixi = /^.+mixi\-platform.com$/.test(document.location.host);
var
	PHOTO_PATH = "http://www.bijint.com/assets/pict/paris/240x320/",
	PHOTO_PATH_L = "http://www.bijint.com/assets/pict/paris/590x450/",
	PHOTO_EXT = ".jpg",
	RANDOM_BASE = "abcdefghijklmnopqrstuvwxyz0123456789",
	PROXY_URL = "http://www.ig.gmodules.com/gadgets/proxy/refresh=3600&container=ig&gadget=http%3A%2F%2Fbijint.com%2Fgadget%2Fparis%2FFgadget.xml/",
	RANDOM_LENGTH = 10,
	MAX_WIDTH = 240,
	MAX_HEIGHT = 320,
	MAX_WIDTH_L = 590,
	MAX_HEIGHT_L = 450,
	PADDING = 0,
	MIXI_MAX_HEIGHT = 212;

function init() {
	wrapper =$("#wrapper");
	if(isCanvas()) {
		wrapper.addClass("canvas");
		MAX_WIDTH = MAX_WIDTH_L;
		MAX_HEIGHT = MAX_HEIGHT_L;
	}
	photoDiv = $("#photo");
	update(new Date());
	$(window).bind("resize",onResize);
	photoDiv.bind("mousedown",function(){
		sendTrack(true,true);
	});
	photoDiv.bind("click",function(){
		var href = $(this).attr("href");
		if(isMixi&&window.mixi&&mixi.util&&typeof mixi.util.requestExternalNavigateTo=="function") {
			setTimeout(function(){
				if(isCanvas())
					mixi.util.requestExternalNavigateTo(href);
				else
					gotoCanvas();
				return false;
			},99);
			return false;
		}
	});
	sendTrack();
	onResize();
}

function gotoCanvas() {
	gadgets.views.requestNavigateTo(new gadgets.views.View("canvas"));
}

function sendTrack(time,click) {
	var path = "/gadget/paris/"+(isMixi?"mixi":"igoogle");
	var view = getView();
	if(view&&view!="home") path += "/"+view;
	if(time) path += "/"+time4Digits();
	if(click) path += "/click";
	try {
		_IG_Analytics("UA-23794612-1",path);
	} catch(e) {}
}

function getView() {
	try {
		return gadgets.views.getCurrentView().getName().toLowerCase();
	} catch(e) { return ""; }
}

function isCanvas() {
	return /^canvas$/.test(getView());
}

function onResize() {
	if(isMixi&&!isCanvas()) {
		photoDiv.css({
			width : Math.ceil(MAX_WIDTH*MIXI_MAX_HEIGHT/MAX_HEIGHT),
			height : MIXI_MAX_HEIGHT
		});
		gadgets.window.adjustHeight(MIXI_MAX_HEIGHT);
		return;
	}
	var w = $(window).width();
	var m = w<MAX_WIDTH+PADDING*2;
	photoDiv.css({
		width : m?"100%":(MAX_WIDTH+"px"),
		height : m?"auto":(MAX_HEIGHT+"px")
	});
	if(!currentPhoto) return;
	setTimeout(function(){
		var h = currentPhoto.height()+PADDING*2;
		try {
			gadgets.window.adjustHeight(h);
		} catch(e) {
			try {
				_IG_AdjustIFrameHeight(h)
			} catch(e) {}
		}
	},0);
}


function getRandom() {
	do {
		var rnd = "";
		while(rnd.length<RANDOM_LENGTH) {
			rnd += RANDOM_BASE.charAt(Math.floor(Math.random()*RANDOM_BASE.length))||"";
		}
	} while(usedRandom[rnd]);
	usedRandom[rnd] = true;
	return rnd;
}

function update(date) {
	var timeout;
	var nextTime = new Date();
	nextTime = new Date(nextTime.getFullYear(),nextTime.getMonth(),nextTime.getDate(),nextTime.getHours(),nextTime.getMinutes()+1);
	if(date) {
		timeout = nextTime.getTime() - date.getTime();
	} else {
		date = nextTime;
		timeout = 60000;
	}
	var img = getImageURL(date);
	var id = "photo-"+getRandom();
	var loaded = false;
	photoDiv.append($([
		"<img src=\"",img,"\" id=\"",id,"\" style=\"display:none;z-index:2;\" />"
	].join("")));
	var ele = $("#"+id);
	setTimeout(function(){
		if(!loaded) update();
	},timeout);
	ele.bind("load",function(){
		var d = new Date();
		var c = d.getTime();
		var t = date.getTime();
		var p = t-c;
		loaded = true;
		if(p<-60000) return ele.remove();
		if(p>0) {
			setTimeout(function(){ fadeIn(ele); },p);
			return;
		}
		fadeIn(ele);
	});
	return img;
}

function fadeIn(ele) {
	ele.fadeIn();
	if(currentPhoto) {
		currentPhoto.css("z-index","1");
		currentPhoto.fadeOut("slow",function(){
			$(this).remove();
		});
	}
	sendTrack(true);
	currentPhoto = ele;
	onResize();
	update();
}

function formatNum(n) {
	return n<10?"0"+n:String(n);
}

function time4Digits(date) {
	date = date || new Date();
	return [
		formatNum(date.getHours()),
		formatNum(date.getMinutes())
	].join("");
}

function getImageURL(date) {
	var urlOrg = [
		isCanvas()?PHOTO_PATH_L:PHOTO_PATH,
		time4Digits(date),
		PHOTO_EXT, "?yyyymmdd=",
		date.getFullYear(),
		formatNum(date.getMonth()+1),
		formatNum(date.getDate()),
		"&ext=", PHOTO_EXT
	].join("");
	var url;
	try {
		url = gadgets.io.getProxyUrl(urlOrg);
	} catch(e) {
		try {
			url = _IG_GetImageUrl(urlOrg);
		} catch(e) {}
	}
	return url==urlOrg?PROXY_URL+urlOrg:url;
}

try {
	gadgets.util.registerOnLoadHandler(init);
} catch(e) {
	try {
		_IG_RegisterOnloadHandler(init);
	} catch(e) {
		$(init);
	}
}


/** start:MIXI AD PROGRAM */
(function(){
	if(!isMixi||!isCanvas()) return;
	var url = "http://mixi.jp/ad_application_program_invoker.pl?appli_id=10909&ad_id=1ed2aa6d5e08e5455c740676a0be1c47002b5906";
	document.writeln(['<scri','pt src="',url,'&ts=',(new Date).getTime(),'">','</scri','pt>'].join(''));
})();
/** end:MIXI AD PROGRAM */

})(jQuery.noConflict(true));

/*-->*/</script>
]]></Content>

</Module>
