function showRights(cid){		
	// University Ranking 
	if(cid == 'urss_hec'){
		if (document.getElementById('urss_hec') != null)		
			document.getElementById('urss_hec').style.display = 'block';
		if (document.getElementById('urss_uni_focal') != null)
			document.getElementById('urss_uni_focal').style.display = 'none';
		if (document.getElementById('urss_dept_user') != null)
			document.getElementById('urss_dept_user').style.display = 'none';
	}		
	if(cid == 'urss_uni_focal'){
		if (document.getElementById('urss_hec') != null)
			document.getElementById('urss_hec').style.display = 'none';
		if (document.getElementById('urss_uni_focal') != null)
			document.getElementById('urss_uni_focal').style.display = 'block';
		if (document.getElementById('urss_dept_user') != null)
			document.getElementById('urss_dept_user').style.display = 'none';
	}
	
	if(cid == 'urss_dept_user'){
		if (document.getElementById('urss_hec') != null)
			document.getElementById('urss_hec').style.display = 'none';
		if (document.getElementById('urss_uni_focal') != null)
			document.getElementById('urss_uni_focal').style.display = 'none';
		if (document.getElementById('urss_dept_user') != null)
			document.getElementById('urss_dept_user').style.display = 'block';
	}
	if(cid == 'urss_none'){
		if (document.getElementById('urss_hec') != null)
			document.getElementById('urss_hec').style.display = 'none';
		if (document.getElementById('urss_uni_focal') != null)
			document.getElementById('urss_uni_focal').style.display = 'none';
		if (document.getElementById('urss_dept_user') != null)
			document.getElementById('urss_dept_user').style.display = 'none';
	}
	// Student Repository
	if(cid == 'sr_none'){
		if (document.getElementById('sr_udu') != null)
			document.getElementById('sr_udu').style.display = 'none';
		if (document.getElementById('sr_uni_focal') != null)
			document.getElementById('sr_uni_focal').style.display = 'none';
		if (document.getElementById('sr_hec') != null)
			document.getElementById('sr_hec').style.display = 'none';
	}
	if(cid == 'sr_udu'){
		if (document.getElementById('sr_udu') != null)
			document.getElementById('sr_udu').style.display = 'block';
		if (document.getElementById('sr_uni_focal') != null)
			document.getElementById('sr_uni_focal').style.display = 'none';		
		if (document.getElementById('sr_hec') != null)
			document.getElementById('sr_hec').style.display = 'none';
		
	}
	if(cid == 'sr_uni_focal'){
		if (document.getElementById('sr_udu') != null)
			document.getElementById('sr_udu').style.display = 'none';
		if (document.getElementById('sr_uni_focal') != null)
			document.getElementById('sr_uni_focal').style.display = 'block';
		if (document.getElementById('sr_hec') != null)
			document.getElementById('sr_hec').style.display = 'none';
	}
	if(cid == 'sr_hec'){
		if (document.getElementById('sr_udu') != null)
			document.getElementById('sr_udu').style.display = 'none';
		if (document.getElementById('sr_uni_focal') != null)
			document.getElementById('sr_uni_focal').style.display = 'none';
		if (document.getElementById('sr_hec') != null)
			document.getElementById('sr_hec').style.display = 'block';
	}
	
}
function swap(action,availcont,selectedcont){
	available_univs = document.getElementById(availcont);
	selected_univs = document.getElementById(selectedcont);
		
	var available_univs_len = available_univs.options.length;
	var selected_univs_len = selected_univs.options.length;
	
	switch(action){
		case 1:
			for(i=0;i<available_univs_len;i++) {
				val = available_univs.options[i].value;
				txt = available_univs.options[i].text;
				var opt = new Option(txt,val);
				selected_univs.options[selected_univs_len++] = opt;
			}
			for(i=available_univs_len-1;i>=0;i--) {
				available_univs.options[i] = null;
			}
			break;
		case 2:
			for(i=0;i<available_univs_len;i++) {
				if(available_univs.options[i].selected) {
					val = available_univs.options[i].value;
					txt = available_univs.options[i].text;
					var opt = new Option(txt,val);
					selected_univs.options[selected_univs_len++] = opt;
				}
			}
			for(i=available_univs_len-1;i>=0;i--) {
				if(available_univs.options[i].selected) {
					available_univs.options[i] = null;
				}
			}
			break;
		case 3:
			for(i=0;i<selected_univs_len;i++) {
				if(selected_univs.options[i].selected) {
					val = selected_univs.options[i].value;
					txt = selected_univs.options[i].text;
					var opt = new Option(txt,val);
					available_univs.options[available_univs_len++] = opt;
				}
			}
			for(i=selected_univs_len-1;i>=0;i--) {
				if(selected_univs.options[i].selected) {
					selected_univs.options[i] = null;
			}
			}
			break;
		case 4:
			for(i=0;i<selected_univs_len;i++) {
				val = selected_univs.options[i].value;
				txt = selected_univs.options[i].text;
				var opt = new Option(txt,val);
				available_univs.options[available_univs_len++] = opt;
			}
			for(i=selected_univs_len-1;i>=0;i--) {
				selected_univs.options[i] = null;
			}

			break;
	}
}

