var jsonUrl="http://downloadnavi.fujixerox.co.jp/json";
var lang="jp";
var softwareTypeId=0;
var categoryId=0;
var seriesId=0;
var modelId=0;
var osId=0;

function writeSearchBox(){

document.write('<div class="pageTab">');
document.write('</div>');
document.write('<div id="searchBox">');
document.write('<div id="searchBoxs">');
document.write('<ol>');
document.write('<li>');
document.write('<div class="stepBox">');
document.write('<dl>');
document.write('<dt><label for="radio1"><img src="/download/index_res/images/title_step1.gif" alt="ソフトウェア種別" width="136" height="33"></label></dt>');
document.write('<dd>');
document.write('<form name="form" action="" name="step1frm">');
document.write('<ul>');
document.write('<li><label for="radio1"><input type="radio" name="radio" id="radio1" onclick="selectItem1(100,\'プリンタードライバー\',0)">プリンタードライバー</label></li>');
document.write('<li><label for="radio2"><input type="radio" name="radio" id="radio2" onclick="selectItem1(200,\'スキャナードライバー\',1)">スキャナードライバー</label></li>');
document.write('<li><label for="radio3"><input type="radio" name="radio" id="radio3" onclick="selectItem1(250,\'ファクスドライバー\',2)">ファクスドライバー</label></li>');
document.write('<li><label for="radio4"><input type="radio" name="radio" id="radio4" onclick="selectItem1(300,\'ファームウェア\',3)">');
document.write('ファームウェア</label></li>');
document.write('<li><label for="radio5"><input type="radio" name="radio" id="radio5" onclick="selectItem1(400,\'ユーティリティ\',4)">ユーティリティ</label></li>');
document.write('<li><label for="radio6"><input type="radio" name="radio" id="radio6" onclick="selectItem1(500,\'補足資料など\',5)">補足資料など</label></li>');
document.write('</ul>');
document.write('</form>');
document.write('</dd>');
document.write('</dl>');
document.write('</div>');
document.write('</li>');
document.write('<li>');
document.write('<div class="stepBox">');
document.write('<dl>');
document.write('<dt><img src="/download/index_res/images/title_step2.gif" alt="商品種別" width="98" height="33"></dt>');
document.write('<dd>');
document.write('<ul>');
document.write('<li><dl>');
document.write('<dt><img src="/download/index_res/images/title_step2_1.gif" width="56" height="14" alt="商品分野" title="商品分野"></dt>');
document.write('<dd id="item1"></dd>');
document.write('</dl>');
document.write('</li>');
document.write('<li><dl>');
document.write('<dt><img src="/download/index_res/images/title_step2_2.gif" width="84" height="14" alt="商品シリーズ" title="商品シリーズ"></dt>');
document.write('<dd id="item2"></dd>');
document.write('</dl>');
document.write('</li>');
document.write('<li class="lastChild"><dl>');
document.write('<dt><img src="/download/index_res/images/title_step2_3.gif" width="41" height="14" alt="商品名" title="商品名"></dt>');
document.write('<dd id="item3"></dd>');
document.write('</dl>');
document.write('</li>');
document.write('</ul>');
document.write('</dd>');
document.write('</dl>');
document.write('</div>');
document.write('</li>');
document.write('<li>');
document.write('<div class="stepBox">');
document.write('<dl>');
document.write('<dt><img src="/download/index_res/images/title_step3.gif" alt="OS種別" width="96" height="34"></dt>');
document.write('<dd>');
document.write('<div id="item4">');
document.write('</div>');
document.write('<div class="rBoxC01"><div><div><div>');
document.write('<ul>');
document.write('<li><a href="#FI01" onclick="flOpn(\'FI01\',event);">ご利用OSのbit数がわからない</a></li>');
document.write('<li><a href="#FI02" onclick="flOpn(\'FI02\',event);">ご利用OSが表示されない</a></li>');
document.write('<li><a href="#FI03" onclick="flOpn(\'FI03\',event);">ダウンロード検索のご利用ガイド</a></li>');
document.write('</ul>');
document.write('</div>');
document.write('</div></div></div>');
document.write('</dd>');
document.write('</dl>');
document.write('</div>');
document.write('</li>');
document.write('<li class="lastChild">');
document.write('<div class="stepBox">');
document.write('<dl>');
document.write('<dt><img src="/download/index_res/images/title_step4.gif" alt="検索" width="85" height="33"></dt>');
document.write('<dd class="alignC">');
document.write('<p id="searchButtonSwitch"></p>');
document.write('</dd>');
document.write('</dl>');
document.write('</div>');
document.write('</li>');
document.write('</ol>');
document.write('<!-- /#searchBoxs --></div>');
document.write('<div id="searchButton">');
document.write('<p id="select1"></p><p id="searchButtonSwitch"></p>');
document.write('</div>');
document.write('<!-- /#searchBox --></div>');
document.write('<ul class="links" id="otherSearch">');
document.write('<li>最新バージョンにアップデートするソフトウェア、評価版、体験版などは対象外です。「商品分野から探す」の「<a href="/download/software/">ソフトウェア</a>」をご覧ください。</li>');
document.write('<li><a href="http://downloadnavi.fujixerox.co.jp/">商品名による「プリンタードライバー」検索</a></li>');
document.write('<li><a href="http://downloadnavi.fujixerox.co.jp/eng/">英語版OSの検索(英文)</a></li>');
document.write('<li><a href="/download/defacto/">OS対応状況</a></li>');
document.write('<li><a href="/support/web_regi/download/dids_index.html">お使いの商品のドライバーなどのアップデート情報配信サービス</a></li>');
document.write('</ul>');
	selectItem1(100,'プリンタードライバー',0,$(".pageTab a:first"));
}

