


var url = " ../basic/showDate.xml";

var rNode= new Array();
var dateArray = new Array();

var monthDays = new Array();
        monthDays[0]=31;
        monthDays[1]=28;
        monthDays[2]=31;
        monthDays[3]=30; 
        monthDays[4]=31;
        monthDays[5]=30;
        monthDays[6]=31;
        monthDays[7]=31;
        monthDays[8]=30;
        monthDays[9]=31;
        monthDays[10]=30;
        monthDays[11]=31;
   

var imageLibrary = new Array();
imageLibrary[0] = new Image(359, 477);
imageLibrary[0].src = "images/band.png";
imageLibrary[1] = new Image(35, 283);
imageLibrary[1].src = "images/blackpiler.png";
imageLibrary[2] = new Image(462, 135);
imageLibrary[2].src = "images/button_sprite.png";
imageLibrary[3] = new Image(133, 36);
imageLibrary[3].src = "images/trackDistance.png";
imageLibrary[4] = new Image(690, 457);
imageLibrary[4].src = "images/frontIce.jpg";
imageLibrary[5] = new Image(568, 127);
imageLibrary[5].src = "images/frontLogo.png";
imageLibrary[6] = new Image(34, 36);
imageLibrary[6].src = "images/greyCarat.gif";
imageLibrary[7] = new Image(507, 49);
imageLibrary[7].src = "images/greyLoopbot.jpg";
imageLibrary[8] = new Image(162, 478);
imageLibrary[8].src = "images/greyLoopleft.png";
imageLibrary[9] = new Image(129, 529);
imageLibrary[9].src = "images/grids.png";
imageLibrary[10] = new Image(789, 126);
imageLibrary[10].src = "images/ice2.png";
imageLibrary[11] = new Image(71, 521);
imageLibrary[11].src = "images/leftLoop.jpg";
imageLibrary[12] = new Image(287, 70);
imageLibrary[12].src = "images/logo.png";
imageLibrary[13] = new Image(134, 50);
imageLibrary[13].src = "images/nilIllegitimi.png";
imageLibrary[14] = new Image(122, 110);
imageLibrary[14].src = "images/signalLight.gif";
imageLibrary[15] = new Image(133, 36);
imageLibrary[15].src = "images/trackBot.png";
imageLibrary[16] = new Image(133, 29);
imageLibrary[16].src = "images/trackTop.png";
imageLibrary[17] = new Image(133, 10);
imageLibrary[17].src = "images/tracks.png";
imageLibrary[18] = new Image(50, 50);
imageLibrary[18].src = "catalogUploads/media/7ql5e0xt_imus3ny8o.png";



var req = null;
// retrieve XML document as document object
function loadXMLDoc(url) {
   // branch for native XMLHttpRequest object
   if (window.XMLHttpRequest) {
      try {
         req = new XMLHttpRequest();
      } catch(e) {
         req = null;
      }
   // branch for IE/Windows ActiveX version
   } else if (window.ActiveXObject) {
      try {
         req = new ActiveXObject("Msxml2.XMLHTTP");
      } catch(e) {
         try {
            req = new ActiveXObject("Microsoft.XMLHTTP");
         } catch(e) {
            req = null;
         }
      }
   }
   if (req) {
      req.open("GET", url, true);
    req.onreadystatechange  =  processRequest;
    req.setRequestHeader("Content-Type", "text/xml");
    req.send("");

   }
}

function processRequest() {
   if (req.readyState == 4 && req.status == 200) {
      var xmlDoc = req.responseXML;
	  if (xmlDoc) {
	rNode = xmlDoc.getElementsByTagName("*");
	dateArray[0]=   rNode[1].attributes[0].nodeValue;	
	dateArray[1] = rNode[2].attributes[0].nodeValue;	
	dateArray[2] = rNode[3].attributes[0].nodeValue;
	dateArray[3]= rNode[4].attributes[0].nodeValue;
	dateArray[4]= rNode[5].attributes[0].nodeValue;
	dateArray[5]= rNode[6].attributes[0].nodeValue;
 ////msgMe("<br />dater length line 97 is   " + dateArray.length); 
	  }else{
	///msgMe("no date scheduled");	  
	return;
	  }
   }
}




