// JavaScript Document for Concert for Life
// Jones Cavalcanti - August 2004
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// string prototypes for trim funciton
String.prototype.lTrim = function () {
    var whitespace = new RegExp("^\\s+","gm");
    return this.replace(whitespace, "");
}

String.prototype.rTrim = function () {
    var whitespace = new RegExp("\\s+$","gm");
    return this.replace(whitespace, "");
}

String.prototype.trim = function () {
    return this.rTrim().lTrim();
}

function gotoURL(strURL)
{
        //popup window variable
        var pop = null;
        var strMyURL = strURL;
        strMyURL = strMyURL.trim();
        if (strMyURL == "")
        {
           return false;
        }
        else
        {
                pop = window.open(strMyURL,"NewWindow","width=600,height=400,left=10,top=120,location=yes,scrollbars=yes,resizable");
                return true;
        }       

// onclick="return gotoURL(document.frmTip)"
}//end function gotoURL

function open_image(strURL)
{
        //popup window variable
        var pop = null;
        var strMyURL = strURL;
        strMyURL = strMyURL.trim();
        if (strMyURL == "")
        {
           return false;
        }
        else
        {
                pop = window.open(strMyURL,"NewWindow","width=780,height=550,left=10,top=120,scrollbars=yes,resizable");
                return true;
        }       

// onclick="return gotoURL(document.frmTip)"
}//end function open_image
//-->

function submit_tickets()
{
        var intAmountIndex = "";
        //loop through radio buttons to see which one was selected
        for (var i= 0; i < document.frm_order_tickets.Price.length; i++)
        {
                if(document.frm_order_tickets.Price[i].checked)
                {
                        intAmountIndex = i;
                        break;
                }
        }//end for loop
        
        //alert ("intAMountindex = " + intAmountIndex)
        switch (intAmountIndex)
        {
                case 0:
                        document.frm_order_tickets.item.value = '$75 Concert & Reception ';
                        break;
                case 1:
                        document.frm_order_tickets.item.value = '$50 Concert only ';
                        break;
                case 2:
                        document.frm_order_tickets.item.value = '$25 Concert (seniors, students, persons living with AIDS)';
                        break;
                                        
                
        }//end switch statement
        //alert ("Description = " + document.frm_order_tickets.item.value);
        return true;
}//end function submit_order


function submit_order()
{
        var intAmountIndex = "";
        //loop through radio buttons to see which one was selected
        for (var i= 0; i < document.frm_order_donations.Price.length; i++)
        {
                if(document.frm_order_donations.Price[i].checked)
                {
                        intAmountIndex = i;
                        break;
                }
        }//end for loop
        
       // alert ("intAMountindex = " + intAmountIndex)
        switch (intAmountIndex)
        {
                case 0:
                        document.frm_order_donations.item.value = '$50 donation';
                        break;
                case 1:
                        document.frm_order_donations.item.value = '$100 donation';
                        break;
                case 2:
                        document.frm_order_donations.item.value = 'comfort ribbon -- 2 concert/reception tickets ($100 tax deductible) ';
                        break;
                case 3:
                        document.frm_order_donations.item.value = '$500 justice ribbon -- 4 concert/reception tickets ($200 tax deductible)';
                        break;
                case 4:
                        document.frm_order_donations.item.value = '$1,000 strength ribbon (fully tax deductible) ';
                        break;
                case 5:
                        document.frm_order_donations.item.value = '$2,500 hope ribbon (fully tax deductible)';
                        break;
                case 6:
                        document.frm_order_donations.item.value = '$5,000 peace ribbon (fully tax deductible) ';
                        break;
                        
                
        }//end switch statement
        //alert ("Description = " + document.frm_order_donations.item.value)
        return true;
}//end function submit_order

function isInteger(inputVal)
{

         inputStr= inputVal.toString()
         for (var i = 0; i < inputStr.length; i++)
         {
        var oneChar = inputStr.charAt(i)
            if (oneChar == ".")
        {
                continue
            }
    
            if (oneChar < "0" || oneChar > "9")
        {
              return false
            } 

         } //end for loop
     return true
         
}//end function isInteger

function submit_donation()
{
        var intDonation = document.frm_donation.Price.value
        intDonation = intDonation.trim()
        
        if (intDonation.length == 0)
        {
                alert ("Please enter amount for the donation before clicking on the button.")
                document.frm_donation.Price.focus()
                return false
        }
        if (isInteger(intDonation))
        {
                return true
        }
        else
        {
                alert ("Please enter only numbers for the donation.")
                document.frm_donation.Price.select
                document.frm_donation.Price.focus()
                return false
        }
}//end function submit_donation
