var gFlag = true;

function PopulateNext(id)
{
	switch (id)
	{
		case '':
			var obj = document.getElementById("selectProd");
			for(var i=0;i < arrProducts.length;i++)
			{
				var item = arrProducts[i];
				option = document.createElement("OPTION");
				option.value = item.split("#")[0];
				option.text = item.split("#")[1];
				obj.options[obj.options.length] = option;
			}
			var btn = document.getElementById("butSubmit");
			btn.disabled = true;
			btn.className = "buttonDis";
			break;
		case 'selectProd':
			var obj = document.getElementById("selectPlatform");
			obj.options.length = 0;
			
			var val = document.getElementById(id).value;
			if (val == "" || val == 0) return;
			var item = arrPlatforms[val];
			if(item == null) return;
			var arr = item.split("$");
			for(var i =0; i < arr.length; i++)
			{
				var values = arr[i];
				option = document.createElement("OPTION");
				option.value = values.split("#")[0];
				option.text = values.split("#")[1];
				obj.options[obj.options.length] = option;
			}
			var btn = document.getElementById("butSubmit");
			btn.disabled = true;
			btn.className = "buttonDis";
			break;	
		default:
			var btn = document.getElementById("butSubmit");
			btn.disabled = false;
			btn.className = "buttonEn";
			btn.focus();
			break;
	}
	
	var qs = new Querystring();
		
	if(qs.get("hidSubmit") == "true" && gFlag)
	{
		gFlag = false;
	
		document.getElementById("selectProd").value = qs.get("selectProd");
		document.getElementById("selectProd").onchange();
		
		document.getElementById("selectPlatform").value = qs.get("selectPlatform");
		
	}
	
}

function ValidateFilterForm()
{
	if(document.getElementById("selectProd").value == "" || document.getElementById("selectPlatform").value == "")
	{
		alert("You must choose all filter values");
		return false;
	}
	document.getElementById('hidSubmit').value = 'true'
	return true;
}

function ShowContent(id)
{
	var tr = document.getElementById("trContent" + id);

	if(tr.style.display == 'none')
		tr.style.display = '';
	else
		tr.style.display = 'none';	
}

function RenderLabels()
{
	var qs = new Querystring();
	
	var prodId = qs.get("selectProd");
	var platId = qs.get("selectPlatform");
	var AuthoSelect = " > ";
		
	for(var i=0; i < arrProducts.length; i++)
	{
		if(arrProducts[i].split("#")[0] == prodId){
			//document.getElementById("tdProd").innerText = arrProducts[i].split("#")[1];	
			AuthoSelect += arrProducts[i].split("#")[1]+" , "	}
	}
	
	var platArr = arrPlatforms[prodId].split("$");
	for(var i=0; i < platArr.length; i++)
	{
		if(platArr[i].split("#")[0] == platId){
			//document.getElementById("tdPlatform").innerText = platArr[i].split("#")[1];	
			AuthoSelect += platArr[i].split("#")[1];		}
	}
	
	
	document.getElementById("tdPath").innerHTML += AuthoSelect;

	
		
}
