/* delete Ad */
function deleteAd(url,title,Adref) 
{
	var add_href= confirm("Ønsker du å slette annonsen med tittel: '"+title+"' og referanse: '"+Adref+"'?");
	if (add_href){
		document.location.href = url+"&Operation=delete";
	} else {
		// cancel no need to do a location.href here.
		//document.location.href = "min_zett.html"; 
	}	
}

/* deactivate Ad */
function deactivateAd (url,title,Adref) 
{
	var add_href= confirm("Ønsker du å deaktivere annonsen med tittel '"+title+"' og referanse: '"+Adref+"'?");
	if (add_href){
		document.location.href = url+"&Operation=deactivate";
	} else {
		// cancel no need to do a location.href here.
		//document.location.href = "min_zett.html"; 
	}
}

/* template Ad */
function templateAd(url)
{
	document.location.href = url+"&Operation=templatebooking";
}


/* partner Ad */
function partnerAd(url,companyId)
{
	document.location.href = url+"&Operation=templatebooking"+"&referer="+companyId;
}


/* extend date */
function extendDate(userId,searchId,num){
	var sel = document.getElementById('extendId'+num);
	var days = sel.options[sel.selectedIndex].value;
    var extenddays = document.getElementById('extendsearch'+num);
    extenddays.href ="my/extendsearch.action?userId="+userId+"&days="+days+"&searchId="+searchId;
	document.mysearch.action=extenddays.href;
}


/* call save user search action */
function saveusersearchcall(dispatcher,query) {
	document.saveusersearch.action="my/saveusersearch.action?dispatcher="+dispatcher+"&query="+query;
}

/* select multiple choices */
function showselectedcheckbox(idOfASearch,idOfElementList) {
	var newSearcBreadcrumb = "";
	var webpageaddress = location.href;
	var list = document.getElementById(idOfElementList);

	if ( list != null ) {
		for ( var i = 0; i<list.childNodes.length;i++) {
			if ( list.childNodes[i].nodeName == 'LI') {;
				for ( var j = 0; j<list.childNodes[i].childNodes.length;j++) {	
					if(list.childNodes[i].childNodes[j].nodeName == 'INPUT' && list.childNodes[i].childNodes[j].checked ) {
						if ( webpageaddress.indexOf('norge') > 0 && idOfElementList == 'geography' ) 
							newSearcBreadcrumb += "navigator*"+idOfElementList+"["+idOfElementList+"]=norge/"+list.childNodes[i].childNodes[j].value+"|";
						else	
							newSearcBreadcrumb += "navigator*"+idOfElementList+"["+idOfElementList+"]="+list.childNodes[i].childNodes[j].value+"|";
					}
				}
			}
		}
		
		if ( webpageaddress.indexOf("?") > 0 )
			webpageaddress = webpageaddress+"|"+newSearcBreadcrumb.substring(0,newSearcBreadcrumb.lastIndexOf("|"));
		else 
			webpageaddress = webpageaddress+"?query="+newSearcBreadcrumb.substring(0,newSearcBreadcrumb.lastIndexOf("|"));
	
		//document.getElementById(idOfASearch).href = encode_utf8( webpageaddress );
		//document.getElementById(idOfASearch).href = decode_utf8( webpageaddress );
		document.getElementById(idOfASearch).href = webpageaddress;
	} else	
		return false;
}

function encode_utf8( s ){  return unescape( encodeURIComponent( s ) );}
function decode_utf8( s ){  return decodeURIComponent( escape( s ) );}