/* Basic */
this.rootDir  = "/common/";
//this.rootDir  = "/netyear/common/";
this.cssDir   = this.rootDir + "css/";

/* Output common */
var cssStaDir = this.rootDir + "css/";
var cssStaTags = '<link rel="stylesheet" type="text/css" href="';
var flag2 = null;

/* Definition */
var _agent = navigator.userAgent.toLowerCase();
var _win = (_agent.indexOf('win') != -1);
var _mac = (_agent.indexOf('mac') != -1);
var _major = parseInt(navigator.appVersion);
var _minor = parseFloat(navigator.appVersion);
var _ns    = ((_agent.indexOf('mozilla') != -1) && (_agent.indexOf('compatible') == -1));
var _ns4   = (_ns && (_major == 4));
var _ns4up = (_ns && (_major >= 5));
var _nav   = (_ns && ((_agent.indexOf(';nav') != -1) || (_agent.indexOf('; nav') != -1)));
var _ie    = (_agent.indexOf('msie') != -1);
var _safari = (_agent.indexOf('safari') != -1);

/* Output css */
var cssDir = this.rootDir + "css/";
var cssTags = '<link rel="stylesheet" type="text/css" title="FontProperty" href="';
var flag = null;
if (_win) {
	if (_ie) {
		flag = 'wie';
		flag2 = 'common';
		document.open();
		document.write(cssStaTags + cssStaDir + flag2 + '.css">'); 
		document.write(cssTags + cssDir + flag + '.css" title="WinIE_style">');
		document.close();
	}
	else if (_ns4 || _nav ||_ns4up) { // win_ns 4.x
		flag = 'wns';
		flag2 = 'common';
		document.open();
		document.write(cssStaTags + cssStaDir + flag2 + '.css">'); 
		document.write(cssTags + cssDir + flag + '.css" title="WinNS4_style">');
		document.close();
	}
	else {
		flag = 'wie';
		flag2 = 'common';
		document.open();
		document.write(cssStaTags + cssStaDir + flag2 + '.css">'); 
		document.write(cssTags + cssDir + flag + '.css" title="WinIE_style">');
		document.close();
	}
}

else if (_mac) {
	if (_ie || _safari) {	// ie or safari
		flag = 'mie';
		flag2 = 'common';
		document.open();
		document.write(cssStaTags + cssStaDir + flag2 + '.css">'); 
		document.write(cssTags + cssDir + flag + '.css" title="MacIE_style">');
		document.close();
	}
	else if (_ns4 || _nav ||_ns4up) { // mac_ns 4.x
		flag = 'mns';
		flag2 = 'common';
		document.open();
		document.write(cssStaTags + cssStaDir + flag2 + '.css">'); 
		document.write(cssTags + cssDir + flag + '.css" title="MacNS4_style">');
		document.close();
	}
	else {
		flag = 'mie';
		flag2 = 'common';
		document.open();
		document.write(cssStaTags + cssStaDir + flag2 + '.css">'); 
		document.write(cssTags + cssDir + flag + '.css" title="MacIE_style">');
		document.close();
	}
}

else {
	flag = 'wie';
	flag2 = 'common';
	document.open();
	document.write(cssStaTags + cssStaDir + flag2 + '.css">'); 
	document.write(cssTags + cssDir + flag + '.css" title="WinIE_style">');
	document.close();
}
/* for debug */
//alert(flag);
//alert(flag2);

/* for access logs */
document.write("<div style='display:none;'><img src='http://www.weekend-homes.com/cgi-bin/_acp/acc/acclog.cgi?");
document.write("referrer="+document.referrer+"&");
document.write("width="+screen.width+"&");
document.write("height="+screen.height+"&");
document.write("color="+screen.colorDepth+"'><\/div>");

/* Normal Menu */
function preimg(){
var loadcomp = false;
	var preload = new Array();
	for(i = 0 ; i < preloadlist.length ; i++) {
		preload[i] = new Image();
		preload[i].src = preloadlist[i];
	}
	loadcomp = true;
}
function chgimg(target,filename){
	document.images[target].src = filename;
}

/* POPUP */
function OpenPopup(Link,WinTarget,breite,hoehe) {
	if (!!window && Link) {
	var winPopup = window.open(Link ,WinTarget,"toolbar=yes,location=no,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,favorites=no,width=" + breite + ",height=" + hoehe + "");
	winPopup.focus();
	}
}

function OpenPopupMap(Link,WinTarget,breite,hoehe) {
	if (!!window && Link) {
	var winPopup = window.open(Link ,WinTarget,"toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,favorites=no,width=" + breite + ",height=" + hoehe + "");
	winPopup.focus();
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/* layer Menu */
function findObj(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=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function showHideLayers() {
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
function preloadImages() {
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}
function swapImgRestore() {
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function swapImage() {
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//** 以下 Weekend
function jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function LTrim(str){
  while(str.charAt(0)==" " || str.charAt(0)=="　"){
    str = str.substring(1,str.length)
  }
  return(str); 
}

function RTrim(str){
  while(str.charAt(str.length-1)==" " || str.charAt(str.length-1)=="　"){
    str = str.substring(0,str.length-1)
  }
  return(str); 
}

//正規表現
function Trim(str){
  str = str.replace(/^[ 　]+/,"");
  str = str.replace(/[ 　]+$/,"");
  return(str);
}

function openSampleWin_movie(url){
	if(document.all || window.opera) {
		var attrs = "menubar=no,";
		attrs += ",toolbar=no";
		attrs += ",location=no";
		attrs += ",directories=no";
		attrs += ",status=no";
		attrs += ",scrollbars=no";
		attrs += ",width=820";
		attrs += ",height=680";
		attrs += ",resizable=no";
	}
	else if(document.getElementById || document.layers){
		var attrs = "menubar=no,";
		attrs += ",toolbar=no";
		attrs += ",location=no";
		attrs += ",directories=no";
		attrs += ",status=no";
		attrs += ",scrollbars=no";
		attrs += ",width=820";
		attrs += ",height=680";
		attrs += ",resizable=no";
	}
	else {
		var attrs = "menubar=no,";
		attrs += ",toolbar=yes";
		attrs += ",location=yes";
		attrs += ",directories=yes";
		attrs += ",status=yes";
		attrs += ",scrollbars=yes";
		attrs += ",resizable=yes";
	}
	var wo = window.open("", "JS_hscroll_sample", attrs);
	wo.focus();
	wo.location.href=url;
}

function JSFX_FloatTopDiv()
{
//	下記は引数にて対応
//	var startX = 620,startY = 200;

	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	function ml(id)
	{
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x;this.style.top=y;};
		el.x = startX;
		if (verticalpos=="fromtop")
		el.y = startY;
		else{
		el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		el.y -= startY;
		}
		return el;
	}
	window.stayTopLeft=function()
	{
		if (verticalpos=="fromtop"){
		var pY = ns ? pageYOffset : document.body.scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		else{
		var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 10);
	}
	ftlObj = ml("divStayTopLeft");
	stayTopLeft();
}
