/*
 * Author : Michael Bosworth 2006
 *
 * Note : This class is dependant on : mootools
 * 
 * These files must be included with this script to function.
*/

var nutritionLayer = null;

nutritionLayer = $("nutrition");
var imgContain = $("recipeimg");
if($("recipeimg") != null){
    if(imgContain.childNodes.length == 1 && imgContain.childNodes[0].nodeType == 3){
        imgContain.style.display = "none";
    }
}

	
function go(box)
{
	if(box != null) {
        var destination = box.options[box.selectedIndex].value;
    }
    if(destination){
        var isPremium = destination.indexOf("xml");
        if(isPremium != -1){
            location.href = "/recipes/collectionDisplay.jsp?collectionId=" + destination;
        }
        else{
            location.href = destination;
        }
    }
}

/* Details Page */
function showNutrition(){

    if(nutritionLayer != null){
        document.getElementById('nutrition').style.display = 'block';
    }
    else{
        window.location.href = "/common/profile/regStep1.jsp";
    }

}

/* Handles Print Views for Recipe Details Print Page */
function printView(size){
    switch(size){
        case "fullPage":
            $("detail").style.width = "485px";
            $("detailcol").style.cssFloat = "left";
            $("detailcol").style.width = "275px";
            $("recipeimg").style.cssFloat = "right";
            document.getElementById("recipeimg").style.marginRight = "0px";
            if($("pnutrition") != null){
                $("pnutrition").style.cssFloat = "left";
                $("pnutrition").style.width = "200px";
            }
        break;
        case "3x5":
            $("detail").style.width = "288px";
            $("detailcol").style.cssFloat = "none";
            $("detailcol").style.width = "288px";
            $("recipeimg").style.cssFloat = "none";
            $("recipeimg").style.marginRight = "88px";
            if($("pnutrition") != null){
                $("pnutrition").style.cssFloat = "none";
                $("pnutrition").style.width = "288px";
            }
        break;
        case "4x6":
            $("detail").style.width = "384px";
            $("detailcol").style.cssFloat = "none";
            $("detailcol").style.width = "384px";
            $("recipeimg").style.cssFloat = "none";
            $("recipeimg").style.marginRight = "184px";
            if($("pnutrition") != null){
                $("pnutrition").style.cssFloat = "none";
                $("pnutrition").style.width = "384px";
            }
        break;
        default:
            $("detail").style.width = "485px";
            $("detailcol").style.cssFloat = "left";
            $("detailcol").style.width = "275px";
            $("recipeimg").style.cssFloat = "right";
            $("recipeimg").style.marginRight = "0px";
            if($("pnutrition") != null){
                $("pnutrition").style.cssFloat = "left";
                $("pnutrition").style.width = "200px";
            }
        break;
    }
}