/**************************************** | | Ivey Eye Institute | http://www.iveyeye.ca | | Created by: Kevin Biskaborn | Copyright 2013 ScriptReaction | http://www.scriptreaction.com | ***************************************** | Load Dependencies : None | Run Dependencies : None ****************************************/ var Global = { includePrefix: "", controls: { allowImageAltStripping: true }, preload: function (){ this.addEvent( window, "load", this.postload ); }, postload: function (){ Global.format.pageImages(); }, exists: function ( object ){ return ( typeof( object ) == "undefined" ) ? false : true; }, addEvent: function ( object, eventType, functionName ){ if( object.addEventListener ){ object.addEventListener( eventType, functionName, false ); return true; } else if( object.attachEvent ) return object.attachEvent( "on" + eventType, functionName ); else return false; }, attach: { cssLink: function ( fileId ){ output = ""; output += ""; this.toDoc( output ); }, jsLink: function ( fileId ){ output = ""; output += ""; this.toDoc( output ); }, toDoc: function ( output ){ document.writeln( output ); } }, format: { pageImages: function (){ if( Global.exists( Browser ) && Browser.isIE() ){ var imageArray = document.images; var whichImage; for( var i = 0; i < imageArray.length; i++ ){ whichImage = imageArray[ i ]; whichImage.galleryimg = "no"; if( Global.controls.allowImageAltStripping ) whichImage.alt = ""; } } } }, display: { goTop: function (){ var y1=y2=y3=0;if(document.documentElement){y1=document.documentElement.scrollTop||0;};if(document.body){y2=document.body.scrollTop||0;}; y3=window.scrollY||0;var y=Math.max(y1,Math.max(y2,y3));window.scrollTo(0,Math.floor(y/1.4));if(y>0){window.setTimeout("Global.display.goTop()",25);}; } }, modify: { setDivContent: function ( divId, content ){ if( document.all ) this.divContent( document.all[ divId ], content ); else this.divContent( document.getElementById( divId ), content ); }, divContent: function ( div, content ){ if( div ) div.innerHTML = content; }, setAlpha: function ( object, opacity ){ opacity = ( opacity == 100 ) ? 99.999 : opacity; object.style.filter = "alpha(opacity:" + opacity + ")"; //ie/win object.style.KHTMLOpacity = opacity/100; //safari<1.2,konqueror object.style.MozOpacity = opacity/100; //older mozilla/firefox object.style.opacity = opacity/100; //safari 1.2,newer firefox/mozilla,css3 } }, email: { count: 0, attach: function ( requestObj ){ var output = ""; var address = this.build( requestObj ); if( address ){ output += ""; output += ""; output += address + ""; } if( output ) Global.attach.toDoc( output ); }, build: function ( requestObj ){ var output = null; //** specify the length of the dynamic prefix appended to each data field ** var dataPrefixLength = 6; var domain = ( typeof( requestObj.d ) == "undefined" ) ? null : requestObj.d.slice( dataPrefixLength ); var ext = ( typeof( requestObj.e ) == "undefined" ) ? "com" : requestObj.e.slice( dataPrefixLength ); var user = ( typeof( requestObj.u ) == "undefined" ) ? null : requestObj.u.slice( dataPrefixLength ); if( domain && user ) this[ "emailObj_" + ++this.count ] = output = user + "@" + domain + "." + ext; return output; }, execute: function (){ var id = parseInt( arguments[ 0 ] ); if( id && id > 0 && this[ "emailObj_" + id ] ) top.location.href = "mailto:" + this[ "emailObj_" + id ]; } } } /******** GLOBAL LAUNCH ********/ Global.preload(); /**************************************** | | Ivey Eye Institute | http://www.iveyeye.ca | | Created by: Kevin Biskaborn | Copyright 2013 ScriptReaction | http://www.scriptreaction.com | ***************************************** | Load Dependencies : None | Run Dependencies : None ****************************************/ /* * Doctor Focus Group (Manager) * * Stores and handles the creation * of the individual groups */ var manager_doctorFocusGroup = { settings: { activeTabClassName: "active", tabItemPrefix: "_tab_", blockItemPrefix: "_block_" }, //store the group objects created groupsCreated: Array(), //creates a new object instance //with requested params launch: function ( inputObject ){ var groupId = inputObject[ "focusGroupId" ]; if( groupId != null ){ //add the group to the creation array //and initilize a new group object this.groupsCreated.unshift( new instance_doctorFocusGroup( inputObject ) ); } //return the newest group object return this.groupsCreated[ 0 ]; } } /* * Doctor Focus Group (Instance) * * An object of a focus group created * by the manager. Handles the tab * navigation of the group */ var instance_doctorFocusGroup = function ( inputObject ){ this.groupId = inputObject[ "focusGroupId" ]; this.itemCount = inputObject[ "blockCount" ]; this.startIndex = inputObject[ "selectedIndex" ]; this.launch = function (){ this.setup(); this.activateTab( this.startTab ); } this.getElement_byId = function ( id ){ return document.getElementById( id ); } this.setup = function (){ //create a reference to this group var groupInstance = this; //create a holder for the starting tab this.startTab = null; //create an array to hold all tabs this.tabOptions = new Array(); //create an array to hold the linked blocks this.linkedBlockElements = new Array(); //create element containers var navTab, aTag = null; //populate the navigation tabs for( var i = 1; i <= this.itemCount; i++ ){ //get ech navigation tab element navTab = this.getElement_byId( this.groupId + manager_doctorFocusGroup.settings.tabItemPrefix + i ); //set the tab click action navTab.onclick = function (){ groupInstance.handleClick( this ); } //get the tab anchor aTag = navTab.getElementsByTagName( "a" )[ 0 ]; //set the anchor click action aTag.onclick = function (){ this.blur(); return false; } //save the linked block this.linkedBlockElements.push( new instance_doctorBlockItem( this.getElement_byId( this.groupId + manager_doctorFocusGroup.settings.blockItemPrefix + i ) ) ); //save the tab item this.tabOptions.push( navTab ); //check for the starting tab if( this.startTab == null && i == this.startIndex ) this.startTab = navTab; } //default to first tab if starting tab not specified if( this.startTab == null ) this.startTab = this.tabOptions[ 0 ]; } this.handleClick = function ( tabItem ){ this.deactivateAll(); this.activateTab( tabItem ); } this.activateTab = function ( tabItem ){ tabItem.className = manager_doctorFocusGroup.settings.activeTabClassName; this.activate_action( tabItem ); } this.deactivateTab = function ( tabItem ){ tabItem.className = ""; this.deactivate_action( tabItem ); } this.deactivateAll = function (){ //cycle through all tabs for( var i = 0; i < this.tabOptions.length; i++ ) this.deactivateTab( this.tabOptions[ i ] ); } this.activate_action = function ( tabItem ){ this.activateBlock_byIndex( this.getTabIndex_fromTabItem( tabItem ) ); } this.deactivate_action = function ( tabItem ){ //cycle through all linked blocks for( var i = 0; i < this.linkedBlockElements.length; i++ ) this.linkedBlockElements[ i ].deactivateBlock(); } this.getTabIndex_fromTabItem = function ( tabItem ){ tabElementId = tabItem.id; //get the last underscore index lastUScoreIndex = tabElementId.lastIndexOf( "_" ); //get the element id number idNumber = tabElementId.slice( lastUScoreIndex + 1, tabElementId.length ); //return the element array index return parseInt( idNumber, 10 ) - 1; } this.activateBlock_byIndex = function ( blockIndex ){ this.linkedBlockElements[ blockIndex ].activateBlock(); } //initilize the object this.launch(); } /* * Doctor Block Item * * An single doctom block item linked * to a corresponding tab in the parent * group object. Handles the block * appearance and fade transitions */ var instance_doctorBlockItem = function ( objectElement ){ this.objectElement = objectElement; this.setElementDisplay = function ( displayStyle ){ this.objectElement.style.display = displayStyle; } this.activateBlock = function (){ this.setElementDisplay( "block" ); } this.deactivateBlock = function (){ this.setElementDisplay( "none" ); } } /**************************************** | | Ivey Eye Institute | http://www.iveyeye.ca | | Created by: Kevin Biskaborn | Copyright 2013 ScriptReaction | http://www.scriptreaction.com | ***************************************** | Load Dependencies : Global | Run Dependencies : None ****************************************/ /* * Focal Feed (Manager) */ var FocalFeed = { settings: { addClassToNewWindowHrefTags: true, addStyleToTopOfWindowSpanTags: true, newWindowHrefTagClass: "openWindowLink" }, launch: function (){ // check for new window hrefs if( this.settings.addClassToNewWindowHrefTags ) this.actions.applyNewWindowHrefTags(); // check for top of window links if( this.settings.addStyleToTopOfWindowSpanTags ) this.actions.applyTopOfWindowSpanTags(); }, get: { focalFeedContainer: function (){ return this.element_byId( "focalfeed" ); }, element_byId: function ( id ){ return document.getElementById( id ); } }, actions: { applyNewWindowHrefTags: function (){ //get the focal feed div element var targetContainer = FocalFeed.get.focalFeedContainer(); //get all divs in the container var feedDivArray = targetContainer.getElementsByTagName( "div" ); //set the target div var applyToTargetId = "contentColumnLeft"; var divElement = null; var targetFound = false; //cycle through all div elements for( var i = 0; i < feedDivArray.length && !targetFound; i++ ){ divElement = feedDivArray[ i ]; //test each div id for the target if( divElement.id == applyToTargetId ){ targetFound = true; //get all anchor tags in the div var anchorArray = divElement.getElementsByTagName( "a" ); var aElement = null; // cycle through all anchor elements for( j in anchorArray ){ aElement = anchorArray[ j ]; // test if the anchor target is a new window // AND that it is NOT flagged as noAutoTarget if( aElement.target == "_blank" && !JS_Format.elementClass.existsOnElement( aElement, "noAutoTarget" ) ) // add the new window class JS_Format.elementClass.addToElement( aElement, FocalFeed.settings.newWindowHrefTagClass ); } } } //end outer for loop }, applyTopOfWindowSpanTags: function (){ // get the focal feed div element var targetContainer = FocalFeed.get.focalFeedContainer(); // get all span tags in the container var arrayOfSpanTags = targetContainer.getElementsByTagName( "span" ); // create the tag contents // to be placed inside all matching tags var tagContents = ""; // create loop containers var spanTag = null; // cycle through all tag elements for( var i in arrayOfSpanTags ){ // get the next tag spanTag = arrayOfSpanTags[ i ]; // check the class of the tag if( spanTag.className == "auto_TopOfPageLink" ){ // set the contents of the tag JS_Format.divElement.setDivContent_byDivElement( spanTag, tagContents ); // set the onclick handler of the tag spanTag.onclick = function (){ Global.display.goTop(); } } } // end tag element loop } } } /**************************************** | | Ivey Eye Institute | http://www.iveyeye.ca | | Created by: Kevin Biskaborn | Copyright 2013 ScriptReaction | http://www.scriptreaction.com | ***************************************** | Load Dependencies : Global | Run Dependencies : None ****************************************/ /* * Administration Controller */ var Administration_Controller = { Common: { submitForm: function ( formId ){ document[ formId ].submit(); } }, Logout: { formId_logout: "FRM_Logout", execute: function (){ Administration_Controller.Common.submitForm( Administration_Controller.Logout.formId_logout ); } }, Login: { preload: function (){ Global.addEvent( window, "load", Administration_Controller.Login.postload ); }, postload: function (){ // call the update form function Administration_Controller.Login.updateForm(); // create a delay on the function call setTimeout( "Administration_Controller.Login.updateForm()", 100 ); }, formId_login: "FRM_adminLogin", fieldId_userName: "login_user", fieldId_password: "login_pass", fieldId_submitBtn: "login_confirm", minLength_userName: 6, minLength_password: 8, get: { elementById: function ( id ){ return document[ Administration_Controller.Login.formId_login ][ id ]; }, field_userName: function (){ return this.elementById( Administration_Controller.Login.fieldId_userName ); }, field_password: function (){ return this.elementById( Administration_Controller.Login.fieldId_password ); }, field_loginBtn: function (){ return this.elementById( Administration_Controller.Login.fieldId_submitBtn ); } }, action: { btn_over: function ( btnId ){ var btn = Administration_Controller.Login.get.elementById( btnId ); JS_Format.elementClass.addToElement( btn, "active" ); }, btn_out: function ( btnId ){ var btn = Administration_Controller.Login.get.elementById( btnId ); JS_Format.elementClass.removeFromElement( btn, "active" ); }, btn_click: function ( btnId ){ var btn = Administration_Controller.Login.get.elementById( btnId ); JS_Format.elementClass.removeFromElement( btn, "active" ); Administration_Controller.Login.btn.deactivate( btnId ); }, btn_submit: function ( btnId ){ // use this function when the button press is also the submit action // call the button click Administration_Controller.Login.action.btn_click( btnId ); // call the form submit Administration_Controller.Login.action.submitForm(); }, submitForm: function (){ document[ Administration_Controller.Login.formId_login ].submit(); } }, btn: { activate: function ( btnId ){ var btn = Administration_Controller.Login.get.elementById( btnId ); btn.disabled = false; JS_Format.elementClass.removeFromElement( btn, "locked" ); }, deactivate: function ( btnId ){ var btn = Administration_Controller.Login.get.elementById( btnId ); btn.disabled = true; JS_Format.elementClass.addToElement( btn, "locked" ); } }, updateForm: function (){ var fieldIsValid_userName = false; var fieldIsValid_password = false; // get the fields var field_userName = Administration_Controller.Login.get.field_userName(); var field_password = Administration_Controller.Login.get.field_password(); // get the field values if( field_userName.value.length >= Administration_Controller.Login.minLength_userName ) fieldIsValid_userName = true; if( field_password.value.length >= Administration_Controller.Login.minLength_password ) fieldIsValid_password = true; // get the button id var btnId = Administration_Controller.Login.fieldId_submitBtn; // check if the fields are valid if( fieldIsValid_userName && fieldIsValid_password ) Administration_Controller.Login.btn.activate( btnId ); else // fields are NOT valid Administration_Controller.Login.btn.deactivate( btnId ); } } } /**************************************** | | Ivey Eye Institute | http://www.iveyeye.ca | | Created by: Kevin Biskaborn | Copyright 2013 ScriptReaction | http://www.scriptreaction.com | ***************************************** | Load Dependencies : Global{} | Run Dependencies : None ****************************************/ var Browser = { info: { type: "", version: -1 }, controls: { useBrowserSpecificCSS: true }, preload: function (){ this.detect.clientBrowser(); this.populate.css(); }, detect: { clientBrowser: function (){ if( window.XMLHttpRequest ){ if( document.documentMode ){ // IE 8+ (NOTE THE PLUS, catches all newer browsers) Browser.info.type = "ie"; Browser.info.version = 8; return; } else if( window.ActiveXObject && !document.documentMode ){ // IE 7 Browser.info.type = "ie"; Browser.info.version = 7; return; } else { // Opera, Safari, Firefox Browser.info.type = "gecko"; return; } } else { // IE6 and below Browser.info.type = "ie"; Browser.info.version = 6; } } }, populate: { css: function (){ if( Browser.controls.useBrowserSpecificCSS && Browser.isIE() ){ var cssUrl = ""; switch( Browser.info.version ){ case 7: cssUrl = "global_fixIE7"; break; case 6: cssUrl = "global_fixIE6"; break; } Global.attach.cssLink( cssUrl ); } } }, isIE: function (){ return ( this.info.type == "ie" ) ? true : false; } } /******** GLOBAL LAUNCH ********/ Browser.preload(); /**************************************** | | ScriptReaction Data Structure | Queue (Array Implementation) | | Created by: Kevin Biskaborn | Copyright 2010 ScriptReaction | http://www.scriptreaction.com | ***************************************** | Load Dependencies : None | Run Dependencies : None ****************************************/ //create a new Queue (FIFO) Data Structure var Queue = function (){ //the list of elements this.qArray = new Array(); //returns true if the queue is empty, and false otherwise this.isEmpty = function (){ return ( this.size() == 0 ); } //returns the size of this Queue this.size = function (){ return this.qArray.length; } //gets the element at the front of the queue //returns undefined if the Queue is empty this.firstElement = function (){ var element = undefined; if ( !this.isEmpty() ) //get the first element in the array element = this.qArray[ 0 ]; return element; } //enqueues the specified element in this Queue this.enqueue = function ( element ){ this.qArray.push( element ); } //dequeues an element from this Queue //returns undefined if the Queue is empty this.dequeue = function (){ //get the queue first element var element = this.firstElement(); if( typeof( element ) != "undefined" ) //strip the array of the first index position this.qArray = this.qArray.splice( 0, 1 ); return element; } } /**************************************** | | ScriptReaction Data Structure | Cyclic Queue (Array Implementation) | | Created by: Kevin Biskaborn | Copyright 2010 ScriptReaction | http://www.scriptreaction.com | ***************************************** | Load Dependencies : None | Run Dependencies : None ****************************************/ //create a new Cyclic Queue Data Structure var CyclicQueue = function ( elementArray ){ //the list of elements this.qArray = elementArray; //set the first index position this.firstIndex = 0; //returns true if the queue is empty, and false otherwise this.isEmpty = function (){ return ( this.size() == 0 ); } //returns the size of this Queue this.size = function (){ return this.qArray.length; } //get the next element in the cycle //returns undefined if the queue is empty this.getNextElement = function (){ var element = undefined; if( !this.isEmpty() ){ //increment the first index //and check if the first index is out of range if( this.firstIndex++ >= this.size() ) //reset the first index to zero this.firstIndex = 0; element = this.qArray[ firstIndex ]; } return element; } //sets the cyclic queue starting index this.setFirstIndex = function ( index ){ //check for invalid indexes if( index < 0 || index >= this.size() ) this.firstIndex = 0; else this.firstIndex = index; } } /**************************************** | | Ivey Eye Institute | http://www.iveyeye.ca | | Created by: Kevin Biskaborn | Copyright 2013 ScriptReaction | http://www.scriptreaction.com | ***************************************** | Load Dependencies : None | Run Dependencies : None ****************************************/ var JS_Format = { array: { itemExistsInArray: function ( needle, haystackArray ){ var output = false; for( var i = 0; i < haystackArray.length; i++ ){ if( haystackArray[ i ] == needle ){ output = true; break; } } return output; }, unique: { //accepts object arrays by reference //otherwise, use: myArray = addItem( newItem, myArray ); addItem: function ( itemToAdd, haystackArray ){ if( !JS_Format.array.itemExistsInArray( itemToAdd, haystackArray ) ) haystackArray.push( itemToAdd ); return haystackArray; }, removeItem: function ( itemToRemove, haystackArray ){ for( var i = 0; i < haystackArray.length; i++ ){ if( haystackArray[ i ] == itemToRemove ){ haystackArray.splice( i, 1 ); break; } } return haystackArray; } }, clear: function ( inputArray ){ return inputArray.splice( 0, inputArray.length ); }, shuffle: function ( inputArray ){ var output = new Array(); var index; // continue extracting items while the array has more to give while( inputArray.length > 0 ){ // get the next index to be extracted index = JS_Format.number.randomize.fromZero( inputArray.length ); // add the element at that index to the output output.push( inputArray[ index ] ); // remove the element from the array inputArray.splice( index, 1 ); } return output; }, strip: { lastElementIfEmpty:function ( inputArray ){ // get the last index in the array var lastIndex = inputArray.length - 1; // get the last element in the array var lastElement = inputArray[ lastIndex ]; // determine if the element is empty if( lastElement == "" || lastElement == null ) // remove the last element inputArray.splice( lastIndex, 1 ); return inputArray; } } }, string: { trim: { doubleSpace: function ( str ){ return str.replace( /\s\s/, " " ); }, left: function ( str ){ return str.replace( /^\s+/, "" ); }, right: function ( str ){ return str.replace( /\s+$/, "" ); }, full: function ( str ){ return this.right( this.left( str ) ); } }, strip: { htmlTags: function ( inputString ){ return inputString.replace( /(<([^>]+)>)/ig, "" ); } }, condition: { beginsWith: function ( inputString, prefix ){ if( inputString.substring( 0, prefix.length ) == prefix ) return true; else return false; }, endsWith: function ( inputString, suffix ){ if( inputString.substring( inputString.length - suffix.length, inputString.length ) == suffix ) return true; else return false; } }, remove: { prefix: function ( inputString, prefix ){ if( JS_Format.string.condition.beginsWith( inputString, prefix ) ) return inputString.substring( prefix.length, inputString.length ); else return inputString; }, suffix: function ( inputString, suffix ){ if( JS_Format.string.condition.endsWith( inputString, suffix ) ) return inputString.substring( 0, inputString.length - suffix.length ); else return inputString; } }, parseQueryStringToObject: function ( queryString ){ var output = new Object(); //remove the leading query string char queryString = JS_Format.string.remove.prefix( queryString, "?" ); //remove the trailing query string char queryString = JS_Format.string.remove.suffix( queryString, "&" ); //split the query string //into individual data items var dataItemArray = queryString.split( "&" ); //create variable containers var dataItem = ""; var itemArray = Array(); //cycle through all data items for( var i = 0; i < dataItemArray.length; i++ ){ dataItem = dataItemArray[ i ]; //split the data item //into id and value pairs itemArray = dataItem.split( "=" ); //add the item to the output output[ itemArray[ 0 ] ] = itemArray[ 1 ]; } return output; }, parseSpanClassTags: function ( inputString ){ return JS_Format.string.parseClassTags( inputString, "span" ); }, parseClassTags: function ( inputString, tagName ){ var output = ""; // specify the separation delimiters var delimStart = "%%="; var delimEnd = "%%;" // split the input string on all end delimiters // sample elements at this point: className=value var arrayOfEntries = inputString.split( delimEnd ); // check if the last element is empty arrayOfEntries = JS_Format.array.strip.lastElementIfEmpty( arrayOfEntries ); // create loop containers var entry, pairArray, nameOfClass, tagContents; // cycle through all the entries for( var i = 0; i < arrayOfEntries.length; i++ ){ // get the next entry entry = arrayOfEntries[ i ]; // split he entry into a class/value pair pairArray = entry.split( delimStart ); // extract pair values nameOfClass = pairArray[ 0 ]; tagContents = pairArray[ 1 ]; // buld the tag // and add it to the output stream output += "<" + tagName + " class=\"" + nameOfClass + "\">"; output += tagContents; output += ""; } return output; }, validateFormat: { emailAddress: function ( targetEmailAddress ){ // set the regular expression mask for email addresses var maskFilter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; // test the incoming target value return ( maskFilter.test( targetEmailAddress ) ); } } }, number: { padding: { prefix_zero: function ( inputNumber, size ){ return this.prefix( inputNumber.toString(), "0", size ); }, prefix: function ( numberString, padCharString, size ){ while( numberString.length < size ) numberString = padCharString + numberString; return numberString; } }, randomize: { fromOneToMax: function ( maximum ){ this.fromZero( maximum ) + 1; }, fromZero: function ( maximum ){ return Math.floor( Math.random() * maximum ); } } }, date: { monthCodeArrays: { code3_short: Array( "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" ) } }, elementClass: { addToElement: function ( elementObject, classToAdd ){ this.set( elementObject, this.add( classToAdd, elementObject.className ) ); }, removeFromElement: function ( elementObject, classToRemove ){ this.set( elementObject, this.remove( classToRemove, elementObject.className ) ); }, add: function ( classToAdd, className ){ classArray = className.split( " " ); if( !JS_Format.array.itemExistsInArray( classToAdd, classArray ) ) classArray.push( classToAdd ); return classArray.join( " " ); }, remove: function ( classToRemove, className ){ classArray = className.split( " " ); for( var i = 0; i < classArray.length; i++ ){ if( classArray[ i ] == classToRemove ){ classArray.splice( i, 1 ); break; } } return classArray.join( " " ); }, set: function ( elementObject, newClassString ){ elementObject.className = newClassString; }, existsOnElement: function ( elementObject, className ){ //create a class exists flag var classExists = false; //verify that the object has a className parameter if( elementObject.className ){ //get an array of all the classes on the element var classArray = elementObject.className.split( " " ); //check whether the requested class exists in the array classExists = JS_Format.array.itemExistsInArray( className, classArray ); } return classExists; } }, elementAlpha: { info: { defaultFadeSpeed: 20 }, empty: function ( objectElement ){ this.set( objectElement, 0 ); }, fill: function ( objectElement ){ this.set( objectElement, 100 ); }, set: function ( objectElement, targetAlpha ){ Global.modify.setAlpha( objectElement, targetAlpha ); }, fadeIn: function ( inputObject ){ inputObject.initialAlpha = 0; inputObject.targetAlpha = 100; inputObject.fadeDirection = 1; var fader = new JS_Format.elementAlpha.activeFader( inputObject ); fader.apply( fader ); }, fadeOut: function ( inputObject ){ inputObject.initialAlpha = 100; inputObject.targetAlpha = 0; inputObject.fadeDirection = -1; var fader = new JS_Format.elementAlpha.activeFader( inputObject ); fader.apply( fader ); }, activeFader: function ( inputObject ){ this.activeObject = inputObject[ "objectElement" ]; this.fadeDirection = inputObject[ "fadeDirection" ]; this.targetAlpha = inputObject[ "targetAlpha" ]; this.initialAlpha = inputObject[ "initialAlpha" ]; this.activeAlpha = this.initialAlpha; this.onFinishMethod = ( !( typeof( inputObject[ "onFinishMethod" ] ) == null ) ) ? inputObject[ "onFinishMethod" ] : ""; //get the fade speed this.fadeSpeed = ( !(typeof( inputObject[ "fadeSpeed" ] ) == null) ) ? inputObject[ "fadeSpeed" ] : JS_Format.elementAlpha.info.defaultFadeSpeed; this.fadeJump = 10; this.updateAlpha = function (){ JS_Format.elementAlpha.set( this.activeObject, this.activeAlpha ); } this.onFinish = function (){ if( typeof( this.onFinishMethod ) != "undefined" && !( this.onFinishMethod == "" ) ) eval( this.onFinishMethod )(); } //set the active object to its initial alpha this.updateAlpha(); this.apply = function ( fadeObject ){ var fadeComplete = false; if( fadeObject.fadeDirection > 0 ){ //FADING IN if( fadeObject.activeAlpha < fadeObject.targetAlpha ) fadeObject.activeAlpha += fadeObject.fadeJump; else { fadeObject.activeAlpha = fadeObject.targetAlpha; fadeComplete = true; } } else { //FADING OUT if( fadeObject.activeAlpha > fadeObject.targetAlpha ) fadeObject.activeAlpha -= fadeObject.fadeJump; else { this.activeAlpha = fadeObject.targetAlpha; fadeComplete = true; } } //update the new alpha fadeObject.updateAlpha(); //check for fade completion if( fadeComplete ) fadeObject.onFinish(); else setTimeout( fadeObject.apply, fadeObject.fadeSpeed, fadeObject ); } } }, divElement: { getById: function ( id ){ return document.getElementById( id ); }, setDisplay_block: function ( divElement ){ this.setStyle.divDisplay( divElement, "block" ); }, setDisplay_none: function ( divElement ){ this.setStyle.divDisplay( divElement, "none" ); }, setDivContent_byDivId: function ( divId, newContents ){ Global.modify.setDivContent( divId, newContents ); }, setDivContent_byDivElement: function ( divElement, newContents ){ Global.modify.divContent( divElement, newContents ); }, getDivContent_byDivElement: function ( divElement ){ return divElement.innerHTML; }, refreshDivContent: function ( divElement ){ this.setDivContent_byDivElement( divElement, this.getDivContent_byDivElement( divElement ) ); }, setStyle: { divDisplay: function( divElement, displayMode ){ divElement.style.display = displayMode; }, divBackgroundImage: function ( divElement, bgImagePath ){ var newBg = ( bgImagePath == "none" ) ? bgImagePath : "url(" + bgImagePath + ")"; divElement.style.backgroundImage = newBg; } }, getAllOnPage_usingClass: function ( classNameString ){ return JS_Format.get.allElementsOnPage_usingClass( "div", classNameString ); } }, file: { get: { extension: function ( filePathString ){ var extStartIndex = filePathString.lastIndexOf( "." ); return filePathString.slice( extStartIndex + 1, filePathString.length ); } } }, get: { arrayOfElementsByTagName: function ( tagName ){ return document.getElementsByTagName( tagName ); }, allElementsOnPage_usingClass: function ( elementTag, classNameString ){ //create output container var outputArray = new Array(); //get all elements with the requested tag name var arrayOfElements = this.arrayOfElementsByTagName( elementTag ); //create element container var element; //cycle through all elements for( var i in arrayOfElements ){ //get the next element element = arrayOfElements[ i ]; //test if the element is using the requested class if( JS_Format.elementClass.existsOnElement( element, classNameString ) ) //add the element to the output array outputArray.push( element ); } return outputArray; } } } /**************************************** | | Ivey Eye Institute | http://www.iveyeye.ca | | Created by: Kevin Biskaborn | Copyright 2013 ScriptReaction | http://www.scriptreaction.com | ***************************************** | Load Dependencies : None | Run Dependencies : Global{} ****************************************/ var NavPrimary = { controls: { anchorDivId: "navigation", subMenuDivPrefix: "nav_", useAnimation: false, menuHideDelay: 1500 //delay before menu closes on mouseout }, info: { activeAnchorArray: Array(), activeMenuArray: Array(), menuOpenArray: Array(), menuCount: 0 }, launch: function (){ if( this.controls.useAnimation ) Global.attach.jsLink( "tween" ); this.populatePrimaryAnchors(); this.setupMenuDivs(); this.actions.closeAll(); }, get: { element: function ( id ){ return document.getElementById( id ); }, menuNameFromId: function ( id ){ return id.split( "_" )[ 0 ]; }, menuIndexFromId: function ( id ){ return id.split( "_" )[ 1 ]; }, menuDivFromArrayById: function ( id ){ return NavPrimary.info.activeMenuArray[ this.menuIndexFromId( id ) ]; }, menuDivFromDocById: function ( id ){ return this.element( NavPrimary.controls.subMenuDivPrefix + this.menuNameFromId( id ) ); }, anchorTagFromArrayById: function ( id ){ return this.anchorTagFromArrayByIndex( this.menuIndexFromId( id ) ); }, anchorTagFromArrayByIndex: function ( index ){ return NavPrimary.info.activeAnchorArray[ index ]; } }, states: { isOpen: function ( menuIndex ){ return NavPrimary.info.menuOpenArray[ menuIndex ]; }, set: function ( menuIndex, state ){ NavPrimary.info.menuOpenArray[ menuIndex ] = state; }, doOpen: function ( menuIndex ){ this.set( menuIndex, true ); }, doClose: function ( menuIndex ){ this.set( menuIndex, false ); } }, populatePrimaryAnchors: function () { var anchorDiv = this.get.element( this.controls.anchorDivId ); var anchorTagArray = anchorDiv.getElementsByTagName( "a" ); var whichAnchor; for( var i = 0; i < anchorTagArray.length; i++ ){ whichAnchor = anchorTagArray[ i ]; if( whichAnchor.name ){ //check if anchor tag has name param set //update the anchor name whichAnchor.name = whichAnchor.name + "_" + this.info.menuCount++; //anchor has a corresponding sub menu whichAnchor.onmouseover = function (){ NavPrimary.actions.closeAll(); NavPrimary.actions.over( this.name ); } whichAnchor.onmouseout = function (){ NavPrimary.actions.out( this.name ); } whichAnchor.onclick = function (){ this.blur(); } //save the anchor this.info.activeAnchorArray.push( whichAnchor ); //save the corresponding menu this.info.activeMenuArray.push( this.get.menuDivFromDocById( whichAnchor.name ) ); //save the menu open state this.info.menuOpenArray.push( true ); } else { //anchor has NO sub menu whichAnchor.onmouseover = function (){ NavPrimary.actions.closeAll(); } } } }, setupMenuDivs: function (){ var anchorArray = this.info.activeAnchorArray; var menuDivArray = this.info.activeMenuArray; var i, j, whichMenu, menuName, menuOptions, whichOption; for( i = 0; i < menuDivArray.length; i++ ){ whichMenu = menuDivArray[ i ]; menuId = anchorArray[ i ].name; menuOptions = whichMenu.getElementsByTagName( "a" ); for( j = 0; j < menuOptions.length; j++ ) this.assignOptionEvents( menuOptions[ j ], menuId ); //assign the actions to the other menu components this.assignOptionEvents( whichMenu.getElementsByTagName( "div" )[0], menuId ); } }, assignOptionEvents: function ( element, elementId ){ element.name = elementId; element.onmouseover = function (){ NavPrimary.actions.over( this.name ); } element.onmouseout = function (){ NavPrimary.actions.out( this.name ); } element.onclick = function (){ this.blur(); NavPrimary.actions.closeAll(); } }, collapse: function (){ this.actions.closeAll(); }, actions: { get:{ menuById: function ( id ){ return NavPrimary.get.menuDivFromArrayById( id ); }, anchorById: function ( id ){ return NavPrimary.get.anchorTagFromArrayById( id ); }, menuIndexFromId: function ( id ){ return NavPrimary.get.menuIndexFromId( id ); } }, over: function ( id ){ var menuDiv = this.get.menuById( id ); var anchorItem = this.get.anchorById( id ); var menuIndex = this.get.menuIndexFromId( id ); NavPrimary.timers.destroy( menuIndex ); if( !NavPrimary.states.isOpen( menuIndex ) ) this.openMenu( id ); }, out: function ( id ){ var menuDiv = this.get.menuById( id ); var anchorItem = this.get.anchorById( id ); var menuIndex = this.get.menuIndexFromId( id ); NavPrimary.timers.create( menuIndex ); }, openMenu: function ( id ){ var menuDiv = this.get.menuById( id ); var anchorItem = this.get.anchorById( id ); var menuIndex = this.get.menuIndexFromId( id ); if( !NavPrimary.states.isOpen( menuIndex ) ){ if( NavPrimary.controls.useAnimation ){ /*var targetY = NavPrimary.animate.get.posY_active( menuDiv ); if( menuDiv.style.top <= targetY ){ menuDiv.style.top = targetY; t1 = new Tween(menuDiv.style,'top',Tween.strongEaseOut,parseInt(menuDiv.style.top),parseInt(targetY),.2,'px'); t1.start(); }*/ } else { menuDiv.style.display = "block"; //raise the menu open flag NavPrimary.states.doOpen( menuIndex ); } //set anchor appearance anchorItem.className = "active"; } }, closeMenu: function ( id ){ var menuDiv = this.get.menuById( id ); var anchorItem = this.get.anchorById( id ); var menuIndex = this.get.menuIndexFromId( id ); if( NavPrimary.states.isOpen( menuIndex ) ){ if( NavPrimary.controls.useAnimation ){ // } else menuDiv.style.display = "none"; //set anchor appearance anchorItem.className = ""; //lower the menu open flag NavPrimary.states.doClose( menuIndex ); } }, closeAll: function (){ var anchorArray = NavPrimary.info.activeAnchorArray; for( var i = 0; i < anchorArray.length; i++ ) this.closeMenu( anchorArray[ i ].name ); } }, timers: { create: function ( index ){ this.destroy( index ); this[ "timer_" + index ] = setTimeout( "NavPrimary.timers.expire(" + index + ")", NavPrimary.controls.menuHideDelay ); }, expire: function ( index ){ NavPrimary.actions.closeMenu( NavPrimary.get.anchorTagFromArrayByIndex( index ).name ); }, destroy: function ( index ){ if( typeof( this[ "timer_" + index ] ) != "undefined" ) clearTimeout( this[ "timer_" + index ] ); } }, animate: { get: { posY_active: function ( menuDiv ){ return 0 + "px"; }, posY_inactive: function ( menuDiv ){ return (-1 * menuDiv.clientHeight) + "px"; } } } } /**************************************** | | Ivey Eye Institute | http://www.iveyeye.ca | | Created by: Kevin Biskaborn | Copyright 2013 ScriptReaction | http://www.scriptreaction.com | | Last Modified by: | K. Biskaborn, Jan-08-2010 @ 6:35 PM | ***************************************** | Load Dependencies : None | Run Dependencies : None ****************************************/ var manager_tabPanelGroup = { settings: { optionDivClassRef: "options", contentDivClassRef: "content_area", activeTabClassName: "active", tabOptionItemPrefix: "tabPanelOption_", tabContentItemPrefix: "tabPanelBlock_" }, groupsCreated: Array(), launch: function ( inputObject ){ var groupId = inputObject["panelGroupId"]; if(groupId != null){ this.groupsCreated.unshift( new instance_tabPanelGroup( inputObject ) ); } return this.groupsCreated[ 0 ]; } } var instance_tabPanelGroup = function ( inputObject ){ this.groupId = inputObject[ "panelGroupId" ]; this.startId = inputObject[ "selectedTabId" ]; this.action = inputObject[ "onPressAction" ]; this.launch = function (){ this.setup(); this.activateTab( this.startTab ); } this.formatTabIdToContentItemId = function ( tabId ){ var idPrefixLength = manager_tabPanelGroup.settings.tabOptionItemPrefix.length; return manager_tabPanelGroup.settings.tabContentItemPrefix + tabId.slice(idPrefixLength, tabId.length); } this.setup = function (){ var groupInstance = this; var groupHolderDiv = document.getElementById(this.groupId); var divsInGroup = groupHolderDiv.getElementsByTagName("div"); var optionHolderClassRef = manager_tabPanelGroup.settings.optionDivClassRef; var contentHolderClassRef = manager_tabPanelGroup.settings.contentDivClassRef; var optionHolderDiv, contentHolderDiv, whichDiv = null; //extract the option holder from the group div for(var i = 0; i < divsInGroup.length; i++){ whichDiv = divsInGroup[i]; if(optionHolderDiv == null && whichDiv.className == optionHolderClassRef) optionHolderDiv = whichDiv; if(contentHolderDiv == null && whichDiv.className == contentHolderClassRef) contentHolderDiv = whichDiv; } //extract the content items from the content holder this.contentItems = contentHolderDiv.getElementsByTagName("div"); //extract the options from the option holder var tabOptions_items = optionHolderDiv.getElementsByTagName("li"); this.tabOptions = new Array(); this.startTab = null; var itemId, whichItem, whichHref; for(var i = 0; i < tabOptions_items.length; i++){ whichItem = tabOptions_items[i]; itemId = whichItem.id; //check if item name is defined if( itemId ){ whichHref = whichItem.getElementsByTagName("a")[0]; whichItem.onclick = function (){ groupInstance.handleClick( this ); } whichHref.onclick = function (){ this.blur(); return false; } //save the tab item this.tabOptions.push( whichItem ); //set starting tab if( this.startTab == null && itemId == this.startId ) this.startTab = whichItem; } } //default to first tab if starting tab not specified if(this.startTab == null) this.startTab = this.tabOptions[0]; } this.activateTabById = function ( tabId ){ for( var i = 0; i < this.tabOptions.length; i++ ){ if( this.tabOptions[ i ].id == tabId ){ this.handleClick( this.tabOptions[ i ] ); break; } } } this.handleClick = function ( tabItem ){ this.deactivateAll(); this.activateTab( tabItem ); } this.activateTab = function ( tabItem ){ tabItem.className = manager_tabPanelGroup.settings.activeTabClassName; this.activate_action( tabItem ); } this.deactivateTab = function ( tabItem ){ tabItem.className = ""; this.deactivate_action( tabItem ); } this.deactivateAll = function (){ for(var i = 0; i < this.tabOptions.length; i++) this.deactivateTab(this.tabOptions[i]); } this.getTabContentItem = function ( tabItem ){ var contentItem; for(var i = 0; i < this.contentItems.length; i++){ var contentItem = this.contentItems[i]; if(contentItem.id == this.formatTabIdToContentItemId(tabItem.id)) break; } return contentItem; } this.activate_action = function ( tabItem ){ var itemId = tabItem.value; if(this.action == "default"){ this.getTabContentItem( tabItem ).style.display = "block"; } } this.deactivate_action = function ( tabItem ){ var itemId = tabItem.value; if(this.action == "default"){ this.getTabContentItem( tabItem ).style.display = "none"; } } //initilize the object this.launch(); }