function getSearch(video_id, channel_id, group_id, image_path)
{
	var objPanel = document.getElementById("search_display_panel");
	objPanel.style.height="100px";
	//loading
	objPanel.innerHTML = "<img src='images/spacer.gif' width='120' height='176' /><img src='images/map_loading.gif' width='200' height='176' />";
	
	objPanel.innerHTML = "";
	
	var space_image = "images/spacer.gif";

	var search_from = document.createElement("form");
		search_from.setAttribute("id", "search_f");
		search_from.setAttribute("name", "search_f");
		search_from.setAttribute("method", "get");
		search_from.setAttribute("action", "search_result.php");
		

	var objTableObj = new _IC_Table("search_display");
	var objTable = objTableObj.getTableObj();	
		objTable.setAttribute("border", "0");
		objTable.setAttribute("width", "100%");
		objTable.setAttribute("cellPadding", "5");
		objTable.setAttribute("cellSpacing", "0");
	var objBody = objTableObj.getTableBodyObj();

	var tRow1 = addRow();
		tRow1.setAttribute("id", "1");
		//tRow1.style.backgroundColor = "#FFFFFF";
	var tCol1_1 = addCol();
		tCol1_1.setAttribute("width", "22%");
		tCol1_1.setAttribute("noWrap", "true");
		tCol1_1.setAttribute("align", "right");		
		tCol1_1.innerHTML = "請選擇日期：";
	
	var tCol1_2 = addCol();
		tCol1_2.setAttribute("width", "28%");
		tCol1_2.setAttribute("noWrap", "true");	
		//tCol1_2.innerHTML = "由 ";
		
	var time = new Date();
	var month = time.getMonth()+1;	//Returns the month. (Range is 0-11)!
	var day = time.getDate();		//Returns the day of the month (Range is 1-31)
	var year = time.getYear();		//Returns the year, in 4 digit format or otherwise depending on browser. Deprecated in favor of getFullYear().

	//var datecount = 91;
	var diff_dat = new Date();
		//diff_dat.setDate(day - datecount);
//		diff_dat.setMonth(diff_dat.getMonth()-3);  -- Modify search period from 3m to 1y and Requested by Editorial at 27/01/2010
		diff_dat.setMonth(diff_dat.getMonth()-12);

	var from_month = diff_dat.getMonth()+1;
	var from_day = diff_dat.getDate();
	var from_year = diff_dat.getYear();


	//FROM
	var selectbox_year = document.createElement("SELECT");
		selectbox_year.setAttribute("name", "fromYear");
		selectbox_year.setAttribute("id", "fromYear");
		
		for (i=from_year;i<=year;i++)
		{
			var optn = document.createElement("OPTION");
				optn.text = i;
				optn.value = i;							
				selectbox_year.options.add(optn);
		}	
		// set selected on the option
		for(var x = 0; x < selectbox_year.options.length; x++)
		{
			if(selectbox_year[x].value == from_year)
			{
				selectbox_year[x].selected = true;
			}
		}

	var selectbox_month = document.createElement("SELECT");
		selectbox_month.setAttribute("name", "fromMonth");
		selectbox_month.setAttribute("id", "fromMonth");
		
		for (i=1;i<=12;i++)
		{
			var optn = document.createElement("OPTION");
				optn.text = i;
				optn.value = i;				

				selectbox_month.options.add(optn);
		}
		// set selected on the option
		for(var x = 0; x < selectbox_month.options.length; x++)
		{
			if(selectbox_month[x].value == from_month)
			{
				selectbox_month[x].selected = true;
			}
		}
	
	var selectbox_day = document.createElement("SELECT");
		selectbox_day.setAttribute("name", "fromDay");
		selectbox_day.setAttribute("id", "fromDay");
		
		for (i=1;i<=31;i++)
		{
			var optn = document.createElement("OPTION");
				optn.text = i;
				optn.value = i;
				/*
				if (i==day)
				{
					optn.selected = true;
				}
				*/
				selectbox_day.options.add(optn);
		}	
		// set selected on the option
		for(var x = 0; x < selectbox_day.options.length; x++)
		{
			if(selectbox_day[x].value == from_day)
			{
				selectbox_day[x].selected = true;
			}
		}
		
		//append to td
		tCol1_2.appendChild(selectbox_year);	
	var space_img = document.createElement("IMG");
		space_img.src=space_image;
		space_img.width="2";
		tCol1_2.appendChild(space_img);		
		tCol1_2.appendChild(selectbox_month);
	var space_img2 = document.createElement("IMG");
		space_img2.src=space_image;
		space_img2.width="2";
		tCol1_2.appendChild(space_img2);			
		tCol1_2.appendChild(selectbox_day);
	
	var tCol1_3 = addCol();
		tCol1_3.setAttribute("width", "43%");
		tCol1_3.setAttribute("noWrap", "true");	
		tCol1_3.innerHTML = "至&nbsp;&nbsp;&nbsp;";
		
	// TO
	var selectbox_toyear = document.createElement("SELECT");
		selectbox_toyear.setAttribute("name", "toYear");
		selectbox_toyear.setAttribute("id", "toYear");
		
		for (i=from_year;i<=year;i++)
		{
			var optn = document.createElement("OPTION");
				optn.text = i;
				optn.value = i;
				selectbox_toyear.options.add(optn);
		}	
		// set selected on the option
		for(var x = 0; x < selectbox_toyear.options.length; x++)
		{
			if(selectbox_toyear[x].value == year)
			{
				selectbox_toyear[x].selected = true;
			}
		}

	var selectbox_tomonth = document.createElement("SELECT");
		selectbox_tomonth.setAttribute("name", "toMonth");
		selectbox_tomonth.setAttribute("id", "toMonth");
		
		for (i=1;i<=12;i++)
		{
			var optn = document.createElement("OPTION");
				optn.text = i;
				optn.value = i;				
				selectbox_tomonth.options.add(optn);
		}
		// set selected on the option
		for(var x = 0; x < selectbox_tomonth.options.length; x++)
		{
			if(selectbox_tomonth[x].value == month)
			{
				selectbox_tomonth[x].selected = true;
			}
		}
	
	var selectbox_today = document.createElement("SELECT");
		selectbox_today.setAttribute("name", "toDay");
		selectbox_today.setAttribute("id", "toDay");
		
		for (i=1;i<=31;i++)
		{
			var optn = document.createElement("OPTION");
				optn.text = i;
				optn.value = i;				
				selectbox_today.options.add(optn);
		}	
		// set selected on the option
		for(var x = 0; x < selectbox_today.options.length; x++)
		{
			if(selectbox_today[x].value == day)
			{
				selectbox_today[x].selected = true;
			}
		}
		
		//append to td
		tCol1_3.appendChild(selectbox_toyear);	
	var space_img = document.createElement("IMG");
		space_img.src=space_image;
		space_img.width="2";
		tCol1_3.appendChild(space_img);		
		tCol1_3.appendChild(selectbox_tomonth);
	var space_img2 = document.createElement("IMG");
		space_img2.src=space_image;
		space_img2.width="2";
		tCol1_3.appendChild(space_img2);			
		tCol1_3.appendChild(selectbox_today);

		//append to row
		tRow1.appendChild(tCol1_1);
		tRow1.appendChild(tCol1_2);
		tRow1.appendChild(tCol1_3);

	var tRow2 = addRow();
		tRow2.setAttribute("id", "2");
	var tCol2_1 = addCol();
		tCol2_1.setAttribute("width", "22%");		
		tCol2_1.setAttribute("noWrap", "true");
		tCol2_1.setAttribute("align", "right");		
		tCol2_1.innerHTML = "關鍵字：";
	
	var tCol2_2 = addCol();		
		tCol2_2.setAttribute("noWrap", "true");
		tCol2_2.setAttribute("colSpan", "2");
		
	var input_text = document.createElement("INPUT");
		input_text.setAttribute("type", "text");
		input_text.setAttribute("id", "inTitle");
		input_text.setAttribute("name", "inTitle");
	
	//topic1
	var select_desc = document.createElement("SELECT");
		select_desc.setAttribute("name", "topic1");
		select_desc.setAttribute("id", "topic1");
		
		var optn1 = document.createElement("OPTION");
			optn1.text = "標題";
			optn1.value = 2;
			optn1.selected = 1;
			select_desc.options.add(optn1);
		var optn2 = document.createElement("OPTION");
			optn2.text = "全文";
			optn2.value = 3;
			select_desc.options.add(optn2);
		var optn3 = document.createElement("OPTION");
			optn3.text = "標題或全文";
			optn3.value = 1;
			select_desc.options.add(optn3);
		
			//append to td
			tCol2_2.appendChild(input_text);
		var space_img3 = document.createElement("IMG");
			space_img3.src=space_image;
			space_img3.width="2";
			tCol2_2.appendChild(space_img3);
			tCol2_2.appendChild(select_desc);

		//append to row
		tRow2.appendChild(tCol2_1);
		tRow2.appendChild(tCol2_2);

/*	
	var tRow3 = addRow();
		tRow3.setAttribute("id", "3");
		tRow3.style.backgroundColor = "#FFFFFF";
	var tCol3_1 = addCol();
		tCol3_1.setAttribute("width", "22%");		
		tCol3_1.setAttribute("noWrap", "true");
		tCol3_1.setAttribute("align", "right");		
		tCol3_1.innerHTML = "新聞類別：";
	
	var tCol3_2 = addCol();		
		tCol3_2.setAttribute("noWrap", "true");
		tCol3_2.setAttribute("colSpan", "2");
		
	var channel = document.createElement("INPUT");
		channel.setAttribute("type", "hidden");
		channel.setAttribute("id", "channel_id");
		channel.setAttribute("name", "channel_id");
		channel.setAttribute("value", "2");
	var f_o_g_c = document.createElement("INPUT");
		f_o_g_c.setAttribute("type", "hidden");
		f_o_g_c.setAttribute("id", "f_o_g_c");
		f_o_g_c.setAttribute("name", "f_o_g_c");
		f_o_g_c.setAttribute("value", "T");
	
	//group_id
	var select_group = document.createElement("SELECT");
		select_group.setAttribute("name", "topic");
		select_group.setAttribute("id", "topic");
		
	var optn1 = document.createElement("OPTION");
		optn1.text = "本地";
		optn1.value = 1;		
		select_group.options.add(optn1);
	var optn2 = document.createElement("OPTION");
		optn2.text = "兩岸";
		optn2.value = 0;
		select_group.options.add(optn2);
	var optn3 = document.createElement("OPTION");
		optn3.text = "國際";
		optn3.value = 3;
		select_group.options.add(optn3);
	var optn4 = document.createElement("OPTION");
		optn4.text = "體育";
		optn4.value = 4;
		select_group.options.add(optn4);
	var optn5 = document.createElement("OPTION");
		optn5.text = "財經";
		optn5.value = 2;
		select_group.options.add(optn5);
	var optn6 = document.createElement("OPTION");
		optn6.text = "全部";
		optn6.value = 5;	
		//optn6.selected = 1;
		select_group.options.add(optn6);

		// set selected on the option
		for(var x = 0; x < select_group.options.length; x++)
		{
			if(select_group[x].value == 5)
			{
				select_group[x].selected = true;
			}
		}
	
		//append to td
		tCol3_2.appendChild(select_group);
		tCol3_2.appendChild(channel);
		tCol3_2.appendChild(f_o_g_c);

		//append to row
		tRow3.appendChild(tCol3_1);
		tRow3.appendChild(tCol3_2);


	var tRow4 = addRow();
		tRow4.setAttribute("id", "4");
	var tCol4_1 = addCol();
		tCol4_1.setAttribute("width", "22%");		
		tCol4_1.setAttribute("noWrap", "true");
		tCol4_1.setAttribute("align", "right");		
		tCol4_1.innerHTML = "只限視像：";
	
	var tCol4_2 = addCol();		
		tCol4_2.setAttribute("noWrap", "true");
		tCol4_2.setAttribute("colSpan", "2");
	
	var check_box = document.createElement("INPUT");
		check_box.setAttribute("type", "checkbox");
		check_box.setAttribute("id", "video");
		check_box.setAttribute("name", "video");
		check_box.setAttribute("value", "on");

		//append to td
		tCol4_2.appendChild(check_box);

		//append to row
		tRow4.appendChild(tCol4_1);
		tRow4.appendChild(tCol4_2);
*/
	
	var tRow5 = addRow();
		tRow5.setAttribute("id", "5");
		//tRow5.style.backgroundColor = "#FFFFFF";
	var tCol5_1 = addCol();
		tCol5_1.setAttribute("width", "22%");		
		tCol5_1.setAttribute("noWrap", "true");
		tCol5_1.setAttribute("align", "right");		
		tCol5_1.innerHTML = "&nbsp";
	
	var tCol5_2 = addCol();		
		tCol5_2.setAttribute("noWrap", "true");
		tCol5_2.setAttribute("colSpan", "2");
	
	var input_submit = document.createElement("INPUT");
		input_submit.setAttribute("type", "submit");
		input_submit.setAttribute("id", "Submit");
		input_submit.setAttribute("name", "Submit");
		input_submit.setAttribute("value", "搜尋");
		
	
	var input_reset = document.createElement("INPUT");
		input_reset.setAttribute("type", "reset");
		input_reset.setAttribute("id", "reset");
		input_reset.setAttribute("name", "reset");
		input_reset.setAttribute("value", "重設");

		//append to td
		tCol5_2.appendChild(input_submit);
		tCol5_2.appendChild(input_reset);

		//append to row
		tRow5.appendChild(tCol5_1);
		tRow5.appendChild(tCol5_2);	

		//append to table and form and div
		objBody.appendChild(tRow1);
		objBody.appendChild(tRow2);
		//objBody.appendChild(tRow3);
		//objBody.appendChild(tRow4);
		objBody.appendChild(tRow5);
		objTable.appendChild(objBody);		
		search_from.appendChild(objTable);	
		objPanel.appendChild(search_from);	

	var header_search = document.getElementById("header_search");
		if(header_search != null)
		{
			var image_string = image_path;
				image_string = image_string.substring(0,image_string.length-4);
				image_string = image_string+"_on.jpg";
				//alert (image_string);
				
				header_search.setAttribute("src", image_string);
				header_search.onclick = function()
				{
					closegetSearch(video_id, channel_id, group_id, image_path);
				}
		}
}




