
//used on all pages, includes adding print button

function setup() {
	//for calendar
	var cal = new CalendarPopup();
	// creates print holder
	if (window.print) {
		if (document.getElementById('printholder')) {
			document.getElementById('printholder').innerHTML ='<div class="content lightblue print"><ul id="list_print"><li><a href="javascript:pageprint();" class="link_print">Print</a></li></ul></div>';
		}
		if (document.getElementById('printholder2')) {
		document.getElementById('printholder2').innerHTML ='<input type="submit" value="Print" onclick="javascript:pageprint();" />';
		}
		if (document.getElementById('printholder3')) {
		document.getElementById('printholder3').innerHTML ='<input type="submit" value="Print" onclick="javascript:pageprint();" />';
		}
	}
	// creates activity log lookup
	//if on activity log page, add open and close windows
	if (document.getElementById('lookup_holder')) {
		document.getElementById('lookup_holder').innerHTML = '<a href="#" onclick="showelement(\'guidance_notes\'); return false;">Look up codes in Study Guidance notes</a>';
		document.getElementById('closewin_holder').innerHTML = '<a href="#" onclick="hideelement(\'guidance_notes\'); return false;" id="close_win">close</a>';
		//hide the panel as its closed, but only if the select boxes within it are not in use
		if (document.getElementById('section').value =='' ) {
			hideelement('guidance_notes');
		}
	}
}

//prints page. called by setup()
function pageprint() {
	window.print();
}

//this is used by the document privacy toggle on the development pack pages
function submitform() {
	document.getElementById('development_pack_form').submit();
}

function showelement(element) {
	document.getElementById(element).style.display = 'block';
	document.getElementById(element).style.visibility = 'visible';

}

function hideelement(element) {
	document.getElementById(element).style.display = 'none';

}

function inputcheck(type,value) {
	//Quarterly Record check
	if (type == 'qr') {
		if (value == '' || value == 'a' ||  value == 'A' || value == 'b' || value == 'B' || value == 'c' || value == 'C' || value == 'd' || value == 'D') {
			exit;
		}
		else {
			alert('Please insert a letter from A to D');
		}
	}
}

function checkUncheckAll(theElement) {
	var theForm = theElement.form, z = 0;
	for(z=0; z < theForm.length;z++) {
  		if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall') {
 			theForm[z].checked = theElement.checked;
  		}
 	}
}

function replaceTextAreas() {
	var textAreas = document.getElementsByTagName("textarea"); 
	for (var i = 0; i < textAreas.length; i++) { 
    	var oFCKeditor = new FCKeditor( textAreas[i].name ) ;
		oFCKeditor.Width  = '75%';
		oFCKeditor.BasePath = '/fckeditor/';	
		oFCKeditor.ToolbarSet = 'S24' ;
		oFCKeditor.ReplaceTextarea() ;
	}
}