
function contextInit(){		
	document.oncontextmenu=contextShow;
	document.body.onclick 		= contextHide;		
	document.onclick = contextHide;
}
var contextEnable = false;

function contextHide(event){	
	$("windowContext").style.display="none";	
}

function contextShow(event){		
	if(!contextEnable){
		
		contextHide(); //better safe then sorry
		return true;
	}
	if(!event)
		event = window.event;
	var mPoint = mouseCoords(event);	
	$("windowContext").style.display='block';
	$("windowContext").style.left = mPoint.x;
	$("windowContext").style.top = mPoint.y;
	return false;	
}

// as IE doesnt support hovers on <il> s
function contextMenuItemHover(el,on){
	if(on){
		el.style.border = "1px solid #E0E0E0";
		el.style.backgroundColor = "#F0F0F0";
	}else{
		el.style.border = "1px solid #FFFFFF";
		el.style.backgroundColor = "#FFFFFF";
	}	
	
}

function contextAction(action){
	var win = WindowMng.windows[WindowMng.windows.length-1];
	
	switch(action){
		case 0:	// edit note
				win.createEditor(); break;
		case 1: //edit title
				win.createTitleEditor();break;
		case 2: //mark as important
				markNoteAsImportant(win.id); break;
		case 3: //delete note
				if(confirm("This note will be deleted permamently.\nAre you sure?")){							
					win.mainDiv.style.display="none";
					win.onClose(win);				
					WindowMng.removeWinById(win.id);								
				}
				break;
		case 4: //email				
				if(global_user_info.status == 1)
					setView("emailNote"); 
				else{
					alert("Sorry, but guests can not to use this feature.\n You can register for FREE using the link on the right!");					
				}	
					break;				
		//standart actions
		case 10: contextCopy();
				break;	
	}

}

function contextCopy(){
	return;
	
	if(document.all){
		var selectedText = document.selection;		
		if (selectedText.type == 'Text') {
			var newRange = selectedText.createRange();
			alert(newRange.text+newRange.htmlText);
						
		}	
	}
	var textVal = "osman";
	if(document.all){
		window.clipboardData.setData('Text', textVal);
	}else{
		prompt("Please right click on the text and click copy again",textVal);
	}
}