function get_login_credentials() {
	w = 390;
	h = 200;
	Control.Modal.open(false, {
		iframe: true,
        width: w,
        height: h
    });
	$('modal_iframe').src = 'get_login_credentials.php';
    var h1 = Control.Modal.getWindowHeight() + 20;
	var h2 = document.body.scrollHeight + 20;
	$('modal_overlay').style.height = new String(h1 > h2 ? h1 : h2) + 'px';
	$('modal_overlay').style.position = 'absolute';
}

function get_esr_data() {
	w = 970;
	h = 700;
	Control.Modal.open(false, {
		iframe: true,
        width: w,
        height: h
    });
	$('modal_iframe').src = 'https://esociety.netkey.at/esr/myuserarea/index.php?module=forgotaccountdata';
    var h1 = Control.Modal.getWindowHeight() + 20;
	var h2 = document.body.scrollHeight + 20;
	$('modal_overlay').style.height = new String(h1 > h2 ? h1 : h2) + 'px';
	$('modal_overlay').style.position = 'absolute';
	
}

function show_guidelines(role) {
	w = 480;
	h = 480;
	
	switch (role) {
		case 'editor': url = '../editor/guidelines_editor.php'; break;
		case 'reviewer': url = '../reviewer/guidelines_reviewer.php'; break;
		case 'submitter': url = '../submission/guidelines_submitter.php'; break;
	}
	Control.Modal.open(false, {
		iframe: true,
		href: url,
        width: w,
        height: h
    });
    var h1 = Control.Modal.getWindowHeight() + 20;
	var h2 = document.body.scrollHeight + 20;
	$('modal_overlay').style.height = new String(h1 > h2 ? h1 : h2) + 'px';
	$('modal_overlay').style.position = 'absolute';
}

function show_reviewerstats(editor_id) {
	w = 640;
	h = 400;
	Control.Modal.open(false, {
		contents: 'Loading ...',
        width: w,
        height: h
    });
    new Ajax.Updater('modal_container', '../editor/reviewer_stats.php?editor_id=' + editor_id);
    var h1 = Control.Modal.getWindowHeight() + 20;
	var h2 = document.body.scrollHeight + 20;
	$('modal_overlay').style.height = new String(h1 > h2 ? h1 : h2) + 'px';
	$('modal_overlay').style.position = 'absolute';
}
function show_stuck_cases(){
	w = 640;
	h = 400;
	Control.Modal.open(false, {
		contents: 'Loading ...',
        width: w,
        height: h
    });
    new Ajax.Updater('modal_container', '../scripts/stuck_cases.php');
    var h1 = Control.Modal.getWindowHeight() + 20;
	var h2 = document.body.scrollHeight + 20;
	$('modal_overlay').style.height = new String(h1 > h2 ? h1 : h2) + 'px';
	$('modal_overlay').style.position = 'absolute';
	
}
function search_cases() {
	document.search.submit();
}

function search_archive(archive) {
	$('search_archive').value = archive;
	document.search.submit();
}

function search_section(id) {
	$('search_section_id').value = id;
	document.search.submit();
}

function search_type(id) {
	$('search_type_id').value = id;
	document.search.submit()
}

function search_author(name) {
	$('search_author').value = name;
	document.search.submit();
}

function sort_results(sort) {
	$('search_order_by').value = sort;
	document.search.submit();
}

function search_toggle() {
	if ($('advanced_search').style.display == 'none') {
		new Effect.Appear('advanced_search', { duration:.5 });
		$('adv_search_lnk_open').show();
		$('adv_search_lnk').hide();
	} else {
		new Effect.Fade('advanced_search', { duration:.5, delay:.25 });
		$('adv_search_lnk_open').hide();
		$('adv_search_lnk').show();
	}
}

function archive_toggle(id) {
	if ($(id).style.display == 'none') {
		$(id + '_lnk').className = 'archive open';
		new Effect.BlindDown(id);
	} else {
		new Effect.BlindUp(id);
		$(id + '_lnk').className = 'archive';
	}
}

function faq_toggle(id) {
	if ($(id).style.display == 'none') {
		$(id + '_lnk').className = 'open';
		new Effect.BlindDown(id, { duration:.5 });
	} else {
		new Effect.BlindUp(id, { duration:.5 });
		$(id + '_lnk').className = '';
	}
}

function section_toggle(id) {
	if ($(id).className == 'hide') {
		$(id).className = '';
		$(id + '_lnk').className = 'section_tgl_open';
	} else {
		$(id).className = 'hide';
		$(id + '_lnk').className = 'section_tgl';
	}
}

function email_case(id) {
	w = 480;
	h = 560;
	Control.Modal.open(false, {
		iframe: true,
		href: 'case_email.php?attach=' + id,
        width: w,
        height: h
    });
    var h1 = Control.Modal.getWindowHeight() + 20;
	var h2 = document.body.scrollHeight + 20;
	$('modal_overlay').style.height = new String(h1 > h2 ? h1 : h2) + 'px';
	$('modal_overlay').style.position = 'absolute';
}

function contact_author(id) {
	w = 480;
	h = 460;
	Control.Modal.open(false, {
		iframe: true,
		href: 'case_contact.php?id=' + id,
        width: w,
        height: h
    });
    var h1 = Control.Modal.getWindowHeight() + 20;
	var h2 = document.body.scrollHeight + 20;
	$('modal_overlay').style.height = new String(h1 > h2 ? h1 : h2) + 'px';
	$('modal_overlay').style.position = 'absolute';
}

function bookmark_case(id) {
	w = 480;
	h = 290;
	Control.Modal.open(false, {
		iframe: true,
		href: 'case_bookmark.php?id=' + id, 
        width: w,
        height: h
    });
    var h1 = Control.Modal.getWindowHeight() + 20;
	var h2 = document.body.scrollHeight + 20;
	$('modal_overlay').style.height = new String(h1 > h2 ? h1 : h2) + 'px';
	$('modal_overlay').style.position = 'absolute';
}

function show_message(width, height) {
	width = parseInt(width);
	height = parseInt(height);
	
	Control.Modal.open(false, {
		contents: $('message').innerHTML,
		width: width > 0 ? width : 350,
		height: height > 0 ? height : 220 
	});
}