function openUrl(l)
{
	var s = document.getElementsByTagName("base")[0].href + l;
	window.location.href = s.replace(/\/.\//, "/")
}

function submitProductForm(a, p, i)
{
	if(!checkProductForm(p, i))
		return;
	
	var o = document.getElementById("form"+p);
	o.action = a;
	o.submit();
}

function checkProductForm(p, i)
{
	for(var j = 0; j < i; j++)
	{
		var o = document.getElementById("option"+p+"_"+j);
		if(o.selectedIndex == 0)
		{
			alert("Please make a selection for each option");
			return false;
		}
	}
	
	return true;
}

function submitGottaHaveIt(p, i)
{
	if(!checkProductForm(p, i))
		return;

	var f = document.getElementById('form'+p);
	var o = getOptions(f, p, i);
//	alert('gottahaveit_add.php?p=' + p + '&o[]=' + o);
	window.location = 'gottahaveit_add.php?p=' + p + '&o[]=' + o;
}

function getOptions(f, p, i)
{
	var ret_val = new Array();
	var idx = 0;
	var txt = '';
	for(var j = 0; j < i; j++)
	{
		var o = document.getElementById("option"+p+"_"+j);
		if(o.selectedIndex != 0)
		{
			idx = o.selectedIndex;
			txt = o.options[0].text.replace(' ', '-');
			ret_val[j] = txt + '^' + o.options[idx].value;
		}
	}
	
	return ret_val;
}

