/*
 * Author : Michael Bosworth 2006
 *
 *
 * Note : This class is dependant on : /web/common/js/lib/prototype/prototype.lite.js
 *                                     /web/common/js/lib/moofx/moo.fx.js
 *                                     /web/common/js/lib/moofx/moo.fx.utils.js
 *                                     /web/common/js/ui/carousel/carousel.js
 * These files must be included with this script to function.
*/
var isLoaded = false;
var nutritionLayer = null;

window.addEvent('domready', function(){
    nutritionLayer = $("nutrition");
    var imgContain = $("recipeimg");
    if($("recipeimg") != null){
        if(imgContain.childNodes.length == 1 && imgContain.childNodes[0].nodeType == 3){
            imgContain.style.display = "none";
        }
   	}
    isLoaded = true;
});



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(isLoaded){
        if(nutritionLayer != null){
            document.getElementById('nutrition').style.display = 'block';
        }
        else{
            window.location.href = "/common/profile/regStep1.jsp";
        }
    }
}


var rollover;
function toggleDisplay(parent){
    if(rollover == null){
        rollover = $("rcrollover");
        rollover.style.visibility = "hidden";
    }
    if(rollover != null){
        if(rollover.style.visibility == "hidden"){
          rollover.style.visibility = "visible";
        }
        else{
          rollover.style.visibility = "hidden";
        }
    }
}

/* 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;
    }
}

function gPrintView(size){
    switch(size){
        case "fullPage":
            $("details").style.width = "485px";
        break;
        case "3x5":
            $("details").style.width = "288px";
        break;
        case "4x6":
            $("details").style.width = "384px";
        break;
        default:
            $("details").style.width = "485px";
        break;
    }
}