﻿// JScript File

//change the MatrixSquare for show rollover image
function ChangeMatrixSquare(obj,html)
{
    try
    {
        if(!obj|| !html|| html.Length<1) return;
         if(obj.style.cursor!="pointer")
         {
             obj.innerHTML = html;
             if (obj.style.cursor!='default')
             {
                obj.style.cursor="pointer";
             }
         }
    }
    catch(e)
    {
        return;
    }
}

//initiate the menu items
var ci = null;
function initMenuItems()
{
    try
    {
        var lis = document.getElementsByTagName("LI");
        for(i = 0;i < lis.length; i++)
        {
            var li = lis[i];
            if(li.className || li.className.indexOf("item") < 0) continue;
            if(!li.onmouseover)
            {
               li.onmouseover = function()
               {
                    if(!document.uniqueID) return;
                    if(this.childNodes[0].tagName == "LI")return;
                    var item = this.parentNode.parentNode.parentNode.childNodes[0];
                    if(item == null || item.style == null)return;
                    item.style.backgroundImage = "url('RadControls/Menu/Skins/Default/Img/MainItemBackground-1.jpg')";            
                };
            }
            if(!li.onmouseout)
            {
                li.onmouseout = function()
                {
                    if(!document.uniqueID) return;
                    if(this.childNodes[0].tagName == "LI")return;
                    var item = this.parentNode.parentNode.parentNode.childNodes[0];
                    if(item == null || item.style == null)return;
                    item.style.backgroundImage = "url('RadControls/Menu/Skins/Default/Img/MainItemBackground.gif')";   
                    item.style.color="black"  ;                
                 };
            }
            if(!li.onclick)
            {
                   li.onclick = function()
                   {
                    //TODO: set the background of parent menu item as black;
                   };
            }
         }
      }
      catch(e)
      {
      }
} 

function MenuItemClick(sender, args)
{			
         if(args.Item.Value == "prijsvraag")
         {
                  ShowQuestionnaire();
         }
         if(args.Item.Value == "nieuwsbrief")
         {
                 ShowNewsletter();
         }
}
function ShowQuestionnaire()
{   
          tb_show("","Questionnaire.aspx?rnd="+Math.random()+"&keepThis=true&TB_iframe=true&height=324&width=519&modal=true",false);
}           
function ShowTips()
{      
          tb_show("","Tips.aspx?keepThis=true&TB_iframe=true&height=324&width=519&modal=true",false);        
}            
function ShowTop10()
{    
          tb_show("","Top10.aspx?keepThis=true&TB_iframe=true&height=324&width=519&modal=true",false);
}
function ShowGetest()
{             
          tb_show("","Getest.aspx?keepThis=true&TB_iframe=true&height=324&width=519&modal=true",false);
}
function ShowNewsletter()
{     
          tb_show("","Newsletter.aspx?keepThis=true&TB_iframe=true&height=324&width=464&modal=true",false);           
}
function ClosePopup()
{
          tb_remove();
}

function checkCookie4Q()
{
    var c = getCookie("Visited");
    if(!c)
    {
        //stop auto popup every 24 hours 2007-9-28
         // ShowQuestionnaire();
          setCookie("Visited","Visited",getExpDate(1,0,0),"","","");
    }    
}

// utility function to retrieve an expiration data in proper format;
function getExpDate(days, hours, minutes)
    {
        var expDate = new Date();
        if(typeof(days) == "number" && typeof(hours) == "number" && typeof(hours) == "number")
        {
            expDate.setDate(expDate.getDate() + parseInt(days));
            expDate.setHours(expDate.getHours() + parseInt(hours));
            expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
            return expDate.toGMTString();
        }
    }
    
//utility function called by getCookie()
function getCookieVal(offset)
    {
        var endstr = document.cookie.indexOf(";", offset);
        if(endstr == -1)
        {
            endstr = document.cookie.length;
        }
        return unescape(document.cookie.substring(offset, endstr));
    }
    
function getCookie(name)
    {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while(i < clen)
        {
            var j = i + alen;
            if (document.cookie.substring(i, j) == arg)
            {
                return getCookieVal(j);
            }
            i = document.cookie.indexOf(" ", i) + 1;
            if(i == 0) break;
        }
        return;
    }
    
function setCookie(name, value, expires, path, domain, secure)
    {
        document.cookie = name + "=" + escape(value) +
            ((expires) ? "; expires="+ expires : "") +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            ((secure) ? "; secure" : "");
    }
    
// remove the cookie by setting ancient expiration date
function deleteCookie(name,path,domain)
    {
        if(getCookie(name))
        {
            document.cookie = name + "=" +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                "; expires=Thu, 01-Jan-70 00:00:01 GMT";
        }
    }
