<!--
function collapse(aImageNode, aRootNode, aPortletId) {
  var aContentId = aPortletId + '_collapse_content';
  var aContentNode = document.getElementById(aRootNode, aContentId);
  if (aContentNode == null) {
  	aContentNode = document.getElementById(aContentId);
  	if (aContentNode == null)
    	return;
  }
  aContentNode.style.display = "none";
  var aDownImageName = "";
  var aBaseImageName = aImageNode.getAttribute("src");
  if (aBaseImageName != null) {
  	var aPos = aBaseImageName.lastIndexOf(".");
  	var aPos2 = aBaseImageName.lastIndexOf("_");
  	if (aPos != -1 && aPos2 != -1) {
  		aDownImageName = aBaseImageName.substring(0, aPos2);
  		aDownImageName += "_down";
  		aDownImageName = aDownImageName + aBaseImageName.substring(aPos, aBaseImageName.length);
  	}
  	else 
  		aDownImageName = aBaseImageName;
  }  
  aImageNode.setAttribute("src", aDownImageName);
  aImageNode.setAttribute("alt", "down");
  aImageNode.setAttribute("collapsed", "yes");
  
  // write data to cookie
  var allCookies = document.cookie;
  var aPos = allCookies.indexOf("alpin_portlet_state=");
  if (aPos != -1) {
  	var aEnd = allCookies.indexOf(";", aPos);
  	if (aEnd == -1)
  		aEnd = allCookies.length;
  	var aContent = allCookies.substring(aPos+20, aEnd);
  	aContent = unescape(aContent);
  	var aPortletPos = aContent.indexOf(aPortletId);
  	if (aPortletPos == -1) {  		
		aContent = aContent + aPortletId + ",";		
  		var expireDate = new Date;
		expireDate.setDate(expireDate.getDate()+180);
		var expirationString = "; expires=" + expireDate.toGMTString();
		document.cookie = "alpin_portlet_state=" + escape(aContent) + expirationString;		
  	}
  }
  else {
  	// new cookie
  	var aContent = "alpin_portlet_state=" + escape(aPortletId + ",");
  	
  	var expireDate = new Date;
	expireDate.setDate(expireDate.getDate()+180);
	var expirationString = "; expires=" + expireDate.toGMTString();
	
	document.cookie = aContent + expirationString;		
  }
}
function expand(aImageNode, aRootNode, aPortletId, aBaseImageName) {
  var aContentId = aPortletId + '_collapse_content';
  var aContentNode = document.getElementById(aRootNode, aContentId);
  if (aContentNode == null) {
  	aContentNode = document.getElementById(aContentId);
  	if (aContentNode == null) {
    	return;
    }
  }
  aContentNode.style.display = "";
  var aUpImageName = "";
  var aBaseImageName = aImageNode.getAttribute("src");
  if (aBaseImageName != null) {
  	var aPos = aBaseImageName.lastIndexOf(".");
  	var aPos2 = aBaseImageName.lastIndexOf("_");
  	if (aPos != -1 && aPos2 != -1) {
  		aUpImageName = aBaseImageName.substring(0, aPos2);
  		aUpImageName += "_up";
  		aUpImageName = aUpImageName + aBaseImageName.substring(aPos, aBaseImageName.length);
  	}
  	else 
  		aUpImageName = aBaseImageName;
  }  
  aImageNode.setAttribute("src", aUpImageName);
  // remove attribute
  aImageNode.setAttribute("collapsed", "no");
  aImageNode.setAttribute("alt", "up");
  
  var allCookies = document.cookie;
  var aPos = allCookies.indexOf("alpin_portlet_state=");
  if (aPos != -1) {
  	var aEnd = allCookies.indexOf(";", aPos);
  	if (aEnd == -1)
  		aEnd = allCookies.length;
  	var aContent = allCookies.substring(aPos+20, aEnd);
  	aContent = unescape(aContent);
  	var aNewContent;
  	var aPortletPos = aContent.indexOf(aPortletId);
  	if (aPortletPos != -1) {
		// remove portlet
		aNewContent = aContent.substring(0, aPortletPos);
		aNewContent = aNewContent + aContent.substring(aPortletPos+aPortletId.length+1, aContent.length);			
  		var expireDate = new Date;
		expireDate.setDate(expireDate.getDate()+180);
		var expirationString = "; expires=" + expireDate.toGMTString();		
		document.cookie = "alpin_portlet_state=" + escape(aNewContent) + expirationString;
  	}
  	else {
  	}
  		
  }
}
function toggle(aNode, aPortletId) {
  // get portlet parent node (by aPortletId)
  var aParentNode = aNode.parentNode;
  while (aParentNode != null) {
    // get attribute id and compare it to aProtletId
    if (aParentNode.getAttribute("id") == aPortletId)
      break;
    aParentNode = aParentNode.parentNode;
  }

  if (aParentNode == null) {  // not found 
    return;
   }

  var aCollapseAttribute = aNode.getAttribute("collapsed");
  if (aCollapseAttribute == "yes")
    // expand node
    expand(aNode, aParentNode, aPortletId);
  else
    // collapse node
    collapse(aNode, aParentNode, aPortletId);
}

function checkWorkmenSearch(aDistrict, aJob) {
	if (aDistrict == "99999" && aJob == "99999") {
		alert("Sie können nicht 'alle Bezirke' UND 'alle Berufe' gleichzeitig wählen!\nNon puo' scegliere 'tutti i circondari' e 'tutti i mestieri' insieme!");
		return false;	
	}
	return true;
}
//-->
