/* [charset="UTF-8"]
 Stylesheet Selector for IE 5+ and Gecko (Standards Extra EDITION)
 v 0.8.0 + (Opera 7.5x + XHTMLモード対策済)
 (c) Hiro Konda. 2005/07/27
 http://www.minc.ne.jp/~konda/web_resoce/js/css-select/index.html
*/

var d = document;
var w = window;
var nv = navigator;
var ua = nv.userAgent;

/* ++++ Settings [START] (設定 ここから) ++++ */

// IE 5.0以降のみ動作？
var cssFormIeOnly = false;

// クッキーを使用して CSS選択タイトル記憶？
var cssCookieEnabled = true;

// クッキー名
var cssCookieTitleKey = "CSS_SELECT";// 選択タイトルキー
var cssCookieDisplayKey = "CSS_SELECT_DISP";// ウィンドウ表示キー

// クッキー有効 期限日数
var cssCookieExpiresDays = 15;

// クッキー有効 ディレクトリ
var cssCookiePath = (w.location.protocol == "file:") ? '' : '/iguttchi/';

// スタイル無効化用 クッキー保存タイトル
var cssDisabledTitle = "Disabled CSS";

// スタイル選択フォーム用 挿入先ID (無しだと body 直下)
var cssFormInsId = "";

// スタイル選択フォーム用 スタイル (不要ならば、空にしてください。外部CSSならば #cssForm)
var cssFormStyle = "#cssForm";

// エラーメッセージを抑圧する
var cssAlertSuppress = false;

// タイトルが不明な場合は、各ページ共通スタイルとして有効か？
var cssNoTitleEnabled = true;

// バージョン情報 (不要ならば、空にしてください)
var cssScriptVersion = "Stylesheet Selector for IE 5+ and Gecko v 0.8.0 + \n\n";

/* ++++ Settings [END] (設定 ここまで) ++++ */

var nsURI = (d.documentElement && d.documentElement.namespaceURI) ? d.documentElement.namespaceURI : '';
var isXHTML = (nsURI == 'http:\/\/www.w3.org\/1999\/xhtml' || nsURI == 'http:\/\/www.w3.org\/2002\/06\/xhtml2\/') ? 1 : 0;
var userLang = (nv.userLanguage) ? nv.userLanguage : (nv.language) ? nv.language:'';
var jp = (userLang.indexOf('ja')!=-1) ? 1 : 0;
//alert('isXHTML (1/0) ? '+isXHTML+'\nnsURI = '+nsURI);

/* ++++ JavaScript Support Check ++++ */

var axo = (w.ActiveXObject) ? 1 : 0;
var gtn = (d.getElementsByTagName) ? 1 : 0;
var ccs = (d.createCDATASection) ? 1 : 0;
var cns = (d.createElementNS) ? 1 : 0;
var cm  = (d.compatMode) ? 1 : 0;
var op = (w.opera) ? 1 : 0;
var vs = (nv.vendor && typeof nv.vendor == 'string') ? 1 : 0;

var jsv = 0;
var winIe = 0;
var macIe = 0;
/*@cc_on jsv = @_jscript_version; @if (@_win64 || @_win32 || @_win16) winIe = 1; @elif (@_mac && (@_PowerPC || @_mc680x0)) macIe = 1; @end @*/

var saf = (vs && ccs && cns && ua.indexOf('AppleWebKit') != -1) ? 1 : 0;
var kde = (vs && ccs && cns && ua.indexOf('Konqueror') != -1) ? 1 : 0;
var gec = (vs && ccs && cns && nv.product && nv.product == 'Gecko' && !saf && !kde) ? 1 : 0;
var winIe7 = (winIe && gtn && cm && axo && jsv > 5.6) ? 1 : 0;
var winIe6 = (winIe && gtn && cm && axo && jsv == 5.6) ? 1 : 0;
var winIe55 = (winIe && gtn && !cm && axo && jsv == 5.5) ? 1 : 0;
var winIe5 = (winIe && gtn && !cm && axo) ? 1 : 0;
var macIe5 = (macIe && gtn && !cm && !cns && ccs) ? 1 : 0;
var op8 = (op && cns && ccs) ? 1 : 0;
var op7 = (op && cns && !ccs && cm) ? 1 : 0;
var op6 = (op && !cns && !cm) ? 1 : 0;
var nn4 = (d.layers) ? 1 : 0;

