//these are all the variables that control the style of the scroller(set to default values):
var sid=1;           //song id
var btc=1;           //button color 1-72
var w=190;           //width
var bgc="#CCCCCC";    //background-color
var txc="black";     //song lyrics-color
var tc="black";      //title-color
var bc="#CCCCCC";     //border-color
var bgo=100;          //background-opacity
var bto=100;          //button-opacity
var bo=100;           //border-opacity

//the first 2 function's code is to make allowances for Firefox browsers:
function FFsupport() {
if(navigator.appName=="Netscape") {
//If you are using FireFox...
//get the current width and height of the song box
var sbw = document.getElementById('songbox').offsetWidth;
var sbh = document.getElementById('songbox').offsetHeight;

//(subtract 20 from each to make it correct then take another 20 to match IE):
var sbw2 = sbw-40;
var sbh2 = sbh-40;
document.getElementById('songbox').style.width=sbw2;
document.getElementById('songbox').style.height=sbh2;
}
}//end FFsupport function.

function FFsupport2() {
if(navigator.appName=="Netscape") {
//If you are using FireFox...
//get the current width and height of the song box
var sbw = document.getElementById('songbox').offsetWidth;

//(subtract 20 from width when resizing the songbox to match IE):
var sbw2 = sbw-40;
document.getElementById('songbox').style.width=sbw2;
}
}//end FFsupport2 function.


function scrollfast(speed) {
document.getElementById('markey').scrollAmount=speed;
}//end scrollfast function.

//these are the actual direction of the text,(if you were to "scroll up" in the text, you would actually scrolldown!):
function scrolldown() {
document.getElementById('markey').direction="down";
document.getElementById('markey').scrollAmount=10;
}

function scrollup() {
document.getElementById('markey').direction="up";
document.getElementById('markey').scrollAmount=2;
}

function stopscroll() {
document.getElementById('markey').scrollAmount=0;
}

function startscroll() {
document.getElementById('markey').scrollAmount=2;
}

function namecolor(elm,col) {

if(elm=="border"){document.getElementById('songbox').style.borderColor=col;
var txt = "Border<br />Color<br /><br /><br />"+col;
document.getElementById('colo').style.backgroundColor=col;
document.getElementById('colo').innerHTML=txt;
if(col=="#000000"||col=="#382509"||col=="#57401E"||col=="#1D0A55"){document.getElementById('colo').style.color="white";}
else{document.getElementById('colo').style.color="black";}
bc=col;
}

if(elm=="background"){document.getElementById('bgbox').style.backgroundColor=col;
var txt = "Background<br />Color<br /><br /><br />"+col;
document.getElementById('colo2').style.backgroundColor=col;
document.getElementById('colo2').innerHTML=txt;
if(col=="#000000"||col=="#382509"||col=="#57401E"||col=="#1D0A55"){document.getElementById('colo2').style.color="white";}
else{document.getElementById('colo2').style.color="black";}
bgc=col;
}

if(elm=="songtitle"){document.getElementById('titlebox').style.color=col;
var txt = "Song Title<br />Color<br /><br /><br />"+col;
document.getElementById('colo3').style.backgroundColor=col;
document.getElementById('colo3').innerHTML=txt;
if(col=="#000000"||col=="#382509"||col=="#57401E"||col=="#1D0A55"){document.getElementById('colo3').style.color="white";}
else{document.getElementById('colo3').style.color="black";}
tc=col;
}

if(elm=="songtext"){document.getElementById('markey').style.color=col;
var txt = "Lyrics<br />Color<br /><br /><br />"+col;
document.getElementById('colo4').style.backgroundColor=col;
document.getElementById('colo4').innerHTML=txt;
if(col=="#000000"||col=="#382509"||col=="#57401E"||col=="#1D0A55"){document.getElementById('colo4').style.color="white";}
else{document.getElementById('colo4').style.color="black";}
txc=col;
}
}//end namecolor function.









