﻿

function getSelected(opt) {
    var selected = new Array();
    var index = 0;
    for (var intLoop = 0; intLoop < opt.length; intLoop++) {
        if ((opt[intLoop].selected) ||
                   (opt[intLoop].checked)) {
            alert("yesyes");
            index = selected.length;
            selected[index] = new Object;
            selected[index].value = opt[intLoop].value;
            selected[index].index = intLoop;
        }
    }
    return selected;
}



 function UpdateSubscriptions(url)
 {

     var cb = document.getElementById("subcribecat");
     var values="";
     
     
 
     
     
         var sel = getSelected(cb);

         
         for (var item in sel){

             values += sel[item].value + ";";
}
        

//     }
//     else {
//

 //        if (cb.checked || cb.selected) {
  //           values = cb.value;
//         } 
//     }

     if (values == "") {
         values = "999";
     }
     
         document.location.href = url + "?subscriptions=" + values;
     
    
     


 }

function OpenVikariatPopup()
{

window.open('http://www.bf.dk/vikariatmail/default.aspx', 'formular', 'height=800,width=660,status=yes,scrollbars=yes,toolbar=no,menubar=no,location=no');
}

function gotoEmployeeGroup(path)
{
 var selector = document.getElementById('NewsAchiveAreaFilter');
 
 if(selector)
    {
        var selected  = selector.item(selector.selectedIndex).value;
        
       document.location.href = path + "#"+selected;
			
    }
}


function search(e, v)
{

var characterCode

    if(e && e.which)
    {
    e = e
    characterCode = e.which
    }
    else
    {
    e = event
    characterCode = e.keyCode
    }


if(characterCode == 13)
{

var loc;

    if(location.hostname=="www.bf.dk")
    {    
        var area = getCheckedRadio();

        if(area==undefined)
        {
           loc = "/Service/Search.aspx?search="+encodeURI(v)+"&page=1";             
        }
        else
        {    
           loc = "/Service/Search.aspx?search="+encodeURI(v)+"&page=1&cat="+area;
        }
    }
    else if(location.hostname=="www.bibliotekspressen.dk")
    {
        var area = getCheckedRadio();

        if(area==undefined)
        {
            loc = "http://www.bibliotekspressen.dk/Service/Search.aspx?search="+encodeURI(v)+"&page=1";
        }
        else
        { 
            loc = "http://www.bibliotekspressen.dk/Service/Search.aspx?search="+encodeURI(v)+"&page=1&cat="+area;           
        }
    } 
window.location.href=loc;
return false;
}
return false;

}

function getCheckedRadio() 
{
      var radioButtons = document.getElementsByName("area");
      for (var x = 0; x < radioButtons.length; x ++) {
        if (radioButtons[x].checked) {
          return radioButtons[x].value;
        }
      }
}
function clickSearch(v)
{
if(v != "")
{
    if(location.hostname=="www.bf.dk")
    {
    var area = getCheckedRadio();
    
        if(area==undefined)
        {
        window.location.href= "http://www.bf.dk/Service/Search.aspx?search="+encodeURI(v)+"&page=1";
        }
        else
        {    
        window.location.href= "http://www.bf.dk/Service/Search.aspx?search="+encodeURI(v)+"&page=1&cat="+area;
        }
    }
    else if(location.hostname=="www.bibliotekspressen.dk")
    {
        var area = getCheckedRadio();
        if(area==undefined)
        {
            window.location.href= "http://www.bibliotekspressen.dk/Service/Search.aspx?search="+encodeURI(v)+"&page=1";
        }
        else
        {
            window.location.href= "http://www.bibliotekspressen.dk/Service/Search.aspx?search="+encodeURI(v)+"&page=1&cat="+area;
        }
    }
    else if(location.hostname=="kulturforvalterne.test.springcompany.dk")
    {
        if(area==undefined)
        {
        window.location.href= "http://kulturforvalterne.test.springcompany.dk/service/search.aspx?search="+encodeURI(v)+"&page=1";
        }
        else
        {    
        window.location.href= "http://kulturforvalterne.test.springcompany.dk/service/search.aspx?search="+encodeURI(v)+"&page=1&cat="+area;
        }
    }
    return false;
}else
{
    return true;
}

}