/* decryp addresses*/
function dcmadr(nnnn){
    var a = "";
    for(i=0,m=nnnn.length;i < m;i++){
        if(i%3==0){
            a += String.fromCharCode(nnnn.substr(i, 3));
        }
    }
    location.href=(a);
}


/* search box */
function removeDefault(formField, value){
    if(formField.value == value){
        formField.value = "";
    }
    formField.style.color = "#000";
}
function resetDefault(formField, value){
    if(formField.value == ""){
        formField.value = value;
        formField.style.color = "#888";
    }
}
function checkSearchBox(ff,st,eft){
    var t = ff.search.value;
    if(t == ''||t==st){
        alert(eft);
        ff.search.focus();
        ff.search.select();
        return false;
    }
}

/* executed when document is loaded */
$(document).ready(function(){
     $(".hideLink").mousedown(function(){
        $("#contentparagraphs").fadeOut("fast");
        setTimeout('revealContent()', contentFadeInTime)
    });
    $(".history").mousedown(function(){
        var act = !$(".historyListDetail",this).is(':visible');
        if(act){
            $(".historyListDetail.openEntry").slideUp();
            $(".historyListDetail.openEntry").removeClass("openEntry");
            $(".historyListDetail",this).slideDown();
            $(".historyListDetail",this).addClass("openEntry")
        }
    });
    $(".historyList h2").css("background-color", "red");
    /// FOCUS DETAIL
    focusDetailFunctionalities();

});

function focusDetailFunctionalities(){
    if($.getUrlVar("focusId")!=undefined){
        var $d = $("#"+$.getUrlVar("focusId"));
//        if(eventListBackLinkText.length>2){$d.append("<br/><br/><a href='javascript:history.back()'>"+eventListBackLinkText+"</a>");}
        $d.addClass("focusedNewsEntry");
        var t = $d.offset().top;
        $('html,body').animate({scrollTop: t-8}, 1000);
//        $.scrollTo(t-22, 100);
    }
}


/* helper methods */

Array.prototype.shuffle = function( b ) {
 var i = this.length, j, t;
 while( i ) {
  j = Math.floor( ( i-- ) * Math.random() );
  t = b && typeof this[i].shuffle!=='undefined' ? this[i].shuffle() : this[i];
  this[i] = this[j];
  this[j] = t;
 }
 return this;
};
function get_radio_value(formhandle){
    var r = "";
    for (var i=0; i < formhandle.length; i++){
        if (formhandle[i].checked){
            r = formhandle[i].value;
        }
    }
    return r;
}
$.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    return $.getUrlVars()[name];
  }
});

