function favorieten(){
var tlh = this.location.href;
var tdt = this.document.title;
if (document.all){
window.external.AddFavorite(tlh,tdt)
} else if (window.sidebar) { 
window.sidebar.addPanel(tdt, tlh,""); 
} else if( window.opera && window.print ) {
return true;
}
}

function bookmarkClick(bookmarkId,action,pageSrc){
	//actions= constants
	//0= add to bookmarks
	//1= delete from bookmarks
	//2= don't show anymore
	new Ajax.Request('http://mijn.vacature.com/_updateBookmark.php' , {
		onSuccess : function(resp) {
			eval(resp.responseText);
			if (errors.length==0){
			
			} else {
				errorsHandle(errors);
			}
		},
		onFailure : function(resp) {
			reportAjaxError(resp);
		},
		parameters : "jsEnabled=1&bookmarkId="+bookmarkId+"&action="+action+"&pageSrc="+pageSrc
	});
	return false;
}

function bookmarkUpdateMarker(bookmarkId,action,pageSrc){
	//triggered by Ajax Service
	//actions= constants
	//0= add to bookmarks
	//1= delete from bookmarks
	//2= don't show anymore
	switch (action) {
		case 0:
			$('bookmark'+bookmarkId).getElementsByTagName('IMG')[0].src=$('bookmark'+bookmarkId).getElementsByTagName('IMG')[0].src.replace('_off.','_on.');
			break;		
		case 1:
			//removing a bookmark from the bookmarklist
			if (pageSrc=='listBookmarks'&&$('bookmark'+bookmarkId)){
				Element.remove('bookmark'+bookmarkId);
				
				//update counter
				if($('listCounterCount')&&$('listCounterTotal')){
					$('listCounterCount').innerHTML--;
					$('listCounterTotal').innerHTML--;
				}
			}
			$('bookmark'+bookmarkId).getElementsByTagName('IMG')[0].src=$('bookmark'+bookmarkId).getElementsByTagName('IMG')[0].src.replace('_on.','_off.');
			break;		
		case 2:
			//delete li Item
			if ($('bookmark'+bookmarkId)){
				Element.remove('bookmark'+bookmarkId);
			}
			//update counter
			if($('listCounterCount')&&$('listCounterTotal')){
				$('listCounterCount').innerHTML--;
				$('listCounterTotal').innerHTML--;
			}
			break;		
		default:
			break;		
	}
}

function bookmarkUpdateLink(bookmarkId,text){
	//updating text link values
	$('bookmarkMainAction'+bookmarkId).innerHTML=unescape(text.replace(/\+/g,' '));
	
	//updating iconlink values
	$('bookmarkIconLink'+bookmarkId).href=$('bookmarkTextLink'+bookmarkId).href;
	$('bookmarkIconLink'+bookmarkId).onclick=$('bookmarkTextLink'+bookmarkId).onclick;
}

function bookmarkUpdateCount(n){
	if(!$('bookmarkStarNumber')) return;
	$('bookmarkStarNumber').innerHTML=n;
}
function jobOfferUpdateCount(count,total){
//	counterJobOfferItems
//	counterJobOfferTotal

}

function getBookmarkComment(id,method){

	//textarea not present (request not made yet)
	if(!$('bookmark'+id).getElementsByTagName('TEXTAREA').length){
		//getting infos from server
		new Ajax.Request('http://mijn.vacature.com/_getBookmarkComment.php' , {
			onSuccess : function(resp) {
				
				eval(resp.responseText);
				if (errors.length==0){
				
					var ta=document.createElement('TEXTAREA');
						ta.setAttribute('id','ta'+retrievedComment.id);
						ta.className='bookmarkComment';
					var tb=document.createTextNode(unescape(retrievedComment.comment.replace(/\+/g,' ')));
						ta.appendChild(tb);
					
					$('bookmark'+retrievedComment.id).appendChild(ta);
					$('lnkBookmarkComment'+retrievedComment.id).onclick=function(){getBookmarkComment(retrievedComment.id,'set');};
					Element.update($('lnkBookmarkComment'+retrievedComment.id),(typeof(LBL_SAVE_COMMENT!='undefined')?LBL_SAVE_COMMENT:'Save and close.'));
				
				} else {
					errorsHandle(errors);
				}
			},
			onFailure : function(resp) {
				reportAjaxError(resp);
			},
			
			parameters:"method=get&cvId="+id+"&jsEnabled=1"
		});
	} else {
		if (method=='get') {
		//textarea already there but user wants to see comment
			$('lnkBookmarkComment'+id).onclick=function(){getBookmarkComment(id,'set');};
			Element.update($('lnkBookmarkComment'+id),(typeof(LBL_SAVE_COMMENT!='undefined')?LBL_SAVE_COMMENT:'Save and close.'));
			Element.show($('ta'+id));
				
	
		} else if (method=='set') {
			//user save and close the comment
			//sending infos to server
			new Ajax.Request('http://mijn.vacature.com/_getBookmarkComment.php' , {
				onSuccess : function(resp) {
					
					eval(resp.responseText);
					if (errors.length==0){
					
						$('lnkBookmarkComment'+retrievedComment.id).onclick=function(){getBookmarkComment(retrievedComment.id,'get');};
						Element.update($('lnkBookmarkComment'+retrievedComment.id),(typeof(LBL_VIEW_COMMENT!='undefined')?LBL_VIEW_COMMENT:'View Comment'));
						Element.hide($('ta'+retrievedComment.id));
					
					} else {
						errorsHandle(errors);
					}
				},
				onFailure : function(resp) {
					reportAjaxError(resp);
				},
				parameters:"comment="+escape(Form.Element.getValue($('ta'+id)).replace(/w/g,'<br />'))+"&method=set&cvId="+id+"&jsEnabled=1"
			});
		}
	}
}
function printBookmarkComment(id,txt){

}