function selectUnivs() {
	
	if (typeof document.usermanageform.urss_hec_selected_university_id != 'undefined'){
		
		var selected_univs_len = document.usermanageform.urss_hec_selected_university_id.options.length;
		for(i=0;i<selected_univs_len;i++) {
			document.usermanageform.urss_hec_selected_university_id.options[i].selected = true;
		}
	}
	if (typeof document.usermanageform.sr_hec_selected_university_id != 'undefined'){
		var selected_univs_len2 = document.usermanageform.sr_hec_selected_university_id.options.length;
		for(i=0;i<selected_univs_len2;i++) {
			document.usermanageform.sr_hec_selected_university_id.options[i].selected = true;
		}
	}
	
}
// Calender script
function showCalendar(id) {
	var el = document.getElementById(id);
	//alert(el.name);
	if (calendar != null) {
		// we already have one created, so just update it.
		calendar.hide();		// hide the existing calendar
		calendar.parseDate(el.value); // set it to a new date
	} else {
		// first-time call, create the calendar
		var cal = new Calendar(true, null, selected, closeHandler);
		calendar = cal;		// remember the calendar in the global
		cal.setRange(1900, 2070);	// min/max year allowed
		calendar.create();		// create a popup calendar
		calendar.parseDate(el.value); // set it to a new date
	}
	calendar.sel = el;		// inform it about the input field in use
	calendar.showAtElement(el);	// show the calendar next to the input field

	// catch mousedown on the document
	Calendar.addEvent(document, "mousedown", checkCalendar);
	return false;
}
function checkCalendar(ev) {
	var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
	for (; el != null; el = el.parentNode)
	// FIXME: allow end-user to click some link without closing the
	// calendar.  Good to see real-time stylesheet change :)
	if (el == calendar.element || el.tagName == "A") break;
	if (el == null) {
		// calls closeHandler which should hide the calendar.
		calendar.callCloseHandler(); Calendar.stopEvent(ev);
	}
}
function selected(cal, date) {
	cal.sel.value = date; // just update the value of the input field
}
function closeHandler(cal) {
	cal.hide();			// hide the calendar

	// don't check mousedown on document anymore (used to be able to hide the
	// calendar when someone clicks outside it, see the showCalendar function).
	Calendar.removeEvent(document, "mousedown", checkCalendar);
}
// End Calender

function winopen(xurl,xwidth,xheight){
	params = 'toolbar=no,location=no,directories=no,status=yes,menubar=no,';
	params +='scrollbars=yes,resizable=no,width='+xwidth+',height='+xheight+',left=200,top=50';
	window.open (xurl,'ProdWind', params);
}
function winopen2(xurl,xwidth,xheight,obj,e){
	
	xleft = getposOffset(document.getElementById(obj),'left') - 100;	
	xtop = getposOffset(document.getElementById(obj),'top') + 50;
	params = 'toolbar=no,location=no,directories=no,status=no,menubar=no,';
	params +='scrollbars=no,resizable=no,width='+xwidth+',height='+xheight+',left='+xleft+',top='+xtop;
	window.open (xurl,'ProdWind', params);
}
// fck
function get_ed_text(editor_name){
   	var oEditor = FCKeditorAPI.GetInstance(editor_name) ;
   		if (oEditor.EditorDocument.body.innerHTML) { 
       	return oEditor.EditorDocument.body.innerHTML;
   	}
   	else return '';
}
function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}
