//----------------------------------------------------------------------------------------------- // Browser Detect var g_bScns4 =(document.layers)?true:false; var g_bScns6 =(!document.all && document.getElementById)?true:false; var g_bScopera =(navigator.userAgent.indexOf("opera")!=-1)?true:false; var g_bScie =(document.all)?true:false; var g_bScmac =(navigator.platform == 'mac')?true:false; var g_nNS4PositionTop = 200; var g_nNS4PositionLeft = 200; var g_oScrollers = new Array(); var g_nScrollers = -1; //################################################################################################ function ScrollElement(_cText , _cURL , _cStyle) { //--- Members ----------- this.m_cText = _cText; this.m_cURL = _cURL; this.m_cStyle = _cStyle; } function Scroller(_cID , _nHeight, _nWidth , _cStyle , _nSpeed , _nStep , _cDirection) { //--- Members ----------- this.m_cID = _cID; this.m_nHeight = _nHeight; this.m_nWidth = _nWidth; this.m_cStyle = _cStyle; this.m_nSpeed = _nSpeed; this.m_nStep = _nStep; this.m_cDirection = _cDirection; this.m_nElement = -1; this.m_oElement = new Array(); this.m_nScrollEndPos = 0; this.m_bScrollRun = false; this.m_nScrollTimerID = 0; //--- functions Members----------- this.AddElement = _AddElement; this.Draw = _Draw; this.Start = _Start; this.Stop = _Stop; this.Box = _Box; //--- functions ----------- function _AddElement(_cText , _cURL , _cStyle) { this.m_nElement ++; this.m_oElement[this.m_nElement] = new ScrollElement(_cText , _cURL , _cStyle); } function _Draw() { var cHTMLSyntax = ''; var cHTMLNs = ''; var cHTMLOther = ''; var i = 0; var docElemMain; var docElemIn; // Main Box------------------------------ if (g_bScns4) { cHTMLSyntax += ''; } else { cHTMLSyntax += '
'; } // Inside Box --------------------------------- if (this.m_cDirection == "LEFT" || this.m_cDirection == "RIGHT") { this.m_nScrollEndPos = (this.m_nWidth * (this.m_nElement+1)); if (g_bScns4) { cHTMLSyntax += ''; } else { cHTMLSyntax += '
'; } cHTMLSyntax += ''; cHTMLSyntax += ''; } else { this.m_nScrollEndPos = (this.m_nHeight * (this.m_nElement+1)); if (g_bScns4) { cHTMLSyntax += ''; } else { cHTMLSyntax += '
'; } cHTMLSyntax += '
'; } // Detail--------------------------- for(i=0 ; i <= this.m_nElement ; i++) { if (this.m_oElement[i] != null) { if (this.m_cDirection == "DOWN" || this.m_cDirection == "UP") { cHTMLSyntax += ''; } //--- event on right element --> browser type ----------------- if (g_bScns4) { cHTMLNs = ' onmouseover="ScrollStop(\''+this.m_cID+'\','+i+')" onmouseout="ScrollStart(\''+this.m_cID+'\','+i+')" '; cHTMLOther = ''; } else { cHTMLNs = ''; cHTMLOther = ' onmouseover="ScrollStop(\''+this.m_cID+'\','+i+')" onmouseout="ScrollStart(\''+this.m_cID+'\','+i+')" '; } cHTMLSyntax += ''; if (this.m_cDirection == "DOWN" || this.m_cDirection == "UP") { cHTMLSyntax += ''; } } } if (this.m_cDirection == "LEFT" || this.m_cDirection == "RIGHT") { cHTMLSyntax += ''; } cHTMLSyntax += '
'; cHTMLSyntax += ''+ this.m_oElement[i].m_cText + ""; cHTMLSyntax += '
'; if (g_bScns4) {cHTMLSyntax += '';} else {cHTMLSyntax += '
';} //////////////////// // Write and start scroll ////////////////////////////////// document.write(cHTMLSyntax); this.Start(); /////////////////////////// // Problem of Size With g_bScns4 /////////////////////////////////////// if (g_bScns4) { docElemMain = ScrollGetElementStyle('ScrollMain-'+this.m_cID); docElemMain.clip.width = this.m_nWidth; docElemMain.clip.height = this.m_nHeight; docElemIn = docElemMain.document.layers['ScrollIn-'+this.m_cID]; docElemMain.visibility = "show"; docElemIn.visibility = "show"; } } function _Start(_nIndex) { var docElem; if (_nIndex == null) { _nIndex = 0; } docElem = ScrollGetElement('ScrollElem-'+this.m_cID+'-'+_nIndex); if (docElem) { if (! g_bScopera && ! g_bScns4) { docElem.className = this.m_oElement[_nIndex].m_cStyle; } } this.m_bScrollRun = true this.m_nScrollTimerID = setTimeout('ScrollBox(\''+ this.m_cID +'\')',this.m_nSpeed); } function _Stop(_nIndex) { var docElem; if (_nIndex == null) { _nIndex = 0;} docElem = ScrollGetElement('ScrollElem-'+this.m_cID+'-'+_nIndex); if (docElem) { if (! g_bScopera && ! g_bScns4) { docElem.className = this.m_oElement[_nIndex].m_cStyle + 'On'; } } //stop scroll if (this.m_nScrollTimerID != 0) { clearTimeout( this.m_nScrollTimerID ); this.m_nScrollTimerID = 0; } this.m_bScrollRun = false; } function _Box() { var docElem = ScrollGetElementStyle('ScrollIn-'+this.m_cID); if (g_bScns4) { docElem = ScrollGetElementStyle('ScrollMain-'+this.m_cID); if (docElem) { docElem = docElem.document.layers['ScrollIn-'+this.m_cID]; } } switch (this.m_cDirection.toUpperCase()) { case "UP" : docElem.top = (parseInt(docElem.top) - this.m_nStep); if ( parseInt(docElem.top) < (2-this.m_nScrollEndPos) ) { docElem.top = this.m_nHeight; } break; case "DOWN" : docElem.top = (parseInt(docElem.top) + this.m_nStep); if ( parseInt(docElem.top) > this.m_nHeight ) { docElem.top = -(this.m_nScrollEndPos); } break; case "LEFT" : docElem.left = (parseInt(docElem.left) - this.m_nStep); if ( parseInt(docElem.left) < (2-this.m_nScrollEndPos) ) { docElem.left = this.m_nWidth; } break; case "RIGHT" : docElem.left = (parseInt(docElem.left) + this.m_nStep); if ( parseInt(docElem.left) > this.m_nWidth ) { docElem.left = -(this.m_nScrollEndPos); } break; //default : } if (this.m_bScrollRun) { this.m_nScrollTimerID = setTimeout('ScrollBox(\''+ this.m_cID +'\')',this.m_nSpeed); } } } //################################################################################################ function ScrollGetElement(_cID) { var doc; if (g_bScns4) { eval('doc = document.' + _cID); if (! doc) { eval('doc = document.layers["'+_cID+'"]'); } } if (g_bScns6 || g_bScopera) { doc = document.getElementById(_cID); } if (g_bScie) { doc = document.all[_cID]; } return doc; } function ScrollGetElementStyle(_cID) { var doc; var doc2; if (g_bScns4) { doc = ScrollGetElement(_cID); } if (g_bScns6 || g_bScopera) { doc2 = document.getElementById(_cID); if(doc2) { doc = doc2.style; } } if (g_bScie) { doc2 = document.all[_cID] if (doc2) { doc = doc2.style; } } return doc; } //################################################################################################ function ScrollAdd(_cID , _nHeight, _nWidth , _cStyle , _nSpeed , _nStep , _cDirection) { var nCreateScroller = -1; if (_nHeight == "" || _nHeight == null || _nHeight == 0) { nCreateScroller = 0; } if (_nWidth == "" || _nWidth == null || _nWidth == 0) { nCreateScroller = 0; } if (_nSpeed == "" || _nSpeed == null || _nSpeed == 0) { nCreateScroller = 0; } if (_nStep == "" || _nStep == null || _nStep == 0) { nCreateScroller = 0; } if( nCreateScroller == -1){ g_nScrollers ++; g_oScrollers[g_nScrollers] = new Scroller(_cID , _nHeight, _nWidth , _cStyle , _nSpeed , _nStep , _cDirection); } } function ScrollAddElement(_cID , _cText , _cURL , _cStyle) { var nIndex = -1; nIndex = ScrollByID(_cID); if( nIndex != -1 ) g_oScrollers[nIndex].AddElement(_cText , _cURL , _cStyle); } function ScrollByID(_cID) { var nIndex = -1; var nScroll = 0; for(nScroll = 0 ; nScroll <= g_nScrollers ; nScroll ++) { if( g_oScrollers[nScroll].m_cID == _cID) { nIndex = nScroll; } } return nIndex; } function ScrollBox(_cID) { var nIndex = -1; nIndex = ScrollByID(_cID); if( nIndex != -1 ) g_oScrollers[nIndex].Box(); } function ScrollStart(_cID , _nIndex) { var nIndex = -1; nIndex = ScrollByID(_cID); if( nIndex != -1 ) g_oScrollers[nIndex].Start(_nIndex); } function ScrollStop(_cID , _nIndex) { var nIndex = -1; nIndex = ScrollByID(_cID); if( nIndex != -1 ) g_oScrollers[nIndex].Stop(_nIndex); } function ScrollDraw(_cID) { var nIndex = -1; nIndex = ScrollByID(_cID); if( nIndex != -1 ) g_oScrollers[nIndex].Draw(); }