// Jump to Published Report page according to date in value field 
function JumpToPubReport(list) {
	var datevar = list.options[list.selectedIndex].value
	if (datevar != "None") {
		location.href = "published.php?filter="+datevar+""
	}
}

// Accepts two objects (dropdowns) to ensure the selected values are not 0 
function CheckLists(list1,list2) {
	if ((list1.options[list1.selectedIndex].value == "0") || (list2.options[list2.selectedIndex].value == "0"))
	{
		alert("Please choose a value from each menu!");
		return false;
	}
	else {
		return true;
	}
}

// Accepts one object (dropdown) to ensure the selected value is not 0
function CheckList(list1) {
	if (list1.options[list1.selectedIndex].value == "0")
	{
		alert("Please choose a value from the dropdown menu!");
		return false;
	}
	else {
		return true;
	}
}

// SwitchMarkets dropdown redirector 
function SwitchMarkets(list,prcid) {
	var marketID = list.options[list.selectedIndex].value
	if (marketID != "None") {
		location.href = "market1.php?prcid="+prcid+"&mid="+marketID+""
	}
}

// SwitchProducts dropdown redirector 
function SwitchProducts(list) {
	var prid = list.options[list.selectedIndex].value
	if (prid != "0") {
		location.href = "product.php?prid="+prid
	}
}

// SwitchProductCats dropdown redirector
function SwitchProductCats(list,redirectTo,mid,mid2,mid3,mid4) {
	var prcid = list.options[list.selectedIndex].value
	var urlStr = redirectTo+"?prcid="+prcid+"&mid="+mid;

	if (mid2 != null)
	{
		urlStr = urlStr+"&mid2="+mid2;
	}
	if (mid3 != null)
	{
		urlStr = urlStr+"&mid3="+mid3;
	}
	if (mid4 != null)
	{
		urlStr = urlStr+"&mid4="+mid4;
	}
	
	if (prcid != "None") {
		location.href = urlStr;
	}
}

/* Verify both a category and markets have been chosen (used on *_choose.php files); */
function CheckMarkets(catlist,mlist1,mlist2) {
	if (catlist.options[catlist.selectedIndex].value == "0")
	{
		alert("Please choose a product category!");
		return false;
	}
	else if (
		(mlist1.options[mlist1.selectedIndex].value == "0") ||
		(mlist2.options[mlist2.selectedIndex].value == "0"))
	{
		alert("Please choose a market to compare from each menu!");
		return false;
	}
	else {
		return true;
	}
}

/* Verify both a category and markets have been chosen (used on market4_choose.php files); */
function CheckMarkets4(catlist,mlist1,mlist2,mlist3,mlist4) {
	if (catlist.options[catlist.selectedIndex].value == "0")
	{
		alert("Please choose a product category!");
		return false;
	}
	else if (
		(mlist1.options[mlist1.selectedIndex].value == "0") ||
		(mlist2.options[mlist2.selectedIndex].value == "0") ||
		(mlist3.options[mlist3.selectedIndex].value == "0") ||
		(mlist4.options[mlist4.selectedIndex].value == "0"))
	{
		alert("Please choose a market to compare from each menu!");
		return false;
	}
	else {
		return true;
	}
}
