// **
// * top quest ajax
// * アンケート
// * create : 2008/3/25
// **
function on_click_top_quest(oj)
{
	var res  = oj.responseText
	document.getElementById("top_quest").innerHTML=res
}


function openkigyowin_e() {
	window.open("../enjin/index.php?c=kigyosearch&m=index", "企業ID", "width=760,height=400,scrollbars=yes,resizable=yes");
}

function setParent(kigyoid){
  if (kigyoid) {
  	ct = kigyoid;
  } else {
  	ct = document.getElementById("kigyoid").value;
  }
  window.opener.document.getElementById("kigyoid").value = ct;
  window.close();
}

function openkaiinwin(x) {
	if ( x == 1 ) {
		window.open("../tool/kaiin_search.php?key=1", "会員ID", "width=350,height=250");
	} else {
		window.open("../tool/kaiin_search.php", "会員ID", "width=350,height=250");
	}
}

function openkaiinwin_e(x) {
	if ( x == 1 ) {
		window.open("../enjin/kaiin_search.php?key=1", "会員ID", "width=350,height=250");
	} else {
		window.open("../enjin/kaiin_search.php", "会員ID", "width=350,height=250");
	}
}

function setParent2(){
  ct = document.getElementById("kaiinid").value
  window.opener.document.getElementById("kaiinid").value = ct
  window.close()
}

function changeModeSubmit(mode, form) {
	document[form].mode.value = mode;
	document[form].submit();
}

function changeActionSubmit(action, mode, form) {
	document[form].mode.value = mode;
	document[form].action = action;
	document[form].submit();
}

function changeBlogColor(form) {
	var index = document[form].blogcolor.selectedIndex;
	var color = document[form].blogcolor.options[index].value;
	document.getElementById('blogcolor').className = color;
	document.getElementById('entrybtn').src          = './images/blog/'+color+'/blog_hozon_off.gif';
	document.getElementById('entrybtn').onmouseover  = function anonymous() { this.src='./images/blog/'+color+'/blog_hozon_on.gif'; };
	document.getElementById('entrybtn').onmouseout   = function anonymous() { this.src='./images/blog/'+color+'/blog_hozon_off.gif'; };
	document.getElementById('cancelbtn').onmouseover = function anonymous() { this.src='./images/blog/'+color+'/torisesi_on.gif'; };
	document.getElementById('cancelbtn').onmouseout  = function anonymous() { this.src='./images/blog/'+color+'/torisesi_off.gif'; };
}

//BLOG削除
function blogdel(url){
	quest=confirm("選択されたブログを削除しますか？");
	if(quest==true){
		location.href=url;
	}
}

function grep (pattern) {
    try {
        var regex = new RegExp(pattern, "i");
        var spans = document.getElementsByTagName('span');
        var length = spans.length;
        for (var i = 0; i < length; i++) {
            var e = spans[i];
            if (e.className == "line") {
                if (e.innerHTML.match(regex)) {
                    e.style.display = "inline";
                } else {
                    e.style.display = "none";
                }
            }
        }
    } catch (e) {
        // 正規表現の文法エラーを無視する
    }
}

// **
// *
// * 賢者詳細
// *
// **
function on_load_details(oj)
{
	var res  = oj.responseText;
	document.getElementById("details").innerHTML=res;
}

function on_load_touch_details(oj)
{
	var res  = oj.responseText;
	document.getElementById("details").innerHTML=res;
}

function on_click_touch_detail(kaiinid){
	sendRequest(on_load_touch_details,'&kaiinid='+kaiinid,'GET','./ajax/touch_ajax.php',true,true);
}

//Google Map
function get_map(keido,ido)
{
						var lon  = keido;
						var lat  = ido;
						var map  = new GMap2(document.getElementById("map"));
						var mark = new GLatLng(lat,lon)
		
						map.setCenter(mark,16);
						map.addControl(new GLargeMapControl());
						map.addControl(new GMapTypeControl());
		
						createMarker(mark);
		
						function createMarker(point) {
							var marker = new GMarker(point);
							map.addOverlay(marker);
						}

}

