/**
 * ====================================================
 * JavaScript (html contents)
 *
 * @author    : maomao
 * @date      : 2006/09/01
 * @copyright : (c) maomao-studio. All Rights Reserved.
 *     
 * ====================================================
 */

// _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ 
//
//  Constant
//
// _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ 
var SCREEN_WIDTH_JUDGE = 600;
document.oncontextmenu = new Function("return false"); // Just For IE -> right button invalid.


// _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ 
//
//  Global Function
//
// _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ 

var MMS = {};

/**********************************************************
 * 機　能： 入力された値がEmail（xxx@xxx.xx）であるかどうかチェック 
 * 引　数： arg　入力された値 
 * 戻り値： 正：true　不正：false 
 **********************************************************/ 
MMS.isEmail = function(arg) {

	var checkTLD=1;

	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

	var emailPat=/^(.+)@(.+)$/;

	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

	var validChars="\[^\\s" + specialChars + "\]";

	var quotedUser="(\"[^\"]*\")";

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	var atom=validChars + '+';

	var word="(" + atom + "|" + quotedUser + ")";

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	var matchArray=arg.match(emailPat);

	if (matchArray==null) {
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];

	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			return false;
	   }
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			return false;
	   }
	}

	if (user.match(userPat)==null) {
		return false;
	}

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {

	for (var i=1;i<=4;i++) {
		if (IPArray[i]>255) {
			return false;
	   }
	}
	return true;
	}

	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			return false;
	   }
	}

	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
		return false;
	}

	if (len<2) {
		return false;
	}

	return true;
};

/**
 * ポップアップ画面
 */
MMS.popWindow = function(name, href, width, height) {
	var sw = screen.width, sh=screen.height;
	if (typeof(width) == "undefined"){width = 300;}
	if (typeof(height) == "undefined"){height = 400;}

	var left = (sw - width)/2, top = (sh - height)/2;

	var option = "screenX=0,screenY=0,top="+top+",left="+left+",width=" + width + ",height=" + height + ",scrollbars=yes,resizable=no";
	var child = window.open(href, name, option);
	child.focus();
};

/**
 * 画面サイズを取得
 */
MMS.getPageSize = function() {
	var d = document.documentElement;
	var w = window.innerWidth || self.innerWidth  || (d && d.clientWidth)  || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (d && d.clientHeight) || document.body.clientHeight;
	return [w, h];
};

/**
 * スクロール位置を取得
 */
MMS.getPageScrollPosition = function() {
	var xScrollLeft, yScrolltop;
	if (self.pageYOffset) {
		yScrolltop = self.pageYOffset;
		xScrollLeft = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict
		yScrolltop = document.documentElement.scrollTop;
		xScrollLeft = document.documentElement.scrollLeft;
	} else if (document.body) { // all other Explorers
		yScrolltop = document.body.scrollTop;
		xScrollLeft = document.body.scrollLeft;
	}
	if (typeof(xScrollLeft) == "undefined"){
		xScrollLeft = 0;
	}
	if (typeof(yScrolltop) == "undefined"){
		yScrolltop = 0;
	}
	return [xScrollLeft, yScrolltop]; 
};

/**
 * 減速スクロール
 */
MMS.scrj = 1;
MMS.softScrollBack = function() {
	var scrolltop = MMS.getPageScrollPosition()[1];
	if (MMS.scrj<50 && scrolltop) {
		scrolltop = (scrolltop>2) ? Math.ceil(scrolltop*.2) : 1;
		MMS.scrj++;
		scrollBy(0, -scrolltop);
		setTimeout("MMS.softScrollBack()", 20);
	} else {
		scrollTo(0,0);
		MMS.scrj = 1;
	}
};

/**
 * MENU BARのコントロール
 */
MMS.resetMenuPos = function(){};
MMS.ifScreenWide = screen.width > SCREEN_WIDTH_JUDGE; //MMS.getPageSize()[0]


// _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ 
//
//  EventHandle
//
// _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ 

var EventHandle = Class.create();
EventHandle.prototype = {
    //  コンストラクタ
    initialize : function(id) {
		this.id = id;
		this.err = [];
		this.form = null;
		this.focus = null;
		this.__frms = 5;
		this.__speed = 40;
		this.timer = null;
		this.scrollFlag = false;
		this.POSITIONS = {top:32, profile:128, works:222, gallery:320, essay:408, contact:498}; 
		this.LOADING = '<DIV id="loading"></DIV>';
		this.currentPosition = null;
		this.targetPosition = null;
    },

	set : function(id) {
		this.id = id;
		//Element.setStyle("mNaviFocus", {left : this.POSITIONS[this.id] + "px"});
	},

	focusIn : function(evt) {
		var o = Event.element(evt);
		Element.addClassName(o, "input-active");
	},

	focusOut : function(evt) {
		var o = Event.element(evt);
		Element.removeClassName(o, "input-active");
	},

	detail : function(pid, date, no) {
		var href = "./info_detail.php?pid=" + pid + "&date=" + date + "&no=" + no;
		MMS.popWindow("info_detail", href, 650, 400);
	}
};

// _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ 
//
//  Main Contents
//
// _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ 

function loadTop() {
}

function loadProfile() {
	initLightbox();
}

function loadInfo() {

}

function loadHistory() {

}



// _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ 
//
//  New a EventHandle Object.
//
// _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ 
var eventHandle = new EventHandle();
