function openBigPic(src)
{
	var imgWin = window.open(src,'PrdImg','width=540,height=450');
	imgWin.title = "Product image";
	imgWin.focus();
}
function openMainGroup(treeId, groupId)
{
	document.location.href='productlist.aspx?treeid='+treeId+'&groupId='+groupId;
}
function openTreeItem(treeId, groupId, productId, tplName)
{
	if(productId==0) {
		document.location.href=tplName + '.aspx?treeid='+treeId+'&groupId='+groupId;
	} else {
		document.location.href='productview.aspx?treeid='+treeId+'&groupId='+groupId+'&productId='+productId;
	}
}
function openApplication(treeId, selObj)
{
	if(selObj.value>0)
	{
		document.location.href='applicationlist.aspx?treeid='+treeId+'&ddtid='+selObj.value;
	}
	else
		selObj.selectedIndex=0;
}
function toggleTree(groupId, forceOpen)
{
	var imgObj = document.getElementById("img" + groupId);
	
	if(imgObj.src.indexOf('open')>0 || forceOpen)
	{
		imgObj.src=imgObj.src.replace('open','close');
		document.getElementById('grpul_'+groupId).style.display='block';
	}
	else
	{
		imgObj.src=imgObj.src.replace('close','open');
		document.getElementById('grpul_'+groupId).style.display='none';
	}
}
var currentTabId=1;
function prdSelectTab(id)
{
	var liObj=null;
	if(currentTabId!=null)
	{
		liObj=document.getElementById('prdTab'+currentTabId);
		if(liObj.previousSibling)
		{
			liObj.previousSibling.className=liObj.previousSibling.className.replace('preselected','');
		}
		liObj.className=liObj.className.replace('selected','');
		document.getElementById('prdTabbody'+currentTabId).style.display='none';
	}
	currentTabId=id;
	liObj=document.getElementById('prdTab'+currentTabId);
	if(liObj.previousSibling)
	{
		liObj.previousSibling.className='preselected';
	}
	liObj.className+='selected';
	document.getElementById('prdTabbody'+currentTabId).style.display='';
}
function prdOpenCompare(treeId, groupId, productId)
{
	var list = document.getElementsByName("compairproducts");
	var prdlist = "";
	for(var ind=0;ind<list.length;ind++)
	{
		if(list[ind].checked)
		{
			if(prdlist!="")
				prdlist+="|";
				
			prdlist+=list[ind].value;
		}
	}
	if(prdlist!="")
		document.location.href="productcompare.aspx?treeid=76&fromtreeid="+treeId+"&fromgroupid="+groupId+"&fromproductid="+productId+"&prdlist="+prdlist;
	return false;
}

function prdOpenCompareGuide(treeId, groupId)
{
	var list = document.getElementsByName("compairproducts");
	var prdlist = "";
	var productId = 0;
	
	for(var ind=0;ind<list.length;ind++)
	{
		if(list[ind].checked)
		{
			if (productId == 0) {
				productId = list[ind].value;
			} else {
				if(prdlist!="")
					prdlist+="|";
					
				prdlist+=list[ind].value;
			}
		}
	}
	if(prdlist!="")
		document.location.href="productcompare.aspx?treeid=76&fromtreeid="+treeId+"&fromgroupid="+groupId+"&fromproductid="+productId+"&prdlist="+prdlist;
	return false;
}

function searchProductGuide(search) {

	var curApp;
	var airConePattern;
	var material;
	
	if (search) {
		step = 4;
	} else {
		var step = getQueryString("curstep", null);

		if (step == "") {
			step = 2;
		} else {
			step++;
		}
	}
	
	var curTreeID = getQueryString("treeid", null);
	
	switch (curTreeID) {
		case "267":
		case "269":
		case "271":
		case "273":
			var stepTreeID = new Array("267", "269", "271", "273");			
			break;
		default:
			var stepTreeID = new Array("276", "279", "280", "281");			
	}
	
	if (document.getElementById('currentApplication')) {
		curApp = document.getElementById('currentApplication').value;
	} else {
		curApp = (getQueryString("pipe", null) == "") ? 0 : getQueryString("pipe", null);
	}

	if (document.getElementById('airConePattern')) {
		airConePattern = document.getElementById('airConePattern').value;
	} else {
		airConePattern = (getQueryString("aircone", null) == "") ? 0 : getQueryString("aircone", null);
	}

	if (document.getElementById('material')) {
		material = document.getElementById('material').value;
	} else {
		material = (getQueryString("material", null) == "") ? 0 : getQueryString("material", null);
	}			
	
	if (step < 4) {
		document.location.href = 'productguidesteps.aspx?Treeid=' + stepTreeID[step - 1] + '&curstep=' + step + '&pipe=' + curApp + '&aircone=' + airConePattern + '&material=' + material;
	} else {
		document.location.href = 'productguideresult.aspx?Treeid=' + stepTreeID[step - 1] + '&curstep=' + step + '&pipe=' + curApp + '&aircone=' + airConePattern + '&material=' + material;
	}
	return false;		
}

function toggleGroupText(id) {
	if (document.getElementById(id)) {
		if (document.getElementById(id).style.display == "none" || document.getElementById(id).style.display == "") {
			document.getElementById(id).style.display = "block";
			document.getElementById("groupTextBg").style.display = "block";
		} else {
			document.getElementById(id).style.display = "none";
			document.getElementById("groupTextBg").style.display = "none";
		}
	}
}	
