function getSessionId()
{	
	var pageUrl = document.location.toString();
	var i = pageUrl.split("/");
	if(i[2].indexOf("crutchfield.com") != -1)
	{
		return i[3] + "/";
	}
	else
	{
		return "";
	}
}

function getFlashSessionId()
{	
	var pageUrl = document.location.toString();
	var i = pageUrl.split("/");
	if(i[2].indexOf("crutchfield.com") != -1)
	{
		return i[3];
	}
	else
	{
		return "";
	}
}

function redirectSearch(id) 
{
	var form = document.getElementById(id);
	var opt1Checked = false;
	var opt2Checked = false;
	var opt3Checked = false;
	if (form == null)
	{
		return false;
	}
	var inputElements = document.getElementsByTagName('input');
	for (var i = 0; i < inputElements.length; i++)
	{
		if ((inputElements[i].type == 'checkbox') && (inputElements[i].checked == true))
		{
			var checkbox = inputElements[i];
			if (checkbox.id == 'opt1')
			{
				opt1Checked = true;
			}
			else if (checkbox.id == 'opt2')
			{
				opt2Checked = true;
			}
			else if (checkbox.id == 'opt3')
			{
				opt3Checked = true;
			}			
		}
	}
	var option = 0;
	if (opt1Checked)
	{
		if (!opt2Checked && !opt3Checked)
		{
			option = 1;
		}
		else if (opt2Checked && !opt3Checked)
		{
			option = 2;
		}
		else if (!opt2Checked && opt3Checked)
		{
			option = 3;
		}
		else
		{
			option = 4;
		}
	}
	else
	{
		if (opt2Checked && opt3Checked)
		{
			option = 5;
		}
		else if (opt2Checked && !opt3Checked)
		{
			option = 6;
		}
		else if (!opt2Checked && opt3Checked)
		{
			option = 7;
		}
		else
		{
			option = 8;
		}
	}
	
	var newLocation;
	switch(option)
	{
		case 1:
			newLocation = 'http://www.crutchfield.com/' + getSessionId() + 'cgi-bin/prodgroup.asp?g=270650&nvpair=AG%5FGeneral%5FFeatures%7CFFLive%5FTraffic%5FService#see_all';	
			break;
		case 2:
			newLocation = 'http://www.crutchfield.com/' + getSessionId() + 'cgi-bin/prodgroup.asp?g=270650&nvpair=AG%5FGeneral%5FFeatures|FFLive%5FTraffic%5FService&nvpair=AG%5FGeneral%5FFeatures%7CFFMP3%5FPlayback#see_all';
			break;
		case 3:
			newLocation = 'http://www.crutchfield.com/' + getSessionId() + 'cgi-bin/prodgroup.asp?g=270650&nvpair=AG%5FGeneral%5FFeatures|FFLive%5FTraffic%5FService&nvpair=AG%5FGeneral%5FFeatures%7CFFOut%5Fof%5FCar%5FUse#see_all';
			break;
		case 4:
			newLocation = 'http://www.crutchfield.com/' + getSessionId() + 'cgi-bin/prodgroup.asp?g=270650&nvpair=AG%5FGeneral%5FFeatures|FFLive%5FTraffic%5FService&nvpair=AG%5FGeneral%5FFeatures|FFMP3%5FPlayback&nvpair=AG%5FGeneral%5FFeatures%7CFFOut%5Fof%5FCar%5FUse#see_all';
			break;
		case 5:
			newLocation = 'http://www.crutchfield.com/' + getSessionId() + 'cgi-bin/prodgroup.asp?g=270650&avf=Y&nvpair=AG%5FGeneral%5FFeatures|FFMP3%5FPlayback&nvpair=AG%5FGeneral%5FFeatures%7CFFOut%5Fof%5FCar%5FUse#see_all';
			break;
		case 6:
			newLocation = 'http://www.crutchfield.com/' + getSessionId() + 'cgi-bin/prodgroup.asp?g=270650&avf=Y&nvpair=AG%5FGeneral%5FFeatures%7CFFMP3%5FPlayback#see_all';
			break;
		case 7:
			newLocation = 'http://www.crutchfield.com/' + getSessionId() + 'cgi-bin/prodgroup.asp?g=270650&avf=Y&nvpair=AG%5FGeneral%5FFeatures%7CFFOut%5Fof%5FCar%5FUse#see_all';
			break;
		case 8:
			newLocation = 'http://www.crutchfield.com/' + getSessionId() + 'cgi-bin/prodgroup.asp?g=270650&avf=Y';
			break;
		default:
	}
	window.open(newLocation);
}