var tastingXSL = null;
var tastingEventXSL = null;
var tastingShowAllXSL = null;
var tastingShowAllEventXSL = null;
var tastingShowAllEventPromoXSL = null;
var tastingShowAllEventPromoAloneXSL = null;
var calendarMainXSL = null;
var calendarEventOverlayXSL = null;

var scroller = null;
var scrollbar = null;
var selectedTSmagning = null;
var queryString = window.top.location.search.substring(1);

var closeFunction = null;
var canSee="block";

var ToolTip = null;
var ToolTip2 = null;
var ToolTip3 = null;
var _scrollTimer = null;
var mouseoverobject = null;

String.prototype.trim = function(){
  return
  (this.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, ""))
}
String.prototype.startsWith = function(str)
{
  return (this.match("^"+str)==str)
}

String.prototype.endsWith = function(str)
{
  return (this.match(str+"$")==str)
}

String.prototype.reverse = function(){
  splitext = this.split("");
  revertext = splitext.reverse();
  reversed = revertext.join("");
  return reversed;
}






window.onload=function()
{
  if (document.addEventListener)
  {
    //alert("addeventlistener");
    document.addEventListener('click',
    function (event) {
      if (!event) var event = window.event;
      //   alert("1");
      //   alert(""+event);
      // handle event here e.g.
      //   alert("1");
      // event.target.style.color='red';
      "".toLowerCase()
      var selNode = event.target.nodeName.toLowerCase();
      if (selNode == 'img' || selNode == 'embed')
      {
        var parentNode = event.target.parentNode.parentNode;
        if (parentNode.getAttribute("isAdd") != null && parentNode.getAttribute("isAdd") != '')
        {
          this.addSeleted(parentNode.getAttribute("id"));
        }
      }

    },
    true
  );
  }
  else if (document.attachEvent) {
    //alert("attachEvent");
    document.attachEvent('onclick',
    function (event) {
      // handle event here e.g.
      // alert('2:'+event.type + ' for ' + event.srcElement);
      var selNode = event.srcElement.nodeName.toLowerCase();
      if (selNode == 'img' || selNode == 'embed')
      {
        var parentNode = event.srcElement.parentNode.parentNode;
        if (parentNode.getAttribute("isAdd") != null && parentNode.getAttribute("isAdd") != '')
        {
          this.addSeleted(parentNode.getAttribute("id"));
        }
      }
    }
  );
  }
  else {
    alert("no listener");
  }


  page_loaded=true;
  if(navigator.appName.indexOf("Microsoft") > -1){
    canSee = 'block'
  } else {
    canSee = 'table-row';
  }
  loadXSL();
  getTasting();
  loadSpecialofferXSL('specialoffer/xsl/specialoffer_2.xsl?date ='+new Date())
  loadForumXSL('forum/xsl/forum.xsl?date ='+new Date());
  loadWinnerXSL('weekwinner/xsl/weekwinner.xsl?date ='+new Date());
  loadNewsXSL('news/xsl/news.xsl?date ='+new Date());
  checkStartup();
  ToolTip = document.getElementById("ToolTip");
  ToolTip2 = document.getElementById("ToolTip2");
  ToolTip3 = document.getElementById("ToolTip3");
}
function checkUser()
{
  alert("checkuser");
  //if (validate_mail_form(document.userform))
  {
    //Post.Send(document.userform, 'admin/checkUser.php','Sending...',Post.OnResponse2);
  }
  return false;
}

function userIsLoggedIn()
{

}

function getParameter ( queryString, parameterName )
{   // Add "=" to the parameter name (i.e. parameterName=value)
  var parameterName = parameterName + "=";
  if ( queryString.length > 0 )
  {      // Find the beginning of the string
    begin = queryString.indexOf ( parameterName );
    // If the parameter name is not found, skip it, otherwise return the value
    if ( begin != -1 ) {
      // Add the length (integer) to the beginning
      begin += parameterName.length;
      // Multiple parameters are separated by the "&" sign
      end = queryString.indexOf ( "&" , begin );
      if ( end == -1 )
      {
        end = queryString.length
      }      // Return the string
      return unescape ( queryString.substring ( begin, end ) );
    }   // Return "null" if no parameter has been found
    return "null";

  }

}


function checkboxClick(chbox)
{

  if (chbox != null)
  {
    var src = chbox.src;

    var a = src.split("/");
    var a_length = a.length-1;
    var aa = a[a_length];


    if (aa =="tilvalgsknap.jpg")
    {
      chbox.src = "images/tilvalgsknap_markeret.jpg"
      chbox.setAttribute("checked","checked");
    }
    else
    {
      chbox.src = "images/tilvalgsknap.jpg"
      chbox.setAttribute("checked","unchecked");
    }
  }
}

