var whatsThisWindow = null;
var menuWindow = null;

/*
 * Simple hover method to change the CSS class of an object when mousing over.  Example below:
 *    <input type="button" value="Submit" class="btn" onmouseover="hov(this,'btnhov')" 
 *                                                    onmouseout="hov(this,'btn')" />
 */
function hov(obj,cssClass)
{
    if(obj.className)
    {
        obj.className=cssClass;
    }
}

function itemRadioClick(cellToHighlight, styleName, dropDownName)
{
    document.getElementById(cellToHighlight).className = styleName;
    
    var dropd = document.forms[0][dropDownName];
    if( dropd != null )
        dropd.selectedIndex = 0;
}

function itemDropDownChange(cellToToggle, radioName, onStyleName, offStyleName, val)
{
    var radioGroup = document.forms[0][radioName];

    if( val.indexOf("-1") != -1 )
    {
        document.getElementById(cellToToggle).className = offStyleName; 
        
        if( radioGroup != null )       
            CheckNoneForToday(cellToToggle, radioGroup);
    }
    else
    {
        document.getElementById(cellToToggle).className = onStyleName;
        
        if( radioGroup != null )    
            UnCheckAllRadiosForToday(cellToToggle, radioGroup);
    }
}

function resetDay(cellToReset, dropdownName, styleName)
{  
    document.getElementById(cellToReset).className = styleName;
    
    var dropd = document.forms[0][dropdownName];
    if( dropd != null )
        dropd.selectedIndex = 0;
}

function CheckNoneForToday(cellToToggle, radioGroup)
{
    for (var i=0; i < radioGroup.length; i++)
    {
        if (radioGroup[i].value.indexOf("-1") != -1)
        {
            radioGroup[i].checked = true;
        }
    }
}

function UnCheckAllRadiosForToday(cellToToggle, radioGroup)
{
    for (var i=0; i < radioGroup.length; i++)
    {
        radioGroup[i].checked = false;
    }
}

// Specify popup size of s | m | l | xl
function whatsThis(location_, size)
{
    if(!whatsThisWindow || whatsThisWindow.closed){
        if (size=='s')
            whatsThisWindow = window.open(location_,'help','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes,width=230, height=170');
        else if (size=='m')
            whatsThisWindow = window.open(location_,'help','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes,width=360, height=320');
        else if (size=='l')
            whatsThisWindow = window.open(location_,'help','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes,width=425, height=415');
        else if (size=='xl')
            whatsThisWindow = window.open(location_,'help','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes,width=575, height=575');            
        else if (size=='xxl')
            whatsThisWindow = window.open(location_,'help','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes,width=650, height=450');
        else if (size=='custom_feedback')
            whatsThisWindow = window.open(location_,'help','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes,width=400, height=550');            
    } else {
        whatsThisWindow.location = location_;
    }
    whatsThisWindow.focus();
    return false;
}

/* 
 * This method is a dynamic version of whatsThis, which simply parses
 * the value of the dropdown and changes the url location to open.
*/
function whatsThisCold(location_, size, dropdownName)
{
    var dropd = document.forms[0][dropdownName];
    var updatedLocation = '';
    if( dropd != null )
    {
        var selectedVal = dropd.options[dropd.selectedIndex].value;
        var split = selectedVal.split('_');
        
        if( split[1] == "-1" )
        {
            alert("In order to view details for cold items, please first select a cold entree from the list.");
        }
        else
        {
            updatedLocation = location_.replace("{0}", split[1]);
            whatsThis(updatedLocation, size);
        }
    }
}

function openMenuWindow(location_)
{
    if(!menuWindow || menuWindow.closed){
        menuWindow = window.open(location_,'menuWindow','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes,width=780, height=550');
    } else {
        menuWindow.location = location_;
    }
    menuWindow.focus();
    return false;
}

var url="http://www.choicelunch.com";
var title="Children's Choice Online";
function bookmarkPage()
{
    if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4))
    {
        document.write('<A HREF="javascript:window.ext');
        document.write('ernal.AddFavorite(url,title);" ');
        document.write('onMouseOver=" window.status=');
        document.write("'Add www.choicelunch to your favorites!'; return true ");
        document.write('"onMouseOut=" window.status=');
        document.write("' '; return true ");
        document.write('">Add www.choicelunch.com to your favorites!</a>');
    }
    else
    {
        var msg = "Don't forget to bookmark www.choicelunch.com.";
        if(navigator.appName == "Netscape") msg += "  (CTRL-D)";
        document.write(msg);
    }
}

function showhide(layer_ref, path) 
{ 
    var showUri = '/Images/show.gif';
    var hideUri = '/Images/hide.gif';
    
    var div = null;
    var img = null;
    
    if (document.all) 
    { //IS IE 4 or 5 (or 6 beta) 
           
        div = eval( "document.all." + layer_ref);
        img = eval( "document.all." + layer_ref + '_img');
    } 
    if (document.layers) 
    { //IS NETSCAPE 4 or below 
        div = document.layers[layer_ref]; 
        img = document.layers[layer_ref + '_img']; 
    } 
    if (document.getElementById &&!document.all) 
    { 
        div = document.getElementById(layer_ref); 
        img = document.getElementById(layer_ref + '_img'); 
    }
    
    if( div != null )
    {
        div.style.display = (div.style.display == 'none') ? 'block' : 'none';
    }
    if( img != null )
    {
        img.src = (img.src.indexOf('hide') != -1) ? path + showUri : path + hideUri;
    }
} 

function toggleDIV(val, hideval, layer_ref)
{    
    var div = null;
    
    if (document.all) 
    { //IS IE 4 or 5 (or 6 beta) 
        div = eval( "document.all." + layer_ref);
    } 
    if (document.layers) 
    { //IS NETSCAPE 4 or below 
        div = document.layers[layer_ref]; 
    } 
    if (document.getElementById &&!document.all) 
    { 
        div = document.getElementById(layer_ref); 
    }

    if( val == hideval )
    {
        // Keep it hidden
        div.style.display = 'none';        
    }
    else
    {
        // Show it.
        div.style.display = 'block';
    }
}



