﻿var numberOfDivs = 3;
//This is how many divs we have.
//If you add more divs, update this number.
function showDiv(divId) 
{
	//divId is the integer of the div we want to show, all others will be hidden
	for(var i =1; i <= numberOfDivs; i++)
	{
		//this goes throu and turns off all divs except the one we want to show.
		var divTemp = document.getElementById("ac"+i);
		var aTemp = document.getElementById("a"+i);
		if(i != divId || aTemp.className == "active")
		{
			//hide the sucker
			divTemp.style.display = "none";
			aTemp.setAttribute("class", "");
			aTemp.setAttribute("className", "");
        }
		else
		{
			//this one is good, show it
			divTemp.style.display = "block";
			aTemp.setAttribute("class", "active");
			aTemp.setAttribute("className", "active");
		}
	}
}
function tabActive(aID)
{
    var divTemp = document.getElementById("tab_div");
    if(aID!="off")
    {
        
        divTemp.setAttribute("class", aID+"_hover");
	    divTemp.setAttribute("className", aID+"_hover");
	    //alert(aID+"_hover");
	} else {
	    divTemp.setAttribute("class", "no_hover");
	    divTemp.setAttribute("className", "no_hover");
	}
}
function toggleDisplay(id) {
    var el = document.getElementById(id)
    if (el != null) {
        if (el.style.display == 'none')
            el.style.display = 'inline'
        else
            el.style.display = 'none'
    }
}
function openPrintRecipe(type) {
    var url = "/recipes/print.htm"
    if (type != null)
        url += "?type=" + type
    var win = window.open(url, "recipe_print", "toolbar=no, directories=no, location=no, status=yes, menubar=no, resizable=yes, scrollbars=yes, width=560, height=680")
    win.focus()
    return false
}
function openPrintContent(sourceId) {
    var url = "/common/printcontent.htm?id=" + sourceId
    var win = window.open(url, "content_print", "toolbar=no, directories=no, location=no, status=yes, menubar=no, resizable=yes, scrollbars=yes, width=740, height=680")
    win.focus()
    return false
}

function startPairing(pairingGroupId) {
    var hidPairingGroup = $get(gPairingControlPrefix + "hidPairingGroupId")
    hidPairingGroup.value = pairingGroupId
    for(var i=0; i < 5; i++){
	    var divTemp = document.getElementById("pair_"+i);
		if(i != pairingGroupId){
		    divTemp.setAttribute("class", "");
		    divTemp.setAttribute("className", "");
		} else {
		    divTemp.setAttribute("class", "active");
		    divTemp.setAttribute("className", "active");
		}
	}

    var linkButton = $get(gPairingControlPrefix + "btnStartPairing")
    eval(linkButton.href)
}
function selectPairing(pairingId) {
    var hidPairing = $get(gPairingControlPrefix + "hidPairingId")
    hidPairing.value = pairingId

    var i = 0;
    while (true) {
        var aTag = document.getElementById("choose_" + i);
        if (aTag == null)
            break
        if (aTag.href.indexOf("(" + pairingId + ")") < 1) {
            aTag.setAttribute("class", "");
            aTag.setAttribute("className", "");
        } else {
            aTag.setAttribute("class", "active");
            aTag.setAttribute("className", "active");
        }
        i++
    }
    
    var linkButton = $get(gPairingControlPrefix + "btnChoosePairing")
    eval(linkButton.href)
}