/* === TEST JAVASCRIPT SUPPORT === */ var DOM = !!(document.getElementById && document.getElementsByTagName); /* Basic W3C DOM Support */ var advDOM = !!(DOM && document.createElement); /* More Advanced W3C DOM Support */ /* === DEBUGING HELPERS === */ var debug = (getURLVars()['debug'] != null); function dalert(msg) { if (debug) alert(msg); } /* === SETTINGS AND GLOBAL VARIABLES === */ var popups = { // commonly used popup window settings full : "width=760,height=500,scrollbars,resizable,menubar,toolbar,location,status,directories", normal : "width=760,height=500,scrollbars,resizable,menubar", form : "width=760,height=500,scrollbars,resizable", notice : "width=240,height=200", movie : "width=450,height=400,status" }; var re = { // commonly used regex protocol : new RegExp("(ftp|https?)://"), index : new RegExp("(/|((default|index)\\.(htm|html|cfm|php)))$"), email : new RegExp("^(mailto:)?\\w+([+\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,})+$"), // bob@gmail.com or mailto:bob@gmail.com pccemail : new RegExp("^(mailto:)?\\w+([\\.-]?\\w+)*@pcc\\.edu$"), // webteam@pcc.edu or mailto:webteam@pcc.edu cfvar : new RegExp("^[A-z]\\w*$") // compliant coldfusion var name, used in form inspection }; var fns = {}; // folder alias' used in addDirNav() fns["/business"] = 'Center for Business and Industry'; fns["/resources/culture"] = 'Multicultural Center'; fns["/about/events/ease"] = 'EASE'; fns["/resources/academic/eac"] = 'Educational Advisory Council'; fns["/prepare/esl"] = 'English as a Second Language'; fns["/resources/first-term"] = 'Panther Tracks: First Term Guide'; fns["/resources/testing/ged"] = 'GED'; fns["/resources/guia"] = 'Gu\u00eda en Espa\u00F1ol'; // must use unicode for special chars fns["/resource/media"] = 'Media Services'; fns["/programs"] = 'Academic Programs'; fns["/resources/rcesc"] = 'Rock Creek Environmental Studies Center'; fns["/resources/tlc"] = 'Teaching Learning Center'; fns["/resources/css"] = 'Curriculum Support Services'; fns["/hr"] = 'Human Resources'; fns["/resources/tss"] = 'Technology Solutions Services'; fns["/programs/think-big"] = 'ThinkBIG'; fns["/resources/aspcc"] = 'ASPCC'; fns["/prepare/esol"] = 'ESOL'; fns["/business/ihp"] = 'Institute for Health Professionals'; fns["/community"] = 'Community Education'; fns["/programs/mri"] = 'MRI'; /* === INITIALIZE === */ // Use .ready to run functions prior to image load $(document).ready(function() { var i, j, o, c; //activateGnav(); // turn on correct tab designTime(); // Presentational Scripting linkSetup(); // setup links (to self, popup, etc.) addFeeds(); // Add Feed autofinds site-wide addDirNav(); // create breadcrumb style directory path links addFormValidation(); // add validation to forms setAnalytics(); // add google analytics }); // Use addEvent to run functions that require loaded images addEvent(window, "load", fixColumns); // extend main to match sidebar /* === ADD ANALYTICS TO THE PAGE === */ function setAnalytics() { var gaTrackCode = "UA-1329150-1"; var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); jQuery.getScript(gaJsHost + "google-analytics.com/ga.js", function(){ var pageTracker = _gat._getTracker(gaTrackCode); pageTracker._setDomainName("pcc.edu"); pageTracker._initData(); pageTracker._trackPageview(); }); } /* === ADD FEED AUTOFIND SITE-WIDE === */ function addFeeds() { $("head").append(''); $("head").append(''); $("head").append(''); } /* === PRESENTATIONAL SCRIPTING, FIXES AND HACKS === */ function designTime() { // remove design time styles to avoid breaking dw/contribute design view - lame I know $('body').removeClass('design-time'); // add corner to forms with class advanced $('form.advanced').css({position:"relative"}).append('
'); // add ! to alert $('#alert').prepend('!'); // update copyright var currentYear = (new Date()).getFullYear(); $('#copyright').text( $('#copyright').text().replace("2000","2000-"+currentYear) ); // collapse and animate dl.collapse $("dl.faq dd").hide(); $("dl.faq dt").click(function() { $(this).toggleClass("open"); $(this).nextUntil("dt").slideToggle("normal",fixColumns); // make sure that the column length is correct after change }).hover(function () { $(this).addClass("hover"); }, function () { $(this).removeClass("hover"); }); } // make sure #snav is not longer than #main function fixColumns() { try { // wrapping in empty try/catch block for silent failure var main = document.getElementById('main'), snav = document.getElementById('snav'); if (!main || !snav) return; // store default padding in global variable, needed for runtime changes (show/hide) if (window.defaultMainPaddingBottom == null) { if (main.currentStyle) window.defaultMainPaddingBottom = main.currentStyle.paddingBottom; else if (document.defaultView && document.defaultView.getComputedStyle) window.defaultMainPaddingBottom = document.defaultView.getComputedStyle(main,'').getPropertyValue('padding-bottom'); } // restore default padding before calculating column heights main.style.paddingBottom = window.defaultMainPaddingBottom; // add bottom padding to #main to make it at least as tall as snav if shorter if (main.offsetHeight < snav.offsetHeight) main.style.paddingBottom = parseInt(window.defaultMainPaddingBottom)+snav.offsetHeight-main.offsetHeight+'px'; } catch(e) { } } /* === CLASSNAME FUNCTIONS === */ String.prototype.hasClass = function(cls) { return new RegExp('(^| )'+cls+'( |$)').test(this); }; String.prototype.addClass = function(cls) { if (this == '') return cls; if (this.hasClass(cls)) return this; return this+" "+cls; }; String.prototype.removeClass = function(cls) { return this.replace(new RegExp('(^| )'+cls+'( |$)'), ''); }; function getElementsByClassName(node, cls, tag) { if (!DOM) return []; var i, elem, elems = node.getElementsByTagName( (tag != null ? tag : '*') ), results = []; for (i=0; elem = elems[i]; i++) if (elem.className.hasClass(cls)) results.push(elem); return results; } /* === URL/PATH/HISTORY INFORMATION/MANIPULATION === */ function getDirs(path) { // returns an array of directory hierarchy var folders = path.split('/'); if (folders[0] == "") folders.shift(); // remove empty first element if (re.index.test(folders[folders.length-1])) folders[folders.length-1] = ''; return folders; } function getReferringPage() { if (document.referrer) return document.referrer; else if (window.opener) return window.opener.location; else return ''; } function getURLVars() { var url = document.URL; //used document.URL instead of location because URL is returned as a string, location as an object if (!url || url.indexOf('?') < 0) return {}; var pairs, i, v, vars = {}; pairs = url.replace(/&(amp;)?/, '&').substring(url.lastIndexOf('?')+1).split('&'); //account for & and & delimeters for (i=0; i