function rockMyWorld(){
 loadXMLDoc(url);
 countMeDown(dateArray);
}





var TheRailsRock;
function makePlayerWindow(){
 TheRailsRock = window.open("","RAILS","status,height=130,width=440");
 makePlayer();
}
function makePlayer(){
var mPlayer='<html><head><title>THE RAILS AUDIO STREAM</title></head><body bgcolor="#990000"><div align="center">';
  mPlayer += '<OBJECT id=\'mediaPlayer1\' width="180" height="20" classid=\'CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6\' codebase=\'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\' standby=\'Loading Microsoft Windows Media Player components...\' ';
  mPlayer += 'type=\'application/x-oleobject\'><param name=\'fileName\' value="http://gold.slserver.com:8026"><param name=\'animationatStart\' value=\'true\'><param name=\'transparentatStart\' value=\'true\'>';
  mPlayer += '<param name=\'autoStart\' value="true"><param name=\'showControls\' value="true"><param name ="ShowAudioControls"value="true"><param name="ShowStatusBar" value="true"><param name=\'loop\' value="false">';
  mPlayer += '<EMBED type=\'application/x-mplayer2\' pluginspage=\'http://microsoft.com/windows/mediaplayer/en/download/\' ';
  mPlayer += 'id=\'mediaPlayer\' name=\'mediaPlayer\' displaysize=\'4\' autosize=\'1\' bgcolor=\'white\' showcontrols="false" showtracker=\'-1\'showdisplay=\'0\' showstatusbar=\'-1\' videoborder3d=\'-1\' ';
  mPlayer += 'width="420" height="380" src="http://gold.slserver.com:8026" autostart="true" designtimesp=\'5311\' loop="false"></EMBED></OBJECT>';
  mPlayer +='</div></body></html>';
 TheRailsRock.document.write(mPlayer);
}


