$(function()
{
	/*$("li[class*=producttype]").toggle(function()
	{
		var i = parseInt($(this).attr("class").replace("producttype",""))+1;
		var obj = $(this).next().find("ul");
		if (obj.html() != null)
		{
			obj.find(".producttype"+i).show();
		}
		else
		{
			window.location.href = $(this).find("a").attr("href");
		}
	},function()
	{
		var i = parseInt($(this).attr("class").replace("producttype",""))+1;
		var obj = $(this).next().find("ul");
		if (obj.html() != null)
		{
			for (index=i; index<10; index++)
			{
				var temp = obj.find(".producttype"+index);
				if (temp != null)
				{
					temp.hide();
				}
			}
		}
		else
		{
			window.location.href = $(this).find("a").attr("href");
		}
	});*/

	var tid = QueryString("tid");
	if (tid != null)
	{
		//$("a[href*=tid="+ tid +"]").parent().parent().parent().find("li[class*=producttype]").show();
        var typediv = $("ul[class=producttype]");
		var temp = typediv.find("a[href*=tid="+ tid +"]");
		var tarr = temp.attr("href").split("?");
		var url = tarr[0];
		temp = typediv.find("a[href="+ url +"?tid="+ tid +"]").parent();

        var i = parseInt(temp.attr("class").replace("producttype",""));
        var level = i+1;
		var child = $("#producttype"+tid);
		if (child != null)
		{
			child.find("li[class=producttype"+ level +"]").show();
		}

		/*temp = temp.parent();*/

		for (index=i; index>0; index--)
		{
			temp.parent().find(".producttype"+ index).show();
			temp = temp.parent().parent();
		}
	}
});

function QueryString(fieldName)
{
  var urlString = document.location.search;
  if(urlString != null)
  {
	   var typeQu = fieldName+"=";
	   var urlEnd = urlString.indexOf(typeQu);
	   if(urlEnd != -1)
	   {
			var paramsUrl = urlString.substring(urlEnd+typeQu.length);
			var isEnd =  paramsUrl.indexOf('&');
			if(isEnd != -1)
			{
				 return paramsUrl.substring(0, isEnd);
			}
			else
			{
				return paramsUrl;
			}
	   }
	   else
	   {
			return null;
	   }
  }
 else
 {
	return null;
 }
}