/* Primary Script Library for www.pcc.edu | Source: http://www.pcc.edu/_source/scripts/pcclib.source.js */
var DOM=!!(document.getElementById&&document.getElementsByTagName);var advDOM=!!(DOM&&document.createElement);var debug=(getURLVars()['debug']!=null);function dalert(msg){if(debug)alert(msg);}var popups={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={protocol:new RegExp("(ftp|https?)://"),index:new RegExp("(/|((default|index)\\.(htm|html|cfm|php)))$"),email:new RegExp("^(mailto:)?\\w+([+\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,})+$"),pccemail:new RegExp("^(mailto:)?\\w+([\\.-]?\\w+)*@pcc\\.edu$"),cfvar:new RegExp("^[A-z]\\w*$")};var fns={};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';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["/community"]='Community Education';fns["/programs/mri"]='MRI';fns["/about/business-opportunities/mwesb"]='MWESB';fns["/pavtec"]='PAVTEC';$(document).ready(function(){var i,j,o,c;designTime();linkSetup();addFeeds();addDirNav();addFormValidation();setAnalytics();addNews();});addEvent(window,"load",fixColumns);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();});}function addNews(){$(".pccnews").each(function(){var feed_string=encodeURI($(this).attr("title"));$(this).load("/about/feeds/proxy/pccnews.cfm?"+feed_string);});}function addFeeds(){$("head").append('<link rel="alternate" type="application/rss+xml" title="News Releases | Portland Community College" href="http://www.pcc.edu/about/feeds/news/" />');$("head").append('<link rel="alternate" type="application/rss+xml" title="Profiles | Portland Community College" href="http://www.pcc.edu/about/feeds/profiles/" />');$("head").append('<link rel="alternate" type="application/rss+xml" title="Videos | Portland Community College" href="http://www.pcc.edu/about/feeds/videos/" />');}function designTime(){$('body').removeClass('design-time');$('form.advanced').css({position:"relative"}).append('<div id="foldcorner" class="corner"/>');$('#alert').prepend('<span id="alert-icon">!</span>');var currentYear=(new Date()).getFullYear();$('#copyright').text($('#copyright').text().replace("2000","2000-"+currentYear));$("dl.collapse dd").hide();$("dl.collapse dt").click(function(){$(this).toggleClass("open");$(this).nextUntil("dt").slideToggle("normal",fixColumns);}).hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");});}function fixColumns(){try{var main=document.getElementById('main'),snav=document.getElementById('snav');if(!main||!snav)return;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');}main.style.paddingBottom=window.defaultMainPaddingBottom;if(main.offsetHeight<snav.offsetHeight)main.style.paddingBottom=parseInt(window.defaultMainPaddingBottom)+snav.offsetHeight-main.offsetHeight+'px';}catch(e){}}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;}function getDirs(path){var folders=path.split('/');if(folders[0]=="")folders.shift();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;if(!url||url.indexOf('?')<0)return{};var pairs,i,v,vars={};pairs=url.replace(/&(amp;)?/,'&amp;').substring(url.lastIndexOf('?')+1).split('&amp;');for(i=0;i<pairs.length;i++){v=pairs[i].split('=');vars[v[0]]=unescape(v[1]);}return vars;}function populateFormFromGets(){if(!DOM)return;var id,vars=getURLVars();for(id in vars)if(document.getElementById(id)&&document.getElementById(id).value!=null)document.getElementById(id).value=unescape(vars[id]);}function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}else var expires="";document.cookie=name+"="+value+expires+"; path=/";}function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}return null;}function eraseCookie(name){createCookie(name,"",-1);}function filterPath(string){return string.replace(/^\//,'').replace(/(index|default).[a-zA-Z]{3,4}$/,'').replace(/\/$/,'');}function linkSetup(){var locationPath=filterPath(location.pathname);$("a[href]").each(function(){var thisPath=filterPath(this.pathname);if(locationPath==thisPath&&(location.hostname==this.hostname)&&!this.href.match(/(\?|#)/)){$(this).addClass('current');}});$("a[href*=.pdf]:parent:not(:has(img))").append(' <em class="link-type" title="Portable Document Format - www.pcc.edu/help/">[pdf]</em>');$("a[href*=.doc]:parent:not(:has(img))").append(' <em class="link-type" title="Microsoft Word Document - www.pcc.edu/help/">[doc]</em>');$("a[href*=.xls]:parent:not(:has(img))").append(' <em class="link-type" title="Microsoft Excel Document - www.pcc.edu/help/">[xls]</em>');$("a[@href^=http://intranet.pcc.edu]:parent:not(:has(img))").append(' <em class="link-type" title="Only Available on PCC Campus - www.pcc.edu/help/">[intranet]</em>');$("a[href^=mailto:][href$=@pcc.edu]:not([onclick])").each(function(){var address=$(this).attr("href").replace('mailto:','');var linkHtml=$(this).html();if($(this).attr("title").length){address+="&subject="+$(this).attr("title");}else{$(this).attr("title","Send mail to "+address);}$(this).attr("href","http://www.pcc.edu/resources/web/forms/email/?to="+address).html(linkHtml).addClass('popup');});$("a[class^=popup]:not([onclick])").click(function(){var s=/popup-(\w+)/.exec(this.className);s=s?s[1]:'default';return popup(this.href,s);});}function popup(url,s){if(!url)return true;if(window.opener)window.location=url;else window.open(url,'popup'+(new Date().getSeconds()),(s&&popups[s])?popups[s]:popups.normal);return false;}function addDirNav(){if(!advDOM)return;hostname=location.hostname.split('.').reverse();if(hostname[0]!="edu"||hostname[1]!="pcc"||hostname[2]!="www")return;var stitle=document.getElementById('stitle');if(!stitle||document.getElementById('dirnav')||document.getElementById('page').className.hasClass('popup'))return;var folders=getDirs(window.location.pathname);if(folders.length<2||(folders.length==2&&folders[folders.length-1]==''))return;if(folders.pop()=='')folders[folders.length-1]='';folders.unshift('PCC');var p,i,j,f,a,href,c='';p=document.createElement('p');p.setAttribute('id','dirnav');for(i=0;i<folders.length;i++){f=unescape(folders[i]);if(f=='')continue;if(i>0)c+='/'+f;f=(fns[c])?fns[c]:f.replace(/-/g,' ');a=document.createElement('a');href='';j=folders.length-i;if(j==1)href+="./";else while(--j)href+="../";a.setAttribute('href',href);a.appendChild(document.createTextNode(f));p.appendChild(a);p.appendChild(document.createTextNode(' \u002f '));}stitle.insertBefore(p,stitle.firstChild);}function addFormValidation(){if(!DOM)return;var i,form,forms=document.getElementsByTagName('form');for(i=0;frm=forms[i];i++){if(frm.onsubmit==null){frm.onsubmit=function(){return validateForm(this);};}if(frm.onreset==null){frm.onreset=function(){return resetWarning(this);};}}}function resetWarning(frm,s){return confirm("Are you sure you want to clear the form?\nYou will have to start over...");}var valid=validateForm;function validateForm(frm,s){if(!DOM||!frm)return;var silent=(s||s=='silent')?true:frm.className.hasClass('fail-silent')?true:false;var i,j,ok,field,errors=[],devErrors=[];for(i in frm.elements){field=frm.elements[i];if(field&&field.type){if(field.name&&!re.cfvar.test(field.name)){devErrors.push("Invalid field name: \""+field.name+"\"");}if(field.id&&!re.cfvar.test(field.id)){devErrors.push("Invalid field id: \""+field.id+"\"");}}if(field&&field.className&&field.className.hasClass('required')){switch(field.type){case'text':case'textarea':case'password':if(!(/\w+/).test(field.value))errors.push(field);else if(field.className.hasClass('pccemail')){if(!re.pccemail.test(field.value)){errors.push(field);}}else if(field.className.hasClass('email')){if(field.value.toLowerCase()=='none'){field.value='webadmin@pcc.edu';}else if(!re.email.test(field.value)){errors.push(field);}}break;case'select-one':case'select-multiple':if(field.selectedIndex<0||field.options[field.selectedIndex].value=="null")errors.push(field);break;case'radio':for(j=0,ok=false;j<frm[field.name].length;j++){if(frm[field.name][j].checked){ok=true;break;}}if(!ok){for(j=0,ok=false;j<errors.length;j++){if(errors[j].name==field.name){ok=true;break;}}if(!ok)errors.push(field);}break;case'checkbox':if(!field.checked)errors.push(field);break;}}}if(devErrors.length>0){var mess="Warning - this form contains errors...\n\n";for(i in devErrors){mess+="     "+devErrors[i]+"\n";}mess+="\nPlease contact webteam@pcc.edu\n";alert(mess);return false;}else if(errors.length>0){if(!silent){var mess="The form appears to be incomplete, please include...\n\n";for(i in errors){if(errors[i].title){j=errors[i].title;}else if((errors[i].parentNode.nodeName=="LABEL")&&(errors[i].parentNode.title)){j=errors[i].parentNode.title;}else{j=errors[i].name;}mess+="    * "+j+'\n';}alert(mess);}errors[0].focus();return false;}return true;}function getLabel(field){var i,labels=document.getElementsByTagName("label");for(i=0;i<labels.length;i++){if(labels[i].htmlFor==field.id)return labels[i];}return null;}function addEvent(elm,evType,fn,useCapture){if(elm.addEventListener){elm.addEventListener(evType,fn,useCapture);return true;}else if(elm.attachEvent){var r=elm.attachEvent("on"+evType,fn);return r;}else{return false;}}function removeEvent(elm,evType,fn,useCapture){if(elm.removeEventListener){elm.removeEventListener(evType,fn,useCapture);return true;}else if(elm.detachEvent){var r=elm.detachEvent("on"+evType,fn);return r;}else{return false;}}function addCorner(elem,cornerId){var o=(typeof elem=='string')?document.getElementById(elem):elem;if(!elem)return false;var corner=document.createElement('div');if(cornerId)corner.id=cornerId;corner.className='corner';elem.appendChild(corner);return true;}
