dojo.require("dojox.fx");

var menuStatus = [];


//Function linked to the button to trigger the wipe.
function wipeIt(menuItem) {
   dojo.byId("menu"+menuItem).style.marginBottom='0px';
    var wipeArgs = {
        node: "subMenu"+menuItem
    };

    if(menuStatus[menuItem] == 1){
        dojo.fx.wipeOut(wipeArgs).play();
        menuStatus[menuItem] = 0;
    }else if(menuStatus[menuItem] == 0){
        dojo.fx.wipeIn(wipeArgs).play();
        menuStatus[menuItem] = 1;
    }else if(menuStatus[menuItem] == undefined){
        dojo.fx.wipeIn(wipeArgs).play();
        menuStatus[menuItem] = 1;
    }
}

function morphOpen(id)
{
//  alert ('h');
  var newsBox = 'newsBox'+id;
  var newsText = 'newsTextFull'+id;
//  alert (newsText);
  dojo.animateProperty({
  node:dojo.byId(newsBox),
  duration: 70,
//  beforeBegin: getFullNews(id),
  properties: {
      height: dojo.byId(newsText).offsetHeight +40
//      height: 300
  }
}).play();
//alert (dojo.byId('newsText1').clientHeight);
}

function morphClose(id)
{
  var newsBox = 'newsBox'+id;
  dojo.animateProperty({
      node:dojo.byId(newsBox),
        duration: 70,
      properties:
      {
          height: 132
      }
    }).play();
}

function getFullNews(id)
{
    dojo.style("newsText"+id, "display", "none");
    dojo.style("newsTextFull"+id, "display", "block");
    morphOpen(id);
}

function getMinNews(id)
{
    morphClose(id);
    dojo.style("newsTextFull"+id, "display", "none");
    dojo.style("newsText"+id, "display", "block");

}
    
function fadeIt(id,pointer) {
    var newsText = '';
    if(pointer == 0)
    {
        newsText = 'newsText'+id;
    }
    else if(pointer == 1)
    {
        newsText = 'newsTextFull'+id;
    }

//    alert('haha');
            dojo.style(newsText, "opacity", "0");
            var fadeArgs = {
                node: newsText,
                duration: 300
            };
            dojo.fadeIn(fadeArgs).play();
        }


//function showBigBottle(weinID){
//    //The parameters to pass to xhrGet, the url, how to handle it, and the callbacks.
//        xhrArgs = {
//            url: './ajax/custom.ajax.php',
//            handleAs: 'text',
//            preventCache: true,
//            content: {
//                id:(weinID),
//                pointer:1
//            },
//            load: function(data) {
//
//                dojo.byId('bigBottleImage').style.backgroundImage = 'url('+data+')';
//                dojo.byId('bigBottleImage').style.display = 'block';
//
//            },
//            error: function(error) {
//                alert(error);
//            }
//        }
//        //Call the asynchronous xhrGet
//        dojo.xhrPost(xhrArgs);
//
//}










