	function Right(str, n){
			if (n <= 0)
			return "";
			else if (n > String(str).length)
			return str;
			else {
			var iLen = String(str).length;
			return String(str).substring(iLen, iLen - n);
			}
		}

	
		function SubmitForm(){
			
			var search = $('Search').value;
			var genre = $('CatID').value;
			var yearfrom = $('YearFrom').value;
			var yearto = $('YearTo').value;
			
			var redirect = '/Songs/Song-Search?'

			if ((search != 'Search by Song Title, Writer or Artist') && (search != ''))
			{
				if (Right(redirect, 1) != '?')  
				{
					redirect = redirect + '&'
				}
				
				redirect = redirect + 'Search='+search;
			} 
			
			if (genre != '')
			{
				if (Right(redirect, 1) != '?') 
				{
					redirect = redirect + '&'
				}			
				redirect = redirect + 'CatID='+genre;
			} 			
			
			if ((yearfrom != 'Copyright year from') && (yearfrom != ''))
			{
				if (Right(redirect, 1) != '?')  
				{
					redirect = redirect + '&'
				}			
				redirect = redirect + 'YearFrom='+yearfrom;
			} 

			if ((yearto != 'Copyright year to') && (yearto != ''))
			{
				if (Right(redirect, 1) != '?' ) 
				{
					redirect = redirect + '&'
				}			
				redirect = redirect + 'YearTo='+yearto;
			} 

			window.location = redirect;
		}
