function SubmitFreeSearch(fObj)
{
    fObj.submit();
}

function actionChange(fObj)
{
	fObj.action = "sougou.pl";
	var formBaitai = fObj.baitai;
	for(var i = 0;i < formBaitai.length;i++){
		if(formBaitai.options[i].selected == true){
			if(formBaitai.options[i].value == ""){
				break;
			}
			if(formBaitai.options[i].value == "reportonly"){
				break;
			}
			if(formBaitai.options[i].value == "diconly"){
				fObj.action = "dicsearch.pl";
				break;
			}
		}
	}
}

function SubmitReportSearch(fObj)
{
    fObj.submit();
}


function SubmitReportSrc(fObj)
{
	var i;
	for(i = 0;i < 4;i++){
		if(fObj.baitai[i].checked == true){
			break;
		}
	}
	if(i == 4){
        alert('媒体が選択されていません。');
		return;
	}
    fObj.submit();
}

/* 半角数字チェック */
function nenCheck(year)
{
	if(year){
		if( year.value.match( /[^0-9]+/ ) ) {
			alert("年は、半角数字のみで入力して下さい。");
			year.value = "";
			year.focus();
			return -1;
		}
	}
	return 0;
}


function nendoCheck(year)
{
	if(year){
		if( year.value.match( /[^0-9]+/ ) ) {
			alert("年度は、半角数字のみで入力して下さい。");
			year.value = "";
			year.focus();
			return -1;
		}
	}
	return 0;
}


function areaChange(formArea,formCountry)
{
	var areaname =  formArea[formArea.selectedIndex].value;
	
	var selectcount = 0;
	for(var i = 0;i < formArea.length;i++){
		if(formArea.options[i].selected == true){
			selectcount++;
		}
	}
	
	formCountry.length = 1;
	if(areaname != "" && areaname != "グローバル" && selectcount == 1){
		if(document.getElementById("selectcountry"))
			document.getElementById("selectcountry").style.display = "block";
		if(document.getElementById("selectcountry2"))
			document.getElementById("selectcountry2").style.display = "block";
		if(document.getElementById("selectcountry_hidden"))
			document.getElementById("selectcountry_hidden").style.display = "none";
		if(document.getElementById("selectcountry2_hidden"))
			document.getElementById("selectcountry2_hidden").style.display = "none";
		
		for(var i = 0;i < CountryName[areaname].length;i++){
		    formCountry.length = formCountry.length+1;
	    	formCountry.options[formCountry.length-1].text = CountryName[areaname][i][0];
	    	formCountry.options[formCountry.length-1].value = CountryName[areaname][i][1];
	  		formCountry.options[formCountry.length-1].selected = false;
		}
	}else{
		if(document.getElementById("selectcountry"))
			document.getElementById("selectcountry").style.display = "none";
		if(document.getElementById("selectcountry2"))
			document.getElementById("selectcountry2").style.display = "none";
		if(document.getElementById("selectcountry_hidden"))
			document.getElementById("selectcountry_hidden").style.display = "block";
		if(document.getElementById("selectcountry2_hidden"))
			document.getElementById("selectcountry2_hidden").style.display = "block";
	}
   	formCountry.options[0].selected = true;
   	return false;
}

function areaChangeEdit(formArea,formCountry)
{
	var areaname =  formArea[formArea.selectedIndex].value;
	
	var selectcount = 0;
	for(var i = 0;i < formArea.length;i++){
		if(formArea.options[i].selected == true){
			selectcount++;
		}
	}
	
	formCountry.length = 1;
	if(areaname != "" && selectcount == 1){
		for(var i = 0;i < CountryName[areaname].length;i++){
		    formCountry.length = formCountry.length+1;
	    	formCountry.options[formCountry.length-1].text = CountryName[areaname][i][0];
	    	formCountry.options[formCountry.length-1].value = CountryName[areaname][i][0];
	  		formCountry.options[formCountry.length-1].selected = false;
		}
	}
   	formCountry.options[0].selected = true;
   	return false;
}

function areaPopup(evt,areaname)
{
	var arealist='';
	arealist+='<a href="sougou.pl?area='+encodeURIComponent(areaname)+'">'+areaname+'</a>';
	for(var i = 0;i < CountryName[areaname].length;i++){
		arealist+='<a href="sougou.pl?area='+encodeURIComponent(areaname)+'&country='+encodeURIComponent(CountryName[areaname][i][1])+'">&nbsp;&nbsp;'+CountryName[areaname][i][0]+'</a>';
	}
	showmenu(evt,arealist, '200px',CountryName[areaname].length+1 );
}

function areaSearch(areaname)
{
	document.location = "sougou.pl?area="+encodeURIComponent(areaname);
}

function getCookie(key,  tmp1, tmp2, xx1, xx2, xx3) {
    tmp1 = " " + document.cookie + ";";
    xx1 = xx2 = 0;
    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, tmp) {
    tmp = key + "=" + escape(val) + "; ";

/*
    var expireperiod = 1000*60*60*24*30;     // 有効期間( 30日 )
	var today = new Date();
	var expires = new Date();
	expires.setTime(today.getTime()+expireperiod);
    tmp += "expires="+expires.toGMTString()+"; ";
*/

    document.cookie = tmp;
}


