function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function changeStart(newvalue){
 $('change_start').value = newvalue;
 setTimeout('__doPostBack(\'change_start\',\'\')', 0)
}
   
// used to know if DOM is ready
// better than window.onload
addDOMLoadEvent = (function(){
    // create event function stack
    var load_events = [],
        load_timer,
        script,
        done,
        exec,
        old_onload,
        init = function () {
            done = true;
            // kill the timer
            clearInterval(load_timer);
    // execute each function in the stack in the order they were added
            while (exec = load_events.shift())
                exec();
            if (script) script.onreadystatechange = '';
        };
    return function (func) {
        // if the init function was already ran, just run this function now and stop
        if (done) return func();
        if (!load_events[0]) {
            // for Mozilla/Opera9
            if (document.addEventListener)
                document.addEventListener("DOMContentLoaded", init, false);
            // for Internet Explorer
            /*@cc_on @*/
            /*@if (@_win32)
                document.write("<script id=__ie_onload defer src=//0><\/scr"+"ipt>");
                script = document.getElementById("__ie_onload");
                script.onreadystatechange = function() {
                    if (this.readyState == "complete")
                        init(); // call the onload handler
                };
            /*@end @*/
            // for Safari
            if (/WebKit/i.test(navigator.userAgent)) { // sniff
                load_timer = setInterval(function() {
                    if (/loaded|complete/.test(document.readyState))
                        init(); // call the onload handler
                }, 10);
            }
            // for other browsers set the window.onload, but also execute the old window.onload
            old_onload = window.onload;
            window.onload = function() {
                init();
                if (old_onload) old_onload();
            };
        }
        load_events.push(func);
    }
})();
function preselectCategory(){    // Preselect the category
 //e.g. ?area=Digital%20Imaging
 if(location.search){
  var params = new Object();
  params = location.search.toQueryParams();
  
  for (iLoop = 0; iLoop< document.getElementById("area_select_list").options.length; iLoop++) {    
   if (document.getElementById("area_select_list").options[iLoop].value == params.area.valueOf()){
    document.getElementById("area_select_list").options[iLoop].selected = true;
    break;
    }
   }
  setTimeout('__doPostBack(\'area_select_list\',\'\')', 0);
 }
}
function categorySelect (elmnt, targetpath){ 
 for (i = 0; i < elmnt.length; ++i){
  if (elmnt.options[i].selected == true) {
   if (elmnt.options[i].value != ""){
    window.location.href= targetpath +"?area=" + elmnt.options[i].value;
   }else{
    window.location.href= targetpath;
   }
  }
 }
}
function localpressSelect (elmnt){ 
 for (i = 0; i < elmnt.length; ++i){
  if (elmnt.options[i].selected == true) {
   if (elmnt.options[i].value != ""){
    window.location.href = elmnt.options[i].value;
   }
  }
 }
}
function resetDate(){
    $('periodFrom').value = "dd.mm.yyyy"
    $('periodTo').value = "dd.mm.yyyy"
}
   
function clearField(elmnt){
 if(elmnt.value == "dd.mm.yyyy") {
  elmnt.value="";
  $('periodAll').checked = false;
 }
}
function preselectKeyword(){    // Preselect the category
 //e.g. ?keyword=Digital%20Imaging
 var params = new Object();
   params = location.search.toQueryParams();
 
 if(location.search){
  if($('searchfor').value == "Keyword"){
   $('searchfor').value = unescape(params.keyword.valueOf().replace(/\+/g, "%20"));
   setTimeout('__doPostBack(\'area_select_list\',\'\')', 0);
  }
 }
}
function shortLongVersion(elmnt){
 if(elmnt.value == "short"){
  $('shortversion').style.display = "inline";
  $('longversion').style.display = "none"
 }else{
  $('shortversion').style.display = "none";
  $('longversion').style.display = "inline"
 }
}
function textversions(){
 if($('shortversion') == undefined)  $('textversions').style.display = "none";   
}