function buttoncol(c) {
var txt = "Button<br />Color<br /><br /><br />"+c;
document.getElementById('colo4b').style.backgroundColor=c;
document.getElementById('colo4b').innerHTML=txt;
if(c=="#000000"||c=="#382509"||c=="#57401E"||c=="#1D0A55"){document.getElementById('colo4b').style.color="white";}
else{document.getElementById('colo4b').style.color="black";}

var pic1 = "";
var pic2 = "";
if(c=="#000000"){pic1="b1/up1.png";pic2="b2/down1.png";btc=1;}
if(c=="#AC4311"){pic1="b1/up2.png";pic2="b2/down2.png";btc=2;}
if(c=="#E3AD00"){pic1="b1/up3.png";pic2="b2/down3.png";btc=3;}
if(c=="#006E29"){pic1="b1/up4.png";pic2="b2/down4.png";btc=4;}
if(c=="#00593F"){pic1="b1/up5.png";pic2="b2/down5.png";btc=5;}
if(c=="#00484D"){pic1="b1/up6.png";pic2="b2/down6.png";btc=6;}
if(c=="#00316E"){pic1="b1/up7.png";pic2="b2/down7.png";btc=7;}
if(c=="#1D0A55"){pic1="b1/up8.png";pic2="b2/down8.png";btc=8;}
if(c=="#6A0056"){pic1="b1/up9.png";pic2="b2/down9.png";btc=9;}
if(c=="#9C0F56"){pic1="b1/up10.png";pic2="b2/down10.png";btc=10;}
if(c=="#9C0F0F"){pic1="b1/up11.png";pic2="b2/down11.png";btc=11;}
if(c=="#382509"){pic1="b1/up12.png";pic2="b2/down12.png";btc=12;}
if(c=="#555753"){pic1="b1/up13.png";pic2="b2/down13.png";btc=13;}
if(c=="#CF4913"){pic1="b1/up14.png";pic2="b2/down14.png";btc=14;}
if(c=="#F3C300"){pic1="b1/up15.png";pic2="b2/down15.png";btc=15;}
if(c=="#00892C"){pic1="b1/up16.png";pic2="b2/down16.png";btc=16;}
if(c=="#00734D"){pic1="b1/up17.png";pic2="b2/down17.png";btc=17;}
if(c=="#006066"){pic1="b1/up18.png";pic2="b2/down18.png";btc=18;}
if(c=="#00438A"){pic1="b1/up19.png";pic2="b2/down19.png";btc=19;}
if(c=="#34176E"){pic1="b1/up20.png";pic2="b2/down20.png";btc=20;}
if(c=="#85026C"){pic1="b1/up21.png";pic2="b2/down21.png";btc=21;}
if(c=="#BF0361"){pic1="b1/up22.png";pic2="b2/down22.png";btc=22;}
if(c=="#BF0303"){pic1="b1/up23.png";pic2="b2/down23.png";btc=23;}
if(c=="#57401E"){pic1="b1/up24.png";pic2="b2/down24.png";btc=24;}
if(c=="#888A85"){pic1="b1/up25.png";pic2="b2/down25.png";btc=25;}
if(c=="#EC7331"){pic1="b1/up26.png";pic2="b2/down26.png";btc=26;}
if(c=="#FFDD00"){pic1="b1/up27.png";pic2="b2/down27.png";btc=27;}
if(c=="#37A42C"){pic1="b1/up28.png";pic2="b2/down28.png";btc=28;}
if(c=="#009966"){pic1="b1/up29.png";pic2="b2/down29.png";btc=29;}
if(c=="#007880"){pic1="b1/up30.png";pic2="b2/down30.png";btc=30;}
if(c=="#0057AE"){pic1="b1/up31.png";pic2="b2/down31.png";btc=31;}
if(c=="#462886"){pic1="b1/up32.png";pic2="b2/down32.png";btc=32;}
if(c=="#A02786"){pic1="b1/up33.png";pic2="b2/down33.png";btc=33;}
if(c=="#E20071"){pic1="b1/up34.png";pic2="b2/down34.png";btc=34;}
if(c=="#E20800"){pic1="b1/up35.png";pic2="b2/down35.png";btc=35;}
if(c=="#75511A"){pic1="b1/up36.png";pic2="b2/down36.png";btc=36;}
if(c=="#BABDB6"){pic1="b1/up37.png";pic2="b2/down37.png";btc=37;}
if(c=="#F29B68"){pic1="b1/up38.png";pic2="b2/down38.png";btc=38;}
if(c=="#FFEB55"){pic1="b1/up39.png";pic2="b2/down39.png";btc=39;}
if(c=="#77B753"){pic1="b1/up40.png";pic2="b2/down40.png";btc=40;}
if(c=="#00B377"){pic1="b1/up41.png";pic2="b2/down41.png";btc=41;}
if(c=="#00A7B3"){pic1="b1/up42.png";pic2="b2/down42.png";btc=42;}
if(c=="#2C72C7"){pic1="b1/up43.png";pic2="b2/down43.png";btc=43;}
if(c=="#644A9B"){pic1="b1/up44.png";pic2="b2/down44.png";btc=44;}
if(c=="#B14F9A"){pic1="b1/up45.png";pic2="b2/down45.png";btc=45;}
if(c=="#E85290"){pic1="b1/up46.png";pic2="b2/down46.png";btc=46;}
if(c=="#E85752"){pic1="b1/up47.png";pic2="b2/down47.png";btc=47;}
if(c=="#8F6B32"){pic1="b1/up48.png";pic2="b2/down48.png";btc=48;}
if(c=="#D3D7CF"){pic1="b1/up49.png";pic2="b2/down49.png";btc=49;}
if(c=="#F2BB88"){pic1="b1/up50.png";pic2="b2/down50.png";btc=50;}
if(c=="#FFF299"){pic1="b1/up51.png";pic2="b2/down51.png";btc=51;}
if(c=="#B1D28F"){pic1="b1/up52.png";pic2="b2/down52.png";btc=52;}
if(c=="#00CC88"){pic1="b1/up53.png";pic2="b2/down53.png";btc=53;}
if(c=="#00C4CC"){pic1="b1/up54.png";pic2="b2/down54.png";btc=54;}
if(c=="#6193CF"){pic1="b1/up55.png";pic2="b2/down55.png";btc=55;}
if(c=="#8E79B9"){pic1="b1/up56.png";pic2="b2/down56.png";btc=56;}
if(c=="#C173B0"){pic1="b1/up57.png";pic2="b2/down57.png";btc=57;}
if(c=="#F082B0"){pic1="b1/up58.png";pic2="b2/down58.png";btc=58;}
if(c=="#F08682"){pic1="b1/up59.png";pic2="b2/down59.png";btc=59;}
if(c=="#B3925D"){pic1="b1/up60.png";pic2="b2/down60.png";btc=60;}
if(c=="#FFFFFF"){pic1="b1/up61.png";pic2="b2/down61.png";btc=61;}
if(c=="#FCD9B0"){pic1="b1/up62.png";pic2="b2/down62.png";btc=62;}
if(c=="#FFF6C8"){pic1="b1/up63.png";pic2="b2/down63.png";btc=63;}
if(c=="#D8E8C2"){pic1="b1/up64.png";pic2="b2/down64.png";btc=64;}
if(c=="#99DCC6"){pic1="b1/up65.png";pic2="b2/down65.png";btc=65;}
if(c=="#A8DDE0"){pic1="b1/up66.png";pic2="b2/down66.png";btc=66;}
if(c=="#A4C0E4"){pic1="b1/up67.png";pic2="b2/down67.png";btc=67;}
if(c=="#C3B4DA"){pic1="b1/up68.png";pic2="b2/down68.png";btc=68;}
if(c=="#E8B7D7"){pic1="b1/up69.png";pic2="b2/down69.png";btc=69;}
if(c=="#F9CADE"){pic1="b1/up70.png";pic2="b2/down70.png";btc=70;}
if(c=="#F9CCCA"){pic1="b1/up71.png";pic2="b2/down71.png";btc=71;}
if(c=="#DEBC85"){pic1="b1/up72.png";pic2="b2/down72.png";btc=72;}

document.getElementById('button1').src=pic1;
document.getElementById('button2').src=pic2;
}


