
/* #####################################################

■admin_post.js
　コンパネ制御スクリプト

■Index
　---------
　Cookie
　---------
　Old Func
　
　※grobal.js、zoomimage.jsを内包

##################################################### */



/* Cookie制御
------------------------------------------------------------------------------------------ */

var Cookie = {

	set : function(p_name, p_value, p_expires, p_path, p_domain, p_secure){
		var v_text = '';
		var v_text = p_name + '=' + escape(p_value);
		if(p_expires){ v_text = v_text + '; expires=' + p_expires.toGMTString(); }
		if(p_path){ v_text = v_text + '; path=' + p_path; }
		if(p_domain){ v_text = v_text + '; domain=' + p_domain; }
		if(p_secure){ v_text = v_text + ';' + p_secure; }
		document.cookie = v_text;
	},
	
	get : function(p_name){
		if(document.cookie){
			index = document.cookie.indexOf(p_name, 0);
			if(index != -1){
				var val_start = (document.cookie.indexOf('=', index) + 1);
				var val_end = document.cookie.indexOf(';', index);
				if(val_end == -1){ val_end = document.cookie.length; }
				return(unescape(document.cookie.substring(val_start, val_end)));
			}
		}
		return(null);
	},
	
	save : function(sId, value, rimit){
		var p_expires = new Date();
		if(value == '' ) value = 'null';
		p_expires.setTime(p_expires.getTime() + (rimit * 30 * 24 * 60 * 60 * 1000));
		var p_path = '/';
		var p_domain = null;
		var p_secure = false;
		this.set(sId, value, p_expires, p_path, p_domain, p_secure);
	}
}



/* ------------------------------------------------------------------------------------------ */



/* grobal.js
------------------------------------------------------------------------------------------ */

/******************************************************************************
	関数名		ShowSearchLog
	機能		対象のログを表示する
	
	入力		sForm			フォーム名
				sKeyword		キーワード(YYYY/MM)
	出力		なし
	
	処理概要	1. 検索キーワードを入力フォームに格納する
				2. 月表示用FORMをsubmitする
******************************************************************************/
function ShowSearchLog(sForm, sKeyword){
	document.forms[sForm].elements['search_word'].value = sKeyword;
	document.forms[sForm].submit();
}



// ----------------------------------------------
// StyleSwitcher functions written by Paul Sowden
// http://www.idontsmoke.co.uk/ss/
// - - - - - - - - - - - - - - - - - - - - - - -
// For the details, visit ALA:
// http://www.alistapart.com/stories/alternate/
//
// nifty StyleSwitcher scripts modified by Aaron Jones 10/10/2002
// ----------------------------------------------

function setActiveStyleSheet(title, reset) {
	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;
		}
	}
	if (reset == 1) {
		CreateCookie("petit", title, 365);
	}
}

function setStyle(){
	var style = ReadCookie("petit");
	if (style != null) {
		setActiveStyleSheet(style, 0);
	}
}

function popChild(url, width, height, winName){
	var features = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=" + width + ",height=" + height;
	if (winName == "") {
		winName = "childWin";
	}
	SmallWin = window.open(url,winName,features);
	if (window.focus) {
		SmallWin.focus();
	}
}

function loadParent(url) {
	var parentWin = window.opener;
	if (window.opener.closed) {
		window.open(url,"parentWin");
	} else {
		parentWin.location = url;
		
		if (window.focus) {
			parentWin.focus();
		}
	}
}

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=/; domain=petit.cc;";
	// ローカルでのチェック用
	//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;
	
}



/******************************************************************************
	サイドメニュー制御関連
******************************************************************************/
// サイドメニュー用オブジェクト格納配列
// ※ 関数呼び出しの際、「gSM[～ID名～].chgSideMenu()」と記述する
gSM = {};

function oSideMenu(idname){
	//メニューヘッダID名
	this.oHeader = idname + '_header';
	//メニューリストID名
	this.oContent = idname + '_content';
	//コンテンツ表示フラグ(0 : 非表示、1 : 表示)
	this.bFlg = 1;
}

/******************************************************************************
	関数名		chgSideMenu
	機能		サイドメニューを閉じたり開いたり
******************************************************************************/
oSideMenu.prototype.chgSideMenu = function(){
	//ヘッダの高さを変更(背景画像の高さに合わせるため)
	document.getElementById(this.oHeader).style.height = (this.bFlg)? '25px' : '23px';
	//ヘッダの背景画像を変更
	document.getElementById(this.oHeader).style.backgroundImage = (this.bFlg)? 'url(/0img/bkg_sm_close.gif)' : 'url(/0img/bkg_sm_open.gif)';
	//メニューリストの表示を変更
	document.getElementById(this.oContent).style.display = (this.bFlg)? 'none' : 'block';
	//フラグ変更
	this.bFlg = (this.bFlg)? 0 : 1;
}

/******************************************************************************
	サイドメニューオブジェクトを生成
******************************************************************************/
for(iCnt = 0; iCnt < 4; iCnt++){ gSM['sm' + iCnt] = new oSideMenu('sm' + iCnt); }






/* zoomimage.js
------------------------------------------------------------------------------------------ */

/*******************************************************************************
	関数名		ZoomImage
	機能		画像をクリックすると、別ウィンドウに画像を表示する。
	
	入力		sImg		画像ファイル名
				sImgClass	画像に設定するクラス名
*******************************************************************************/
function ZoomImage(sImg, sImgClass){
	aHtmlLines = new Array();
	var iCnt=0;
	var iTmpCnt=0;
	var sNavigator = GetNavigatorName();
	wImg = window.open('', '_blank');
	
	if(sNavigator == "Safari"){
		
		// ウィンドウサイズを取得する
		iWindowHeight = wImg.innerHeight;
		
	} else {
		// ウィンドウサイズを100%とする
		iWindowHeight = "100%";
	}
		
aHtmlLines[0] = "<html><head><title>ZOOM IN</title>";
aHtmlLines[1] = "<meta http-equiv='Content-Type' content='text/html;charset=Shift_JIS'>";
aHtmlLines[2] = "<link rel='stylesheet' href='../1tools/color_zoom.css' type='text/css'>";
aHtmlLines[3] = "</head><body scroll='auto' topmargin='0' leftmargin='0' marginheight='0' marginwidth='0'>";
aHtmlLines[4] = "<table border='0' cellpadding='0' cellspacing='0' width='100%' height='" + iWindowHeight + "'>";
aHtmlLines[5] = "<tr><td align='center' valign='center' width='100%' height='" + iWindowHeight + "'>";
aHtmlLines[6] = "<table border='0' cellpadding=0 cellspacing=0><tr>";
aHtmlLines[7] = "<td align='center' nowrap><a href='javascript:window.close()' title='ウィンドウを閉じる'><img src='" + sImg + "' class='" + sImgClass + "' border=0></a></td>";
aHtmlLines[8] = "</tr></table></td></tr></table></body></html>";
	
	wImg.document.open();
	for(iCnt=0; iCnt < 9; iCnt++){
		wImg.document.write(aHtmlLines[iCnt]);
	}
	wImg.document.close();
}


function GetNavigatorName(){
	if(navigator.IBM_HPR) return "HomepageReader";
	
	aName  = navigator.userAgent.toUpperCase();
	if (aName.indexOf("SAFARI") >= 0) return "Safari";
	if (aName.indexOf("CHIMERA") >= 0) return "Camino";
	
	aName = navigator.appName.toUpperCase();
	if (aName.indexOf("NETSCAPE") >= 0)  return "Netscape";
	if (aName.indexOf("MICROSOFT") >= 0) return "Explorer";
	return "";
}
