﻿Spif.StyleMorpher.setMorphableProperties(["display", "overflow", "top", "left", "right", "width", "height", "backgroundColor", "color", "marginTop", "marginLeft", "opacity", "fontSize", "paddingTop", "paddingBottom"]);

Spif.ClassNameAbstraction.addClassNameSequence("on", ["pre"], 5*Spif.DEFAULTMORPHDURATION/6);
Spif.ClassNameAbstraction.addClassNameSequence("off", ["pre"], 5*Spif.DEFAULTMORPHDURATION/6);

function animateHeaderButton()
{
  if (document.getElementById("previousUrl"))
  {
    Spif.ClassNameAbstraction.replace(document.getElementById("buttonbar"), "open", "close");   
  }
}


function fucosLogin()
{
  document.getElementById("loginField").focus();
}

function blurElement(El)
{
  El.blur();
}

function changeExcercise(from, to, exercisecount)
{
  var fromEl = document.getElementById('exercise-'+from);
  var toEl = document.getElementById('exercise-'+to);  
  
  if( from > to )
  {
    Spif.ClassNameAbstraction.replace(fromEl,'current', 'next');
    Spif.ClassNameAbstraction.replace(toEl,'previous', 'current'); 
  }
  
  else if ( from < to )
  {   
    if ( exercisecount >= to )
    {
      Spif.ClassNameAbstraction.replace(fromEl,'current', 'previous');
      Spif.ClassNameAbstraction.replace(toEl,'next', 'current'); 
    }
    else
    {
      var endofexercises = document.getElementById("finishedexercises");
      Spif.ClassNameAbstraction.replace(fromEl,'current', 'previous');
      Spif.ClassNameAbstraction.replace(endofexercises,'next', 'current'); 
    }
  }
  
}

function doMoveMenu(droppedEl, oldParent, oldNextSibling, newParent, newNextSibling)
{
  var draggingId = droppedEl.id;  
  
  if (newNextSibling){
    var dropbeforeId = newNextSibling.id;
  }
  
  else {
    var dropbeforeId = -1;
  }
 
    var result = loadPage("moveMenuNode.aspx?draggingid=" + draggingId + "&dropbeforeid=" + dropbeforeId );
    if (result != null && result.indexOf("Error")!=-1)
      alert(result);
}
 
function getXMLHTTP()
{
  if (typeof(XMLHttpRequest)!="undefined")
    return new XMLHttpRequest();
  else if (document.all)
    return new ActiveXObject("Msxml2.XMLHTTP");
}
 

function loadPage(url)
{
  top.getXMLHTTP = getXMLHTTP;
  top.foo = function()
  {  
    var xmlhttp = getXMLHTTP();
    xmlhttp.open("get", url, false);
    xmlhttp.send(null);
    return xmlhttp.responseText;
  }
  var result = top.foo(url);
  return result;
}

function toggleThemeScore(value)
{
  var themes = document.getElementById("themeresults").childNodes;
  for ( var i=0;i<themes.length;i++ )
  
  {
    if (themes[i].nodeName=="#text")
      continue;
    
    if (themes[i].id != ("themescore-" + value))
      themes[i].className = "themescore-hidden";
    
    if (themes[i].id == ("themescore-" + value))
      themes[i].className = "themescore";
  }
}

function handleQuestion(answer)
{
  document.getElementById('answer-input').value = answer;
  document.getElementById('questionform').submit()
}

function toggleVideolistClassname(list)
{
    if ( Spif.ClassNameAbstraction.contains(list,"hasnoton") )
      Spif.ClassNameAbstraction.replace(list, "hasnoton", "hason");
    else
      Spif.ClassNameAbstraction.replace(list, "hason", "hasnoton");
}
