function init() {
	init_zoom();
	init_notation();
}

function init_zoom() {
	var z = document.getElementById('zoom');
	z.onclick = function () { zoomTo(this); }
}

function zoomTo( el ) {
	sWidth = el.options[ el.selectedIndex ].value;
	sHeight = sWidth * 1.3 + 26; // letter size ratio
	
	s = document.getElementById("scorch");
	s.style.width = sWidth + "px";
	s.style.height = sHeight + "px";

	createCookie('timeless_score_zoom', sWidth, 1000000);
}



function init_notation() {
	var n = document.getElementById('standard');
	n.onclick = function () { setNotation(this); }
	var n = document.getElementById('shaped');
	n.onclick = function () { setNotation(this); }
	
	var el = document.getElementById('apply');
	el.style.visibility = 'hidden';
}

var notation = '';
function setNotation( el ) {
	if(notation == el.id) { return; }
	notation = el.id;

	var new_cookie = '';
	var str_mxs = ''; var str_rxs = '';
	var str_mxp = ''; var str_rxp = '';
	if(notation == 'shaped') {
		new_cookie = '+';
		str_mxs = /\.sib/;
		str_mxp = /\.pdf/;
	}
	if(notation == 'standard') {
		new_cookie = '';
		str_mxs = /\+\.sib/;
		str_mxp = /\+\.pdf/;
	}
	str_rxs = new_cookie + '.sib';
	str_rxp = new_cookie + '.pdf';

	var xs = document.getElementById('xs');
	if(xs) {
		var sfile = xs.data.replace(str_mxs, str_rxs);
		var s = document.getElementById('scorch');
		s.innerHTML = '<div style="width:100%; height:100%;"><object id="xs" style="width:100%; height:100%;" type="application/x-sibelius-score"'
		+ ' data="' + sfile + '"><param name="src" value="' + sfile + '" />'
		+ '<param name="scorch_minimum_version" value="3000" /><param name="scorch_shrink_limit" value="100" /></object></div>';
	}
	var xp = document.getElementById('xp');
	if(xp) {
		xp.src = xp.src.replace(str_mxp, str_rxp);
	}

	createCookie('timeless_score_notes', new_cookie.replace(/\+/,'%2B'), 1000000);
}

addEvent(window, "load", init);
