// JavaScript Document
/*
//ヘッダー部分 検索窓用スクリプト
//2006/09/01

*/
var FirstValue = " ";
var usrInputValue = FirstValue;

function isBrowser(browser){
    if(browser == 'ie'){
	return (navigator.appName == 'Microsoft Internet Explorer') ? 1 : 0;
    }else if(browser == 'ff'){
	return (navigator.userAgent.indexOf('Gecko') != -1) ? 1 : 0;
    }else if(browser == 'safari'){
	return (navigator.userAgent.indexOf('Safari') != -1) ? 1 : 0;
    }else if(browser == 'opera'){	
	return (window.opera) ? 1 :0;
    }else{
	return 0;
    }
}

function encodeText (text) {
    var esc = escape(text);
    return decodeURIComponent(esc);
}

function getPage(pageURL) {
	usrInputValue = document.getElementById("hs").value;
	xmlhttp = createXMLHttp();
	if (xmlhttp)
	{
	    xmlhttp.onreadystatechange = setPageData;
	    xmlhttp.open('GET', pageURL);
	    xmlhttp.send(null);
	}else{
	    alert("Failed to XMLHttpRequest");
	}
}
function setPageData()
{
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
	{
	    document.getElementById("hsDisp").innerHTML = (isBrowser('opera')) 
		? encodeText(xmlhttp.responseText) 
		: xmlhttp.responseText;
	    setFirstValue("hs", usrInputValue);
	}
}
// XMLHttpsオブジェクト作成
function createXMLHttp()
{
	try {
	    return (isBrowser('ie'))
		? new ActiveXObject ("Microsoft.XMLHTTP")
		: new XMLHttpRequest();
	}catch(e){
	    return null;
	}
	return null;
}

function setFirstValue(ElementName,text) {
var sWin=document.getElementById(ElementName);
   sWin.value="&#32;&#26908;&#32034;&#32;";

if(document.getElementById&&(navigator.userAgent.match(/Win/)||navigator.userAgent.match(/Firefox/)||navigator.userAgent.match(/Safari/))){
	if(FirstValue != text) sWin.style.color="#000";
	sWin.value= text;
}
sWin.onfocus=function(){
	if(FirstValue == text){
		sWin.value="";sWin.style.color="#000";
	}
};	
}

function dsongSearch()
{
	if (document.dsong.tp[0].checked)
		document.dsong.action = "http://www.oricondd.com/search/index.php";
	else if (document.dsong.tp[1].checked)
		document.dsong.action = "http://www.oricondd.com/atrac/search/index.php";
		else
			document.dsong.action = "http://www.oricondd.com/search/search_index.php";
}

function tupsongSearch()
{
	if (document.tupsong.search_type.value == "tieup_pro")
		document.tupsong.tieup_pro.value = document.tupsong.search_string.value;
	else if (document.tupsong.search_type.value == "tieup_com")
		document.tupsong.tieup_com.value = document.tupsong.search_string.value;
		else
			return 0;
}

function msongSearch()
{
	if (document.msong.search_type.value == ".artist" )
		document.msong.artist.value = document.msong.search_string.value;
	else if (document.msong.search_type.value == ".song")
		document.msong.song.value = document.msong.search_string.value;
		else
			return 0;
}

function chartSearch()
{
	if (document.chart.search_type[0].checked)
		document.chart.kbn.value = "js";
	else if (document.chart.search_type[1].checked)
		document.chart.kbn.value = "ja";
		else
			return 0;
}

function ticketSearch()
{
	alert(escape(document.ticket.search_string.value));
	document.ticket.ps12.value = encodeURIComponent(document.ticket.search_string.value);
	alert(document.ticket.ps12.value);
}

function SelectCDListTab(SelectValue){
	var num = SelectValue.options[SelectValue.selectedIndex].value;
	var txt = document.getElementById("hs_cd_search_box"+num).innerHTML;
	document.getElementById("hs_cd_search_box").innerHTML = txt;
}


