function setframe() {
document.getElementById('riffs').style.display = 'block';
document.getElementById('welcome').style.display = 'block';
document.getElementById('bt_welcome').style.backgroundColor = "#CCCCCC";
document.getElementById('epcount').value = Vault.EpChkDVD.length;

//Get Number of Rhino Eps
thisOne = document.getElementById("rhino_list");
items = thisOne.getElementsByTagName("li");
document.getElementById("Rtot").value = items.length
}

function setframe_bots() {

document.getElementById('servo').style.display = 'none';
document.getElementById('bt_servo').style.backgroundColor = "";
document.getElementById('crow').style.display = 'none';
document.getElementById('bt_crow').style.backgroundColor = "";
document.getElementById('gypsy').style.display = 'none';
document.getElementById('bt_gypsy').style.backgroundColor = "";

document.getElementById('bot_riffs').style.display = 'block';
document.getElementById('welcome').style.display = 'block';
document.getElementById('bt_welcome').style.backgroundColor = "#CCCCCC";




}

function rprint()
{
var rtext
rtext = "<font size='4'><strong>Rhino & Shout Factory Episodes</strong></font><br><br>"+'\n'
var x = document.getElementById('rhino_list');
if (!x) return;
var y = x.getElementsByTagName('li');
for (var i=0;i<y.length;i++){
rtext += y[i].title+'\n'
 }

  winId = window.open('','newwin');
  with (winId.document) {
   write('<body onLoad="window.focus();window.print()"><img src="/Images/MST-Moon.gif"><pre>'+rtext+'</pre><\/body><a href="javascript:window.close()">Close Window</a>');
  close();
  }
}

function toggle(id) {
document.getElementById('welcome').style.display = 'none';
document.getElementById('bt_welcome').style.backgroundColor = "";
document.getElementById('about').style.display = 'none';
document.getElementById('bt_about').style.backgroundColor = "";
document.getElementById('bset').style.display = 'none';
document.getElementById('bt_bset').style.backgroundColor = "";
document.getElementById('ktma').style.display = 'none';
document.getElementById('bt_ktma').style.backgroundColor = "";
document.getElementById('s1').style.display = 'none';
document.getElementById('bt_s1').style.backgroundColor = "";
document.getElementById('s2').style.display = 'none';
document.getElementById('bt_s2').style.backgroundColor = "";
document.getElementById('s3').style.display = 'none';
document.getElementById('bt_s3').style.backgroundColor = "";
document.getElementById('s4').style.display = 'none';
document.getElementById('bt_s4').style.backgroundColor = "";
document.getElementById('s5').style.display = 'none';
document.getElementById('bt_s5').style.backgroundColor = "";
document.getElementById('s6').style.display = 'none';
document.getElementById('bt_s6').style.backgroundColor = "";
document.getElementById('s7').style.display = 'none';
document.getElementById('bt_s7').style.backgroundColor = "";
document.getElementById('s8').style.display = 'none';
document.getElementById('bt_s8').style.backgroundColor = "";
document.getElementById('s9').style.display = 'none';
document.getElementById('bt_s9').style.backgroundColor = "";
document.getElementById('s10').style.display = 'none';
document.getElementById('bt_s10').style.backgroundColor = "";
document.getElementById('sR').style.display = 'none';
document.getElementById('bt_sR').style.backgroundColor = "";
document.getElementById('order').style.display = 'none';
document.getElementById('bt_order').style.backgroundColor = "";
document.getElementById('rhino').style.display = 'none';
document.getElementById('bt_rhino').style.backgroundColor = "";
document.getElementById(id).scrollTop;
document.getElementById(id).scrollLeft;
document.getElementById(id).style.display = 'block';
document.getElementById('bt_'+id).style.backgroundColor = "#CCCCCC";
}