window.onload = function(){
	$("input#radio1").attr("checked","checked");
}

function search(){
	if(softwareTypeId==0){
		if(lang=="jp")
			alert("ソフトウェアの種類を選択してください");
		else
			alert("Please select Software Type");
		return;
	}
	else if(categoryId==0){
		if(lang=="jp")
			alert("商品カテゴリーを選択してください");
		else
			alert("Please select Product Category");
		return;
	}
	else if(seriesId==0){
		if(lang=="jp")
			alert("商品シリーズを選択してください");
		else
			alert("Please select Product Family ");
		return;
	}
	else if(modelId==0){
		if(lang=="jp")
			alert("商品名を選択してください");
		else
			alert("Please select Product Name ");
		return;
	}
	else if(osId==0){
		if(lang=="jp")
			alert("osを選択してください");
		else
			alert("Please select Operating System");
		return;
	}
	if(lang=="jp")
		document.location = "http://downloadnavi.fujixerox.co.jp/result/jp/m="+modelId+"&o="+osId+"&s="+softwareTypeId;
	else
		document.location = "http://downloadnavi.fujixerox.co.jp/result/en/m="+modelId+"&o="+osId+"&s="+softwareTypeId;
}

var selectedStr="を選択しました";
if(lang=="en")
	selectedStr="is selected.";
function selectItem1(id,text,index){
	softwareTypeId = id;
	$.jsonp({
	  url: jsonUrl,
	  data: {item:2,softwareTypeId:softwareTypeId},
	  callbackParameter: "callback",
	  dataType: 'jsonp',
	  timeout: 5000,
	  success: function(data,status)
	  {
	  		$("#item1").html(data.html);
	  },
	  error: function()
	  {
	  	  $(".pageTab").html("");
	  	  $("#searchBox").html("");
	  	  $(".annotationList").html("");
	  	  $("#otherSearch").html("");
	  	  $("#searchBox").html("<p>現在検索機能はご利用できません。「商品分野から探す」をご利用ください。</p>");
	  }
	});
	if(lang=="jp")
		$("#item2").html("<p>先に<em>1.商品分野</em>を選択してください</p>"),
		$("#item3").html("<p>先に<em>1.商品分野</em>を選択してください</p>"),
		$("#item4").html("<p>先に<em>1.商品分野</em>を選択してください</p>"),
		$("#searchButtonSwitch").html("<a href=\"javascript:search();\"><img src=\"/download/index_res/images/btn_search_g.gif\" alt=\"検索\" width=\"145\" height=\"36\"></a>");
//		$("#select1").html("<em>" + text + "</em> " + selectedStr);
	else
		$("#item2").html("<p>1.Select Product Category.</p>"),
		$("#item3").html("<p>1.Select Product Category.</p>"),
		$("#item4").html("<p>1.Select Product Category.</p>");
	categoryId = 0;
	seriesId = 0;
	modelId = 0;
	osId = 0;
	
	return false;
}

