function sortBy(val1)
{
	//alert(val1);
	if(val1 != '')
	{

		document.frmSort.s_flag.value='sort';
//		alert(document.getElementById("ServerPath").value);
		var spath = document.getElementById("ServerPath").value;
		//alert(spath);
		//return false;
		var hta = document.getElementById("htaccess").value;
		if(hta == 'No')
		{
			document.getElementById("sort").value=val1;
			document.getElementById("sort_dn").value=val1;
			document.frmSort.submit();
		}
		else
		{
			document.getElementById("sort").value=val1;
		document.getElementById("sort_dn").value=val1;
			//alert("else");	
			var letter = document.frmSort.letter.value;
			if(letter !='')
			{
				url = spath + "alphabetsearch/"+letter+".html";
				document.frmSort.action = url;
				document.frmSort.submit();		
			}
			else
			{
				var price_range = document.frmSort.price_range.value;
				if(price_range!='')
				{
					url = spath + "price_search/"+price_range+".html";
					document.frmSort.action = url;
					document.frmSort.submit();		
				}
				else
				{
					var cat_id = document.frmSort.cat_id.value;
					if(cat_id!='')
					{
						url = spath + "category/"+cat_id+".html";
						document.frmSort.action = url;
						document.frmSort.submit();		
					}
					else
					{
						var keyword = document.frmSort.keyword.value;
						if(keyword!='')
						{
							url = spath + "search/"+keyword+".html";
							document.frmSort.action = url;
							document.frmSort.submit();		
						}
						else
						{
							var file = document.frmSort.file.value;
							if(file == 'prod_new')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							else if(file == 'prod_featured')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							else if(file == 'prod_special')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							else if(file == 'prod_offer')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							
						}
						
					}
				
				}
			}
		}
	}
	else
		return false;
}
function checkforpages(limit)
{

	var pageno = document.frmSort.gotopage.value;
	if(pageno == '' || pageno == 0)
	{
		alert("Please Enter Page Number");
		document.frmSort.gotopage.value='';
		document.frmSort.gotopage.focus();
		return false;
	}
	else if(pageno < 0)
	{
		alert("Please Enter +ve Value For Page Number");
		document.frmSort.gotopage.value='';
		document.frmSort.gotopage.focus();
		return false;
	}
	if(pageno > limit)
	{
		alert("Your Page Number Exceeds Maximum Page Limit");
		document.frmSort.gotopage.value='';
		document.frmSort.gotopage.focus();
		return false;
	}
		var spath = document.frmHidden.ServerPath.value;
		var hta = document.frmHidden.htaccess.value
		if(hta == 'No')
			document.frmSort.submit();
		else
		{
			
			var letter = document.frmSort.letter.value;
			if(letter !='')
			{
				url = spath + "alphabetsearch/"+letter+".html";
				document.frmSort.action = url;
				document.frmSort.submit();		
			}
			else
			{
				var price_range = document.frmSort.price_range.value;
				if(price_range!='')
				{
					url = spath + "price_search/"+price_range+".html";
					document.frmSort.action = url;
					document.frmSort.submit();		
				}
				else
				{
					var cat_id = document.frmSort.cat_id.value;
					if(cat_id!='')
					{
						url = spath + "category/"+cat_id+".html";
						document.frmSort.action = url;
						document.frmSort.submit();		
					}
					else
					{
						var keyword = document.frmSort.keyword.value;
						if(keyword!='')
						{
							url = spath + "search/"+keyword+".html";
							document.frmSort.action = url;
							document.frmSort.submit();		
						}
						else
						{
							var file = document.frmSort.file.value;
							if(file == 'prod_new')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							else if(file == 'prod_featured')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							else if(file == 'prod_special')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							else if(file == 'prod_offer')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							
						}
					}
				
				}
			}	
		
		}
}
function sortByDn(val2)
{
	if(val2 != '')
	{
		document.frmSort.s_flag.value='sortdn';
		var spath = document.frmHidden.ServerPath.value;
		var hta = document.frmHidden.htaccess.value
		if(hta == 'No')
		document.frmSort.submit();
		else
		{
			
			var letter = document.frmSort.letter.value;
			if(letter !='')
			{
				url = spath + "alphabetsearch/"+letter+".html";
				document.frmSort.action = url;
				document.frmSort.submit();		
			}
			else
			{
				var price_range = document.frmSort.price_range.value;
				if(price_range!='')
				{
					url = spath + "price_search/"+price_range+".html";
					document.frmSort.action = url;
					document.frmSort.submit();		
				}
				else
				{
					var cat_id = document.frmSort.cat_id.value;
					if(cat_id!='')
					{
						url = spath + "category/"+cat_id+".html";
						document.frmSort.action = url;
						document.frmSort.submit();		
					}
					else
					{
						var keyword = document.frmSort.keyword.value;
						if(keyword!='')
						{
							url = spath + "search/"+keyword+".html";
							document.frmSort.action = url;
							document.frmSort.submit();		
						}
						else
						{
							var file = document.frmSort.file.value;
							if(file == 'prod_new')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							else if(file == 'prod_featured')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							else if(file == 'prod_special')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							else if(file == 'prod_offer')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							
						}
					}
				
				}
			}
		
		}
	}
	else
		return false;}