/* ブラウザ別実行 */
if (winIe7 || winIe6 || winIe55 || winIe5) {
	w.attachEvent("onload", cssInIt);
} else if (macIe5) {
	w.onload = function() { cssInIt();}
} else if (op7 || op8) {
	w.attachEvent("onload", cssInIt);
} else if (d.implementation && d.implementation.hasFeature("HTMLEvents", "2.0")) {
	// Gecko, Safari
	w.addEventListener("load", cssInIt, false);
} else if (nn4) {
	var nW = w.innerWidth;
	var nH = w.innerHeight;
	w.captureEvents(Event.RESIZE);
	w.onresize = onresizeNN4;
}

/* 開始チェック (各種エラー避け) */
function cssInIt() {

	/* 最低限これが動かなきゃ...。 */
	if (!(d.getElementsByTagName || d.getElementsByTagNameNS)) { return;}

	/* IE 専用ですか？ */
	if (cssFormIeOnly && !((winIe || macIe))) { cssErrFunc(1,''); return;}

	/* さて選択フォームを作りましょう */
	makeCssSelectForm();
}

/* スタイル選択フォームを作る */
function makeCssSelectForm() {

/* スタイルシート配列 取得 */
var ss = (d.styleSheets) ? d.styleSheets : getStyleSheetsArray(true);
if (!ss) { return;}

/* フォーム挿入先要素 */
var insTopElement = (cssFormInsId == '') ? (GetElementsByPrefixTagName(nsURI,'html','body'))[0] : d.getElementById(cssFormInsId);

/* cookie 取得 */
var getCssTitle = (nv.cookieEnabled && cssCookieEnabled) ? getCookie(cssCookieTitleKey) : "";
var getCssDisplay = (nv.cookieEnabled && cssCookieEnabled) ? getCookie(cssCookieDisplayKey) : "";

var i = 0;
var selIdx = 0;
var mulIdx = 0;
var ssLeng = ss.length;

/* フォームバッファ */
var optBuf = new Array(ssLeng + 1);
var frmBuf = '';

/* フォーム設定リソース */
var buttonStyle = "cursor:pointer;_cursor:hand;";
var buttonHelpStyle = "cursor:help;";
if (jp) {
	optBuf[ssLeng] = 'Disabled CSS (無効)'; var actButton = '変更'; var helpTips = 'ヘルプ'; var cookieClearTips = 'Cookie消去'; var closeTips = 'スタイルフォーム最小化'; openTips = 'スタイルフォーム最大化';
} else {
	optBuf[ssLeng] = 'Disabled CSS'; var actButton = 'Change'; var helpTips = 'Help ?'; var cookieClearTips = 'Set old expires Cookie'; var closeTips = 'CSS Selecter Menu Hide'; var openTips = 'CSS Selecter Menu Show';
}

	/* cookie 取得タイトルによるスタイル初期化 */
	if (getCssTitle != "") {
		if (getCssTitle == cssDisabledTitle) {
			cssSetDisabled(-1); selIdx = ssLeng;
		} else if (ssLeng > 0) {
			while (i < ssLeng) {
				if (ss[i].title == getCssTitle) { selIdx = i; break;}
				i++;
			}
			if (i < ssLeng) {
				if (ss[i].disabled == true) { cssSetDisabled(i);}
			}
			i = 0;
		}
	}

	/* スタイルタイトル取得 */
	while (i < ssLeng) {
		optBuf[i] = (ss[i].title && typeof ss[i].title == 'string') ? ss[i].title : 'StyleSheet ['+i+']';
		if (ss[i].disabled == false) { mulIdx++; if (mulIdx < 2) { selIdx = i;}}
		i++;
	}

	/* (X)HTMLベタフォーム部品を作る */
	if (!isXHTML) {
		frmBuf = '<div id="cssFormDiv"><select id="cssSel">'; i = 0;
		while (i < ssLeng + 1) {
			frmBuf += '<option';
			if (selIdx == i) { frmBuf += ' selected="selected"';}
			frmBuf += ' value="'+i+'">'+optBuf[i]+'<\/option>';
			i++;
		}
		frmBuf += '<\/select><br \/>';
		frmBuf += '<input id="cssFormAct" type="button" onclick="cssChangeSelected()" style="'+buttonStyle+'" value="'+actButton+'" title="'+actButton+'" \/>';
		if (cssCookieEnabled) { frmBuf += '<input id="cssFormCC" type="button" onclick="cssCookieClear()" style="'+buttonStyle+'" value=" C " title="'+cookieClearTips+'" \/>';}
		frmBuf += '<input id="cssFormHide" type="button" onclick="cssSelectDisplay(0,1)" style="'+buttonStyle+'" value=" - " title="'+closeTips+'" \/>';
		frmBuf += '<input id="cssFormHelp" type="button" onclick="cssSelectHelp()" style="'+buttonHelpStyle+'" value=" ? " title="'+helpTips+'" \/><\/div>';
		frmBuf += '<div id="cssFormShowDiv" style="display:none;"><input id="cssFormShow" type="button" onclick="cssSelectDisplay(1,1)" style="'+buttonStyle+'" value=" + " title="'+openTips+'" \/><\/div>\n';
	}

	/* (X)HTMLを挿入 */
	if (!isXHTML && (winIe || macIe)) {
		insTopElement.insertAdjacentHTML('afterBegin','<form id="cssForm" style="'+cssFormStyle+'" action="#">'+frmBuf+'<\/form>\n');
	} else {
		CEInsert('afterBegin',insTopElement,new Array('form','id','cssForm','style',cssFormStyle,'action','#'),'');
		if (isXHTML) {
			CEAppendChild(d.getElementById('cssForm'),new Array('div','id','cssFormDiv'));
			CEAppendChild(d.getElementById('cssFormDiv'),new Array('select','id','cssSel'));
			OptAppendChild(d.getElementById('cssSel'),selIdx,optBuf,null);
			CEInsert('afterEnd',d.getElementById('cssSel'),new Array('input','id','cssFormAct','type','button','style',buttonStyle,'value',actButton,'title',actButton,'onclick','cssChangeSelected()'),'');
			CEInsert('afterEnd',d.getElementById('cssFormAct'),new Array('input','id','cssFormHide','type','button','style',buttonStyle,'value',' - ','title',closeTips,'onclick','cssSelectDisplay(0,1)'),'');
			CEInsert('afterEnd',d.getElementById('cssFormHide'),new Array('input','id','cssFormHelp','type','button','style',buttonHelpStyle,'value',' ? ','title',helpTips,'onclick','cssSelectHelp()'),'');
			if (cssCookieEnabled) CEInsert('afterEnd',d.getElementById('cssFormAct'),new Array('input','id','cssFormCC','type','button','style',buttonStyle,'value',' C ','title',cookieClearTips,'onclick','cssCookieClear()'),'');
			CEInsert('afterEnd',d.getElementById('cssSel'),new Array('br'),'');
			CEInsert('afterEnd',d.getElementById('cssFormDiv'),new Array('div','id','cssFormShowDiv','style','display:none;'),'');
			CEAppendChild(d.getElementById('cssFormShowDiv'),new Array('input','type','button','id','cssFormShow','style',buttonStyle,'value',' + ','title',openTips,'onclick','cssSelectDisplay(1,1)'));
		} else {
			d.getElementById('cssForm').innerHTML = frmBuf;
		}
	}
	if (getCssDisplay == "0") { cssSelectDisplay(0,0);}
}