function selectItem2(id,text,index){
	$("#item1 .cur").removeClass("cur");
	$("#b1-"+index).addClass("cur");
	
	categoryId=id;
	$.ajax({
	  url: jsonUrl,
	  data: {item:3,softwareTypeId:softwareTypeId,categoryId:categoryId},
	  dataType: 'jsonp',
	  success: function(data)
	  {
	  		$("#item2").html(data.html);
	  }
	});
	if(lang=="jp")
		$("#item3").html("<p>先に<em>2.商品シリーズ</em>を選択してください</p>"),
		$("#item4").html("<p>先に<em>2.商品シリーズ</em>を選択してください</p>"),
		$("#searchButtonSwitch").html("<a href=\"javascript:search();\"><img src=\"/download/index_res/images/btn_search_g.gif\" alt=\"検索\" width=\"145\" height=\"36\"></a>");
//		$("#select1").html("<em>" + text + "</em> " + selectedStr);
	else
		$("#item3").html("<p>2.Select Product Family.</p>"),
		$("#item4").html("<p>2.Select Product Family.</p>");
	seriesId = 0;
	modelId = 0;
	osId = 0;
}

function selectItem3(id,text,index){
	$("#item2 .cur").removeClass("cur");
	$("#c1-"+index).addClass("cur");
	
	seriesId=id;
	$.ajax({
	  url: jsonUrl,
	  data: {item:4,softwareTypeId:softwareTypeId,categoryId:categoryId,seriesId:seriesId},
	  dataType: 'jsonp',
	  success: function(data)
	  {
	  		$("#item3").html(data.html);
	  }
	});
	if(lang=="jp")
		$("#item4").html("<p>先に<em>3.商品</em>を選択してください。</p>"),
		$("#searchButtonSwitch").html("<a href=\"javascript:search();\"><img src=\"/download/index_res/images/btn_search_g.gif\" alt=\"検索\" width=\"145\" height=\"36\"></a>");
//		$("#select1").html("<em>" + text + "</em> " + selectedStr);
	else
		$("#item4").html("<p>3.Select Product Name.</p>");
	modelId = 0;
	osId = 0;
}

function selectItem4(id,text,index){
	$("#item3 .cur").removeClass("cur");
	$("#d1-"+index).addClass("cur");

	modelId=id;
	$.ajax({
	  url: jsonUrl,
	  data: {item:5,softwareTypeId:softwareTypeId,categoryId:categoryId,seriesId:seriesId,modelId:modelId},
	  dataType: 'jsonp',
	  success: function(data)
	  {
	  		$("#item4").html(data.html);
	  }
	});
	if(lang=="jp")
		$("#searchButtonSwitch").html("<a href=\"javascript:search();\"><img src=\"/download/index_res/images/btn_search_g.gif\" alt=\"検索\" width=\"145\" height=\"36\"></a>");
//		$("#select1").html("<em>" + text + "</em> " + selectedStr);
	osId = 0;
}

function selectItem5(id,text,index){
	$("#item4 .cur").removeClass("cur");
	$("#e1-"+index).addClass("cur");
	if(lang=="jp")
		$("#searchButtonSwitch").html("<a href=\"javascript:search();\"><img width=\"145\" height=\"36\" class=\"rollover\" alt=\"検索\" src=\"/download/index_res/images/btn_search.gif\" hsrc=\"/download/index_res/images/btn_search_ov.gif\"></a>");
//		$("#select1").html("<em>" + text + "</em> " + selectedStr);
	osId=id;
}