function checkforpages_dn(limit)
{

	var pageno = document.frmSort.gotopage_dn.value;
//	alert(pageno);
	if(pageno == '' || pageno == 0)
	{
		alert("Please Enter Page Number");
		document.frmSort.gotopage_dn.value='';
		document.frmSort.gotopage_dn.focus();
		return false;
	}
	else if(pageno < 0)
	{
		alert("Please Enter +ve Value For Page Number");
		document.frmSort.gotopage_dn.value='';
		document.frmSort.gotopage.focus();
		return false;
	}
	if(pageno > limit)
	{
		alert("Your Page Number Exceeds Maximum Page Limit");
		
		document.frmSort.gotopage_dn.value='';
		document.frmSort.gotopage_dn.focus();
		return false;
	}
		var spath = document.frmHidden.ServerPath.value;
		var hta = document.frmHidden.htaccess.value
		if(hta == 'No')
			document.frmSort.submit();
		else
		{
			
			var letter = document.frmSort.letter.value;
			if(letter !='')
			{
				url = spath + "alphabetsearch/"+letter+".html";
				document.frmSort.action = url;
				document.frmSort.submit();		
			}
			else
			{
				var price_range = document.frmSort.price_range.value;
				if(price_range!='')
				{
					url = spath + "price_search/"+price_range+".html";
					document.frmSort.action = url;
					document.frmSort.submit();		
				}
				else
				{
					var cat_id = document.frmSort.cat_id.value;
					if(cat_id!='')
					{
						url = spath + "category/"+cat_id+".html";
						document.frmSort.action = url;
						document.frmSort.submit();		
					}
					else
					{
						var keyword = document.frmSort.keyword.value;
						if(keyword!='')
						{
							url = spath + "search/"+keyword+".html";
							document.frmSort.action = url;
							document.frmSort.submit();		
						}
						else
						{
							var file = document.frmSort.file.value;
							if(file == 'prod_new')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							else if(file == 'prod_featured')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							else if(file == 'prod_special')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							else if(file == 'prod_offer')
							{
								url = spath +file+".html";
								document.frmSort.action = url;
								document.frmSort.submit();		
							}
							
						}
					}
				
				}
			}
		
		}
}
function sortBySearch(val1)
{
	if(val1 != '')
	{
		document.frmSortSearch.s_flag.value='sort';
		var spath = document.frmHidden.ServerPath.value;
		var hta = document.frmHidden.htaccess.value
		if(hta == 'No')
			document.frmSortSearch.submit();
		else
		{
			var file = document.frmSortSearch.file.value;
			var keyword = document.frmSortSearch.keyword.value;
			if(keyword !='')
			{	
				if(file == 'advancesearch')
				{
					url = spath + "advancesearch.html";
					document.frmSortSearch.action = url;
					document.frmSortSearch.submit();
				}
				else if(file == 'search')
				{
					url = spath + "search/"+keyword+".html";
					document.frmSortSearch.action = url;
					document.frmSortSearch.submit();
				}
			}
		}
	}
	else
		return false;
}
function sortBySearch_dn(val2)
{
	if(val2 != '')
	{
		document.frmSortSearch.s_flag.value='sortdn';
		var spath = document.frmHidden.ServerPath.value;
		var hta = document.frmHidden.htaccess.value
		if(hta == 'No')
			document.frmSortSearch.submit();
		else
		{
			var file = document.frmSortSearch.file.value;
			var keyword = document.frmSortSearch.keyword.value;
			if(keyword !='')
			{	
				if(file == 'advancesearch')
				{
					url = spath + "advancesearch.html";
					document.frmSortSearch.action = url;
					document.frmSortSearch.submit();
				}
				else if(file == 'search')
				{
					url = spath + "search/"+keyword+".html";
					document.frmSortSearch.action = url;
					document.frmSortSearch.submit();
				}
			}
		}
//		document.frmSortSearch.submit();
	}
	else
		return false;
}
function checkforpagesSearch(limit)
{
	var pageno = document.frmSortSearch.gotopage.value;
	if(pageno == '' || pageno == 0)
	{
		alert("Please Enter Page Number");
		document.frmSortSearch.gotopage.value='';
		document.frmSortSearch.gotopage.focus();
		return false;
	}
	else if(pageno < 0)
	{
		alert("Please Enter +ve Value For Page Number");
		document.frmSortSearch.gotopage.value='';
		document.frmSortSearch.gotopage.focus();
		return false;
	}
	if(pageno > limit)
	{
		alert("Your Page Number Exceeds Maximum Page Limit");
		document.frmSortSearch.gotopage.value='';
		document.frmSortSearch.gotopage.focus();
		return false;
	}
		var spath = document.frmHidden.ServerPath.value;
		var hta = document.frmHidden.htaccess.value
		if(hta == 'No')
			document.frmSortSearch.submit();
		else
		{
			var file = document.frmSortSearch.file.value;
			var keyword = document.frmSortSearch.keyword.value;
			if(keyword !='')
			{	
				if(file == 'advancesearch')
				{
					url = spath + "advancesearch.html";
					document.frmSortSearch.action = url;
					document.frmSortSearch.submit();
				}
				else if(file == 'search')
				{
					url = spath + "search/"+keyword+".html";
					document.frmSortSearch.action = url;
					document.frmSortSearch.submit();
				}
			}
		}
}
function checkforpagesSearch_dn(limit)
{

	var pageno = document.frmSortSearch.gotopage_dn.value;
	if(pageno == '' || pageno == 0)
	{
		alert("Please Enter Page Number");
		document.frmSortSearch.gotopage_dn.value='';
		document.frmSortSearch.gotopage_dn.focus();
		return false;
	}
	else if(pageno < 0)
	{
		alert("Please Enter +ve Value For Page Number");
		document.frmSortSearch.gotopage_dn.value='';
		document.frmSortSearch.gotopage.focus();
		return false;
	}
	if(pageno > limit)
	{
		alert("Your Page Number Exceeds Maximum Page Limit");
		
		document.frmSortSearch.gotopage_dn.value='';
		document.frmSortSearch.gotopage_dn.focus();
		return false;
	}
		var spath = document.frmHidden.ServerPath.value;
		var hta = document.frmHidden.htaccess.value
		if(hta == 'No')
			document.frmSortSearch.submit();
		else
		{
			var file = document.frmSortSearch.file.value;
			var keyword = document.frmSortSearch.keyword.value;
			if(keyword !='')
			{	
				if(file == 'advancesearch')
				{
					url = spath + "advancesearch.html";
					document.frmSortSearch.action = url;
					document.frmSortSearch.submit();
				}
				else if(file == 'search')
				{
					url = spath + "search/"+keyword+".html";
					document.frmSortSearch.action = url;
					document.frmSortSearch.submit();
				}
			}
		}
}