/* document.styleSheets もどき (Non supported xml-stylesheet) */
function getStyleSheetsArray(ini) {
var ss = new Array();
var ssCnt = 0;
var i = 0;
var hChilds = (GetElementsByPrefixTagName(nsURI,'html','head'))[0].childNodes;

	while (i < hChilds.length) {
		var elm = hChilds.item(i);
		if (elm.tagName != undefined) {
			var tag = elm.tagName.toLowerCase();
			if (tag == 'link' || tag == 'html:link') {
				var ssRel = (typeof elm.rel == 'string') ? elm.rel.toLowerCase() : '';
				if (ssRel == "stylesheet" || ssRel == "alternate stylesheet") {
					ss[ssCnt] = elm; ssCnt++;
					if (ini) { elm.disabled = (ssRel == "stylesheet") ? false : true;}
				}
			} else if (tag == 'style' || tag == 'html:style') {
				ss[ssCnt] = elm; ssCnt++;
			}
// alert('idx = ' + i + ' ssCnt ['+ssCnt+'] / tagName = ' +elm.tagName);
		}
		i++;
	}
	return (ssCnt > 0) ? ss : new Array(0);
}

/* スタイル変更 */
function cssSetDisabled(exclude) {
var ss = (d.styleSheets) ? d.styleSheets : getStyleSheetsArray(false);
if (!ss) { cssErrFunc(1,''); return;}

var i = 0;
var flg;

	while (i < ss.length) {
		if (exclude == -1) {
			ss[i].disabled = true;
		} else {
			if (typeof ss[i].title == 'string' && cssNoTitleEnabled) {
				flg = (ss[i].title == '') ? false : true;
			}
			ss[i].disabled = (exclude == i) ? false : flg;
		}
		i++;
	}
}

