NS4 = (document.layers);
IE4 = (document.all);
ver4 = (NS4 || IE4);
IE5 = (IE4 && navigator.appVersion.indexOf("5.")!=-1);
isMac = (navigator.appVersion.indexOf("Mac") != -1);
isMenu = (NS4 || (IE4 && !isMac) || (IE5 && isMac));

if (isMac) { 
$ops = 1; 
}
else { 
$ops = 2; 
}

var savedSel;
var recruit_text = '&#x53;&#x6f;&#x72;&#x72;&#x79;&#x2c;&#x20;&#x79;&#x6f;&#x75;&#x20;&#x61;&#x72;&#x65;&#x20;&#x6e;&#x6f;&#x74;&#x20;&#x61;&#x6c;&#x6c;&#x6f;&#x77;&#x65;&#x64;&#x20;&#x74;&#x6f;&#x20;&#x63;&#x6f;&#x70;&#x79;&#x20;&#x74;&#x68;&#x65;&#x20;&#x6c;&#x79;&#x72;&#x69;&#x63;&#x73;&#x20;&#x66;&#x72;&#x6f;&#x6d;&#x20;&#x74;&#x68;&#x69;&#x73;&#x20;&#x73;&#x69;&#x74;&#x65;&#x2e;';
var recruit_keydown = false;

function mark_all(elem) {
  if (document.selection && document.selection.createRange) {
    var textRange = document.selection.createRange();
    textRange.moveToElementText(elem);
    textRange.select();
  } else if (document.createRange && window.getSelection) {
    var range = document.createRange();
    range.selectNode(elem);
    var selection = window.getSelection();
    selection.removeAllRanges();
    selection.addRange(range);
	}
}

function saveSelection(){
	savedSel = rangy.saveSelection();
}

function restoreSelection(){
	rangy.restoreSelection(savedSel);
	rangy.removeMarkers(savedSel);
}

function select_invisible(){
	mark_all(document.getElementById("spacer"));
}		

function edit_invisible(){
	var sel = rangy.getSelection();
	document.getElementById("spacer").innerHTML = recruit_text;
//	document.getElementById("invisible").innerHTML = recruit_text + "<br><br>" + sel.toHtml();
}

function edit_and_select_invisible(){
	saveSelection();
	edit_invisible();
	select_invisible();
}
		
function block_it(e){
	var code = (document.all) ? e.keyCode:e.which;
	if (code==67){
        recruit_keydown = true;
		edit_and_select_invisible();
	}
	return e;
}

function load_track(id){
    tmpImg = new Image();
    tmpImg.src = '/105/'+id+'/pad.png';
}

function mark_back(e){
    recruit_keydown = false;
	restoreSelection();
}

function init(){
	document.body.oncopy = function(e){
        if (!recruit_keydown)
            edit_invisible();
		select_invisible();
	}
}

