
// "rotate.js"
// by Mikami Kenichi (2009/6/30)
// ....I'm very Tired. X-(

window.onorientationchange = function () {
	webkitmes();
	rotatejump();
	};

addEvent(window,'load',function () { webkitmes(); rotatejump(); });

function rotatejump(){

	switch ( window.orientation ) {
		case 0:
				if( location.href.indexOf("/i/") < 0 ) {
					location.href = location.protocol + "//" + location.host + "/i" + location.pathname;
				}
				break;
		case 90:
		case -90:
				if( location.href.indexOf("/i/") > 0 ) {
					location.href = location.href.replace("/i/", "/");
				}
				break;
		default:
				break;

		}

};

function webkitmes(){
	if (navigator.userAgent.match(/(iPod|iPhone).+WebKit/i)) {
		 document.getElementById("forwebkit").innerHTML = "<div class=\"mes\"><img src=\"/images/black-icons-158.gif\" width=\"13\" height=\"13\" alt=\"！\">&nbsp;本体を回転させると、PC用とiPhone用表示が切り替わります。</div>";
		}
};

function addEvent( elx, event, func ){
	if ( elx.addEventListener ) {
		elx.addEventListener( event, func, false );
	} else {
		elx.attachEvent( 'on'+event, func );
	}
}


