//URLエンコード
function urlEncode(str) {
	var ret;
	//if(ua()=='sf') {
		//ret = encodeURIComponent(str);
	//} else {
		ret = escape(str).replace(/\+/g,'%2B');
	//}
	return ret;
}
//HTMLエンコード
function enc(str) {
	return str.replace(/\</g,'&lt;');
}
//チェック項目取得
function getValue(lst) {
	var data = '';
	var i;
	if (!lst) return '';
	if (!lst[0]) {
		if (lst.checked == true) {
			return lst.value;
		} else {
			return '';
		}
	}
	for (i=0;i<lst.length;i++) {
		if (lst[i].checked == true) {
			if (data>'') data = data + ',';
			data = data + lst[i].value
		}
	}
	return data;
}
//チェック状態取得
function getFlg(ctr) {
	if (ctr.checked == true) {
		return '1';
	} else {
		return '0';
	}
}
//要素選択
function $(element) {
    return document.getElementById(element);
}
//ブラウザ判別
function ua() {
	var agent = navigator.userAgent;
	if(agent.indexOf('Opera') > -1) return 'op';
	if(agent.indexOf('MSIE') > -1) return 'ie';
	if(agent.indexOf('Firefox') > -1) return 'ff';
	if(agent.indexOf('Netscape') > -1) return 'ns';
	if(agent.indexOf('Safari') > -1) return 'sf';
	return 'etc';
}
//テキスト出力
function changeText(layName,html){
	if(document.getElementById){        //e5,e6,n6,n7,m1,o7,s1
		document.getElementById(layName).innerHTML=html;
	} else if(document.all){            //e4
		document.all(layName).innerHTML=html;
	} else if(document.layers) {        //n4
		with(document.layers[layName].document){
			open();
			write(html);
			close();
		}
	}
}
//イメージ切り替え
function changeImage(layName,html){
	if(document.getElementById){        //e5,e6,n6,n7,m1,o7,s1
		document.getElementById(layName).src=html
	} else if(document.all){            //e4
		document.all(layName).src=html
	} else if(document.layers) {        //n4
	}
}
//リンク先切り替え
function changeLink(layName,html){
	if(document.getElementById){        //e5,e6,n6,n7,m1,o7,s1
		document.getElementById(layName).href=html
	} else if(document.all){            //e4
		document.all(layName).href=html
	} else if(document.layers) {        //n4
	}
}
//サーバー通信(ie5,ns6,op6,ff1)
function getdata(url, ctrl) {
	var uagent = ua();
	//if (uagent=='sf'||uagent=='etc') return false;
	var result;
	try {
		var xmlhttp = this.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP") || new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.open('GET', url);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				result = xmlhttp.responseText;
				changeText(ctrl, result);
			}
		};
		xmlhttp.send('');
	}
	catch(e) {
		return false;
	}
	return true;
}
//サーバー通信(ie5,ns6,op6,ff1)
function postdata(url) {
	var result;
	try {
		var xmlhttp = this.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP") || new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.open('GET', url);
		xmlhttp.send('');
	}
	catch(e) {
		return false;
	}
	return true;
}
//サーバー同期通信(ie5,ns6,op6,ff1)
function getdatasyn(url) {
	var uagent = ua();
	//if (uagent=='sf'||uagent=='etc') return false;
	var result;
	try {
		var xmlhttp = this.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP") || new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.open('GET', url, false);
		xmlhttp.send(null);
		result = xmlhttp.responseText;
	}
	catch(e) {
		result = '';
	}
	return result;
}
//写真集表示
function openBook(id) {
	var mydate = new Date();
	window.open('/photostock_title.aspx?id=' + id, 'win' + mydate.getTime());
}
//メンバー詳細表示
function openM(id) {
	var mydate = new Date();
	window.open('/prof.aspx?id=' + id, 'win' + mydate.getTime());
}
//サイト表示
function openS(id) {
	var mydate = new Date();
	window.open('/site_search.aspx?n2=' + id, 'win' + mydate.getTime());
}
//イベント表示
function openE(id) {
	var mydate = new Date();
	window.open('/event_info.aspx?id=' + id, 'win' + mydate.getTime());
}
//同盟詳細表示
function openC(id) {
	var mydate = new Date();
	window.open('/comm.aspx?id=' + id, 'win' + mydate.getTime());
}
//同盟トピック詳細表示
function openTopic(cid, id) {
	var mydate = new Date();
	window.open('/community_topic.aspx?id=' + cid + '&ti=' + id, 'win' + mydate.getTime());
}
//日記詳細表示
function openDiary(mid, pid) {
	var mydate = new Date();
	window.open('/profile_diary.aspx?id=' + mid + '&pi=' + pid, 'win' + mydate.getTime());
}
//アンケート表示
function openQuestion(id, qi) {
	var mydate = new Date();
	window.open('/community_quest.aspx?id=' + id + '&qi=' + qi, 'win' + mydate.getTime());
}
//パス番号取得
function pathNo(id) {
	return Math.floor(parseInt(id)/1000);
}
//ギャラリーファイル表示
function gfile(m, id) {
	var mydate = new Date();
	window.open('/view_photo.aspx?id=' + id + '&m=' + m, 'win' + mydate.getTime());
}
//ギャラリーファイル転送
function rgfile(m, id) {
	var mydate = new Date();
	window.open('/redirect_photo.aspx?id=' + id + '&m=' + m, 'win' + mydate.getTime());
}
//サイト表示
function viewsite(id, url) {
	var mydate = new Date();
	window.open('/view_site.aspx?id=' + id, 'win' + mydate.getTime());
}
//アンケート回答
function qvote(cid, qid) {
	var ch = getValue(document.MyForm.sidechoice);
	var com = document.MyForm.sideComment.value;
	var url = '/community_quest.aspx?id=' + cid + '&qi=' + qid + '&act=vote&ch=' + ch + '&com=' + urlEncode(com);
	if (parent) {
		parent.location.href = url;
	} else {
		location.href = url;
	}
}
//ENTERキー入力
function onEnter(event, fnc) {
	event = event || window.event;
	if (event.keyCode == 13) {
		eval(fnc);
		return false;
	}
}
//ウィンドウオープン
function openWin(url, width, height) {
	var mydate = new Date();
	window.open(url, 'win' + mydate.getTime(), 'scrollbars=no,resizable=yes,menubar=no,status=no,toolbar=no,location=no,directories=no,width=' + width + ',height=' + height);
}
//ウィンドウオープン
function openWinS(url, width, height) {
	var mydate = new Date();
	window.open(url, 'win' + mydate.getTime(), 'scrollbars=yes,resizable=yes,menubar=no,status=no,toolbar=no,location=no,directories=no,width=' + width + ',height=' + height);
}
//ウィンドウ閉じる
function closeWin() {
	//if(opener.window.formRefresh) {
	//	opener.window.formRefresh();
	//}
	window.close();
}