function showHelpTextMouseOver(e,help_id,motype)
{
  // alert(help_id);
  var posx = 0;
  var posy = 0;

  var mPos = getMousePos(e);

  var oThis = this;
  if(oThis.timer)
  {
    clearTimeout(oThis.timer);
  }
  var x = e.clientx;
  var y = e.clienty;
  oThis.timer = setTimeout(function() {
    showHelpText(mPos[0],mPos[1],help_id,motype);
  }, 40);
}

function showHelpText(x,y,eid,motype)
{
  var tt = document.getElementById("ToolTip3");
  tt.innerHTML="<div class=\"outerpair1 absoluteimage\"><div class=\"outerpair2\"><div class=\"shadowbox\"><div class=\"innerbox thinborder\"><div style=\"postition:absolute;left:16px;top:16px\"><div id=\"help_text\" style=\"margin:16 16 16 16;\"></div></div></div></div></div></div>";
  var pos = getScrollingPosition();
  tt.style.left=(x+15+pos[0]);
  tt.style.width="400px";
  tt.style.top=(y);
  //ToolTip.style.bottom=(y+document.body.scrollTop-100)+"px";
  new net.ContentLoader('admin/functions/getHelpText.php?id='+eid+'&MOType='+motype+'&date ='+new Date(),parseHelpText);

}
function parseHelpText()
{
  var xmlDoc = this.req.responseText;
  var el = document.getElementById('help_text');
  if (el != null)
  {
    el.innerHTML = xmlDoc;
  }
  var tt = document.getElementById("ToolTip3");

  var hh = el.offsetHeight;

  if (tt != null)
  {
    var ttTop = tt.style.top;
    if (ttTop.indexOf("px")>0)
    {
      ttTop = ttTop.substring(0,ttTop.indexOf("px"));
      ttTop = parseInt(ttTop);
    }
    var ttt = (ttTop-hh-32);
    if (ttt < 2)
    {
      ttt = 2;
    }
    tt.style.top=(ttt)+"px";
  }

  tt.style.visibility="visible";
}

function showCalendarMouseOver(e,eid)
{
  //alert(comp_id);
  var posx = 0;
  var posy = 0;

  var mPos = getMousePos(e);

  var oThis = this;
  if(oThis.timer)
  {
    clearTimeout(oThis.timer);
  }
  var x = e.clientx;
  var y = e.clienty;
  oThis.timer = setTimeout(function() {
    showCalendarEventTip(mPos[0],mPos[1],eid);
  }, 500);
}

function showCalendarEventTip(x,y,eid)
{
  // alert(x+"_"+y+"_"+comp_id);
  var tt = document.getElementById("ToolTip3");
  tt.innerHTML="<div class=\"outerpair1 absoluteimage\"><div class=\"outerpair2\"><div class=\"shadowbox\"><div class=\"innerbox thinborder\"><div style=\"postition:absolute;left:16px;top:16px\"><div id=\"comp_card\" style=\"margin:16 16 16 16;\"></div></div></div></div></div></div>";
  var pos = getScrollingPosition();
  //ToolTip.style.pixelLeft=(x+15+document.body.scrollLeft);
  //ToolTip.style.pixelLeft=(x+15+pos[0]);
  tt.style.left=(x+15+pos[0]);
  //ToolTip.style.height="216px";
  // ToolTip.style.height="0px";
  // ToolTip.style.height="auto";
  //  ToolTip.style.height="auto";
  tt.style.width="250px";
  //ToolTip.style.pixelTop=(y+pos[1]-100);
  //ToolTip.style.top=(y+pos[1]-100);
  tt.style.top=(y);
  //ToolTip.style.bottom=(y+document.body.scrollTop-100)+"px";

  new net.ContentLoader('calendar/functions/getCalendarMouseOver.php?eid='+eid+'&date ='+new Date(),parseCalendarMouseOver);

}


function showCompanyCard(e,comp_id)
{
  //alert(comp_id);
  var posx = 0;
  var posy = 0;

  var mPos = getMousePos(e);

  var oThis = this;
  if(oThis.timer)
  {
    clearTimeout(oThis.timer);
  }
  var x = e.clientx;
  var y = e.clienty;
  oThis.timer = setTimeout(function() {
    showCompanyTip(mPos[0],mPos[1],comp_id);
  }, 500);
}

