function newImage(ID,file) {
        document.getElementById(ID).src='/images/'+file;
}

function open_window(URL,name,left,top,width,height,menubar){
         rp=window.open(URL,name,"top="+top+",left="+left+",height="+height+",width="+width+",menubar="+menubar+",scrollbars=1,resizable=1,status=1");
         rp.focus();
         return(false);
}
//
// not nice, but we need to trap when the enter button is pressed after entering a
// an income on the calculate prive sub layout
// 
// this CRclickButton will make a click event if it is a CR
function CRClickButton(buttonId,e)
{
  var btnDefault = document.getElementById(buttonId);

  if(e.which)
  { // FF
    if(e.which != 13)
      return;
                    
    var clickEvent = document.createEvent('MouseEvents'); 
    clickEvent.initMouseEvent( "click", true, true, document.defaultView,
                             1, 0, 0, 0, 0, false, false, true, false, 0, null); 
    e.preventDefault()
    btnDefault.dispatchEvent(clickEvent) 
  } else
  { // IE
    if( e.keyCode != 13 )
      return;

    if (btnDefault)
    {
      window.event.cancelBubble = true;
      window.event.returnValue = false;
      btnDefault.click();
    }
  }
}


//
// used to control the selection of locations..
// see search.FindPace and Seacrh.FindSchool ascx controls
// not nice but they did not want the flicker, that a post back causes
//
function ChangeLocation(allId, locIds)
{
  var itemchecked = false;
  checkBoxIDArr = locIds.split("|");
  var arrcounter=0;
  var checkbox;
  var allCheckbox = document.getElementById(allId);
    
  while (arrcounter < checkBoxIDArr.length)
  {
    checkbox = document.getElementById(checkBoxIDArr[arrcounter]);
    if (checkbox.checked)
    {
      itemchecked = true;
    }
    if (itemchecked) break;
    arrcounter++;
  }
  if (!itemchecked)
    allCheckbox.checked = true;
  else
    allCheckbox.checked = false;
}

//
// used to control the selection of locations..
// see search.FindPace and Seacrh.FindSchool ascx controls
// not nice but they did not want the flicker, that a post back causes
//
function AllLocations(allId, locIds)
{
  checkBoxIDArr = locIds.split("|");
  var arrcounter=0;
  var checkbox;
  var allCheckbox = document.getElementById(allId);

  while (arrcounter < checkBoxIDArr.length)
  {
    checkbox = document.getElementById(checkBoxIDArr[arrcounter]);
    checkbox.checked = !allCheckbox.checked;
    arrcounter++;
  }
}

//  ******************************************
//  *  Open new windows                      *
//  ******************************************

function shareLink(linkID) 
{
  var win = window.open("/modules/share link.aspx" + "?link=" + linkID,"","width=440,height=450,scrollbars=yes");
  if (win == null)
  {
    alert("For at tippe en ven skal du tillade brug af pop-up vinduer på denne side.");
  }
}

function subjects(pathID)
{
  var win = window.open("/sitecore modules/search/editors/subjects.aspx?path=" + pathID,"","width=440,height=450,scrollbars=yes");
  if (win == null)
  {
    alert("For at se undervisningstilbud skal du tillade brug af pop-up vinduer på denne side.");
  }
}


function PopWin(url,h,w) 
{ 
  var ww = 480, wh = 340, leftPos = null, topPos = null; 

  IE=(document.all)?true:false; 
  var wh = (IE)?document.body.clientHeight : window.innerHeight; 
  var ww = (IE)?document.body.clientWidth : window.innerWidth; 

  if (top.screen){ 
    if (screen.width){ 
      leftPos = Math.round((ww-w-10)/2); 
      topPos = Math.round((wh-h-29)/2); 
    } else { 
      leftPos = 50 
      topPos = 50 
    } 
  } 
  popupWin = window.open(url, 'popup', 'scrollbars,height=' + h + ',width=' + w + ',top=' + topPos + ',left=' + leftPos + '') 
} 

function textCounter(field, countfieldId, maxlimit)
{
  if (field.value.length > maxlimit) // if too long...trim it!
    field.value = field.value.substring(0, maxlimit);
        // otherwise, update 'characters left' counter
  else 
  {
                var countfield = document.getElementById(countfieldId)
                countfield.value = maxlimit - field.value.length;
        }
}

//  ******************************************
//  *  Print website                         *
//  ******************************************

function printWebsite()
{
  if(document.getElementById("FullText"))
  {
    document.getElementById("schoolAbstract").style.display = "none";
    document.getElementById("schoolText").style.display = "block";
  }
  /* 
  This is also called by pageprint
  window.print() */ 
}


//  ******************************************
//  *  School Abstract / Text                *
//  ******************************************

function schoolText()
{
  document.getElementById("schoolAbstract").style.display = "none";
  document.getElementById("schoolText").style.display = "block";
}

function schoolAbstract()
{
  document.getElementById("schoolText").style.display = "none";
  document.getElementById("schoolAbstract").style.display = "block";
}

//  ******************************************
//  *  Find Schoold                          *
//  ******************************************
function ShowHideElement(elementId)
{
  element = document.getElementById (elementId);
  if (element.className == "ShowMe")
    element.className = "HideMe";
  else if (element.className == "HideMe")
    element.className = "ShowMe";
  else if (element.className == "FilterBoxContent ShowMe")
    element.className = "FilterBoxContent HideMe";
  else if (element.className == "FilterBoxContent HideMe")
    element.className = "FilterBoxContent ShowMe";
}

function ToggleArrow(e, aid, hiddenid)
{
  aelement = document.getElementById(aid);
  hiddenElement = document.getElementById(hiddenid);
  if (hiddenElement.className == "ShowMe")
  {
    aelement.style.backgroundImage = 'url(/images/arrow_up.gif)';
  }
  else if(hiddenElement.className == "HideMe")
  {
    aelement.style.backgroundImage = 'url(/images/arrow_down.gif)';
  }
  else if (hiddenElement.className == "FilterBoxContent ShowMe")
  {
    aelement.style.backgroundImage = 'url(/images/arrow_up.gif)';
  }
  else if (hiddenElement.className == "FilterBoxContent HideMe")
  {
    aelement.style.backgroundImage = 'url(/images/arrow_down.gif)';
  }
}




