/* ---------------------------------------------------------------------- */
/* OTOA Web Site                                                          */
/*                                                                        */
/* OVERSEAS TOUR OPERATORS ASSOCIATION of JAPAN                           */
/*                                                                        */
/* otoa_checkset.js                                                       */
/*                                                                        */
/* ------------------------------------------------------- minatoro works */



/* ---------------------------------------------------------------------- */
// Browser Check & Setup Css ///////////////////////////////////////////////

//User Environment variable
var GL_UserOs, GL_OsVersion, GL_Browser, GL_Version, GL_Standard;

//bsCheck
var bsCheck = new Object();
	bsCheck.an	= navigator.appName
	bsCheck.ua	= navigator.userAgent
	bsCheck.av	= navigator.appVersion
	bsCheck.amv	= navigator.appMinorVersion
	bsCheck.cok	= navigator.cookieEnabled
	bsCheck.userOs 		= null ;
	bsCheck.osVersion = null ;
	bsCheck.browser		= null ;
	bsCheck.version 	= null ;
	bsCheck.otv 			= null ;
	bsCheck.cookie		= null ;
	bsCheck.standard	= null ;
	bsCheck.setEvt = function() {

	var osuaObj;
	var tempObj;

	//振分処理 css
	var macStyle		= '<link rel="stylesheet" href="/_css/hacks/mac_os.css" type="text/css" />';
	var vstStyle		= '<link rel="stylesheet" href="/_css/hacks/vst_os.css" type="text/css" />';
	var wieStyle		= '<link rel="stylesheet" href="/_css/hacks/ie_w.css" type="text/css" />';
	var mieStyle		= '<link rel="stylesheet" href="/_css/hacks/ie_m.css" type="text/css" />';
	var opStyle			= '<link rel="stylesheet" href="/_css/hacks/opera.css" type="text/css" />';
	var mozStyle		= '<link rel="stylesheet" href="/_css/hacks/mozilla.css" type="text/css" />';
	var msfStyle		= '<link rel="stylesheet" href="/_css/hacks/safari.css" type="text/css" />';
	var mcaStyle		= '<link rel="stylesheet" href="/_css/hacks/camino.css" type="text/css" />';
	var mnsStyle		= '<link rel="stylesheet" href="/_css/hacks/ns_m.css" type="text/css" />';
	var mffStyle		= '<link rel="stylesheet" href="/_css/hacks/firefox_m.css" type="text/css" />';
	var oldStyle		= '<link rel="stylesheet" href="/_css/hacks/ob4set.css" type="text/css" />';
	var othStyle		= '<link rel="stylesheet" href="/_css/hacks/other.css" type="text/css" />';


	//OS判定
	if ( this.ua.indexOf('Win') != -1 ){	
		this.userOs = "Win";
		osuaObj = this.ua.indexOf('Windows NT');
		this.osVersion = this.ua.substring(osuaObj + 11,osuaObj + 14);
	}
	else if ( this.ua.indexOf('Mac') != -1 ){	this.userOs = "Mac" ;}
	else{	this.userOs = "OtherOS" ;}

	//ブラウザ判定
	if (this.an.indexOf('Netscape') >= 0){
		if (this.ua.indexOf('Netscape') >= 0){
			this.browser 	= "netscape";
			tempObj = this.ua.indexOf('Netscape/');
			this.version	= this.ua.substring(tempObj + 9,tempObj + 12);
		}	
		else if (this.ua.indexOf('Firefox') >= 0) {
			this.browser 	= 'firefox';
			tempObj = this.ua.indexOf('Firefox/');
			this.version	= this.ua.substring(tempObj + 8,tempObj + 11);
			//this.version	= this.ua.substring(tempObj + 8,this.ua.length);
		}
		else if (this.ua.indexOf('Camino') >= 0) {
			this.browser 	= 'camino';
			tempObj = this.ua.indexOf('Camino/');
			this.version	= this.ua.substring(tempObj + 7,tempObj + 10);
		}
		else if (this.ua.indexOf('Safari') >= 0) {
			this.browser 	= 'safari';
			tempObj = this.ua.indexOf('Version/');
			if(tempObj > 0){
				this.version 	= this.ua.substring(tempObj + 8,tempObj + 11);
			} else {
				tempObj = this.ua.indexOf('Safari/');
				this.version 	= this.ua.substring(tempObj + 7,this.ua.length);
			}
		}
		else if (this.ua.indexOf('Gecko') >= 0) {
			this.browser 	= 'mozilla';
			tempObj = this.ua.indexOf('rv:');
			this.version	= this.ua.substring(tempObj + 3,tempObj + 8);
		}
		else {
			this.browser 	= "netscape";
			this.version 	= this.av.substring( 0,3 ) ;
		}
	}
	else if (this.ua.indexOf('Opera') >= 0){
		this.browser 	= "opera";
		tempObj = this.ua.indexOf('Opera');
		this.version 	= this.ua.substring(tempObj + 6,this.ua.length);
	}	
	else if (this.ua.indexOf('MSIE') >= 0){
		this.browser 	= "ie";
		this.version 	= this.ua.substring((this.ua.indexOf('MSIE') + 5),(this.ua.indexOf('MSIE') + 8)) ;
	}	
	else{
			this.browser 	= "other";
	}

	//Mode Check 
	this.standard = (document.compatMode && document.compatMode=="CSS1Compat");

	//WindowsOS
	if(this.userOs == "Win"){

	//Operaの処理
		if (this.browser == "opera"){ document.writeln(opStyle);}
	//Firefoxの処理
		else if(this.browser == "firefox"){document.writeln();}
	//mozillaの処理
		else if(this.browser == "mozilla"){ document.writeln(mozStyle);}
	//NN4.x以下の処理
		else if(this.browser == "netscape" && this.version < 5){ document.writeln(oldStyle);}
	//IEの処理
		else if(this.browser == "ie"){
			//IE5.5以下の処理
			if(this.version < 5.5){ document.writeln(oldStyle);}
			//IE5.5SP2以下の処理
			else if(this.version == 5.5 && (this.amv.indexOf('SP2',0) < 0 )){ document.writeln(wieStyle);}
			//IE5.5SP2,IE6の処理
			else if(this.version <= 6.0){ document.writeln(wieStyle);}
			//IE7の処理
			else { document.writeln(wieStyle);}
		}
	//その他のブラウザの処理
		else if(this.browser == "other"){ document.writeln(othStyle);}
	//その他の通常処理
		else{	document.writeln();
		}

	//Windows Vista
		if (this.osVersion >= 6.0){ document.writeln(vstStyle);}
	}


	//MacOS
	if (this.userOs == "Mac"){
	//Safariの処理
		if(this.browser == "safari"){	document.writeln(msfStyle);} 
	//Operaの処理
		else if(this.browser == "opera"){ document.writeln(opStyle);}
	//Firefoxの処理
		else if(this.browser == "firefox"){ document.writeln(mffStyle);}
	//Caminoの処理
		else if(this.browser == "camino"){ document.writeln(mcaStyle);}
	//mozillaの処理
		else if(this.browser == "mozilla"){ document.writeln(mozStyle);}
	//IE4.x,NN4.x以下の処理
		else if((this.browser == "ie" && this.version < 5) || (this.browser == "netscape" && this.version < 5)){ document.writeln(oldStyle);}
	//IE5以上の処理
		else if(this.browser == "ie" && this.version >= 5){ document.writeln(mieStyle);}
	//NN6以上の処理
		else if(this.browser == "netscape" && this.version >= 5){ document.writeln(mnsStyle);}
	//その他のブラウザの処理
		else if(this.browser == "other"){ document.writeln(othStyle);}
	//その他の通常処理
		else{	document.writeln();}
	//Mac 共通
		document.writeln(macStyle);
	}

	//OtherOS
	if(this.userOs == "OtherOS"){	document.writeln();
	}


// Set Global Variable
GL_UserOs = this.userOs;
GL_OsVersion = this.osVersion;
GL_Browser = this.browser;
GL_Version = this.version;
GL_Standard = this.standard;

}