function showCompanyTip(x,y,comp_id)
{
  var tt = document.getElementById("ToolTip3");
  if (tt != null)
  {
    tt.innerHTML="<div class=\"outerpair1 absoluteimage\"><div class=\"outerpair2\"><div class=\"shadowbox\"><div class=\"innerbox thinborder\"><div style=\"postition:absolute;left:16px;top:16px\"><div id=\"comp_card\" style=\"margin:16 16 16 16;\"></div></div></div></div></div></div>";
    var pos = getScrollingPosition();
    //ToolTip.style.pixelLeft=(x+15+document.body.scrollLeft);
    //ToolTip.style.pixelLeft=(x+15+pos[0]);
    tt.style.left=(x+15+pos[0]);
    //ToolTip.style.height="216px";
    // ToolTip.style.height="auto";
    tt.style.width="250px";
    //ToolTip.style.pixelTop=(y+pos[1]-100);
    //ToolTip.style.top=(y+pos[1]-100);
    /*
        var bottom = y-100 + ToolTip.offsetHeight;
        //alert(y+"_"+ToolTip.offsetHeight+"_"+screen.availHeight);
        if (y > 500)
        {
          ToolTip.style.top=(y-ToolTip.offsetHeight);
        }
        else
        {
          ToolTip.style.top=(y-100);
        }
     */
    tt.style.top=(y);
    //ToolTip.style.bottom=(y+document.body.scrollTop-100)+"px";
    var el = $("ToolTip2");
    if (el)
    {
      el.innerHTML='getCompanyCard.php?compid='+comp_id+'&';
    }
    new net.ContentLoader('barreltasting/functions/getCompanyCard2.php?compid='+comp_id+'&table=main&date ='+new Date(),parseCompanyCard2);
  }

}

function getMousePos(e)
{
  var mousePos = [0, 0];
  if (!e)
    var e = window.event||window.Event;

  if('undefined'!=typeof e.pageX)
  {
    mousePos = [
      e.pageX,
      e.pageY
    ];
    // mouseX = e.pageX;
    // mouseY = e.pageY;
  }
  else
  {
    mousePos = [
      e.clientX + document.body.scrollLeft,
      e.clientY + document.body.scrollTop
    ];
    // mouseX = e.clientX + document.body.scrollLeft;
    // mouseY = e.clientY + document.body.scrollTop;
  }
  return mousePos;
}


function getScrollingPosition()
{
  var position = [0, 0];
  if (typeof window.pageYOffset != 'undefined')
  {
    position = [
      window.pageXOffset,
      window.pageYOffset
    ];
  }
  else if (typeof document.documentElement.scrollTop
    != 'undefined' && document.documentElement.scrollTop > 0)
  {
    position = [
      document.documentElement.scrollLeft,
      document.documentElement.scrollTop
    ];
  }
  else if (typeof document.body.scrollTop != 'undefined')
  {
    position = [
      document.body.scrollLeft,
      document.body.scrollTop
    ];
  }
  return position;
}


function showToolTip(e,text,shown){
  //alert(text+";"+shown);
  var oThis = this;
  if(oThis.timer)
  {
    clearTimeout(oThis.timer);
  }
  var x = e.x;
  var y = e.y;

  var posx = 0;
  var posy = 0;
  if (!e) var e = window.event;
  if (e.pageX || e.pageY) 	{
    posx = e.pageX;
    posy = e.pageY;
  }
  else if (e.clientX || e.clientY) 	{
    posx = e.clientX + document.body.scrollLeft
      + document.documentElement.scrollLeft;
    posy = e.clientY + document.body.scrollTop
      + document.documentElement.scrollTop;
  }
  // ToolTip2.innerHTML=""+posx+"_"+posy;
  // window.status = ""+posx+"_"+posy;


  // alert(e.screenX+"_"+e.screenY);
  oThis.timer = setTimeout(function() {
    showTip(posx,posy,text,shown);
  }, 500);

}

function showMouseOverToolTip(e,ID)
{
  var text ="";
  if (ID == "TS")
  {
    text = "Dette er en unik m&aring;de vin interesserede kan f&aring; information om at en butik i lokalomr&aring;det har &aring;bnet nogle vine som kan pr&oslash;ve smages gratis. Dette kan v&aelig;re din lokale vinhandler men typisk ogs&aring; dine lokale supermarkeder, som hermed giver dig en mulighed for at pr&oslash;vesmage inden du evt. k&oslash;ber vinen. "+
      "Der er ikke tale om en decideret vinsmagning og det er ikke garanteret at der vil v&aelig;re betjening. <br/><br/>"+

      "Hvis du opretter en profil kan du v&aelig;lge at f&aring; information om t&oslash;ndesmagninger i dit omr&aring;de via mail og Twitter.";
  }
  else if (ID == "FB")
  {
    text = "F Connect, giver dig nem og sikker, mulighed for at fort&aelig;lle dine venner om denne begivinhed, Der sendes ikke noget f&oslash;r du aktivt har accepteret";
  }
  else if (ID == "TW")
  {
    text = "Twitter, giver dig nem og sikker, mulighed for at fort&aelig;lle dine venner om denne begivinhed, Der sendes ikke noget f&oslash;r du aktivt har accepteret";
  }
  else if (ID == "CAL")
  {
    text = "Sender m&oslash;deindkaldelse til din egen kalender";
  }
  else if (ID =="ST")
  {
    text = "Slagtilbud defineres ved at v&aelig;re den ene udvalgte vin fra den enkelte vinhandler der aktuelt er p&aring; tilbud. Det er ikke n&oslash;dvendigvis den vin der spares mest p&aring;, men den vin der er valgt som v&aelig;rende det pt. mest interessante tilbud i den enkelte butik/k&aelig;de. &Eacute;n vinhandler kan s&aring;ledes kun s&aelig;tte &eacute;n vin p&aring; slagtilbud ad gangen. "+
      "<br/><br/>Hvis du opretter en profil kan du v&aelig;lge at f&aring; information om Slagtilbud i dit omr&aring;de via mail og Twitter.";
  }
  else if (ID == "CL")
  {
    text = "Dette er en unik kalender der giver dig overblik over alle vin relaterede ....<br/>"+
      "Beskrive brug af kategorier...<br/><br/>"+
      "Hvis du opretter en profil kan du v&aelig;lge at f&aring; information om begivenheder i dit omr&aring;de via mail og Twitter ";

  }
  else if (ID == "UV")
  {
    text = "Ved udvalg af ugens vindere har aov vurderet ......";
  }
  else if (ID == "UVKriteria")
  {
    text = "Text has not be decided yet";
  }
  else if (ID == "MAIL")
  {
    text = "Send mail til dine venner om denne begivenhed";
  }
  else if (ID == "PRINT")
  {
    text = "Print";
  }


  showMouseOverToolTipTimer(e,text);
}