/* メディアタイプチェック */
function cssMediaTypesCheck(mediaList,supportMedia) {
var enMediaList = new Array('all','screen','print','aural','projection','handheld','tv','ttv','braille','speech');
var jaMediaList = new Array('全般','高解像度モニタ','印刷','音声','プロジェクター','携帯端末','低解像度テレビ','テレタイプ','点字装置','音声操作');
var i = j = andFlg = 0;
var errMediaTypes = "\n";

	while (mediaList.length > i) {
		if (supportMedia.indexOf(mediaList[i]) != -1) { return 1;} i++;
	}
	i = 0;

	while (mediaList.length > i) {
		while (enMediaList.length > j) {
			if (mediaList[i] == enMediaList[j]) {
				errMediaTypes += enMediaList[j];
				errMediaTypes += (jp) ? "("+jaMediaList[j]+")" : " ";
				andFlg++; break;
			}
			j++;
		}
		if (andFlg && mediaList.length > i+1) {
			errMediaTypes += (jp) ? "及び、" : "and, "; andFlg = 0;
		}
		i++; j = 0;
	}

	cssErrFunc(6,errMediaTypes);
	return 0;
}

/* [Change] Change style button (スタイル選択変更ボタン) */
function cssChangeSelected() {
var ss = (d.styleSheets) ? d.styleSheets : getStyleSheetsArray(false);
if (!ss) { cssErrFunc(1,''); return 0;}

var i = parseInt(d.getElementById('cssSel')[d.getElementById('cssSel').selectedIndex].value);
var cssTitleSaveKey, mediaList;

	if (ss.length == i) {
		cssSetDisabled(-1);
		cssTitleSaveKey = cssDisabledTitle;
	} else {
		cssSetDisabled(i);
		cssTitleSaveKey = (ss[i] && typeof ss[i].title == 'string') ? ss[i].title : "StyleSheet ["+i+"]";
		if (ss[i].media) {
			if (typeof ss[i].media == 'string') {/* IE or DOM1 HTML (Style Colection) */
				mediaList = ss[i].media.split(",");
			} else if (typeof ss[i].media == 'object' && ss[i].ownerNode) {/* DOM2 Style */
				mediaList = ss[i].ownerNode.media.split(",");
			}
			if (mediaList.length > 0) {
				if (winIe || macIe || gec || saf || kde) { cssMediaTypesCheck(mediaList,"all,screen,print");}
				else if (op8) { cssMediaTypesCheck(mediaList,"all,screen,print,projection,handheld");}
			}
		}
	}

	if (nv.cookieEnabled && cssCookieEnabled) {
		setCookie(cssCookieTitleKey,cssTitleSaveKey,cssCookieExpiresDays,cssCookiePath);
		var retCookie = getCookie(cssCookieTitleKey);
		if (retCookie == cssTitleSaveKey) { return 1;}
		cssErrFunc(2,'');
	}
	return 0;
}

/* [C] Cookie button (クッキー消去ボタン) */
function cssCookieClear() {

	if (nv.cookieEnabled && d.cookie != "") {
		clearCookie(cssCookieDisplayKey,cssCookiePath);
		var nowCookie = getCookie(cssCookieTitleKey);
		if (nowCookie == "") {
			cssErrFunc(3,cssCookieTitleKey);
		} else {
			var clMsg = (jp) ? "クッキーの有効期限を終了させ消去しますがよろしいですか？\nスタイル："+nowCookie : "Cookie expires time out ? (Remove Cookie)\nSTYLE TITLE : "+nowCookie;
			if (w.confirm(cssScriptVersion + clMsg)) {
				clearCookie(cssCookieTitleKey,cssCookiePath);
				var lestCheck = getCookie(cssCookieTitleKey);
				if (lestCheck != "") { cssErrFunc(5,lestCheck);}
				clMsg = (jp) ? "再描画の為にページを再読込みしますか？" : "Reload This Page ?";
				if (w.confirm(cssScriptVersion + clMsg)) { w.location.reload();}
			}
		}
	} else {
		cssErrFunc(4,'');
	}
}