bsCheck.setEvt();

/* ---------------------------------------------------------------------- */



/* ---------------------------------------------------------------------- */
// library function ////////////////////////////////////////////////////////


// addLoadEvent ////////////////////////////////////////////////////////////
function addLoadEvent(func) {
	// addEventListener
	if(typeof window.addEventListener == 'function'){ 
		window.addEventListener('load', func, false);
		return true;
	}
	// attachEvent(IE)
	else if(typeof window.attachEvent == 'object'){ 
		window.attachEvent('onload', func);
		return true;
	}
	// unknown
	var oldonload = window.onload; 
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
	return false;
}


// addUnLoadEvent //////////////////////////////////////////////////////////
function addUnLoadEvent(func) {
	// addEventListener
	if(typeof window.addEventListener == 'function'){ 
		window.addEventListener('unload', func, false);
		return true;
	}
	// attachEvent(IE)
	else if(typeof window.attachEvent == 'object'){ 
		window.attachEvent('onunload', func);
		return true;
	}
	// unknown
	var oldonunload = window.onunload; 
	if (typeof window.onunload != 'function') {
		window.onunload = func;
	} else {
		window.onunload = function() {
			oldonunload();
			func();
		}
	}
	return false;
}


// set cookie //////////////////////////////////////////////////////////////
function setCookie(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;
  document.cookie = name+"="+value+expires+"; path=/";
}