function showMouseOverToolTipTimer(e,text){

  var oThis = this;
  if(oThis.timer)
  {
    clearTimeout(oThis.timer);
  }
  var x = e.x;
  var y = e.y;

  var posx = 0;
  var posy = 0;
  if (!e) var e = window.event;
  if (e.pageX || e.pageY) 	{
    posx = e.pageX;
    posy = e.pageY;
  }
  else if (e.clientX || e.clientY) 	{
    posx = e.clientX + document.body.scrollLeft
      + document.documentElement.scrollLeft;
    posy = e.clientY + document.body.scrollTop
      + document.documentElement.scrollTop;
  }

  oThis.timer = setTimeout(function() {
    showMouseOverToolTipDelay(posx,posy,text);
  }, 500);

}

function showMouseOverToolTipDelay(x,y,t)
{
  //alert(x+"_"+y+"_"+picture);
  // document.all.ToolTip.innerHTML="<table border=\"0\"><tr><td class=\"ToolTipT\" align=\"center\"><img src=\"images/"+picture+"\" height=\"200px\"/></td></tr></table>";
  var tt = document.getElementById("ToolTip3");
  if (tt != null)
  {
    //tt.innerHTML="<div class=\"outerpair1 absoluteimage\"><div class=\"outerpair2\"><div class=\"shadowbox\"><div class=\"innerbox thinborder\"><div id=\"helpid\" style=\"postition:absolute;left:16px;top:16px;margin:16px\">"+t+"</div></div></div></div></div>";
    tt.innerHTML="<div class=\"thinborder eightpoint\" style=\"position:relative;background:white\"><div id=\"helpid\" style=\"postition:relative;margin:16 16 16 16\">"+t+"</div></div>";
    tt.style.width="300px";
    // tt.style.visibility="visible";
    tt.style.left=(x+15);
    //ToolTip.style.height="auto";
    var hi = document.getElementById("helpid");
    var ttHeight = hi.offsetHeight;
    var topvalue = (y-(ttHeight)-32);
    if (topvalue  < 2)
    {
      topvalue = 2;
    }
    //alert(topvalue);
    tt.style.top=(topvalue)+"px";
    tt.style.visibility="visible";
  }
}


function showTip(x,y,text,shown)
{
  //alert("showTip");
  var tt = document.getElementById("ToolTip3");
  var ttO = document.getElementById("ToolTip");
  var tt2 = document.getElementById("ToolTip2");

  if (shown == null)
  {
    shown = false;
  }
  var moretext = "";
  if (shown)
  {
    moretext = "<br/><br/><span class=\"colormain eightpoint\" style=\"width:100%;text-align:right\">se mere, klik p&acirc; teksten</span>";
  }
  //ToolTip.innerHTML="<div class=\"outerpair1 absoluteimage\"><div class=\"outerpair2\"><div class=\"shadowbox\"><div class=\"innerbox thinborder eightpoint\"><div style=\"margin:16 16 16 16;\">"+text+moretext+"</div></div></div></div></div>";
  tt.innerHTML="<div  class=\"thinborder eightpoint\" style=\"position:relative;background:white\"><div id = \"innerText\" style=\"position:relative;margin:16 16 16 16\">"+text+moretext+"</div></div>";
  //ToolTip.innerHTML=text+moretext+"</br>...";

  // document.all.ToolTip.innerHTML="<table><tr><td class=ToolTipTD>"+text+"</td></tr></table>";
  tt.style.width="200px";
  var docHi = document.getElementById("innerText");
  //var hh = docHi.offsetHeight;
  var hh = docHi.offsetHeight;
  // ToolTip.style.height=hh+"px";
  //  alert(y+"_"+hh);
  //ToolTip.style.pixelLeft=(x+15+document.body.scrollLeft);
  tt.style.left=(x+15)+"px";
  //ToolTip.style.pixelTop=(y+document.body.scrollTop - 100);
  //alert(""+(y)+"px");
  //ToolTip2.innerHTML="("+y+"-"+hh+")px";
  var ttop = (y-hh-32);
  if (ttop < 2)
  {
    ttop = 2;
  }
  tt.style.top=""+(ttop)+"px";


  // ToolTip.style.height="200px";
  // tt2.innerHTML="Showing  element";
  tt.style.visibility="visible";

}
function hideToolTip(){
  var oThis = this;   // IE & Opera
  if(oThis.timer)
  {
    clearTimeout(oThis.timer);
  }
  //var el = ToolTip.style.visibility="hidden";
  var el = document.getElementById("ToolTip3");
  el.innerHTML='';
  el.style.visibility="hidden";
}

