var mediaBoxSiteSect = 15000;
var leftEmptySiteSect = 15001;
var playerSiteSect = 15002;
var audioDirectSect = 15003;
var videoDirectSect = 15004;
var rightBaseSiteSect = 15006;

//////// 
//public
////////

// Opens the mediabox with siteSect
// siteSect: page number of right frame
// anchorRight: anchor to jump to
function openMediaBoxWithSiteSect(siteSect, anchorRight) {

	reallyOpenMediaBox("&mode=base&rightSiteSect=" + siteSect + "&anchorRight=" + anchorRight);
}


// Changes the right player frame
// siteSect: siteSect to change to
// anchorName: anchor in the page to jump to
function changeRightFrame(siteSect, anchorName) {
	newLink = parent.right_frame.location.pathname + 
	"?siteSect=" + siteSect + "#"+ anchorName;
	parent.right_frame.location.href = newLink;
}


// Plays a file in the player frame
// url: file to broadcast
function playMedium(url) {
	newLink = parent.left_frame.location.pathname + 
	"?url=" + escape(url) +
	"&siteSect=" + playerSiteSect;
	parent.left_frame.location.href = newLink;
}




// Opens the mediabox without playing anything
function openMediaBox() {
	reallyOpenMediaBox("&mode=base");
}


// Opens the mediabox and plays the file with corresponding url and displays the
// text from of the newselement with the id newsElementId
// newsElementId: corresponding newsElementId
function openAudio(newsElementId) {
	openMedium(newsElementId, "audioDirect");
}


// Opens the mediabox and plays the file with corresponding url and displays the
// text from of the newselement with the id newsElementId
// newsElementId: corresponding newsElementId
function openVideo(newsElementId) {
	openMedium(newsElementId, "videoDirect");
}


// Opens the mediabox and plays the file with corresponding url and displays the
// given title.
// url: file to display
// title: title to display
function openUrlWithTitle(url, title){
	var suffix = "&url=" + escape(url) + "&title=" + escape(title) + "&mode=titleUrl";
	reallyOpenMediaBox(suffix);
}


// Opens the mediabox and plays the file with corresponding URL and displays the
// site section in the right frame.
// url: file to display
// siteSect: page number of right frame
function openUrlWithSiteSect(url, siteSect){
	var suffix = "&url=" + escape(url) + "&mode=siteSectUrl" + "&rightSiteSect=" + siteSect;
	reallyOpenMediaBox(suffix);
}

/////////////
//private
/////////////

// Opens the mediabox after adding urlSuffix to the standard mediabox URL
function reallyOpenMediaBox(urlSuffix){
	var newUrl = window.location.pathname +
	"?siteSect=" + mediaBoxSiteSect + urlSuffix ;
	window.open(newUrl, 'MediaBox', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=555,height=341,left=20,top=20');
}


// Opens the mediabox and plays the file with corresponding url and displays the
// text from of the newselement with the id newsElementId
function openMedium(newsElementId, mode){
	var urlSuffix = "&ne_id=" + newsElementId +
	"&mode=" + mode ;
	reallyOpenMediaBox(urlSuffix);
}