function countMeDown(dateArray){
if (dateArray[0] == null )
  {
    showCountDownTimer = setTimeout("countMeDown(dateArray)", 0); /*recurse forever*/
  }else{
    var theYear2 = dateArray[0]; /* xml supplied date */
    var theMonth2 = dateArray[1];
    var theDate2 = dateArray[2];
    var theHour2 = dateArray[3];
    var theMins2 = dateArray[4];
    var theSecs2 = 0; /* standards*/
    var theMSecs2 = 0;
    var now = new Date(); /* create date object and vary it according to GMT time offset*/
    var setTheseMinutes = ( now.getHours()+(now.getTimezoneOffset()/60) ) % 1;
    var hourMod = ( now.getHours()+(now.getTimezoneOffset()/60 )) % 1;
    var adjHours = ( now.getHours()+(now.getTimezoneOffset()/60 )) - hourMod ; /*get current gmt hours and remov modulo */
    var adjMinutes  = ((setTheseMinutes*60)+(now.getMinutes()));/* increment to gmt modulo*/
    var adjMonths = now.getMonth() ;
    var adjDays =  now.getDate() ;
    if (adjMinutes > 59){ adjMinutes -= 59; adjHours++; }  /*if minutes more than 60 increment hour */
    if (adjMinutes < 0){ adjMinutes = 59 + adjMinutes;  adjHours--; }/* if neg minutes then decrement hour */
    if (adjHours > 23){ adjHours = adjHours % 24; adjDays++;}/* add a day */
    else if (adjHours < 0){ adjHours += 24; adjDays--;}/* sub tract day*/
    var countDMin =(theMins2-adjMinutes)+59;/*reverse to create countdon*/
    var countDHour =(theHour2-adjHours);
    var countDDays =(theDate2-adjDays);
    var countDMnth =(theMonth2-adjMonths);
    var countDSecs =(59-(now.getSeconds()));
    var countDMSecs =(1000-(now.getMilliseconds()));
     if ( countDMnth > 0 ){ /*account for month crossover between date obj and xml date*/
          var daysLeftInMonth = monthDays[adjMonths]-adjDays;
          countDDays = daysLeftInMonth*1 + theDate2*1;
	    }

  /*display labels*/
    var nsString = '<p style="position:relative;top:-12px; left:6px;display:inline;">'; 
    var dString = "";
    var hString = "";
    var quitMe = 1;
     if ( (countDHour==0)&&( countDDays==0 )&&(countDMnth==0) ){///*live hour*//
            nsString +=' <div style="font-weight:bolder; color:#cc0000; display:inline;position:absolute; top:-10px;left:70px;">Live Now!</div> '; 
			msgMe("1");
     }else if( 
 	        ((countDHour<0)&&(countDDays<=0 )&&(countDMnth<=0))/*over on same day*/
	         ||
	        ( (countDDays<0 )&&(countDMnth<=0) ) /*over later day*/
	        )
     {
            countDMin="_ ";  countDSecs=" _";  countDMSecs="_ ";  countDDays=" _";  countDMnth="_ ";  countDHour="_ ";
		
            return 0;
     }else if ( (countDHour<0)&&( countDDays>=0 ) ){/*partial  day adjustment*/
            nsString +="Live Stream In: </p>"; 
            countDHour+=24; countDDays--;
			
     }else if( (countDHour==0) &&(( countDDays>=0 )||(countDMnth>=0)) ){/*live hour different day*/
           countDDays--;
           countDHour +=24-1;   
		   nsString +="Live Stream In: </p>"; 
		
		   
     }else{
           countDHour--;
           nsString +="Live Stream In: </p>"; 
		
     }
    nsString += '<img src="'+imageLibrary[18].src+'" alt="The Rails" style="position:relative; top:30px; left:6px; top:-8px; border:none;">'; 
    if ( countDDays == 1)/* make string punctuation */
    { dString = countDDays+" Day";  
	 }else if  ( countDDays >1 )
    { dString=countDDays+ " Days"; } 
    if ( countDHour == 1){ 
		hString = countDHour+" Hour";}
    else if  ( countDHour >1 ){
	 hString= countDHour+" Hours";	}
	 
  window.document.getElementById("streamTime").innerHTML ='<div id="The_Rails_Next_Show">'+nsString+'<div id="daysL">'+dString+'</div> <div id="hoursL">'+hString+'</div><div id="minutesL"> '+countDMin+'</div><div id="secondsL">'+countDSecs+'</div><div id="milliL">     '+countDMSecs+'</div></div>';
  }//if date array exists
 showCountDownTimer = setTimeout("countMeDown(dateArray)", 100); /*recurse forever*/
}/*end function*/


function timePause( pageName, pageNum, objID, classStyle, classStyle2){
	 var obj=document.getElementById(objID);
     obj.className=(classStyle);
	 timerID = setTimeout("switchClass('"+pageName+"','"+pageNum+"','"+ objID+"', '"+ classStyle2+"')",500);
}

function switchClass (pageName, pageNum, objID, classStyle2){
	 var obj=document.getElementById(objID);
     obj.className=(classStyle2);
	if (document.getElementById(objID).className=classStyle2){
		timerID = setTimeout("switchWindow('"+pageName+"','"+pageNum+"','"+ objID+"', '"+ classStyle2+"')",1500);
	}else{
		timerID = setTimeout("switchClass('"+pageName+"','"+pageNum+"','"+ objID+"', '"+ classStyle2+"')",0);
	}
}

function switchWindow(pageName, pageNum, objID, classStyle2){
  if ( pageNum >0){
	///window.location.href=pageName + '&pg=' + pageNum;
	}else{
	////window.location.href=pageName;
	}
}

function timeOff( objID, classStyle){
 var obj=document.getElementById(objID);
 obj.className=(classStyle);
 clearTimeout(timerID);
}

function hhInput(idName, thisStyle)
{
  var obj=document.getElementById(idName);
  obj.className=(thisStyle);
}
function msgMe(myMsgString){
	window.document.getElementById("debugBullet").innerHTML+=myMsgString+ " <br />";
}/*func*/



function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=990,height=600,scrollbars=yes');
return false;
}



function swapBK(divName,thiscolor,thisSize,thisStyle)
{
var obj= document.getElementById(divName);
obj.style.borderColor=(thiscolor);
obj.style.borderWidth=(thisSize);
obj.style.borderStyle=(thisStyle);
}






