function showEventPicture(e,picture,max)
{
  var oThis = this;
  if(oThis.timer)
  {
    clearTimeout(oThis.timer);
  }
  var x = e.x;
  var y = e.y;

  var posx = 0;
  var posy = 0;
  if (!e) var e = window.event;
  if (e.pageX || e.pageY) 	{
    posx = e.pageX;
    posy = e.pageY;
  }
  else if (e.clientX || e.clientY) 	{
    posx = e.clientX + document.body.scrollLeft
      + document.documentElement.scrollLeft;
    posy = e.clientY + document.body.scrollTop
      + document.documentElement.scrollTop;
  }


  oThis.timer = setTimeout(function() {
    showEventPictureDelay(posx,posy,picture,max);
  }, 500);
}
function showEventPicture2(e,picture,max)
{
  var oThis = this;
  if(oThis.timer)
  {
    clearTimeout(oThis.timer);
  }
  var x = e.x;
  var y = e.y;

  var posx = 0;
  var posy = 0;
  if (!e) var e = window.event;
  if (e.pageX || e.pageY) 	{
    posx = e.pageX;
    posy = e.pageY;
  }
  else if (e.clientX || e.clientY) 	{
    posx = e.clientX + document.body.scrollLeft
      + document.documentElement.scrollLeft;
    posy = e.clientY + document.body.scrollTop
      + document.documentElement.scrollTop;
  }


  oThis.timer = setTimeout(function() {
    showEventPictureDelay2(posx,posy,picture,max);
  }, 5);
}
function showEventPictureDelay(x,y,picture,max)
{
  //alert(x+"_"+y+"_"+picture);
  // document.all.ToolTip.innerHTML="<table border=\"0\"><tr><td class=\"ToolTipT\" align=\"center\"><img src=\"images/"+picture+"\" height=\"200px\"/></td></tr></table>";
  var tt = document.getElementById("ToolTip3");
  if (tt != null)
  {
    var cd = new Date();
    var ct = cd.getTime();
    tt.innerHTML="<div class=\"thinborder\" style=\"position:relative;background:white\"><div id=\"pictureid\" style=\"postition:relative;margin:16 16 16 16\"><center><img src=\"barreltasting/functions/getEventJPG.php?eid="+picture+"&date="+ct+"\" height=\"125px\"/></center></div></div>";
    //alert(tt.innerHTML);
    tt.style.pixelLeft=(x+15);
    //ToolTip.style.height="216px";
    if (max == null)
    {
      max=125;
      tt.style.pixelLeft=(x+15);
    }
    else
    {
      tt.style.pixelRight=(x-15);
    }
    tt.style.width=max+"px";

    tt.style.top = y;
    /*
          var pid = document.getElementById("pictureid");
          var hh = pid.offsetHeight;
          tt.style.top=(y-hh-32);

          tt.style.visibility="visible";
     */

    new net.ContentLoader('admin/functions/getPicture.php?eid='+picture+'&max='+max+'&date ='+new Date(),parsePictureOver);
  }
}
function showEventPictureDelay2(x,y,picture,max)
{
  //alert(x+"_"+y+"_"+picture);
  // document.all.ToolTip.innerHTML="<table border=\"0\"><tr><td class=\"ToolTipT\" align=\"center\"><img src=\"images/"+picture+"\" height=\"200px\"/></td></tr></table>";
  var tt = document.getElementById("ToolTip3");
  if (tt != null)
  {
    var cd = new Date();
    var ct = cd.getTime();
    tt.innerHTML="<div class=\"thinborder\" style=\"position:relative;background:white\"><div id=\"pictureid\" style=\"postition:relative;margin:16 16 16 16;text-alignment:center\">Loading...</div></div>";
    //alert(tt.innerHTML);
    tt.style.pixelLeft=(x+15);
    //ToolTip.style.height="216px";
    if (max == null)
    {
      max=125;
      tt.style.pixelLeft=(x+15);
    }
    else
    {
      tt.style.pixelRight=(x-15);
    }
    //tt.style.width=max+"px";

    tt.style.top = y;
    tt.style.left = x;
    /*
          var pid = document.getElementById("pictureid");
          var hh = pid.offsetHeight;
          tt.style.top=(y-hh-32);

          tt.style.visibility="visible";
     */
    // tt.style.visibility="visible";
    new net.ContentLoader('admin/functions/getPicture.php?eid='+picture+'&max='+max+'&date ='+new Date(),parsePictureOver2);
  }
}
function parsePictureOver()
{
  var tt = document.getElementById("ToolTip3");
  var pid = document.getElementById("pictureid");
  pid.innerHTML = this.req.responseText;
  var hh = pid.offsetHeight;

  //tt.style.top=(y-hh-32);

  tt.style.visibility="visible";
  if (tt != null)
  {
    var ttTop = tt.style.top;
    if (ttTop.indexOf("px")>0)
    {
      ttTop = ttTop.substring(0,ttTop.indexOf("px"));
      ttTop = parseInt(ttTop);
    }
    var ttt = (ttTop-hh-32);
    if (ttt < 2)
    {
      ttt = 2;
    }
    tt.style.top=(ttt)+"px";
  }
}