function toggle_bots(id) {
document.getElementById('welcome').style.display = 'none';
document.getElementById('bt_welcome').style.backgroundColor = "";
document.getElementById('servo').style.display = 'none';
document.getElementById('bt_servo').style.backgroundColor = "";
document.getElementById('crow').style.display = 'none';
document.getElementById('bt_crow').style.backgroundColor = "";
document.getElementById('gypsy').style.display = 'none';
document.getElementById('bt_gypsy').style.backgroundColor = "";
//document.getElementById('order').style.display = 'none';
//document.getElementById('bt_order').style.backgroundColor = "";

document.getElementById(id).scrollTop;
document.getElementById(id).scrollLeft;
document.getElementById(id).style.display = 'block';
document.getElementById('bt_'+id).style.backgroundColor = "#CCCCCC";
}

// JavaScript Document
function ImHuge(mypage,w,h) {
  if(screen.width){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  }else{winl = 0;wint =0;}
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += 'scrollbars=no,resizable=yes,status=yes';
  window.open (mypage, 'Preview', settings)
}
function cent(amount) {
// returns the amount in the .99 format    amount -= 0;
    amount = (Math.round(amount*100))/100;
    return (amount == Math.floor(amount)) ? amount + '.00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
}

function EpSel(sel)
{

var BlistTemp = new String
var DlistTemp = new String
var BonusTemp = new String
var CostTemp = new String
btitles = new Array("KTMA-TV23 Episodes DVD Boxset", "Comedy Central Season 1 DVD Boxset", "Comedy Central Season 2 DVD Boxset"
					 , "Comedy Central Season 3 DVD Boxset", "Comedy Central Season 4 DVD Boxset", "Comedy Central Season 5 DVD Boxset"
					 , "Comedy Central Season 6 DVD Boxset", "Comedy Central Season 7 DVD Boxset", "Sci-fi Channel Season 8 DVD Boxset"
					 , "Sci-fi Channel Season 9 DVD Boxset", "Sci-fi Channel Season 10 DVD Boxset", "Complete MST3K DVD Boxset");
bcosts = new Array(100, 33, 44, 71.5, 71.5, 49.5, 82.5, 22, 88, 49.5, 33, 550);
DlistTemp = "MST3K episodes:"+'\n'
BlistTemp = "MST3K Boxsets:"+'\n'
BonusTemp = "FREE Bonus DVDs (1 for every 5 single DVDs ordered):"+'\n'
DVDPrc = 7.50
Ship = 0
Dcnt = 0
Dcnt2 = 0
Bcnt = 0
BonusCnt = 0
Btot = 0
Dtot = 0
ChkCnt = 0
TotalCost = 0

//Count DVDs and make list http://www.irt.org/script/number.htm
for (i=0;i<document.Vault.EpChkDVD.length;i++) {
if(document.Vault.EpChkDVD[i].checked == true){
Dcnt += 1}
};

var btemp = (Dcnt/6) 
//var btemp2 = round((Dcnt/6), 2)
var btemp2 = Math.floor(Dcnt/6)

for (i=0;i<document.Vault.EpChkDVD.length;i++) {
if(document.Vault.EpChkDVD[i].checked == true){
Dcnt2 += 1
if(Dcnt2>(Dcnt-btemp2)){
BonusTemp+= "   "+document.Vault.EpChkDVD[i].value+'\n'}
else{DlistTemp += "   "+document.Vault.EpChkDVD[i].value+'\n'};
}
}
Dcnt=Dcnt-btemp2

if (Dcnt ==0){
	Dtot=0
	DlistTemp = ""}
else{DlistTemp += '\n\n'};

if (btemp2 ==0){BonusTemp = ""}
else{BonusTemp += '\n\n'};

//Count Boxsets and make list
for (i=0;i<document.Vault.BoxChkDVD.length;i++) {
if(document.Vault.BoxChkDVD[i].checked == true){
Bcnt += 1
Btot += bcosts[document.Vault.BoxChkDVD[i].value]
BlistTemp += "   "+btitles[document.Vault.BoxChkDVD[i].value]+" - $"+cent(bcosts[document.Vault.BoxChkDVD[i].value])+'\n'}
}
if (Bcnt ==0){
	Btot=0
	BlistTemp = ""}
else{BlistTemp += '\n\n'};

if(Dcnt>=11 && Dcnt<=20){DVDPrc =7.00}
if(Dcnt>=21 && Dcnt<=30){DVDPrc =6.50}
if(Dcnt>=31 && Dcnt<=40){DVDPrc =6.00}
if(Dcnt>=41 && Dcnt<=50){DVDPrc =5.50}
if(Dcnt>=51 && Dcnt<=100){DVDPrc =5.00}
if(Dcnt>=101 && Dcnt<=140){DVDPrc =4.50}
if(Dcnt>=141 && Dcnt<=200){DVDPrc =4.00}

Dtot = (Dcnt * DVDPrc)

if((Dtot + Btot)<50){Ship = 5.00}
else {Ship = 0};

//if(Dcnt>=10){Ship = 0}
//if(Dcnt==1){Ship = 4.00}
//if(Dcnt==0){Ship = 0.00}
//alert(Dtot+" = "+Btot+" = "+Ship+" = "+TotalCost)
if((Dtot + Btot)==0){
	TotalCost = cent(0)}
	else{
TotalCost = Dtot + Btot + Ship
TotalCost = cent(TotalCost)};
//alert(Dtot+" = "+Btot+" = "+Ship+" = "+TotalCost)
document.Vault.sum_bonus.value = btemp2;
document.Vault.sum_items.value = Dcnt+Bcnt;
document.Vault.sum_total.value = TotalCost;

BoxPrc = cent(Btot)
DVDPrc = cent(DVDPrc)
if (Ship ==0){
Ship = "FREE"}
else {
Ship = "$"+cent(Ship)}
if (Dcnt !=0){CostTemp += Dcnt+" Single DVDs @ "+DVDPrc+" each = $"+cent(Dtot)+'\n'}
if (Bcnt !=0){CostTemp += Bcnt+" Boxsets = $"+BoxPrc+'\n'}
if (btemp2 !=0){CostTemp += btemp2+" Bonus DVDs = FREE!"+'\n'}
CostTemp += "Shipping Cost = "+Ship+'\n'
CostTemp += "Total Cost    = $"+TotalCost+'\n\n'
document.Request.Message.value = "Bob,"+'\n\n'+"Below is the list of MST3K episodes I'm interested in getting:"+'\n\n'+BlistTemp+DlistTemp+BonusTemp+CostTemp+'\n'

Ship = 0
ChkCnt = 0
TotalCost = 0
}


