﻿function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

//common
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//******************************************************************************************//
//
//check_mail_form
function check_input(){
	with(document.mail_form){
		if(sender_name.value != ""){
			if(sender_mail_address.value != ""){
				if(sender_tel.value != ""){
					if(inquiry_contents.value != ""){
						submit();
					}else{
						alert("お問い合わせ項目を入力してください。");
					}
				}else{
					alert("電話番号を入力してください。");
				}
			}else{
				alert("メールアドレスを入力してください。");
			}
		}else{
			alert("お名前を入力してください。");
		}
	}
}
//******************************************************************************************//
//
//send_mail_error
function back_mail_form(){
	location.href = "http://www.phiria.co.jp/mail/";
}
//******************************************************************************************//
//******************************************************************************************//
//
//check_mail_form_hitodecheck
function check_input_hitodecheck(){
	with(document.mail_form){
		if(sender_url.value != ""){
			if(sender_name.value != ""){
				if(sender_mail_address.value != ""){
					if(sender_tel.value != ""){
						submit();
					}else{
						alert("電話番号を入力してください。");
					}
				}else{
					alert("メールアドレスを入力してください。");
				}
			}else{
				alert("お名前を入力してください。");
			}
		}else{
			alert("確認したいURLを入力してください。");
		}
	}
}
//******************************************************************************************//
//
//send_mail_error_hitodecheck
function back_mail_form_hitodecheck(){
	location.href = "http://www.phiria.co.jp/mail/hitodecheck.html";
}
//******************************************************************************************//
//
//open_window
function winOpen(winName,url,X,Y,W,H){
 var WinD11=window.open(url,winName,'top='+X+',left='+Y+',screenX='+X+',screenY='+Y+',scrollbars=1,width='+W+',height='+H+'');
  WinD11.document.close()
}
//******************************************************************************************//
//
//check_subscription_form
function check_input_subscription_form(){
	with(document.subscription_form){
		if(sender_name.value != ""){
			if(sender_mail_address.value != ""){
				if(sender_zip_code.value != ""){
					if(sender_address_2.value != ""){
						if(sender_address_3.value != ""){
						 if(sender_tel.value != ""){
							 submit();
						 }else{
							 alert("電話番号を入力してください。");
						 }
						}else{
						 alert("住所3(アパート・マンション名など)を入力してください。");
						}
					}else{
						alert("住所2(市町村名)を入力してください。");
					}
				}else{
					alert("郵便番号を入力してください。");
				}
			}else{
				alert("メールアドレスを入力してください。");
			}
		}else{
			alert("お名前を入力してください。");
		}
	}
}
//******************************************************************************************//
//
//send_mail_error
function back_subscription_form(){
	location.href = "http://www.phiria.co.jp/emprego/subscription.html";
}
//******************************************************************************************//
