//　imagesオンマウス
function MM_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=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage(){
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=7)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore(){
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages(){
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//submit add_term.php
function UtermSubmit(mode){
	document.forms["form3"].mode.value = mode;
	document.forms["form3"].action = '/pp_addTerm/';
	//document.forms["form3"].submit();
}

//submit search_list.php
function keySearchSubmit(mode,now_page){
	var form2 = document.forms["form2"];
//	form2.sort1.value = sort1;
	form2.mode.value = mode;
	form2.now_page.value = now_page;
	document.forms["form2"].submit();
}

//submit all_term.php
function cateSubmit(sort2,bigCate){
	document.location.href = "/pp_allTerm/"+bigCate+"_"+sort2;
}

//submit search_list.php
function cateSearchSubmit(bigCate,sort1,sort2,mode,smallCate,gyouVal,now_page){
	var str = '/pp_searchList/';
	str = str+bigCate;
	str = str+'_'+sort1;
	str = str+'_'+sort2;
	str = str+'_'+mode;
	//str = str+'_'+keyword;
	str = str+'_'+smallCate;
	str = str+'_'+gyouVal;
	if(now_page){
		str = str+'_'+now_page;
	}
	document.location.href = str;
	//document.location.href = "search_list.php?sort2="+sort2+"&bigCate="+bigCate+"&smallCate="+gyou+"&mode="+mode;
}

function fnChk() {
   var form = document.forms["form1"];
   var item;
   if (form.tr_change[1].checked == true) {
		for ( var i = 0; i < form.elements.length; i++ )
		{
			item = form.elements[i];
			if (item.type == "checkbox" )
			{
				item.disabled = false;
			}
		}
   } else {
		for ( var i = 0; i < form.elements.length; i++ )
		{
			item = form.elements[i];
			if (item.type == "checkbox" )
			{
				item.disabled = true;
			}
		}
   }
}
function menuclick(onSubmenu) {
	if(onSubmenu) {
		document.getElementById(onSubmenu).style.display = 'block';
//		document.getElementById(submenu).style.display = 'none';
	}
}
//submit add_term.php
function ToaddtermSubmit(bigCate,sort1,sort2,tr_id){
	var str = '/pp_addTerm/';
	str = str+bigCate;
	str = str+'_'+sort1;
	str = str+'_'+sort2;
	if(tr_id){
		str = str+'_'+tr_id;
	}
	document.location.href = str;
}

//submit add_vote.php
function ToaddvoteSubmit(bigCate,sort1,sort2,tr_id,exp_id,mode,tr_userid,exp_userid){
		var str = '/pp_addVote/';
		str = str+bigCate;
		str = str+'_'+sort1;
		str = str+'_'+sort2;
		str = str+'_'+tr_id;
		str = str+'_'+exp_id;
		str = str+'_'+mode;
		if(tr_userid && exp_userid){
			str = str+'_'+tr_userid;
			str = str+'_'+exp_userid;
		}
		document.location.href = str;
		//document.location.href = "addvote.php?bigCate="+bigCate+"&sort2="+sort2+"&tr_id="+tr_id+"&exp_id="+exp_id+"&mode="+mode;
}
/*
function addvoteSubmit(bigCate,sort1,sort2,tr_id,exp_id,tr_userid,exp_userid,mode){
//		document.location.href = "addvote.php?bigCate="+bigCate+"&sort1="+sort1+"&sort2="+sort2+"&tr_id="+tr_id+"&exp_id="+exp_id+"&tr_userid="+tr_userid+"&exp_userid="+exp_userid+"&mode="+mode;
		document.location.href = "addvote.php?bigCate="+bigCate+"&sort2="+sort2+"&tr_id="+tr_id+"&exp_id="+exp_id+"&tr_userid="+tr_userid+"&exp_userid="+exp_userid+"&mode="+mode;
}
*/
function popOpen(url, target, w, h, s) { 
    if(s) s = 'yes'; 
    else s = 'no'; 
    var its = window.open(url,target,'width='+w+',height='+h+',top=0,left=0,scrollbars='+s+'statusbar=no, toolbar=no'); 
    its.focus(); 
} 

//submit user_intro.php
function toUserIntro(bigCate,sort1,sort2,user_id,mode,now_page) {
	var str = '/pp_userIntro/';
	str = str+bigCate;
	str = str+'_'+sort1;
	str = str+'_'+sort2;
	str = str+'_'+user_id;
/*
	if(!mode){
		mode = '';
	}
*/
	if(mode){
		str = str+'_'+mode;
	}
/*	
	if(!now_page){
		now_page = '';
	}
*/
	if(now_page){
		str = str+'_'+now_page;
	}
	document.location.href = str;
}

//submit term_explain.php
function toTermExplain(bigCate,sort1,sort2,term_id,aname) {
	var str = '/pp_termExplain/';
	str = str+bigCate;
	str = str+'_'+sort1;
	str = str+'_'+sort2;
	str = str+'_'+term_id;
	if(aname){
		str = str+'_'+'#'+aname;
	}
	document.location.href = str;
} 

//submit rank_list.php
function toRankList(bigCate,sort1,sort2,type,mode,now_page) {
	var str = '/pp_rankList/';
	str = str+bigCate;
	str = str+'_'+sort1;
	str = str+'_'+sort2;
	str = str+'_'+type;
	if(mode){
		str = str+'_'+mode;
	}
	if(now_page){
		str = str+'_'+now_page;
	}
	document.location.href = str;
} 

/*
function sendScript(addr){
		document.location.href = "addvote.php?tr_id="+tr_id+"&exp_id="+exp_id+"&tr_userid="+tr_userid;
}
*/
/*
function toUserIntro(){
	alert("test");
//	document.location.href = "user_intro.php?bigCate="+bigCate+"&sort2="+sort2+"&user_id="+user_id;
}
*/
//POPUP
function pachi_popup(mid,w,h) {
	newWindow=window.open("/pachipedia/popup.php?img="+mid,"","status=no,toolbars=no,resizable=no,location=no,menubar=no,scrollbars=no,directories=no,width="+w+",height="+h);
}
//redirect term_explain.php
function redirectToExp(bigCate,sort1,sort2,term_id,aname) {
	alert("既に投票されています。");
	var str = '/pp_termExplain/';
	str = str+bigCate;
	str = str+'_'+sort1;
	str = str+'_'+sort2;
	str = str+'_'+term_id;
	if(aname){
		str = str+'_'+'#'+aname;
	}
	document.location.href = str;
} 
 