function parsePictureOver2()
{
  var tt = document.getElementById("ToolTip3");
  var pid = document.getElementById("pictureid");
  pid.innerHTML = '<center>'+this.req.responseText+'</center>';
  var hh = pid.offsetHeight;
  var hw = pid.offsetWidth;
  //tt.style.top=(y-hh-32);

  if (tt != null)
  {
    var ttTop = tt.style.top;
    if (ttTop.indexOf("px")>0)
    {
      ttTop = ttTop.substring(0,ttTop.indexOf("px"));
      ttTop = parseInt(ttTop);
    }
    var ttt = (ttTop-hh-32);
    if (ttt < 2)
    {
      ttt = 2;
    }
    tt.style.top="100px";

    var ttLeft = tt.style.left;
    if (ttLeft.indexOf("px")>0)
    {
      ttLeft = ttLeft.substring(0,ttLeft.indexOf("px"));
      ttLeft = parseInt(ttLeft);
    }
    var ttt = (ttLeft-hw-50);
    if (ttt < 2)
    {
      ttt = 2;
    }
    tt.style.left=(ttt)+"px";
    tt.style.left="400px";
  }
  tt.style.visibility="visible";
  
}

function scrollbarEvent (o, type) {
  /*
                if (type == "mousedown") {
                    if (o.className == "Scrollbar-Track") o.style.backgroundColor = "#E3E3E3";
                    else o.style.backgroundColor = "#BBB";
                } else {
                    if (o.className == "Scrollbar-Track") o.style.backgroundColor = "#EEE";
                    else o.style.backgroundColor = "#CCC";
                }
   */
}
function loadXSL()
{

  new net.ContentLoader('barreltasting/xsl/tasting_2.xsl?&date ='+new Date(),parseTastingXSL);
  // new net.ContentLoader('barreltasting/xsl/tastingevent.xsl?&date ='+new Date(),parseTastingEventXSL);
  new net.ContentLoader('barreltasting/xsl/tastingShowAll.xsl?&date ='+new Date(),parseTastingShowAllXSL);
  // new net.ContentLoader('barreltasting/xsl/tastingOverlay.xsl?&date ='+new Date(),parseTastingShowAllEventXSL);
  // new net.ContentLoader('barreltasting/xsl/tastingOverlayPromo.xsl?&date ='+new Date(),parseTastingShowAllEventPromoXSL);
  // new net.ContentLoader('barreltasting/xsl/tastingOverlayPromoAlone.xsl?&date ='+new Date(),parseTastingShowAllEventPromoAloneXSL);

  //  new net.ContentLoader('specialoffer/xsl/specialoffer_2.xsl?&date ='+new Date(),parseSpecialofferXSL);
  //new net.ContentLoader('specialoffer/xsl/specialofferevent.xsl?&date ='+new Date(),parseSpecialofferEventXSL);
  //new net.ContentLoader('specialoffer/xsl/specialofferShowAll.xsl?&date ='+new Date(),parseSpecialofferShowAllXSL);
  //new net.ContentLoader('specialoffer/xsl/specialofferOverlay.xsl?&date ='+new Date(),parseSpecialofferShowAllEventXSL);
  //new net.ContentLoader('specialoffer/xsl/specialofferOverlayPromo.xsl?&date ='+new Date(),parseSpecialofferShowAllEventPromoXSL);
  //alert("loadXSL");
  new net.ContentLoader('calendar/xsl/weekView.xsl?&date ='+new Date(),parseMainCalendarXSL);
  new net.ContentLoader('calendar/xsl/monthView.xsl?&date ='+new Date(),parseMonthViewXSL);
  new net.ContentLoader('calendar/xsl/listView.xsl?&date ='+new Date(),this.parseListViewXSL);
  new net.ContentLoader('calendar/xsl/eventOverlay.xsl?&date ='+new Date(),parseCalendarEventOverlayXSL);
}
function isLoaded()
{
  // alert("tastingXSL")
  if (tastingXSL == null)
    return false;
  //if (tastingEventXSL == null)
  //  return false;
  if (tastingShowAllXSL == null)
    return false;
  //if (tastingShowAllEventXSL == null)
  //  return false;
  if (calendarMainXSL == null)
    return false;
  //if (calendarEventOverlayXSL == null)
  //  return false;

  return true;
}

