// JavaScript Document

function CreateCollection(ClassName)    
{
    var obj=new Array();
    eval("var t=new "+ClassName+"()");
    for(_item in t)
        {
            eval("obj."+_item+"=t."+_item);
        }
    return obj;
}
    
function CodeCollection()
{
    this.Container="";
    this.Add=function(obj)
    {
        this.push(obj);
    }
    this.Match = function(userCode)
    {
       var paypalURL = "na";
       for (var i=0; i<this.length; i++) {
        if (this[i].couponCode == userCode) {
           paypalURL = this[i].URL;
           break;
        } 
       }
       return paypalURL;
    }
}
   
function Code(couponCode,URL)
{
    this.couponCode=couponCode;
    this.URL=URL;
}
    
//Using the EmployeeCollection and Employee Obejcts

var cdeCollection=new CreateCollection("CodeCollection");     
cdeCollection.Add(new Code("PBS",6084500));
cdeCollection.Add(new Code("scholarship",0));
cdeCollection.Add(new Code("steppingup",6105530));
cdeCollection.Add(new Code("austin",6237005));
cdeCollection.Add(new Code("test",8529757));
cdeCollection.Add(new Code("seasonedsex",8564462));
cdeCollection.Add(new Code("coaching",8726320));
cdeCollection.Add(new Code("media",8727002));
cdeCollection.Add(new Code("idea",9029339));
cdeCollection.Add(new Code("networking phoenix",9029511));

function checkform()
 {
   var userCode = document.payform.os1.value;
   if (userCode == "") {
      alert("Please enter coupon code.");
      return false;
   }
    else if (userCode == "scholarship") {
	   self.location.href="https://members.austinvickers.com/public/AVickers/UserSignup.jsp?cc=scholarship";
	   return false;
   }
   else {
      var paypalValue = cdeCollection.Match(userCode);
      if (paypalValue == "na") {
          alert("Incorrect coupon code.  Please try again."); 
          return false;
      }else {
         document.payform.hosted_button_id.value = paypalValue;
         return true;
      }
   }
}


function PopWindow (url) { 
var prams = 'menubar=0,location=0,resizable=1,scrollbars=1,width=520,height=420';
newWin = window.open(url,'',prams);
newWin.focus();
return;}
