dojo.require("dojo.fx");


function toggleLanguageBox() {
   var LoginBox = dojo.byId("languageBox");
   var display = LoginBox.getAttribute('displayed');
   if (display == 'on') {
      dojo.fx.wipeOut({
    node: "languageBox",
    duration: 300
  }).play();
     // change the button image
     display = 'off';
   } else {

     dojo.fx.wipeIn({
    node: "languageBox",
    duration: 300
  }).play();
      // change the button image back
      display = 'on';
     
   }
   // remember the toggle state
   LoginBox.setAttribute('displayed', display);
}


function togglePageLanguageBox()
{
   var LoginBox = dojo.byId("pageLanguageBox");
   var display = LoginBox.getAttribute('displayed');
   if (display == 'on') {
     dojo.fx.wipeOut({
    node: "pageLanguageBox",
    duration: 300
  }).play();
     // change the button image
     display = 'off';
   } else {

     dojo.fx.wipeIn({
    node: "pageLanguageBox",
    duration: 300
  }).play();

         // change the button image back
         display = 'on';
     
   }
   // remember the toggle state
   LoginBox.setAttribute('displayed', display);
}

function togglePageRightBox()
{
   var LoginBox = dojo.byId("right_content");
   dojo.fadeIn({
    node: 'right_content',
    duration: 800,
    beforeBegin: function() {
        var node = dojo.byId('right_content');
        dojo.style(node, "opacity", 0);
        dojo.style(node, "display", "block");
    }
}).play();
}




function showMessage(msg)
{
	dojo.event.topic.publish("zipMessage", {message: msg,  delay: 2000});
}

function loadLanguage(lang,searchpid) {
   document.location.href = '/index.php?id=' + searchpid + '&languageId='+lang;
}

function nextSibling(startBrother){
	var tempObj = startBrother.nextSibling;
	while(tempObj.nodeType!=1 && tempObj.nextSibling!=null){
		tempObj = tempObj.nextSibling;
	}
	return (tempObj.nodeType==1)?tempObj:false;
}

function showAnswer(domNode) {
	answer = nextSibling(domNode);
	dojo.query('div.answer').forEach(function(item){item.style.display = 'none';});
	toggleAnswer(answer);

}

function toggleAnswer(domNode) {
   var display = domNode.getAttribute('displayed');
   if (display == 'on') {
     dojo.fx.wipeOut({
    node: domNode,
    duration: 300
  }).play();
     // change the button image
     display = 'off';
   } else {

     dojo.fx.wipeIn({
    node: domNode,
    duration: 550 

  }).play();

         // change the button image back
         display = 'on';
   }
   // remember the toggle state
   domNode.setAttribute('displayed', display);
}