function getTasting()
{
  // new net.ContentLoader('functions/getTasting.php?&date ='+new Date(),parseTastings);
}

function setMouseWheel(elid)
{
  mouseoverobject = elid;
}


function scrollEvent(panel,value,max)
{
  var el = document.getElementById(panel);
  if (el != null)
  {

    var elTop = el.style.top;
    //  $("ToolTip2").innerHTML=""+elTop+"_"+value+"_"+max;
    //alert("elTop:"+elTop);
    if (elTop.indexOf("px")>=0)
    {
      elTop = elTop.substring(0,elTop.indexOf("px"));
      elTop = parseInt(elTop)+ parseInt(value);
      if (elTop > 0)
      {
        elTop = 0;
      }
      else if (elTop < -max)
      {
        elTop = -max
      }
      if (max < 0)
      {
        elTop = 0;
      }
      
      el.style.top = ""+elTop+"px";
    }
  }
}
function startScrollElement(panel,value,el,height)
{
  
  var element = $(el);
  if (element != null)
  {
    //  $("ToolTip2").innerHTML = element.offsetHeight;
    startScroll(panel,value,element.offsetHeight-height);
  }
  
  //startScroll(panel,value,2000);
}
function startScroll(panel,value,max)
{
  //alert("startScroll:"+panel+"_"+max);
  //alert(max);
  //$("ToolTip2").innerHTML=""+max;

  if (this._scrollTimer) window.clearInterval(this._scrollTimer);
  this._scrollTimer = window.setInterval(function () {
    scrollEvent(panel,value,max);
  }, 40);

}
function stopScroll()
{
  if (this._scrollTimer) window.clearInterval(this._scrollTimer);
}

function closeCreatorWindow()
{
  hideBlackShade();
  var el = document.getElementById("Layeradmintrans");

  el.style.visibility = "hidden";
  el.style.display = "none";
  el = document.getElementById("Layeradmin");
  el.innerHTML = '';
  el.style.visibility = "hidden";
  el.style.display = "none";

}
function closeCreateProfileWindow()
{

  var el = document.getElementById("Layercreate");
  el.style.visibility = "hidden";
  el.style.display = "none";
  hideBlackShade();
}
function openCreatorWindow()
{
  setBlackShade();
  //closeFunction = closeCreatorWindow;
  var el = document.getElementById("Layeradmintrans");
  el.style.visibility = "visible";
  el.style.display = "block";
  el = document.getElementById("Layeradmin");
  el.style.visibility = "visible";
  el.style.display = "block";
  new net.ContentLoader('admin/admin.php?&date ='+new Date(),openAdmin);

}
function openAboutWindow()
{
  setBlackShade();
  closeFunction = closeAboutWindow;
  var el = document.getElementById("LayerAbout");
  el.style.visibility = "visible";
  el.style.display = "block";
  new net.ContentLoader('admin/aboutAOV.php?&date ='+new Date(),openAbout);
}
function openAboutWindowTil()
{
  setBlackShade();
  closeFunction = closeAboutWindow;
  var el = document.getElementById("LayerAbout");
  el.style.visibility = "visible";
  el.style.display = "block";
  new net.ContentLoader('admin/aboutAOV.php?TIL=true&date ='+new Date(),openAbout);
}
function openAbout()
{
  var xmlDoc = this.req.responseText;
  var el = $("LayerAbout");
  el.innerHTML = xmlDoc;
}
function openAdmin()
{
  var xmlDoc = this.req.responseText;
  var el = $("Layeradmin");
  el.innerHTML = xmlDoc;
  loadCompanyCard();
}
function closeAboutWindow()
{
  var el = document.getElementById("LayerAbout");
  el.style.visibility = "hidden";
  hideBlackShade();
}

function creatUser()
{
  new net.ContentLoader('admin/functions/createProfile.php?&date ='+new Date(),openOpretWindow);
}
function openOpretWindow()
{
  setBlackShade();
  closeFunction = closeCreateProfileWindow;
  var el = document.getElementById("Layercreate");
  el.style.visibility = "visible";
  el.style.display = "block";
  el.innerHTML=this.req.responseText;
}

