// JavaScript Document
// twitter show and hide
function writeCookie(n,w) {
 document.cookie = n+'='+w+'; expires=0;';
}

function readCookie(n)
{
 a = document.cookie;
 res = '';
 while(a != '')
 {
  while(a.substr(0,1) == ' '){a = a.substr(1,a.length);}
  cookiename = a.substring(0,a.indexOf('='));
  if(a.indexOf(';') != -1)
  {cookiewert = a.substring(a.indexOf('=')+1,a.indexOf(';'));}
  else{cookiewert = a.substr(a.indexOf('=')+1,a.length);}
  if(n == cookiename){res = cookiewert;}
  i = a.indexOf(';')+1;
  if(i == 0){i = a.length}
  a = a.substring(i,a.length);
 }
 return(res)
}

 $(document).ready(function() {
   $('#hide').ready( function() {
    var res='';
    if (document.cookie) {
      res=readCookie('hideTwitter');
   }
   else {
      writeCookie("hideTwitter", 0);
      res='';
   }
   if (res == 1) {
         $('#twitteron').show();
		 $('#twitteroff').hide();
		 $('#twitter').hide();
   }
   else {
         if(res == '') {
           writeCookie("hideTwitter", 0);
           $('#twitteron').hide();
         }
         else {
            writeCookie("hideTwitter", 0);
            $('#twitteron').hide();
         }
     }
   });	
   $('#hide').click( function() {
    writeCookie("hideTwitter", 1);
    $('#twitter').hide();
   });
   $('#hide').click( function() {
    $('#twitteroff').hide();
   });   
   $('#hide').click( function() {
    $('#twitteron').show();
   });  
   $('#show').click( function() {
    writeCookie("hideTwitter", 0);
    $('#twitter').show();
   });
   $('#show').click( function() {
    $('#twitteron').hide();
   });     
   $('#show').click( function() {
    $('#twitteroff').show();
   });     
   $('#toggle').click( function() {
    $('#twitter').toggle();
   });
});
