// JavaScript Document by kazh

//srt mouse over menu//
function mouseOut() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function pLoad() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=pLoad.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function findNIMO(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findNIMO(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function mouseOver() {
  var i,j=0,x,a=mouseOver.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findNIMO(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//end マウスオーバー系ここまで//

/* なだらかにスクロールしてページの上部に戻る */
function fBacktoTop() {
	var d=document;
	/* 画面の左端からの距離 */
	var scroll_left=d.body.scrollLeft || d.documentElement.scrollLeft || d.scrollX || 0;
	 /* 画面の上端からの距離 */
	var scroll_top=d.body.scrollTop || d.documentElement.scrollTop || d.scrollY || 0;
	// 画面スクロール
	scrollTo(scroll_left/2, scroll_top/2);
	/* 画面最上部に移動するまで繰り返す */
	if(scroll_left>0 || scroll_top>0){
		var f=setTimeout("fBacktoTop()", 50);
	}else{
		clearTimeout(f);
	}
}
//なだらかスクロールここまで

//contact form//
function validateForm() {

	//return fValid();
	flag = fValid();
	
	//alert(flag);//false = validateForm is returning false --- should STOP
				//true =  validateForm is returning true --- go forward


}//end of function validateForm()


//-----------fValid--------------------//
function fValid(){
	oName = document.getElementById('jName');
	//oKana = document.getElementById('jKana');
	oEmail = document.getElementById('email');
	oMessage = document.getElementById('textMessage');
	bFormError = false; //flag b=boolean
	
	if (oName.value == ''){
		with (oName){
			style.borderColor = "red";
		}//end of with
		bFormError = true;

	}else{
		with (oName){
			style.borderColor = "gray";	
		}//end of with
	}//end of if and else
/*	if (oKana.value == ''){
		with (oKana){
			style.borderColor = "red";	
		}//end of with
		bFormError = true;
	}else{
		with (oKana){
			style.borderColor = "gray";	
		}//end of with
	}//end of if and else*/
	if (oEmail.value == ''){
		with (oEmail){
			style.borderColor = "red";	
		}//end of with		
		bFormError = true;
	}else{
		with (oEmail){
			style.borderColor = "gray";	
		}//end of with		
	/**/
///////////////////////////////////////validate email/////////////////////////////////////////
			emailRegex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
			errorMsg = "有効なＥメールアドレスではありません";
			bEmailError = false;//boolean only for email
			if( !oEmail.value.match( emailRegex )){
				oEmail.style.borderColor = 'red';
				document.getElementById('alerting2').innerHTML = errorMsg;
				bEmailError = true;
			}else{//end of if
				oEmail.style.borderColor = 'gray';
				document.getElementById('alerting2').innerHTML = "";
			}
///////////////////////////////////////validate email/////////////////////////////////////////

	}//end of if and else
		if ((oMessage.value == '')||(oMessage.value == 'お問い合わせ内容')){
		with (oMessage){
			style.borderColor = "red";	
		}//end of with
		bFormError = true;
	}else{
		with (oMessage){
			style.borderColor = "gray";	
		}//end of with
	}//end of if and else	
	
//	alert(bFormError);
	if(bFormError == true){
		document.getElementById('alerting').innerHTML = '赤い枠の項目は必須となっております。';
		//alert('hello');
		return false;
		
	} else if(bFormError == false){
		document.getElementById('alerting').innerHTML ='';
			if(bEmailError == true)
			{return false;}
		return true;
	}
	

}
//-----------fValid--------------------//


function commentErase(){
	if (contactForm.textMessage.value == ('お問い合わせ内容')){
		contactForm.textMessage.value = ('');
	}//end of if
		contactForm.textMessage.style.color = '000000';
}

function fOnload() {
	contactForm = document.contact;
		
	contactForm.onsubmit = fValid;	//execute function
	contactForm.textMessage.onfocus = commentErase; //just erase default comment
	contactForm.jName.focus();					//just focus on first column when started
	//contactForm.onsubmit = validateForm;// this 'validateForm' is function!
}
//contact formここまで//

//座標ファンクション//
function getElementPosition(element) {
var offsetTrail = (typeof element == 'string') ? document.getElementById(element) : element;
var offsetLeft = 0;
var offsetTop = 0;

while (offsetTrail) {
offsetLeft += offsetTrail.offsetLeft;
offsetTop += offsetTrail.offsetTop;
offsetTrail = offsetTrail.offsetParent;
}

if (navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != "undefined") {
offsetLeft += document.body.leftMargin;
offsetTop += document.body.topMargin;
}

//return ({left: offsetLeft, top: offsetTop});
//alert(offsetTop);
	divFoot = document.getElementById("footer");
	divFoot.style.marginTop = offsetTop+"px";
//alert (divFoot.style.marginTop);
}
//座標ここまで//

//flash//
function flash(obj){
	if(obj == "work"){
	document.write("<embed src='images/work.swf' quality='high' bgcolor='#ffffff' width='178' height='117' name='work' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
	}else if(obj == "imin"){
	document.write("<embed src='images/imin.swf' quality='high' bgcolor='#ffffff' width='178' height='117' name='imin' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />")
	}else if(obj == "job"){
	document.write("<embed src='images/job.swf' quality='high' bgcolor='#ffffff' width='178' height='117' name='job' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />")
	}else if(obj == "testimonial"){
	document.write("<embed src='images/testimonial.swf' quality='high' bgcolor='#ffffff' width='178' height='117' name='testimonial' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />")
	}
}
//flashここまで//


function FlashInsert(FlashIDName, FlashFileName, FlashWidth, FlashHeight, DNSSetting, WMODESetting, FlashBGColor, QSetting, FlashAlign)
{
	document.write('<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write('CODEBASE="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=8,0,22,0" ');
	document.write(' ID="'+FlashIDName+'" WIDTH="' + FlashWidth + '" HEIGHT="' + FlashHeight + '" ALIGN="'+FlashAlign+'">');
	document.write('<PARAM NAME="movie" VALUE="'+ FlashFileName +'">');
	document.write('<PARAM NAME="quality" VALUE="'+QSetting+'">');
	document.write('<PARAM NAME="bgcolor" VALUE="'+FlashBGColor+'">');
	document.write('<PARAM NAME="wmode" VALUE="'+WMODESetting+'">');
	document.write('<PARAM NAME="allowScriptAccess" VALUE="'+DNSSetting+'">');
	document.write('<EMBED SRC="'+ FlashFileName +'"  NAME="'+FlashIDName+'"');
	document.write(' WIDTH="' + FlashWidth + '" HEIGHT="' + FlashHeight + '" QUALITY="'+QSetting+'" BGCOLOR="'+FlashBGColor+'"');
	document.write(' ALLOWSCRIPTACCESS="'+DNSSetting+'" ALIGN="'+FlashAlign+'" WMODE="'+WMODESetting+'" TYPE="application/x-shockwave-flash" ');
	document.write(' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" >');
	document.write('</EMBED>');
	document.write('</OBJECT>');
}

function point(){
	popup = window.open("points.php",'popup','width=583, height=400, scrollbars');
	popup.focus();
	}


