var modified=0; var canSubmit = false; function tableEvenRows(tableID, start, lessMax, className) { var tab = document.getElementById(tableID); if(tab) { var rows = tab.rows; var evenRow=1; for(i=start;i<(rows.length-lessMax); i++) { evenRow^=1; if(evenRow) { row = rows[i]; row.className=className; } else { row = rows[i]; row.className=""; } } } } var CONTROL_TEXT = 1; var CONTROL_TEXTAREA = 2; var CONTROL_RICHEDIT = 3; function switch_control_locale(control_id, locale_id, control_type) { var clicked_link = document.getElementById(control_id+'_'+locale_id+'_link'); var clicked_field = document.getElementById(control_id+'_'+locale_id); var currsel_field = document.getElementById(control_id+'_currsel'); var currsel_link = document.getElementById(control_id+'_'+currsel_field.value+'_link'); var viewer; if(control_type==CONTROL_RICHEDIT) { viewer = CKEDITOR.instances[control_id+'_viewer']; } else { viewer = document.getElementById(control_id+'_viewer'); } var prevfield = document.getElementById(control_id+'_' + currsel_field.value); if(clicked_link==currsel_link) return false; if(clicked_link) { clicked_link.style.color = '#00c'; clicked_link.style.textDecoration = 'none'; currsel_field.value = locale_id; currsel_link.style.color = '#000'; currsel_link.style.textDecoration = 'underline'; // copy viewer text back to prev locale and then copy new locale text to viewer if(control_type==CONTROL_RICHEDIT) { prevfield.value = viewer.getData(); viewer.setData(clicked_field.value); } else if(control_type==CONTROL_TEXTAREA) { prevfield.value = viewer.value; viewer.value = clicked_field.value; } else { prevfield.value = viewer.value; viewer.value = clicked_field.value; } } return false; } function update_from_viewer(control_id, control_type) { var currsel_field_value = document.getElementById(control_id+'_currsel').value; var viewer; if(control_type==CONTROL_RICHEDIT) { if(CKEDITOR.instances[control_id+'_viewer']) { viewer = CKEDITOR.instances[control_id+'_viewer']; } } else { viewer = document.getElementById(control_id+'_viewer'); } var hidden_field_name = control_id+'_'+currsel_field_value; var hidden_field = document.getElementById(hidden_field_name); if(control_type==CONTROL_RICHEDIT) { if(CKEDITOR.instances[control_id+'_viewer']) { hidden_field.value = viewer.getData(); } } else if(control_type==CONTROL_TEXTAREA) { hidden_field.value = viewer.value; } else { hidden_field.value = viewer.value; } return false; } function setModified() { if(modified==0) { modified=1; document.title = document.title+" * (Modified)"; box = document.getElementById("modifiedBox"); if(box) { box.style.backgroundColor="brown"; box.style.fontWeight="900"; box.style.fontSize="8pt"; box.style.padding="3px"; box.innerHTML="Page has been modified"; } box2 = document.getElementById("modifiedBox2"); if(box2) { box2.style.backgroundColor="brown"; box2.style.fontWeight="900"; box2.style.fontSize="8pt"; box2.style.padding="3px"; box2.innerHTML="Page has been modified"; } window.onbeforeunload = checkPageModifiedBeforeUnload; } return true; // don't mess up other events because of this flag } function setCanSubmit() { canSubmit = true; // loop through any ckeditor instances and fire blur event for(var i in CKEDITOR.instances) { if(i) { CKEDITOR.instances[i].fire('blur', ''); } } } function setCanSubmitWithConfirm(confirm_msg) { if ((confirm_msg == '') || confirm(confirm_msg)) { setCanSubmit(); return true; } else { return false; } } function isModified() { return modified; } function checkPageModifiedBeforeUnload() { if (modified && !canSubmit) { return "You have made changes to this page. Click OK to continue without saving or Cancel to return to this page so you can save your changes.\n\nNote: If you click OK you will lose any changes you have made to this page."; } } function checkPageModified() { if(modified) { return confirm("You have made changes to this page. Click OK to continue without saving or Cancel to return to this page so you can save your changes.\n\nNote: If you click OK you will lose any changes you have made to this page."); } else { return true; } } function createMapQuestURL(field,address,city,province,postal) { if(trim(address)=="") { alert("Address needed for map to work properly."); return false; } if(trim(city)=="") { alert("City needed for map to work properly."); return false; } if(trim(province)=="") { alert("Province needed for map to work properly."); return false; } var country = "CA"; switch(province) { case 'AB': country = "CA"; break; case 'BC': country = "CA"; break; case 'MB': country = "CA"; break; case 'NB': country = "CA"; break; case 'NL': country = "CA"; break; case 'NT': country = "CA"; break; case 'NS': country = "CA"; break; case 'NU': country = "CA"; break; case 'PE': country = "CA"; break; case 'SK': country = "CA"; break; case 'ON': country = "CA"; break; case 'QC': country = "CA"; break; case 'YT': country = "CA"; break; default: country = "US"; break; } var link = 'http://www.mapquest.com/maps/map.adp?formtype=address&country='+country+'&address='+address+'&city='+city+'&state='+province+'&zip='+postal; document.getElementById(field).value=link; return false; } function createGoogleMapURL(field,address,city,province,postal) { if(trim(address)=="") { alert("Address needed for map to work properly."); return false; } if(trim(city)=="") { alert("City needed for map to work properly."); return false; } if(trim(province)=="") { alert("Province needed for map to work properly."); return false; } var link = 'http://maps.google.ca/maps?f=q&hl=en&z=11&q='+address+','+city+','+province+','+postal.substr(0,3); document.getElementById(field).value=link; return false; } function openRemoteURL(field1,field2) { var url = document.getElementById(field1).value; if(url=="") { alert("No MAP URL exists."); return false; } var test = document.getElementById(field2); test.href=url; return true; } function confirmDeleteSite() { return(confirm("Are you sure you wish to delete this site?\n\nPlease note that if the site is being pointed to by course data deletion will not be possible. Your best course of action at this point is to just set it to in-active so it no longer shows in drop down lists.")); } function checkModified(editorInstance) { if(editorInstance.checkDirty()) setModified(); } function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""); } function ltrim(stringToTrim) { return stringToTrim.replace(/^\s+/,""); } function rtrim(stringToTrim) { return stringToTrim.replace(/\s+$/,""); } function iterate_markers($markers) { for(var i=0;i\n\n\n"; windowFeatures ="menubar=no,scrollbars=no,location=no,favorites=no,resizable=no,status=no,toolbar=no,directories=no"; var test = "'"; winLeft = (screen.width-width)/2; winTop = (screen.height-(height+110))/2; newWindow = open( '', 'newWin',"width=" + width +",height=" + height + ",left=" + winLeft + ",top=" + winTop + test + windowFeatures + test); if( bOverwrite != false ) { newWindow.document.close(); newWindow.document.open(); } newWindow.document.write( sHead ); newWindow.document.write( sBody ); if( iTimeout > 0 ) { setTimeout( 'closeWin( newWindow )', iTimeout ); // delay x seconds before closing } } function closeWin( objWindow ) { objWindow.close(); // close this window, like from a timed period (as timed events are seperate from their calling functions, and persist) } function date_detail_popup(classID) { popup = window.open('https://pdis.ntanu.ca/date_detail_popup.php?classID='+classID, 'date_popup', 'width=700,height=500,menubar=no,scrollbars=yes,location=no,favorites=no,resizable=yes,status=no,toolbar=no,directories=no'); } function class_settings_popup(id) { popup = window.open('https://pdis.ntanu.ca/admin/class_settings_popup.php?id='+id, 'settings_popup', 'width=800,height=600,menubar=no,scrollbars=yes,location=no,favorites=no,resizable=yes,status=no,toolbar=no,directories=no'); popup.moveTo(0,0); } function course_detail_popup(id) { popup = window.open('https://pdis.ntanu.ca/admin/course_detail_popup.php?id='+id, 'course_detail_popup', 'width=600,height=400,menubar=no,scrollbars=yes,location=no,favorites=no,resizable=yes,status=no,toolbar=no,directories=no'); } function session_list_popup(course_code, active_school_year) { if(course_code=="" || active_school_year=="") { alert("Please make certain that you are on a valid class and also that the Active School year below is set to a valid value."); return false; } popup = window.open('https://pdis.ntanu.ca/admin/session_list_popup.php?course_code='+course_code+'&active_school_year='+active_school_year, 'session_list_popup', 'width=700,height=550,menubar=no,scrollbars=yes,location=no,favorites=no,resizable=yes,status=no,toolbar=no,directories=no'); return false; } function Toggle(id) { // Try to get the FCKeditor instance, if available. var oEditor ; if ( typeof( FCKeditorAPI ) != 'undefined' ) oEditor = FCKeditorAPI.GetInstance( 'DataFCKeditor' ) ; // Get the _Textarea and _FCKeditor DIVs. var eTextareaDiv = document.getElementById( 'Textarea'+id ) ; var eFCKeditorDiv = document.getElementById( 'FCKeditor'+id ) ; // If the _Textarea DIV is visible, switch to FCKeditor. if ( eTextareaDiv.style.display != 'none' ) { // If it is the first time, create the editor. if ( !oEditor ) { CreateEditor(id) ; } else { // Set the current text in the textarea to the editor. oEditor.SetData( document.getElementById('DataTextarea'+id).value ) ; } // Switch the DIVs display. eTextareaDiv.style.display = 'none' ; eFCKeditorDiv.style.display = '' ; // This is a hack for Gecko 1.0.x ... it stops editing when the editor is hidden. if ( oEditor && !document.all ) { if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG ) oEditor.MakeEditable() ; } } } function CreateEditor(id) { // Copy the value of the current textarea, to the textarea that will be used by the editor. document.getElementById('DataFCKeditor'+id).value = document.getElementById('DataTextarea'+id).value ; // Automatically calculates the editor base path based on the _samples directory. // This is usefull only for these samples. A real application should use something like this: // oFCKeditor.BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value. var sBasePath = 'https://pdis.ntanu.ca/fckeditor/'; // Create an instance of FCKeditor (using the target textarea as the name). var oFCKeditor = new FCKeditor( 'DataFCKeditor'+id ) ; oFCKeditor.BasePath = sBasePath ; oFCKeditor.Width = '100%' ; oFCKeditor.Height = '150' ; oFCKeditor.ReplaceTextarea() ; } function SaveFCKtoTextarea( editorInstance ) { var fck = editorInstance.Name; var text = fck.replace('FCKeditor','Textarea'); document.getElementById(text).value = editorInstance.GetXHTML() ; if(editorInstance.IsDirty()) { setModified(); } return(false); } function FCKeditor_OnComplete( editorInstance ) { editorInstance.Events.AttachEvent( 'OnBlur', SaveFCKtoTextarea ) ; } function open_email_client_post(form, paramList, path) { if(path!='') { alert (path); emailclient = window.open(path+"?"+paramList, "email_client", "width=800, height=632, statusbar=0, scrollbars=yes, resizable=yes"); } else { emailclient = window.open("https://pdis.ntanu.ca/email_compose.php?"+paramList, "email_client", "width=800, height=632, statusbar=0, scrollbars=yes, resizable=yes"); } emailclient.blur(); form.target="email_client"; emailclient.focus(); return false; } function clear_form(form_id) { if(document.getElementById(form_id)) { formObj = document.getElementById(form_id); var field_type = ''; for(i=0; i < formObj.elements.length; i++ ) { field_type = formObj.elements[i].type.toLowerCase(); switch(field_type) { case 'text': formObj.elements[i].value = ''; break; case 'select': case 'select-one': case 'select-multiple': formObj.elements[i].selectedIndex = 0; break; case 'checkbox': case 'radio': formObj.elements[i].checked = false; break; case 'textbox': formObj.elements[i].innerHTML = ''; break; } } } } function open_ed_leave_email_client_post(education_leave_id,email_template_id,letter_name) { emailclient = window.open("https://pdis.ntanu.ca/ed_leave_email_compose.php?education_leave_id="+education_leave_id+"&email_template_id="+email_template_id+"&letter_name="+letter_name, "email_client", "width=800, height=632, statusbar=0, scrollbars=yes, resizable=yes"); emailclient.blur(); form.target="email_client"; emailclient.focus(); return false; } function open_project_overseas_email_client_post(project_overseas_id,email_template_id,letter_name) { emailclient = window.open("https://pdis.ntanu.ca/project_overseas_email_compose.php?project_overseas_id="+project_overseas_id+"&email_template_id="+email_template_id+"&letter_name="+letter_name, "email_client", "width=800, height=632, statusbar=0, scrollbars=yes, resizable=yes"); emailclient.blur(); form.target="email_client"; emailclient.focus(); return false; }