﻿/** ログイン処理  */
function doLogin(){
	
	$("#login_id").val(jQuery.trim($("#login_id").val()));
	$("#login_pass").val(jQuery.trim($("#login_pass").val()));

	if($("#login_id").val() == ""){
		alert( "IDを入力してください。" );
		$("#login_id").focus();
		return false;
	}
	
	if($("#login_pass").val() == ""){
		alert( "パスワードを入力してください。" );
		$("#login_pass").focus();
		return false;
	}
	
	var act = "";	
	if($("#login_form").attr("action")){ act = $("#login_form").attr("action"); }

	if(act == ""){
		$("#login_form").attr("action", "https://" + location.hostname + location.pathname);
	}else{
		if(act.match(/^\//)){
			$("#login_form").attr("action", "https://" + location.hostname + act);
		}else{
			$("#login_form").attr("action", "https://" + location.hostname + "/" + act);
		}
	}
	
	return true;
}

/** ログイン前の入力チェック処理 (NewVersion) */
function doLogin2(){

	//Form Check
	if(!document.getElementById("LoginForm")) return false;

	//ID Check	
	if(!document.getElementById("login_id")){
		return false;	
	}else if(document.getElementById("login_id").value.replace(/ /g,"") === ""){
		alert( "IDを入力してください。" );
		document.getElementById("login_id").focus();
		return false;
	}

	//Pass Check
	if(!document.getElementById("login_pass")){
		return false;
	}else if(document.getElementById("login_pass").value.replace(/ /g,"") === ""){
		alert( "パスワードを入力してください。" );
		document.getElementById("login_pass").focus();
		return false;
	}

	if(document.getElementById("LoginForm").action === ""){
		document.getElementById("LoginForm").action = "https://" + location.hostname + location.pathname;
	}else{
		if(document.getElementById("LoginForm").action.match(/^\//)){
			document.getElementById("LoginForm").action = "https://" + location.hostname + document.getElementById("LoginForm").action;
		}else{
			document.getElementById("LoginForm").action = "https://" + location.hostname + "/" + document.getElementById("LoginForm").action;
		}
	}

	return true;
}


/** ログアウト */
function doLogout(){
	var act = "";	
	if($("#login_form").attr("action")){ act = $("#login_form").attr("action"); }

	if(act == ""){
		$("#login_form").attr("action", "http://" + location.hostname + location.pathname);
	}else{
		if(act.match(/^\//)){
			$("#login_form").attr("action", "http://" + location.hostname + act);
		}else{
			$("#login_form").attr("action", "http://" + location.hostname + "/" + act);
		}
	}
}


/** メニュー移動 */
function doChangePage(page){

	if(document.PWForm.action_id){
		document.PWForm.action_id.value = "LeftMenu";
	}

	document.PWForm.action=page;

	document.PWForm.submit();
}


function htmlEscapeString(tmpStr){
	var reStr = tmpStr;
	reStr = reStr.replace(/&/ig, "&amp;");
	reStr = reStr.replace(/</ig, "&lt;");
	reStr = reStr.replace(/>/ig, "&gt;");
	reStr = reStr.replace(/\"/ig, "&quot;");
	reStr = reStr.replace(/\'/ig, "&#39;");

	return reStr;
}

function htmlDecodeString(tmpStr){
	var reStr = tmpStr;
	reStr = reStr.replace(/&amp;/ig,  "$");
	reStr = reStr.replace(/&lt;/ig,   "<");
	reStr = reStr.replace(/&gt;/ig,   ">");
	reStr = reStr.replace(/&quot;/ig, '"');
	reStr = reStr.replace(/&#39;/ig,  "'");

	return reStr;
}

function MM_swapImgRestore() { //v3.0
  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 MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.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 MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

kikan = 7;
icon = "<img src='/img/global/icon/new.gif' width='20' height='9'>";
today = new Date();
upday = new Date();
function koushin(y, m, d) {
   upday.setFullYear(y);
   m = m - 1;
   upday.setMonth(m);
   upday.setDate(d);
   difference = today.getTime() - upday.getTime();
   difference = Math.floor(difference / (1000 * 60 * 60 * 24));
   if (difference < kikan) {
      document.write(icon);
   }
} 

function wopen1(winnam){
myWin = window.open(winnam, "popup3", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, close=yes, width=620, height=570, top=0, left=0");
window.myWin.focus();
return false;
}

function focusPassword(obj,id){
   var elm = document.getElementById(id);
   elm.style.display = "block";
   scroll(0,0);
   obj.style.display = "none";
   elm.focus();
   scroll(0,0);
}
function blurPassword(obj,id){
   var elm = document.getElementById(id);
   if( obj.value == '' ){
      elm.style.display = "block";
      obj.style.display = "none";
   }
}

function  viewFlash(sURL, sName, sFeatures){ 

	var FLASHCAB = "https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"; 
	var FLASHCID = "CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000";
	var FLASHVER = "9,0,0,0"; 

	var sFeature; 
	var sWidth = "100%"; 
	var sHeight = "100%";
	var pmBoolean = "false";
	var sTempArray; 
	var sParamTag; 

	sFeature = sFeatures.split(/\s*,\s*/); 
	for (var i=0; i< sFeature.length ; i++) { 
		sTempArray = sFeature[i].split(/\s*=\s*/); 
		if (sTempArray[0].toLowerCase() == "width") { 
			sWidth = sTempArray[1]; 
		} else if (sTempArray[0].toLowerCase() == "height") { 
			sHeight = sTempArray[1]; 
		} else { 
			if (sTempArray[1].toLowerCase() == "yes" || sTempArray[1] == "1" || sTempArray[1].toLowerCase() == "true") { 
				pmBoolean = "true" 
			} 
			sParamTag = "<PARAM NAME='"+sTempArray[0]+"'VALUE='" + pmBoolean + "'>\n"+sParamTag; 
		} 
	} 

	document.write("<OBJECT ID='"+sName+"' NAME='"+sName+"' CLASSID='"+FLASHCID+"' CODEBASE='"+FLASHCAB+"#version="+FLASHVER+"' WIDTH='"+sWidth+"' HEIGHT='"+sHeight+"'>"); 
	document.write("<PARAM NAME='movie' VALUE='" + sURL + "'>"); 
	document.write("<PARAM NAME='wmode' VALUE='transparent'>");
	document.write("<EMBED SRC='"+sURL+"' MENU='false' WIDTH='"+sWidth+"' HEIGHT='"+sHeight+"' ID='"+sName+"' NAME='"+sName+"' wmode='transparent' TYPE='application/x-shockwave-flash' PLUGINSPAGE='https://www.macromedia.com/go/getflashplayer'>") 
	document.write("</OBJECT>"); 
} 

new function(){

	if(window.addEventListener){
		window.addEventListener('load',alphafilter,false);
	}else if(window.attachEvent){
		window.attachEvent('onload',alphafilter);
	}
	
	function alphafilter(){
		if (typeof document.body.style.maxHeight == "undefined") {//for old ie
			var elements = getElementsByClassName("alphafilter");
			for (var i=0; i<elements.length; i++) {
				var element = elements[i];
				if(element.nodeName=="IMG"){
					var newimg           = document.createElement("b");
					for(var key in element.currentStyle){
						newimg.style[key]=element.currentStyle[key];
					}
					newimg.className     = element.className;
					newimg.style.display = "inline-block";
					newimg.style.width   = element.width;
					newimg.style.height  = element.height;
					newimg.style.float   = element.align;
					newimg.style.filter  = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+element.src+",sizingMethod='scale')";
					element.parentNode.replaceChild(newimg,element);
				}else{
					var anchors = element.getElementsByTagName("a");
					for (var j=0; j<anchors.length; j++) {
						var anchor = anchors[j];
						anchor.style.position="relative";
					}
					var iputs = element.getElementsByTagName("input");
					for (var j=0; j<iputs.length; j++) {
						var iput = iputs[j];
						iput.style.position="relative";
					}
					var iputs = element.getElementsByTagName("textarea");
					for (var j=0; j<iputs.length; j++) {
						var iput = iputs[j];
						iput.style.position="relative";
					}
					var iputs = element.getElementsByTagName("select");
					for (var j=0; j<iputs.length; j++) {
						var iput = iputs[j];
						iput.style.position="relative";
					}
					var  newimg = element.currentStyle.backgroundImage || element.style.backgroundImage;
					newimg.match(/^url[("']+(.*\.png)[)"']+$/i)
					var newimg = RegExp.$1;
					element.style.filter ="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+newimg+",sizingMethod='image')";
					element.style.background = "none";
				}
			}
		}
	}
	
	function getElementsByClassName(className){
		var i, j, eltClass;
		var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
		var objCN = new Array();
		for (i = 0; i < objAll.length; i++) {
			eltClass = objAll[i].className.split(/\s+/);
			for (j = 0; j < eltClass.length; j++) {
				if (eltClass[j] == className) {
					objCN.push(objAll[i]);
					break;
				}
			}
		}
		return objCN;
	}
}

/** ヘッダーバープルダウン **/
function mainmenu(){   
$(" #globalNavi li").hover(function(){   
        $(this).find('ul:first').css({visibility: "visible",display: "none"}).show(600);   
        },function(){   
        $(this).find('ul:first').css({visibility: "hidden"});   
        });   
}   
  
    
    
$(document).ready(function(){                      
    mainmenu();   
}); 