function get_map2(keido,ido,comment)
{
						var lon  = keido;
						var lat  = ido;
						var com  = comment;
						var map  = new GMap2(document.getElementById("map"));
						var mark = new GLatLng(lat,lon)
						map.setCenter(mark,16);
					    
						map.addControl(new GLargeMapControl());
						map.addControl(new GMapTypeControl());
						
						createMarker(mark);
					
						function createMarker(point) {
							var marker = new GMarker(point);
							map.addOverlay(marker);
							GEvent.addListener(marker,"click",function(){
								marker.openInfoWindowHtml(com);
							});
						}
}

function get_map3(keido,ido,comment,url)
{
						var lon   = keido;
						var lat   = ido;
						var com   = comment;
						var link  = url;
						var map  = new GMap2(document.getElementById("map"));
						var mark = new GLatLng(lat,lon)
						map.setCenter(mark,16);
					    
						map.addControl(new GLargeMapControl());
						map.addControl(new GMapTypeControl());
						
						createMarker(mark);
					
						function createMarker(point) {
							var marker = new GMarker(point);
							map.addOverlay(marker);
							GEvent.addListener(marker,"click",function(){
								marker.openInfoWindowHtml('<a href="'+link+'" target="_blank">'+com+'</a>');
							});
						}
}

// **
// *
// * ヘッダー
// *
// **
var MS=navigator.appVersion.indexOf("MSIE")
window.isIE4 =(MS>0) && ((parseInt(navigator.appVersion.substring(MS+5,MS+6)) >= 4)
&& (navigator.appVersion.indexOf("MSIE"))>0)

function myFavorite(){
  var agent=navigator.userAgent;
  var ie=agent.indexOf("MSIE");
  var iever=parseInt(agent.substring(ie+5, ie+6));
  var os=agent.indexOf("Windows");

  if((ie > 0) && (iever >= 5) && (os > 0) && !window.opera){
    var bookmarkURL=self.location; /* window.location.hrefでもOK */
    var bookmarkTITLE=document.title;
    window.external.AddFavorite(bookmarkURL, bookmarkTITLE);
  }else{
    alert("IEのみでサポートされています");
  }
}

// **
// *
// * イベント映像
// *
// **
function openeventmovie(swf,swftitle, swfcaption) {
    Lightview.show({
		href: swf,
		rel: 'flash',
		title: swftitle,
		caption: swfcaption,
		options: {
			width: 640,
			height: 480
		}
	});
}

// **
// *
// * LiteViewからのログイン画面への遷移
// *
// **
function move_login(from, move) {
	Lightview.hide();
	location.href = './index.php?c=move&m='+move+'&from='+from;
}

// **
// *
// * LiteViewからの登録画面への遷移
// *
// **
function move_touroku(from) {
	Lightview.hide();
	location.href = './touroku.php?from='+from;
}

// **
// *
// * 賢者検索
// *
// **
function on_load_search(oj)
{
	var res  = oj.responseText;
	document.getElementById("searchresult").innerHTML=res;
}
// **
// *
// * 賢者検索
// *
// **
function change_item(rootpath, p)
{
	sendRequest(on_load_search,
				"&c=search&m=asearch&p="+p+"&kaiinname="+document.kenjasearch.kaiinname.value+"&kigyoname="+document.kenjasearch.kigyoname.value+"&kenid="+document.kenjasearch.kenid.value+"&lastacademic="+document.kenjasearch.lastacademic.value+"&sex="+document.kenjasearch.sex.value+"&age="+document.kenjasearch.age.value+"&generation="+document.kenjasearch.generation.value+"&honsyaid="+document.kenjasearch.honsyaid.value+"&gyousyuid="+document.kenjasearch.gyousyuid.value+"&eucget=ＴＶ",
				"GET",
				rootpath,
				true,
				true);
				
}
// **
// *
// * サイト内検索(フォーカスイン処理)
// *
// **
function focus_in_search()
{
	if (document.sitesearch.freeword.value == "サイト内検索") {
			document.sitesearch.freeword.value = "";
	}

}
// **
// *
// * サイト内検索(フォーカスアウト処理)
// *
// **
function focus_out_search()
{
	if (document.sitesearch.freeword.value == "") {
		document.sitesearch.freeword.value = "サイト内検索";
	}
}
// **
// *
// * イベント画像変更
// *
// **
function changeEventImage(obj, flag)
{
	if (flag == 'on' || obj.id == document.getElementById('selectedid').value) {
		obj.className = 'movie_on'
	} else {
		obj.className = 'movie_off';
	}
}