// get cookie //////////////////////////////////////////////////////////////
function getCookie(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;
}


// id取得 //////////////////////////////////////////////////////////////////
function $ID(id){
	return document.getElementById(id);
}


// タイマーセット //////////////////////////////////////////////////////////
function STO(target,_scd){
	return window.setTimeout(target,_scd);
}


// window open /////////////////////////////////////////////////////////////
function openWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}


// Jamp menu ///////////////////////////////////////////////////////////////
function selectJump(parts)
{
	if (parts.options[parts.selectedIndex].value != "")
		location = parts.options[parts.selectedIndex].value;
}


// show hide Element ///////////////////////////////////////////////////////
function simpleElmSwitch(id) {
	var target = $ID(id).style;
	if (target.display == "block") {
		target.display = "none";
	} else {
		target.display = "block";
	}
	return false
}


// ウインドウの高さを取得 //////////////////////////////////////////////////
function getWinH(){
	// ie以外
	if (!document.all && (document.layers || document.getElementById)) {
		return window.innerHeight;
  }
	// ie6標準
	else if (document.getElementById && (document.compatMode=='CSS1Compat')) {
		return document.documentElement.clientHeight;
  }
	// ie互換
	else if (document.all) {
		return document.body.clientHeight;
   }
	return false;
}


// Yのoffsetを取得 /////////////////////////////////////////////////////////
function getWinOffY(){
	// ie以外
	if (!document.all && (document.layers || document.getElementById)) {
		return window.pageYOffset;
  }
	// ie6標準
	else if (document.getElementById && (document.compatMode=='CSS1Compat')) {
		return document.body.parentNode.scrollTop;
  }
	// ie互換
	else if (document.all) {
		return document.body.scrollTop;
  }
	return false;
}


// 表示領域の幅を取得 //////////////////////////////////////////////////////
function getPageWidth() {
  var nWidth;
	if(GL_Browser == "ie"){
		if (GL_Standard) {
      nWidth = document.documentElement.clientWidth;
		} else {
			nWidth = document.body.clientWidth;
		}
	} else {
    nWidth = window.innerWidth;
	}
	return nWidth;
}


// 表示領域の高さを取得 ////////////////////////////////////////////////////
function getPageHeight() {
  var nHeight;
	if(GL_Browser == "ie"){
		if (GL_Standard) {
      nHeight = document.documentElement.clientHeight;
		} else {
			nHeight = document.body.clientHeight;
		}
	} else {
    nHeight = window.innerHeight;
	}
	return nHeight;
}


// bodyからの距離(top)を取得 ///////////////////////////////////////////////
function offtop( obj ) {
  var posTop = 0;
  if ( obj ) {
    posTop = obj.offsetTop;
    if ( obj.offsetParent ) {
      posTop += offtop( obj.offsetParent );
    }
  }
  return posTop;
}


// bodyからの距離(left)を取得 //////////////////////////////////////////////
function offleft( obj ) {
  var posLeft = 0;
  if ( obj ) {
    posLeft = obj.offsetLeft;
    if ( obj.offsetParent ) {
      posLeft += offleft( obj.offsetParent );
    }
  }
  return posLeft;
}

/* ---------------------------------------------------------------------- */



/*[F]*/