var navCurrentPage = ""; function parseElementId( elem ) { if( elem.id == undefined ) { return undefined; } var pos = elem.id.lastIndexOf( "_" ); return ( pos < 0 ? undefined : parseInt( elem.id.substr( pos + 1 ) ) ); } function parseElementName( elem ) { if( elem.id == undefined ) { return undefined; } var pos = elem.id.lastIndexOf( "_" ); return ( pos < 0 ? undefined : elem.id.substr( pos + 1 ) ); } function parseImageName( elem ) { return parseElementName( elem ); } var navRules = { 'img.nav' : function(el) { el.onmouseover = function() { var imgName = parseImageName( this ); if( imgName != navCurrentPage ) { this.src = "images/nav/" + imgName + "-on.png"; } }; el.onmouseout = function() { var imgName = parseImageName( this ); if( imgName != navCurrentPage ) { this.src = "images/nav/" + imgName + "-off.png"; } }; }, 'img.sidebar-img' : function(el) { el.onmouseover = function() { var imgSrc = this.src; var pos = imgSrc.lastIndexOf( "-off." ); imgSrc = imgSrc.substring( 0, pos ) + "-on.gif"; this.src = imgSrc; }; el.onmouseout = function() { var imgSrc = this.src; var pos = imgSrc.lastIndexOf( "-on." ); if( pos > -1 ) { imgSrc = imgSrc.substring( 0, pos ) + "-off.gif"; this.src = imgSrc; } }; }, 'img.sidebar-img2' : function(el) { el.onmouseover = function() { var imgSrc = this.src; var pos = imgSrc.lastIndexOf( "-off." ); imgSrc = imgSrc.substring( 0, pos ) + "-on2.gif"; this.src = imgSrc; }; el.onmouseout = function() { var imgSrc = this.src; var pos = imgSrc.lastIndexOf( "-on2." ); if( pos > -1 ) { imgSrc = imgSrc.substring( 0, pos ) + "-off.gif"; this.src = imgSrc; } }; }, '#simSelectionDropdown' : function(el) { el.onchange = function() { changeToSelectedSIM(); }; }, '#all-feed-search-form' : function(el) { el.onsubmit = function() { var val = $F('all-feed-search-input'); if( val == "" ) { alert( "Please enter your search terms first" ); return false; } }; } }; Behaviour.register(navRules);var currentRelevanceId = 3; var sliderRules = { 'img.slider' : function(el) { el.onmouseover = function() { var imgName = parseImageName( this ); if( imgName != navCurrentPage ) { this.src = "images/sl1/slider-no-bar_" + imgName + "-over.gif"; } }; el.onmouseout = function() { var imgName = parseImageName( this ); if( imgName != navCurrentPage ) { this.src = "images/sl1/slider-no-bar_" + imgName + ".gif"; } }; }, 'img.activeSliderLevel' : function(el) { // need to define these functions to overwrite those from the possible previous class 'slider-inline' el.onmouseover = function() {} el.onmouseout = function() {} el.onclick = function() {} }, 'img.slider-inline' : function(el) { el.onmouseover = function() { var cellLevel = parseElementId( this ); var imgName = ( cellLevel * 2 ) - 1; this.src = "images/sl1/slider-no-bar_0" + imgName + "-over.gif"; }; el.onmouseout = function() { var cellLevel = parseElementId( this ); var imgName = ( cellLevel * 2 ) - 1; this.src = "images/sl1/slider-no-bar_0" + imgName + ".gif"; }; el.onclick = function() { var activeElements = document.getElementsByClassName('activeSliderLevel'); $A(activeElements).each( function(elem) { elem.className = "slider-inline"; var oLevel = parseElementId( elem ); var oImgName = ( oLevel * 2 ) - 1; elem.src = "images/sl1/slider-no-bar_0" + oImgName + ".gif"; elem.title = "Relevancy level " + oLevel; } ); var cellLevel = parseElementId( this ); var imgName = ( cellLevel * 2 ) - 1; this.src = "images/sl1/slider-no-bar_0" + imgName + "-sel.gif"; this.className = "activeSliderLevel"; this.title = "Relevancy level " + cellLevel + " (selected)"; $('relevancyLevel').value = cellLevel; Behaviour.apply(); } } }; Behaviour.register( sliderRules ); var formRules = { 'select.simSelectionDropdown' : function(el) { el.onchange = function() { changeToSelectedSIM(); }; }, 'input.submit-image' : function(el) { el.onmouseover = function() { this.style.cursor = "pointer"; }; } }; Behaviour.register(formRules); var articleRules = { '#furtherRelatedArticles_link' : function(el) { el.onmouseover = function() { this.style.cursor = "pointer"; }; el.onclick = function() { Element.show($('furtherRelatedArticles')); Element.hide($('furtherRelatedArticles_link')); } }, 'a.headlineLink' : function(el) { el.onmouseover = function() { if( Element.hasClassName( this, "active-article" ) ) { this.style.cursor = "default"; } else { this.style.cursor = "pointer"; } }; el.onclick = function() { if( Element.hasClassName( this, "active-article" ) ) { return false; } var listing = $('newsletter-headline-listing'); var activeArticles = document.getElementsByClassName( "active-article", listing ); $A(activeArticles).each( function(elem) { Element.removeClassName( elem, "active-article" ); } ); var articleId = this.id; Element.addClassName( this, "active-article" ); activeArticleId = articleId; var url = "view-story.php"; var params = "iid=" + newsletterIssueId; params += "&suc=" + articleId; window.location.hash = url + "?" + params; params += "&inline=true"; var myAjax = new Ajax.Updater( 'main', url, { method: 'get', parameters: params } ); return false; } } }; Behaviour.register(articleRules); var newsRules = { 'div.news-item .title' : function(el) { el.onmouseover = function() { this.style.cursor = "pointer"; this.style.textDecoration = "underline"; }; el.onmouseout = function() { this.style.cursor = ""; this.style.textDecoration = ""; }; }, 'div.news-item .bullet' : function(el) { el.onclick = function() { var itemId = parseElementId( this ); toggleNewsItem( itemId ); }; }, 'div.news-item .expand' : function(el) { el.onclick = function() { var itemId = parseElementId( this ); toggleNewsItem( itemId ); var imgSrc = this.src; var pos = imgSrc.lastIndexOf( "-on-over." ); if( pos > -1 ) { this.src = imgSrc.substring( 0, pos ) + "-off-over.png"; return; } var pos = imgSrc.lastIndexOf( "-off-over." ); if( pos > -1 ) { this.src = imgSrc.substring( 0, pos ) + "-on-over.png"; return; } }; el.onmouseover = function() { this.style.cursor = "pointer"; var imgSrc = this.src; var pos = imgSrc.lastIndexOf( "-off." ); if( pos > -1 ) { this.src = imgSrc.substring( 0, pos ) + "-off-over.png"; return; } var pos = imgSrc.lastIndexOf( "-on." ); if( pos > -1 ) { this.src = imgSrc.substring( 0, pos ) + "-on-over.png"; return; } }; el.onmouseout = function() { var imgSrc = this.src; var pos = imgSrc.lastIndexOf( "-off-over." ); if( pos > -1 ) { this.src = imgSrc.substring( 0, pos ) + "-off.png"; return; } var pos = imgSrc.lastIndexOf( "-on-over." ); if( pos > -1 ) { this.src = imgSrc.substring( 0, pos ) + "-on.png"; return; } }; }, 'div.news-item .related' : function(el) { el.onmouseover = function() { this.style.cursor = "help"; }; }, 'img.rt_icon' : function(el) { el.onmouseover = function() { this.style.cursor = "help"; }; } }; Behaviour.register(newsRules); function toggleNewsItem( itemId ) { var newsItemElement = $('news_item_' + itemId); if( Element.hasClassName( newsItemElement, 'open' ) ) { Element.hide( $('news_summary_' + itemId) ); Element.removeClassName( newsItemElement, 'open' ); } else { Element.show( $('news_summary_' + itemId) ); Element.addClassName( newsItemElement, 'open' ); } } var classInfoTimers = new Array(); function startInfoTimer( classId ) { if( ! classInfoTimers[classId] ) { var timerId = setTimeout( "showClassInfo(" + classId + ")", 1500 ) classInfoTimers[classId] = timerId; // alert( "Started timer '" + timerId + "'\n[start] Currently have " + classInfoTimers.length + " timers" ); } } function showClassInfo( classId ) { // alert( "[show] Currently have " + classInfoTimers.length + " timers" ); if( classInfoTimers[classId] ) { ClassDescriber.showDescription( classId ); delete classInfoTimers[classId]; } } function cancelClassInfo( classId ) { if( classInfoTimers[classId] ) { clearTimeout( classInfoTimers[classId] ); delete classInfoTimers[classId]; } } var map50Rules = { 'img.infoIcon' : function(el) { el.onclick = function() { ClassDescriber.toggleDescription( parseElementId( this ) ); return false; }; }, 'div.classBox_50' : function(el) { el.onmouseover = function() { this.style.cursor = "pointer"; var classId = parseElementId( this ); // startInfoTimer( classId ); if( ! Element.hasClassName( this, "highlight_stick" ) ) { if( classId != MapFocusser.focussedClassId ) { Element.addClassName( this, 'highlight_over' ); } } }; el.onmouseout = function() { if( ! Element.hasClassName( this, "highlight_stick" ) ) { var classId = parseElementId( this ); if( classId != MapFocusser.focussedClassId ) { Element.removeClassName( this, 'highlight_over' ); } cancelClassInfo( classId ); } }; el.onclick = function() { var classId = parseElementId( this ); cancelClassInfo( classId ); if( ! Element.hasClassName( this, "highlight_stick" ) ) { MapFocusser.highlightClass50( classId ); } ClassCompanyListing.listCompanies( classId ); return false; }; }, 'img.closeIcon' : function(el) { var classId = parseElementId( el.parentNode ); el.onmouseover = function() { this.style.cursor = "pointer"; this.src = "icons/close_box2-over.gif"; }; el.onmouseout = function() { this.style.cursor = "default"; this.src = "icons/close_box2.gif"; }; el.onclick = function() { ClassDescriber.hideDescription( classId ); return false; }; }, '.classDescriptionBox .descriptionMenuLink' : function( el ) { el.onclick = function() { var classId = parseElementId( el ) var currentTabId = 'childClassesMenuLink_' + classId; Element.removeClassName( currentTabId , 'currentTab' ); Element.addClassName( el, 'currentTab' ); Element.hide( $( 'childClasses_' + classId ) ); Element.show( $( 'description_' + classId ) ); } }, '.classDescriptionBox .childClassesMenuLink' : function( el ) { el.onclick = function() { var classId = parseElementId( el ) var currentTabId = 'descriptionMenuLink_' + classId; Element.removeClassName( currentTabId, 'currentTab' ); Element.addClassName( el, 'currentTab' ); Element.hide( $( 'description_' + classId ) ); Element.show( $( 'childClasses_' + classId ) ); } }, '#company-search-go' : function(el) { el.onmouseover = function() { this.style.cursor = "pointer"; }; el.onclick = function() { PopupSearch.searchCompanies(); }; }, '#catagory-search-go' : function(el) { el.onmouseover = function() { this.style.cursor = "pointer"; }; el.onclick = function() { PopupSearch.searchCatagories(); }; }, '#mapthis_closebutton' : function(el) { el.onmouseover = function() { this.style.background = "url(icons/close_box2-over.gif);" this.style.backgroundPosition = "center;" this.style.backgroundRepeat = "no-repeat;" }; el.onmouseout = function() { this.style.background = "url(icons/close_box2.gif);" this.style.backgroundPosition = "center;" this.style.backgroundRepeat = "no-repeat;" }; el.onclick = function() { PopupSearch.close(); } }, '#mapthis_go' : function(el) { el.onclick = function() { PopupSearch.gomap(); }; }, '#mapthis_go_class' : function(el) { el.onclick = function() { PopupSearch.gomap_class(); }; } }; Behaviour.register(map50Rules);