/* [?] help button (ヘルプボタン) */
function cssSelectHelp() {
var clMsg = "";

	if (jp) {
		clMsg = "この選択リストから選んだタイトルのスタイルシートを、\n[ 変更 ] ボタンを押して適用させる事が出来ます。";
		if (nv.cookieEnabled && cssCookieEnabled) { clMsg += "\n[ C ] ボタンを押すと、クッキー有効期限を終了させます。";}
		clMsg += "\n[ - ] ボタンを押すと、このフォーム表示を最小化させます。";
		clMsg += "\nフォーム表示最小化の際に [ + ] ボタンを押すと、\nフォームを元の状態に表示復帰させます。";
	} else {
		clMsg = "This is StyleSheets Selector.";
	}
	w.alert(cssScriptVersion + clMsg);
}

/* [ - ] or [ + ] form hide or show (フォーム表示切替えボタン) */
function cssSelectDisplay(flg,blnSave) {
	d.getElementById('cssFormDiv').style.display = (flg) ? 'block' : 'none';
	d.getElementById('cssFormShowDiv').style.display = (flg) ? 'none' : 'block';

	if (!nv.cookieEnabled || !cssCookieEnabled || !blnSave) return;

	if (flg) {
		clearCookie(cssCookieDisplayKey,cssCookiePath);
	} else {
		setCookie(cssCookieDisplayKey,"0",cssCookieExpiresDays,cssCookiePath);
	} 
}

/* Err Messeges */
function cssErrFunc(num,str) {
if (cssAlertSuppress) { return;}
var e;
	switch (num) {
		case 1: e = (jp) ? "このブラウザでは、設定により動作を許可されていません。 " : "Out of servise for the script settings."; break;
		case 2: e = (jp) ? "ブラウザ設定により、クッキーの書き込みに失敗しました。" : "cookie access failed in your web browser security settings."; break;
		case 3: e = (jp) ? "サイト階層に関連するクッキーが存在しますが、クッキーの取得に失敗しました。\n"+str : "Cookie get data failed.\n"+str; break;
		case 4: e = (jp) ? "ブラウザ設定でクッキーが無効化されているか、\nサイト階層に対応する有効なクッキーが存在しません。" : "Non supported Cookie or Do not have any Cookie."; break;
		case 5: e = (jp) ? "ブラウザ設定により、クッキーの上書き消去に失敗したか、\nサイト階層に関連する別のクッキーが残っています。\nスタイル : "+str : "Cookie access failed in your web browser security settings. or the lest in cookie.\nSTYLE TITLE : "+str; break;
		case 6: e = (jp) ? "このスタイルシートは、"+str+"メディアタイプ用なので、ご利用中のブラウザには適しません。\nこのタイトルは、なるべく選択しないでください。" : "This media-types stylesheet is not mach on this browser.\nNon supported "+str+" media-types"; break;
		default: e = (jp) ? '不明なエラーコード' : 'Other'; break;
	}
	w.alert(cssScriptVersion + e);
}

/* +++ Basic cookie functions (original by Mr.tohoho) +++ */
function getCookie(key) {
	var tmp1 = " " + d.cookie + ";";
	var tmp2 = "";
	var xx1 = xx2 = xx3 = 0;
	var len = tmp1.length;
	while (xx1 < len) {
		xx2 = tmp1.indexOf(";", xx1);
		tmp2 = tmp1.substring(xx1 + 1, xx2);
		xx3 = tmp2.indexOf("=");
		if (tmp2.substring(0, xx3) == key) {
			return (unescape(tmp2.substring(xx3 + 1, xx2 - xx1 - 1)));
		}
		xx1 = xx2 + 1;
	}
	return ("");
}

function setCookie(key, val, expiresDays, path) {
	var cd = new Date();
	cd.setTime(cd.getTime() + 24 * 3600 * 1000 * expiresDays);
	var cookieExpires = (expiresDays) ? cd.toGMTString() : "Tue, 31-Dec-2030 23:59:59";
	var tmp = key + "=" + escape(val) + "; expires=" + cookieExpires + "; ";
	if (path != "") { tmp += "path="+path;}
	d.cookie = tmp;
}

function clearCookie(key, path) {
	var tmp = key + "=remove; expires=Tue, 1-Jan-1980 00:00:00;";
	if (path != "") { tmp += "path="+path;}
	d.cookie = tmp;
}

/* +++ DOM 1/2 basical functions (DOM 基本的操作関数群) +++ */

function GetElementsByTagName(xmlnsURI,tagName) {
	return ((xmlnsURI && d.getElementsByTagNameNS) ? d.getElementsByTagNameNS(xmlnsURI,tagName) : d.getElementsByTagName(tagName.toUpperCase()));
}