function clear_searchitem(name, url)
{
	document.forms[name].reset();
	change_item(url);
}
// **
// *
// * LightViewでの映像配信
// *
// **
function openmovie(swf) {
    Lightview.show({
		href: swf,
		rel: 'flash',
		options: {
			width:  320,
			height: 240
		}
	});
}
// **
// *
// * コンタクト情報更新後処理
// *
// **
function on_load_contact(oj)
{
	var res  = oj.responseText;
	alert(res);
}
// **
// *
// * クリップボードへのコピー
// *
// **
function copy_clipbord(copyinfo)
{
	setClipboard(copyinfo);
	document.getElementById("copymsg").innerHTML = "コピーしました";
	setTimeout("hideclipbordmsg()", 2000);
	
}
function hideclipbordmsg()
{
	document.getElementById("copymsg").innerHTML = "&nbsp;";
}

// **
// *
// * ブログ検索
// *
// **
function change_item_for_blog(rootpath, p)
{
	sendRequest(on_load_search,
				"&c=blog&m=search&p="+p+"&kaiinname="+document.blogsearch.kaiinname.value+"&kigyoname="+document.blogsearch.kigyoname.value+"&kenid="+document.blogsearch.kenid.value+"&lastacademic="+document.blogsearch.lastacademic.value+"&sex="+document.blogsearch.sex.value+"&age="+document.blogsearch.age.value+"&generation="+document.blogsearch.generation.value+"&honsyaid="+document.blogsearch.honsyaid.value+"&gyousyuid="+document.blogsearch.gyousyuid.value+"&eucget=ＴＶ",
				"GET",
				rootpath,
				true,
				true);
}

function clear_searchitem_for_blog(name, url)
{
	document.forms[name].reset();
	change_item_for_blog(url);
}

// **
// *
// * 動画変更
// *
// **
function change_movie(rootpath, movieid)
{
	document.getElementById('movie'+movieid).className = "movie_on";
	document.getElementById(document.getElementById('selectedid').value).className = "movie_off";
	document.getElementById('selectedid').value = "movie"+movieid;
	sendRequest(on_load_movie,
				"&c=eventmovie&m=changemovie&id="+escape(movieid),
				"POST",
				rootpath,
				true,
				true);
}

// **
// *
// * 動画変更後読み込み処理
// *
// **
function on_load_movie(oj)
{
	var res = oj.responseXML;
//	var submenu   = dom.core.childNodes(res.getElementsByTagName('submenu').item(0));
	var moviemain = dom.core.childNodes(res.getElementsByTagName('moviemain').item(0));
//	document.getElementById("submenu").innerHTML   = submenu[0].nodeValue;
	document.getElementById("moviemain").innerHTML = moviemain[0].nodeValue;
}

// **
// *
// * ランキング変更処理
// *
// **
function change_ranking(rootpath, method, pointid, month)
{
	sendRequest(on_load_ranking,
				"&c=ranking&m=changesubmenu&callm="+escape(method)+"&point="+escape(pointid)+"&month="+escape(month),
				"POST",
				rootpath,
				true,
				true);
}

// **
// *
// * ランキング変更後読み込み処理
// *
// **
function on_load_ranking(oj)
{
	var res = oj.responseXML;
	var submenutitle = dom.core.childNodes(res.getElementsByTagName('submenutitle').item(0));
	var submenu      = dom.core.childNodes(res.getElementsByTagName('submenu').item(0));
	var rankingmain  = dom.core.childNodes(res.getElementsByTagName('rankingmain').item(0));
	document.getElementById("submenutitle").innerHTML = submenutitle[0].nodeValue;
	document.getElementById("submenu").innerHTML      = submenu[0].nodeValue;
	document.getElementById("rankingmain").innerHTML  = rankingmain[0].nodeValue;
}