//var img_checkbox_chk = "../images/_common_blue/icons/checkbox_checked.gif";
//var img_checkbox = "../images/_common_blue/icons/checkbox.gif";

var img_checkbox_chk = "../images/_common_blue/scot/bookmark.gif";
var img_checkbox = "../images/_common_blue/scot/bookmark_disabled.gif";
var s_remove_bookmark = 'Remove Bookmark?';

function checkbox_check(id) {
	if (document.getElementById(id).checked) {
		document.getElementById(id).checked = false;
		document.getElementById(id + '_img').src = img_checkbox;
	} else {
		document.getElementById(id).checked = true;
		document.getElementById(id + '_img').src = img_checkbox_chk;
	}
}
function erro_cb(e) {
	if (e != '') {
		alert(e);
	} else {
		x_get_my_sessions(person_id, my_sessions_cb);
	}
}
function my_sessions_cb(sessions) {
	var ul = document.getElementById('my_sessions');
	ul.innerHTML = '';
	
	var sids = document.getElementById('_sids');
	var _tmp = "";
	
	if (sessions[0]) {
		ul.innerHTML = '';
		for (var i in sessions) {
			ul.innerHTML += '<li class="my_session">';
			_tmp += sessions[i][0] + ";";
			if (sessions[i][1].length > 8) {
				ul.innerHTML += '<div class="my_day">' + sessions[i][2] + '</div>';
				ul.innerHTML += '<div class="my_time">' + sessions[i][3] + '</div>';
				ul.innerHTML += '<div style="clear:both"><a href="' + s_url + '&session=' + sessions[i][0] + '">' + sessions[i][1] + '</a></div>';
			}
			else {
				ul.innerHTML += '<div class="my_nr"><a href="' + s_url + '&session=' + sessions[i][0] + '">' + sessions[i][1] + '</a></div>';
				ul.innerHTML += '<div class="my_day">' + sessions[i][2] + '</div>';
				ul.innerHTML += '<div class="my_time">' + sessions[i][3] + '</div>';
			}
			ul.innerHTML += '</li>';
			if (window.navigator.userAgent.indexOf("MSIE ") < 1)
				ul.innerHTML += '<div style="clear:both"></div>';
		}
	}
	
	if(sids != null && sids.value != null)
		sids.value = _tmp.substring(0, _tmp.length - 1);

	x_get_my_publications(person_id, my_publications_cb)
}
function my_publications_cb(pubs) {
	var ul = document.getElementById('my_sessions');
	
	var pids = document.getElementById('_pids');
	var _tmp = "";

	if (pubs[0]) {
		ul.innerHTML += '<div><br clear="all"/></div>';
		for (var i in pubs) {
			_tmp += pubs[i][0] + ";";
			ul.innerHTML += '<li class="my_session">';
			ul.innerHTML += '<div class="my_nr"><a href="' + s_url + '&abstract=' + pubs[i][0] + '">' + pubs[i][1] + '</a></div>';
			ul.innerHTML += '</li>';
		}
	}
	
	if(pids != null && pids.value != null)
		pids.value = _tmp.substring(0, _tmp.length - 1);
}
function mark_session(id) {
	if (person_id == 0) {
		alert(s_login_alert);
		return false;
	}
	
	if (document.getElementById('session_' + id).className == 'session_marked') {
		if(!confirm(s_remove_bookmark)) return false;

		document.getElementById('session_' + id).className = 'session';
		x_unmark_session(person_id, id, erro_cb);
	} else {
		document.getElementById('session_' + id).className = 'session_marked';
		x_mark_session(person_id, id, erro_cb);
	}
	
	checkbox_check('mark_' + id);
}
function mark_track(sid, tid) {
	if (person_id == 0) {
		alert(s_login_alert);
		return false;
	}
	
	if (document.getElementById('track_' + sid + '_' + tid).className == 'track_marked') {
		if(!confirm(s_remove_bookmark)) return false;

		document.getElementById('track_' + sid + '_' + tid).className = 'track';
		x_unmark_track(person_id, sid, tid, erro_cb);
	} else {
		document.getElementById('track_' + sid + '_' + tid).className = 'track_marked';
		x_mark_track(person_id, sid, tid, erro_cb);
	}

	checkbox_check('mark_' + sid + '_' + tid);
}
function mark_publication(id) {
	if (person_id == 0) {
		alert(s_login_alert);
		return false;
	}
	
	if (document.getElementById('publication_' + id).className == 'session_marked') {
		if(!confirm(s_remove_bookmark)) return false;

		document.getElementById('publication_' + id).className = 'session';
		x_unmark_publication(person_id, id, erro_cb);
	} else {
		document.getElementById('publication_' + id).className = 'session_marked';
		x_mark_publication(person_id, id, erro_cb);
	}
	
	checkbox_check('mark_' + id);
}
function login_cb(r) {
	if (r == 0) {
		alert(s_login);
		return false;
	}

	s = document.location.href;
	document.location.href = s;
}
function reset_options(x) {
	document.getElementById('day_id').selectedIndex = 0;
	document.getElementById('type_id').selectedIndex = 0;
	document.getElementById('topic_id').selectedIndex = 0;
	document.getElementById('keyword').value = x;
}
function help_window() {
	var i_width = 800;
	var i_height = 600;
	var i_left = (screen.availWidth - i_width) / 2;
	var i_top = (screen.availHeight - i_height) / 2;
	window.open('help/index.php', 'help', 'resizeable=no,scrollbars=yes,status=yes,dependent=yes,width='+i_width+',height='+i_height+',left='+i_left+',top='+i_top);
}
function create_account() {
	var i_width = 500;
	var i_height = 500;
	var i_left = (screen.availWidth - i_width) / 2;
	var i_top = (screen.availHeight - i_height) / 2;
	window.open('itinerary_register.php', 'register', 'resizeable=no,scrollbars=yes,status=yes,dependent=yes,width='+i_width+',height='+i_height+',left='+i_left+',top='+i_top);
}
function forgot_password() {
	var i_width = 400;
	var i_height = 300;
	var i_left = (screen.availWidth - i_width) / 2;
	var i_top = (screen.availHeight - i_height) / 2;
	window.open('itinerary_password.php', 'password', 'resizeable=no,scrollbars=yes,status=yes,dependent=yes,width='+i_width+',height='+i_height+',left='+i_left+',top='+i_top);
}
function print_itinerary() {
	var i_width = 918;
	var i_height = 640;
	var i_left = (screen.availWidth - i_width) / 2;
	var i_top = (screen.availHeight - i_height) / 2;
	window.open('itinerary_print.php', 'print', 'resizeable=no,scrollbars=yes,status=yes,dependent=yes,menubar=yes,width='+i_width+',height='+i_height+',left='+i_left+',top='+i_top);
}
function pdf() {
	var i_width = 918;
	var i_height = 640;
	var i_left = (screen.availWidth - i_width) / 2;
	var i_top = (screen.availHeight - i_height) / 2;
	window.open('itinerary_pdf.php', 'pdf', 'resizeable=no,scrollbars=yes,status=yes,dependent=yes,menubar=yes,width='+i_width+',height='+i_height+',left='+i_left+',top='+i_top);
}
function remove_everything() {
	if (person_id == 0) {
		alert(s_login_alert);
		return false;
	}

	remove_all_sessions();
	remove_all_posters();
	x_get_my_sessions(person_id, my_sessions_cb);
}
function remove_all_sessions() {
	if (person_id == 0) {
		alert(s_login_alert);
		return false;
	}

	var sids = document.getElementById("_sids");
	if(sids != null && sids.value != null) {
		var _tmp = sids.value.split(";");
		for(var i in _tmp)
			x_unmark_session(person_id, _tmp[i], _dummy_cb);
	}
}
function remove_all_posters() {
	if (person_id == 0) {
		alert(s_login_alert);
		return false;
	}

	var pids = document.getElementById("_pids");
	if(pids != null && pids.value != null) {
		var _tmp = pids.value.split(";");
		for(var i in _tmp)
			x_unmark_publication(person_id, _tmp[i], _dummy_cb);
	}
}
function _dummy_cb(e) {
}