function closegetSearch(video_id, channel_id, group_id, image_path)
{
	var objPanel = document.getElementById("search_display_panel");
	
	if(objPanel != null)
	{
		objPanel.style.height="33px";
				
		for(var i = 0; i < objPanel.childNodes.length; i++)
		{
			objPanel.removeChild(objPanel.childNodes[i]);
		}
		
		var space_image = "images/spacer.gif";

		var search_from = document.createElement("form");
			search_from.setAttribute("id", "search_f");
			search_from.setAttribute("name", "search_f");
			search_from.setAttribute("method", "get");
			search_from.setAttribute("action", "search_result.php");

		var objTableObj = new _IC_Table("search_display");
		var objTable = objTableObj.getTableObj();	
			objTable.setAttribute("border", "0");
			objTable.setAttribute("width", "100%");
			objTable.setAttribute("cellPadding", "5");
			objTable.setAttribute("cellSpacing", "0");
		var objBody = objTableObj.getTableBodyObj();

		var tRow1 = addRow();
			tRow1.setAttribute("id", "1");
			//tRow1.style.backgroundColor = "#FFFFFF";
		var tCol1_1 = addCol();
			tCol1_1.setAttribute("width", "22%");
			tCol1_1.setAttribute("noWrap", "true");
			tCol1_1.setAttribute("align", "right");		
			tCol1_1.innerHTML = "關鍵字：";
		
		var tCol1_2 = addCol();
			tCol1_2.setAttribute("width", "78%");
			tCol1_2.setAttribute("noWrap", "true");	
		
		var input_text = document.createElement("INPUT");
			input_text.setAttribute("type", "text");
			input_text.setAttribute("id", "inTitle");
			input_text.setAttribute("name", "inTitle");
	
		//topic1
		var select_desc = document.createElement("SELECT");
			select_desc.setAttribute("name", "topic1");
			select_desc.setAttribute("id", "topic1");
		
		var optn1 = document.createElement("OPTION");
			optn1.text = "標題";
			optn1.value = 2;
			optn1.selected = 1;
			select_desc.options.add(optn1);
		var optn2 = document.createElement("OPTION");
			optn2.text = "全文";
			optn2.value = 3;
			select_desc.options.add(optn2);
		var optn3 = document.createElement("OPTION");
			optn3.text = "標題或全文";
			optn3.value = 1;
			select_desc.options.add(optn3);
		
		var input_submit = document.createElement("INPUT");
			input_submit.setAttribute("type", "submit");
			input_submit.setAttribute("id", "Submit");
			input_submit.setAttribute("name", "Submit");
			input_submit.setAttribute("value", "搜尋");
									
		
		var channel = document.createElement("INPUT");
			channel.setAttribute("type", "hidden");
			channel.setAttribute("id", "channel_id");
			channel.setAttribute("name", "channel_id");
			channel.setAttribute("value", "3");
		
		/*
		var group = document.createElement("INPUT");
			group.setAttribute("type", "hidden");
			group.setAttribute("id", "topic");
			group.setAttribute("name", "topic");
			group.setAttribute("value", "3");

		var f_o_g_c = document.createElement("INPUT");
			f_o_g_c.setAttribute("type", "hidden");
			f_o_g_c.setAttribute("id", "f_o_g_c");
			f_o_g_c.setAttribute("name", "f_o_g_c");
			f_o_g_c.setAttribute("value", "T");
		*/

			//append to td
			tCol1_2.appendChild(input_text);
		var space_img1 = document.createElement("IMG");
			space_img1.src=space_image;
			space_img1.width="2";
			tCol1_2.appendChild(space_img1);
			tCol1_2.appendChild(select_desc);
		var space_img2 = document.createElement("IMG");
			space_img2.src=space_image;
			space_img2.width="2";
			tCol1_2.appendChild(space_img2);
			tCol1_2.appendChild(input_submit);
			tCol1_2.appendChild(channel);
			//tCol1_2.appendChild(group);
			//tCol1_2.appendChild(f_o_g_c);

			//append to row
			tRow1.appendChild(tCol1_1);
			tRow1.appendChild(tCol1_2);
		
			//append to table and form and div
			objBody.appendChild(tRow1);
			objTable.appendChild(objBody);		
			search_from.appendChild(objTable);	
			objPanel.appendChild(search_from);			
		
		var header_search = document.getElementById("header_search");
		if(header_search != null)
		{
			header_search.setAttribute("src", image_path);
			header_search.onclick = function()
			{
				getSearch(video_id, channel_id, group_id, image_path);
			}
		}
	}
}
