﻿// JScript File
function referral(){
    window.open('Referral.aspx','','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=600'); 
}
function AusPromo(){
    window.open('AusPromo.aspx','','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=600'); 
}
function video(){
    window.open('video.aspx','','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=320,height=256'); 
}

function flv(file,width,height){
    if(width == null)
        width = 400;
    if(height == null)
        height = 300;  
    window.open('flv.aspx?file=' + file + '&width=' + width + '&height=' + height ,'','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height); 
}

function wmv(file,width,height){
    if(width == null)
        width = 400;
    if(height == null)
        height = 300;  
    window.open('wmv.aspx?file=' + file + '&width=' + width + '&height=' + height ,'','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height); 
}
function Kit(){
	var theHeight=600;
	var theWidth=720;
	var theTop=(screen.height/2)-(theHeight/2)
	var theLeft=(screen.width/2)-(theWidth/2)
	var	features='height='+theHeight+',width='+theWidth+',top='+theTop+',left='+theLeft;
	var winPopKit = window.open("kit/kit.aspx","kit","menubar=no,location=no,toolbar=no,scrollbars=yes,"+features+",resizable=yes");
	winPopKit.focus();
}

function openPromo(id)
{
    var h=300;
	var w=500;
	var t=(screen.height/2)-(h/2)
	var l=(screen.width/2)-(w/2)
	var	f='height='+h+',width='+w+',top='+t+',left='+l;
	var winPromo = window.open("promo.aspx","promo","menubar=no,location=no,toolbar=no,scrollbars=no,"+f+",resizable=yes");
	winPromo.focus();
}

function openCoupon()
{
    var h=300;
	var w=500;
	var t=(screen.height/2)-(h/2)
	var l=(screen.width/2)-(w/2)
	var	f='height='+h+',width='+w+',top='+t+',left='+l;
	var winPromo = window.open("ExtCoupon.aspx","Coupon","menubar=no,location=no,toolbar=no,scrollbars=no,"+f+",resizable=yes");
	winPromo.focus();
}

function clickButton(e, id)
{
    var key = window.event ? e.keyCode : e.which;
    if(key == 13)
    {
        if(document.getElementById(id))
        {
            //alert(document.getElementById(id).name);
            event.keyCode=0;
            document.getElementById(id).click()
            //__doPostBack(document.getElementById(id).name, '');
            return false;
        }
    }
}

function UpdateBookOrder(price, qtyCity)
{
    var total = 0;
    total += (price * document.getElementById(qtyCity).selectedIndex);
    document.getElementById("Total").innerHTML = "$" + FormatNumber(total, 2);
}
/*
function UpdateBookOrder(price, qtyCity, qtyCorp)
{
    var total = 0;
    total += (price * document.getElementById(qtyCity).selectedIndex);
    total += (14.95 * document.getElementById(qtyCorp).selectedIndex);
    document.getElementById("Total").innerHTML = "$" + FormatNumber(total, 2);
}
*/
function BookPeek(local)
{
    var bookpop = window.open('bookpreview' + local + '.htm', 'bookpop', 'height=600,width=400,menubar=no,resizable=yes,scrollbars=yes');
    bookpop.focus();
}

function SetCascade(parent, child, arr, prompt)
{
    child.selectedIndex = -1;
    for (i = child.length - 1; i>=0; i--)
      child.remove(i);
    child.disabled = parent.selectedIndex == 0;
    
    var itemPrompt = document.createElement('option');
    itemPrompt.text = prompt[0];
    itemPrompt.value = prompt[1]; 
    try{
      child.add(itemPrompt, null); // standards compliant; doesn't work in IE
    }
    catch(ex){
      child.add(itemPrompt); // IE only
    }
    
    for(i = 0; i < arr.length; i++)
    {
        var item = document.createElement('option');
        item.text = arr[i][0];
        item.value = arr[i][1];    
        try{
          child.add(item, null); // standards compliant; doesn't work in IE
        }
        catch(ex){
          child.add(item); // IE only
        }
    }

}

function FormatNumber(Number,Decimals,Separator)
{
 Number += ""          // Force argument to string.
 Decimals += ""        // Force argument to string.
 Separator += ""       // Force argument to string.
 if((Separator == "") || (Separator.length > 1))
  Separator = "."
 if(Number.length == 0)
  Number = "0"
 var OriginalNumber = Number  // Save for number too large.
 var Sign = 1
 var Pad = ""
 var Count = 0
 // If no number passed, force number to 0.
 if(parseFloat(Number)){
  Number = parseFloat(Number)} else {
  Number = 0}
 // If no decimals passed, default decimals to 2.
 if((parseInt(Decimals,10)) || (parseInt(Decimals,10) == 0)){
  Decimals = parseInt(Decimals,10)} else {
  Decimals = 2}
 if(Number < 0)
 {
  Sign = -1         // Remember sign of Number.
  Number *= Sign    // Force absolute value of Number.
 }
 if(Decimals < 0)
  Decimals *= -1    // Force absolute value of Decimals.
 // Next, convert number to rounded integer and force to string value.
 // (Number contains 1 extra digit used to force rounding)
 Number = "" + Math.floor(Number * Math.pow(10,Decimals + 1) + 5)
 if((Number.substring(1,2) == '.')||((Number + '')=='NaN'))
  return(OriginalNumber) // Number too large to format as specified.
 // If length of Number is less than number of decimals requested +1,
 // pad with zeros to requested length.
 if(Number.length < Decimals +1) // Construct pad string.
 {
  for(Count = Number.length; Count <= Decimals; Count++)
   Pad += "0"
 }
 Number = Pad + Number // Pad number as needed.
 if(Decimals == 0){
  // Drop extra digit -- Decimal portion is formatted.
  Number = Number.substring(0, Number.length -1)} else {
  // Or, format number with decimal point and drop extra decimal digit.
 Number = Number.substring(0,Number.length - Decimals -1) +
          Separator +
          Number.substring(Number.length - Decimals -1,
          Number.length -1)}
 if((Number == "") || (parseFloat(Number) < 1))
  Number="0"+Number // Force leading 0 for |Number| less than 1.
 if(Sign == -1)
  Number = "-" + Number  // Set sign of number.
 return(Number)
}