function WishPrint()
{
  text = document.Request.Message.value;
  winId = window.open('','newwin');
  with (winId.document) {
    write('<body onLoad="window.focus();window.print()"><pre>'+text+'</pre><\/body><a href="javascript:window.close()">Close Window</a>');
   close();
  }
}
function ResetList(){
var ans
ans = prompt("This will clear all selections. Procede?", "YES")
if (ans == "YES"){
document.Request.realname.value = ""
document.Request.email.value = ""
document.Request.subject.value = "MST3K Video Request"
document.Request.Message.value = ""
for (i=0;i<Vault.EpChk.length;i++) {
if(document.Vault.EpChk[i].checked == true){document.Vault.EpChk[i].checked = false}
}
for (i=0;i<Vault.EpChkDVD.length;i++) {
if(document.Vault.EpChkDVD[i].checked == true){document.Vault.EpChkDVD[i].checked = false}
}
for (i=0;i<Vault.BoxChkDVD.length;i++) {
if(document.Vault.BoxChkDVD[i].checked == true){document.Vault.BoxChkDVD[i].checked = false}
}

document.Vault.sum_total.value = 0
document.Vault.sum_bonus.value = 0
document.Vault.sum_items.value = 0

Ship = 0
TapePrc = 0
ChkCnt = 0
TotalCost = 0
}
}
function Msent(){
document.Request.Sent.value = "Message Sent"
}

function newWindow(mypage,myname,w,h,features) {
  if(screen.width){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  }else{winl = 0;wint =0;}
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}