function SetOpacity(id, opacityAsInt) {
   var opacityAsDecimal = opacityAsInt;
   
   if (opacityAsInt > 100)
       opacityAsInt = opacityAsDecimal = 100; 
   else if (opacityAsInt < 0)
       opacityAsInt = opacityAsDecimal = 0; 
   
   opacityAsDecimal /= 100;
   if (opacityAsInt < 1)
       opacityAsInt = 1; // IE7 bug, text smoothing cuts out if 0
   
document.getElementById(id).style.opacity = (opacityAsDecimal);
document.getElementById(id).style.filter  = "alpha(opacity=" + opacityAsInt + ")";
//set opacity variables for user's scroller:
if(id=="bgbox"){bgo=opacityAsInt;}
if(id=="button1"){bto=opacityAsInt;}
if(id=="songbox"){bo=opacityAsInt;}
}

//get rid of this if all qorks while quoted out!!!:
/*function testfun() {
var opac_ff = document.getElementById('songbox').style.opacity;
var opac_ie = document.getElementById('songbox').style.filter;
document.getElementById('songbox').style.opacity=opac_ff-0.1;
document.getElementById('songbox').style.filter = 'alpha(opacity=10)';
}*/

function closepopup() {
document.getElementById('imgdiv').style.display='none';
}

function URLDecode(url) //function decode URL
{
// Replace + with ' '
// Replace %xx with equivalent character
// Put [ERROR] in output if %xx is invalid.
var HEXCHARS = "0123456789ABCDEFabcdef"; 
var encoded = url;
var plaintext = "";
var i = 0;
while (i < encoded.length) {
var ch = encoded.charAt(i);
if (ch == "+") {
plaintext += " ";
i++;
} else if (ch == "%") {
if (i < (encoded.length-2) 
&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
plaintext += unescape( encoded.substr(i,3) );
i += 3;
} else {
alert( 'Bad escape combination near ...' + encoded.substr(i) );
plaintext += "%[ERROR]";
i++;
}
} else {
plaintext += ch;
i++;
}
} // while 
return plaintext;
}; 

function addsong(sngtitle,sngid,sngtxt) {
var sgtx = URLDecode(sngtxt);

document.getElementById('songname').innerHTML=sngtitle;
document.getElementById('music').innerHTML=sgtx;
sid=sngid;
}