function CreateElement(xmlnsURI,tagName) {
	return ((xmlnsURI && d.createElementNS) ? d.createElementNS(xmlnsURI,tagName) : d.createElement(tagName.toUpperCase()));
}

/* Opera 7.5 + XHTMLモード対策用 Object Collectionもどき */
function GetElementsByPrefixTagName(xmlnsURI,prefix,tagName) {
if ((GetElementsByTagName(xmlnsURI,'head')).length != 0) { return (GetElementsByTagName(xmlnsURI,tagName));}

var tagsAll = GetElementsByTagName(xmlnsURI,'*');
var tagsAllLen = tagsAll.length;
var pElments = new Array();
var pTagName = prefix + '\:' + tagName;
var getCnt = 0;
var i = 0;
//var debugBuf = '';

	while (tagsAllLen > i) {
		if (tagsAll.item(i).tagName == pTagName) {
			pElments[getCnt] = tagsAll.item(i);
//			debugBuf += tagsAll.item(i).tagName +' ['+getCnt+'] Get AllTags in ['+ i +'] \n';
			getCnt++;
		}
		i++;
	}

	/* Debug List (AlertBox) */
//	w.alert('*** Get Elements '+ pTagName +' for '+tagsAllLen+' Elements ***\n'+ debugBuf);

	return ((getCnt > 0) ? pElments : GetElementsByTagName(xmlnsURI,tagName));
}

/* like insertAdjacentHTML with Single Element and text */
function CEInsert(insFlg,elm,tagDataArray,insTxtValue) {
var elmNew = CreateElement(nsURI,tagDataArray[0]);
	for (var i = 1; tagDataArray.length > i; i = i+2) {
		elmNew.setAttribute(tagDataArray[i],tagDataArray[i+1]);
		/* setAttribute "STYLE" (IE Only) */
		if ((winIe || macIe) && tagDataArray[i] == "style") { elmNew.style.cssText = tagDataArray[i+1];}
	}
	switch (insFlg) {
		case 'beforeBegin':
			elm.parentNode.insertBefore(elmNew,elm); break;
		case 'afterEnd':
			elm.parentNode.insertBefore(elmNew,elm.nextSibling); break;
		case 'afterBegin':
			elm.insertBefore(elmNew,elm.firstChild); break;
		case 'beforeEnd':
			elm.insertBefore(elmNew,elm.nextSibling); break;
		default:
			elm.appendChild(elmNew); break;
	}
	if (insTxtValue != "") { setInnerText(elmNew,insTxtValue);}
}

/* like innerHTML with Single Element */
function CEAppendChild(elm,tagDataArray) {
var elmNew = CreateElement(nsURI,tagDataArray[0]);
	for (var i = 1; tagDataArray.length > i; i = i+2) {
		elmNew.setAttribute(tagDataArray[i],tagDataArray[i+1]);
		/* setAttribute "STYLE" (IE Only) */
		if ((winIe || macIe) && tagDataArray[i] == "style") { elmNew.style.cssText = tagDataArray[i+1];}
	}
	elm.appendChild(elmNew);

}

/* like innerHTML with Multipul 'OPTION' Elements (Selected one Only) */
function OptAppendChild(elm,selIdx,textDataArray,valueDataArray) {
	for (var i = 0; textDataArray.length > i; i++) {
		var newOpt = CreateElement(nsURI,'option');
		newOpt.text = textDataArray[i];
		newOpt.value = (valueDataArray == null) ? i : valueDataArray[i];
		if (winIe || macIe) {
			elm.add(newOpt,i);
		} else {
			elm.appendChild(newOpt);
		}
		if (i == selIdx) {
			newOpt.selected = true;
			newOpt.setAttribute('selected','selected');/* isOpera */
		}
	}
}

/* like innerText (Insert text) */
function setInnerText(elm,text) {
	if (!(d.getElementById || d.all)) return;
	if (elm.firstChild) {
		elm.firstChild.nodeValue = text;
	} else if (d.createTextNode) {
		var newNode = d.createTextNode(text);
		elm.appendChild(newNode);
	}
}

/* like innerText (Get text) */
function getInnerText(elm) {
	if (!(d.getElementById || d.all)) return null;
	if (elm.firstChild) {
		return elm.firstChild.nodeValue;
	} else if (d.createTextNode) {
		return elm.nodeValue;
	}
}

/* resize bug fix (for NN 4.x) */
function onresizeNN4() { if (nn4) { if(nW != w.innerWidth || nH != w.innerHeight) w.location.reload();}}
