function toggleDivClass(toggleDivId, className1, className2) {
	$(toggleDivId).toggle();
	if ($('link').hasClassName(className1)) {
		$('link').toggleClassName(className2);
	} else {
		$('link').toggleClassName(className1);
	}
}

//Menu
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function change(id, state) {
	if ('on' == state) {
		$(id).className = id + 'on';
	} else if ('off' == state){
		$(id).className = id;
	}
}

function changeParent(element, state) {
	//alert(element.parentNode.parentNode.parentNode.className);
	if ('on' == state) {
		element.parentNode.parentNode.parentNode.className = 'parenthover';
	} else if ('off' == state) {
		element.parentNode.parentNode.parentNode.className = '#nav li.sfhover';
		}
}

function collapseAndExpand(id) {
	var e = document.getElementById(id);
	var es = document.getElementsByClassName("answer");

	for (var i = 1; i < es.length + 1; i++) {
		document.getElementById("answer" + i).style.display = "none";
	}

	e.style.display = "block";
}

// Cookie spec

/*
   name - name of the cookie
   value - value of the cookie
   [expires] - expiration date of the cookie
     (defaults to end of current session)
   [path] - path for which the cookie is valid
     (defaults to path of calling document)
   [domain] - domain for which the cookie is valid
     (defaults to domain of calling document)
   [secure] - Boolean value indicating if the cookie transmission requires
     a secure transmission
   * an argument defaults when it is assigned null as a placeholder
   * a null placeholder is not required for trailing omitted arguments
*/

function setCookie(name, value, days, path, domain, secure) {

  var date = new Date();
  date.setTime(date.getTime()+(days*24*60*60*1000));

  var curCookie = name + "=" + escape(value) +
      ((days) ? "; expires=" + date.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
      //alert("Kakan är satt!");
  document.cookie = curCookie;
}

/*
  name - name of the desired cookie
  return string containing value of specified cookie or null
  if cookie does not exist
*/

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
    //alert("Kakan är tagen!");
  return unescape(dc.substring(begin + prefix.length, end));
}

function chkCookie() {
	if (getCookie('LDindexNonFlashLayer') == null)
	$('flashLayer').show();
}

function setC() {
	setCookie('LDindexNonFlashLayer','true');
}

function chkProfCareCookie() {
	if (getCookie('profCareLayer') == null)
	$('profCareLayer').show();
}

function setCProfCare() {
	setCookie('profCareLayer','true', null, '/', '.river.se');
}

function showLoginLayerHeight() {
      loginLayerHeight = $('maincontent').getHeight();
      $('loginLayer').style.height = loginLayerHeight + "px";
      $('loginLayer').style.display = "block";
}

function showProfCareLayerHeidht() {
	  profCareLayerHeight = $('maincontent').getHeight();
      $('profCareLayer').style.height = profCareLayerHeight + "px";	
}

function hideProfCareLayerHeidht() {
	$('profCareLayer').style.display = "none";
}

function newWindow(file,window) {
    msgWindow=open(file,window,'resizable=no,width=500,height=500,scrollbars=yes');
    if (msgWindow.opener == null) msgWindow.opener = self;
}

function clearForm(){
  document.getElementById("LoginForm").Username.value = "";
  document.getElementById("LoginForm").Password.value = "";
  setFocus();
}

function setFocus(){
  document.getElementById("LoginForm").Username.focus();
}

function password_reminder() {
  window.open('/popup/password_login.jsp', 'password', 'width=500,height=300');
}

function openApplyLogin() {
  window.open('/popup/apply_login.jsp', 'ApplyLogin', 'width=500,height=700');
}

function openApplyNewsletter() {
  window.open('/popup/apply_newsletter.jsp', 'ApplyNewsletter', 'width=500,height=530');
}

function showpressLayerHeight(id) {

	pressLayerHeight = $('maincontent').getHeight();

	$(id).style.height = pressLayerHeight + "px";
	$(id).style.display = "block";
}

function hidepressLayerHeight(id) {
	$(id).style.display = "none";
}

function tryClearMsg() {
	try {
		$('pinMessage').innerHTML = '';
		$('unMessage').innerHTML = '';
	}
	catch(err) {

	}
}

function toogletellAFriend() {
	$('tellAFriend').style.display = 'block';
}