<?php
include("session.php");
include("connect.php");
?>
<head>
<script type="text/JavaScript">
function clearempty(){
	var ddd1 = document.getElementById("choose").value;
	if ((ddd1 == "pName") || (ddd1 == "type")){
		var fff = document.getElementById("search").value;
		if (fff == ""){
			alert("Please fill in some keyword to search");
			return false;
		}else{
			return true;
		}
	}else if(ddd1 == "budget"){
		var fff = document.getElementById("search").value;
		var fff1 = document.getElementById("search1").value;
		if((isNaN(parseInt(fff))) || (isNaN(parseInt(fff1)))){
			alert("Please enter the number");
			return false;			
		}
		else if((parseInt(fff1)) < (parseInt(fff))){
			alert("Second number must greater than the first number");
			return false;
		}else{
			return true;
		}	
	}
		
}
function changeinput(getchoose3){
var value3 = getchoose3;
if ((value3 == "pName") || (value3 == "type")){
	document.getElementById('input1').innerHTML = "<input type='text' size='50' name='search' id='search' value='' class='searchText'>";
}
else if(value3 == "budget"){
	document.getElementById('input1').innerHTML = "<input type='text' size='20' name='search' id='search' value='0' class='searchText'> To <input type='text' size='20' name='search1' id='search1' value='0' class='searchText'>";
}
alert(getchoose);
}
</script>
</head>

<center>
<form action="searchlist.php" method="post" target="showframe" name="form1">
<table class="searchBar">
<tr><td>

<table align=center border=0 width="850">
<tr>
<td>
	<div id="input1"><input type="text" size="50" name="search" id="search" value="" class="searchText"></div>
	<input type="hidden" name="page" value="1"> 
</td>
<td>
	<select id="choose" name="chooose" onchange="changeinput(this.value)" class="category">
	<option value="pName">Product Name</option>
	<option value="type">Product Type</option>
	<option value="budget">Budget</option>
	</select>
</td>
<td>
<input type="submit" value="Search" onclick="return clearempty()" class="searchButton">
</td>
<td class="advanced">
<a href="" align=right>Advanced search</a>
</td>
</tr>
</table>

</td></tr>
</table>
</form>
</center>