function setRating(rate){
	var commentForm = document.commentform;
	commentform.rating.value = rate;
	for(var i = 1;i<=5;i++){
		var starObj = document.getElementById('rating-' + i);
		if(i<=rate) {
			starObj.className = 'star';	
		} else {
			starObj.className = 'star-faded';
		}
	}
}


function feedSubBranchList(elem){
	var branchid = elem[elem.selectedIndex].value;
	if (window.XMLHttpRequest) {
		xmlhttp=new XMLHttpRequest();
	} else {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.open('GET', '/composite-4024.htm?branchid=' + branchid, true);
	xmlhttp.send();
	xmlhttp.onreadystatechange = function() {
  		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			xmldoc = xmlhttp.responseXML;
			var subbranches = xmldoc.getElementsByTagName('subbranch');
			var subbranchSelector = null;
			subbranchSelector = document.getElementById('casesubbranchid');
			subbranchSelector.length = subbranches.length + 1;
			subbranchSelector.options[0] = new Option('Alle','');
			for(var i = 0;i<subbranches.length;i++) {
    			subbranchSelector.options[i+1] = new Option(subbranches[i].attributes.getNamedItem("title").nodeValue, subbranches[i].attributes.getNamedItem("id").nodeValue);
			}
    	}
  	}
			
	
}

function setCookie(c_name,value,exdays) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
    document.cookie=c_name + "=" + c_value;
}
function getCookie(c_name) {
    var i,x,y,ARRcookies=document.cookie.split(";");
    for (i=0;i<ARRcookies.length;i++)
    {
        x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
        y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
        x=x.replace(/^\s+|\s+$/g,"");
        if (x==c_name)
        {
            return unescape(y);
        }
    }
}
function checkCookie(){
    var cookieName = getCookie('BureauBiz');
    if (cookieName!=null && cookieName!=''){
        //Do nothing
    } else {
        setCookie('BureauBiz','User',365);
    }
}
checkCookie();


// this deletes the cookie when called
function deleteCookie(name,path,domain) {
	if ( getCookie(name)) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
};


var openElement = 0;
function toggleDropDown(element,form,field) {
    if(openElement == 1){
            document.getElementById(element).style.dislay='none';
            openElement = 0;
    }
    if(openElement != element) {
        document.getElementById(element).style.display='block';
        openElement = 1;
    }
}
function selectWord(word,row,form,field){
        //document.getElementById(row).style.display='none';
        var separator = '';
        if(document.forms[form].elements[field].value != '') { separator = ', ' }
        document.forms[form].elements[field].value += separator + word;
        alert(word + ' er tilføjet.');
}
function selectSearchWord(word,row,form,field){
        //document.getElementById(row).style.display='none';
        var separator = '';
        if(document.forms[form].elements[field].value != '') { separator = ' + ' }
        document.forms[form].elements[field].value += separator + word;
        alert(word + ' er tilføjet.');
}

function deleteLogotypeFile() {
	if(confirm('Slet filen?')){
		document.agencyform.deletefile.value = 'true';
		document.agencyform.submit();
	};
}