function closeOpenWindows()
{
  closeFunction();
}

function updatePage(connected,currUser)
{
  // alert(connected+","+currUser);
  if (connected)
  {
    var el = $("orp");
    el.innerHTML="Mit aov";
    el.onclick=function() {
      openCreatorWindow()
    };

    el = $("login_name");
    if (el != null)
    {
      el.style.display = "none";
    }
    el = $("login_password");
    if (el != null)
    {
      el.style.display = "none";
    }
    el = $("forgotten_code");
    if (el != null)
    {
      el.style.display = "none";
    }
    el = $("newuser");
    if (el != null)
    {
      el.style.display = "none";
    }
    el = $("remembermediv");
    if (el != null)
    {
      el.style.display = "none";
    }
    el = $("loggedonname");
    if (el != null)
    {
      el.innerHTML=currUser;
      el.style.display = "block";
    }
    el = $("loginbutton");
    if (el != null)
    {
      el.innerHTML="Log ud";
    }
    el = $("loginbuttondiv");
    if (el != null)
    {
      el.onclick=function() {
        logOut();
      }
    }

    // new net.ContentLoader('admin/logout.php?&date ='+new Date(),emptyFunction);
    closingDown();
  }
  else
  {
    var el = $("orp");
    el.innerHTML="Bliv bruger";
    el.onclick=function() {
      creatUser()
    };

    el = $("login_name");
    if (el != null)
    {
      el.style.display = "block";
    }
    el = $("login_password");
    if (el != null)
    {
      el.style.display = "block";
    }
    el = $("forgotten_code");
    if (el != null)
    {
      el.style.display = "block";
    }
    el = $("newuser");
    if (el != null)
    {
      el.style.display = "block";
    }
    el = $("remembermediv");
    if (el != null)
    {
      el.style.display = "block";
    }
    el = $("loggedonname");
    if (el != null)
    {
      el.innerHTML=currUser;
      el.style.display = "none";
    }
    el = $("loginbutton");
    if (el != null)
    {
      el.innerHTML="Log in";
    }
    el = $("loginbuttondiv");
    if (el != null)
    {
      el.onclick=function() {
        checkThis();
        hashPass();
        return checkLogin();
      };
    }
  }
  startUpCalendarXSL();
}

function logOut()
{
  this.removeUser();
  new net.ContentLoader('admin/logout.php?&date ='+new Date(),emptyFunction);
  updatePage(false,"");
}
function emptyFunction()
{
  // alert(this.req.responseText);
}
function toggleBackgroundPicture()
{
  var el = $("main");
  var state = el.style.display;
  if (state == 'none')
  {
    el.style.display = canSee;
  }
  else
  {
    el.style.display = 'none';
  }
}
function showDiv(aDiv)
{
  var el = $(aDiv);
  //var state = el.style.display;
  //if (state == 'none')
  {
    el.style.display = canSee;
  }
  /*
  else
  {
    el.style.display = 'none';
  }
   */
}
function displayMainSection()
{
  //alert("displayMainSection");
  showDiv("LayerCalendartransp");
  showDiv("LayerCalendar");

  /*showDiv("LayerTastingtransp");
  showDiv("LayerTasting");*/

  showDiv("LayerWeekTransp");
  showDiv("LayerWeek");
  showDiv("LayerForumTransp");
  showDiv("LayerForum");
  showDiv("LayerNewsTransp");
  showDiv("LayerNews");

  /*showDiv("LayerTilbudTransp");
  showDiv("LayerTilbud");*/
  progress2Stop();
  showDiv("ANN_1");
  showDiv("ANN_2");
  

/*
    <div id="LayerTilbudTransp" class="transp" style="position:absolute; width:426px; height:210px; z-index:1; left: 442px; top: 562px; overflow: hidden">
    </div>
    <div id="LayerTilbud" class="thinborder" style="position:absolute; width:426px; height:210px; z-index:1; left: 442px; top: 562px; overflow: hidden">
    </div>
    
    <div id="<? echo $ANN_1;?>" name="<? echo $ANN_1;?>" isAdd="true" style="position:absolute; width:140px; height:350px; z-index:1; left: 876px; top: 76px; border: 1px none #000000">
    <? echo getAddForPool($ANN_1,'pools/'); ?>
    </div>

    <div id="<? echo $ANN_2;?>" name="<? echo $ANN_2;?>" isAdd="true" style="position:absolute; width:140px; height:350px; z-index:1; left: 876px; top: 434px;  border: 1px none #000000">
    <!--img src="images/announce/ostrig banner 140 x 350.jpg" alt=""/-->
    <? echo getAddForPool($ANN_2,'pools/'); ?>
    </div>
*/
  }



