 function init()
 {
   window.defaultStatus = "Welkom op de site van Scouts en Gidsen Noordland Bredene";
   menu();
 }

 function menu()
 {
   if (document.all&&document.getElementById)
   {
     navRoot = document.getElementById("nav");
     for (i=0; i<navRoot.childNodes.length; i++)
     {
       node = navRoot.childNodes[i];
       if (node.nodeName=="LI")
       {
         node.onmouseover=function()
         {
           this.className+=" over";
         }
         node.onmouseout=function()
         {
           this.className=this.className.replace(" over", "");
         }
       }
     }
   }
 }
 
 function returnDate(date, id)
 {
   window.opener.document.getElementById(id).value = date;
   window.close();
 }
 
 function popDatePicker(id, j, m)
 {
   var url = "../andere/datepicker.php?id=" + id + "&amp;j=" + j + "&m=" + m;

   pop = window.open( url, "_blank", "width=400, height=300, dependant=no, left=200, top=100, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no" );
 }
 
 function insertSmiley(id, text)
 {
   var txtarea = window.document.getElementById(id);
   text = ' ' + text + ' ';

   if( txtarea.createTextRange && txtarea.caretPos )
   {
     var caretPos = txtarea.caretPos;
     caretPos.text = caretPos.text.charAt( caretPos.text.length - 1 ) == ' ' ? text + ' ' : text;
     txtarea.focus();
   }
   else
   {
     txtarea.value  += text;
     txtarea.focus();
   }
 }
 
 function lookup_tag(input)
 {
   if( input.length < 3 )
   {
     $("#suggestions").hide();
   }
   else
   {
     $.post("gettag.php", {naam: ""+input+""}, function(data)
     {
       if( data.length > 0 )
       {
         $("#suggestions").show();
         $("#autoSuggestionsList").html(data);
       }
       else
       {
         $("#suggestions").hide();
         $("#autoSuggestionsList").html('');
       }
     });
   }
 }
 
 function complete_tag(thisValue)
 {
   $("#tagname").val(thisValue);
   $("#suggestions").hide();
 }
 
 function apply_color(input)
 {
   if( input.length == 7 )
   {
     $("#kleur").css({'background-color':input, 'border':'1px solid #000000'});
   }
   else
   {
     $("#kleur").css({'background-color':'transparent', 'border':'1px solid transparent'});
   }
 }
 
 function alter_calendar(id, color)
 {
   var bg = $("#"+id).css("background-color");
   
   //alert( bg );
   
   if( bg == "transparent" )
   {
     $("#"+id).css({'background-color':color});
     $("div[name="+id+"]").css({'display':'block'});
   }
   else
   {
     $("#"+id).css({'background-color':'transparent'});
     $("div[name="+id+"]").css({'display':'none'});
   }
 }
 
 function lookup_flashgroup(id)
 {
   var id = $('#tak :selected').val();
   
   $.post("getflashgroup.php", {id: ""+id+""}, function(data)
   {
     if( data.length > 0 )
     {
       var array = new Array();
       array = data.split(', ');
       
       $("#beginuur option[selected]").removeAttr("selected");
       $("#beginuur option[value='" + array[0] + "']").attr("selected", "selected");

       $("#beginmin option[selected]").removeAttr("selected");
       $("#beginmin option[value='" + array[1] + "']").attr("selected", "selected");

       $("#einduur option[selected]").removeAttr("selected");
       $("#einduur option[value='" + array[2] + "']").attr("selected", "selected");

       $("#eindmin option[selected]").removeAttr("selected");
       $("#eindmin option[value='" + array[3] + "']").attr("selected", "selected");

       $("#waar").val(array[4]);
       $("#wat").val(array[5]);
     }
   });
 }
