﻿// JScript File

            
            function initNewsRotator(divIdName, pDiv)
            {
			    var rotationLength = -1;
			    var rotationCount = 0;
			    var newsDivs = document.getElementById(pDiv);
			    var divs = newsDivs.getElementsByTagName("div");
			    for (var i=0; i < divs.length; i++ ) {
				    var div = divs[i];
				    if ( (div.id != "") && (div.nodeType == 1) ) {
					    div.style.display = "none";
					    div.style.marginBottom =  "0";
					    rotationLength++;
				    }
			    }
			    
			    rotation(divIdName, rotationLength, rotationCount, pDiv);
			}
					
					
		    function rotation (strDivIdName, rotationLength, rotationCount, pDiv)
			{
				if (rotationCount >= rotationLength)
				{
					document.getElementById(strDivIdName + rotationLength).style.display = "none";
					rotationCount = 0;
				} else {
				if (rotationCount != 0)
				{
					/*document.getElementById(strDivIdName + (rotationCount)).style.display = "none";*/
				}
				document.getElementById(strDivIdName + (rotationCount)).style.display = "none";
					rotationCount++;
				}
				document.getElementById(strDivIdName + (rotationCount)).style.display = "inline";
				document.getElementById(strDivIdName + (rotationCount)).style.left = "0px";
				fade(strDivIdName + (rotationCount),0)
				randomTime = 10000 + ((Math.random()*3000)-1500)
				//setTimeout('fadeout("' + strDivIdName + '" + ("' + rotationCount + '"),100,' + pDiv + ')', randomTime-1500);
				setTimeout('rotation("' + strDivIdName + '", ' + rotationLength + ', ' + rotationCount + ', "' + pDiv + '")', randomTime);
				document.getElementById(strDivIdName + (rotationCount)).style.left = 0;
				//scroll(strDivIdName + (rotationCount), 2000);
				if (/*document.getElementById(pDiv).offsetWidth*/ 375 < parseInt(document.getElementById(strDivIdName + rotationCount).offsetWidth))
				{
				    //setTimeout('scroll("' + strDivIdName + (rotationCount) + '", ' + parseInt(document.getElementById(pDiv).offsetWidth) - (document.getElementById(strDivIdName + rotationCount).offsetWidth) + ')', 100);
				    setTimeout('scroll("' + strDivIdName + (rotationCount) + '", ' + (parseInt(document.getElementById(strDivIdName + rotationCount).offsetWidth) - 375) + ')',5000);
				}
			}
			
			function scroll(divId, difference)
			{
			    document.getElementById(divId).style.left = ( parseInt(document.getElementById(divId).style.left) - 200 ) + "px";
			    if (Math.abs(parseInt(document.getElementById(divId).style.left)) <= difference)
			    {
			    //document.write(Math.abs(parseInt(document.getElementById(divId).style.left)) + ' <= ' + difference);
			        setTimeout('scroll("' + divId + '", ' + difference + ')', 500);
			    }
			}
			
			function fade(divId, opacity) {
			  if (opacity <= 100) {
				setOpacity(divId, opacity);
				opacity += 10;
				window.setTimeout("fade('"+divId+"',"+opacity+")", 100);
			  }
			}
			
			function fadeout(divId, opacity, pDiv) {
			  if ((opacity >= 0)) {
				setOpacity(divId, opacity);
				opacity -= 10;
				window.setTimeout("fadeout('"+divId+"',"+opacity+")", 100);
			  }
			}
			
			function setOpacity(divId, opacity) {
			  var div = document.getElementById(divId);
			  opacity = (opacity == 100)?99.999:opacity;
  			  div.style.filter = "alpha(opacity="+opacity+")";
			  div.style.KHTMLOpacity = opacity/100;
			  div.style.MozOpacity = opacity/100;
			  div.style.opacity = opacity/100;
			}
			
			function stopRotation(pDiv)
			{
			    document.getElementById(pDiv + "more").style.display = "none";
			    var newsDivs = document.getElementById(pDiv);
			    var divs = newsDivs.getElementsByTagName("div");
			    for (var i=0; i < divs.length; i++ ) {
				    var div = divs[i];
				    if ( (div.id != "") && (div.nodeType == 1) ) {
					    div.style.display = "block";
					    div.style.marginBottom =  "0";
				    }
			    }
			}
			