   function MM_openBrWindow(theURL,winName,features) {
     window.open(theURL,winName,features);
   }

   function changeClass(pageElement,changeClass) {
   pageElement.className = changeClass;

   }
	 
	 function checkSelectionRegular(iRequired)
{
	var selectionCounter = 0;
	var frm = document.getElementById("frmSelectCourse");
	var chkboxes = frm.elements;
	for(var i = 0; i < chkboxes.length; i++)
	{
		var chkBox = chkboxes[i];
		if (chkBox.type == "checkbox" && chkBox.checked)
			selectionCounter ++;
	}
	if (selectionCounter < iRequired)
	{
		var sCourseText
		if (iRequired == 1)
			sCourseText = "course";
		else
			sCourseText = "courses";
			
		alert('You must select at least ' + iRequired + ' ' + sCourseText + ' to continue.')
		return false;		
	}
	else
		return true;	
}

function checkSelection(lastChecked)
{
var maxAllowed = 6 // Or can put this into page through asp: var maxAllowed = <%= iMaxAllowedItems %>;

var selectionCounter = 0;
var frm = document.getElementById("frmSelectCourse");
var chkboxes = frm.elements;
	
for (var i = 0; i < chkboxes.length; i++)
{
   var chkbox = chkboxes[i];
	
   if (chkbox.type == "checkbox")
      {
         if (chkbox.checked)
         {
            selectionCounter++;
            if (selectionCounter > maxAllowed)
            {
               /*alert('Only ' + (maxAllowed-2) + ' electives may be checked...');*/
               return false;
            }
         }
	
      }
   }
	
   return true; 
}


   function MM_openBrWindow(theURL,winName,features) {
     window.open(theURL,winName,features);
   }

   function changeClass(pageElement,changeClass) {
   pageElement.className = changeClass;

   }

	function Mod10(ccno) {
		ccsum=0;
		cclen=ccno.length;
		if (cclen<13)
		{
			alert("Credit cards must have at least 13 digits.");
			return false;
		}
		else
		{
			for (i=1; i<cclen; i++)
			{
				ccdig=parseInt(ccno.charAt(cclen-(i+1)));
				if (i%2==1)
				{
					ccdig*=2;
					if (ccdig.toString().length==2)
					{
						ccdig=(parseInt(ccdig.toString().charAt(0))+parseInt(ccdig.toString().charAt(1)));
					} 
				}
				ccsum+=ccdig;
			}
			ccsum+=parseInt(ccno.charAt(cclen-1));
			if (ccsum%10==0)
			{
				cc_type_id = 'NOT VALID TYPE';
				if (ccno.match(/^4/) )
					{cc_type_id = 'VISA';}
				if (ccno.match(/^50|^56|^57|^58|^6/) )
					{cc_type_id = 'MAESTRO';}
				if (ccno.match(/^51|^52|^53|^54|^55/) )
					{cc_type_id = 'MASTERCARD';}
				if (ccno.match(/^413733|^413734|^413735|^413736|^413737|^4462|^453978|^453979|^454313|^454313|^454432|^454433|^454434|^454435|^454742|^456725|^456726|^456727|^456728|^456729|^45673|^456740|^456741|^456742|^456743|^456744|^456745|^46583|^46584|^46585|^46586|^46587|^484409|^484410|^49096|^49097|^492181|^492182|^498824/) )
					{cc_type_id = 'DELTA';}
				if (ccno.match(/^450875|^484406|^484407|^484408|^484411|^484412|^484413|^484414|^484415|^484416|^484417|^484418|^484419|^48442|^48443|^48444|^484450|^484451|^484452|^484453|^484454|^484455|^49173|^49174|^49175|^491880/) )
					{cc_type_id = 'ELECTRON';}
				if (ccno.match(/^405501|^405502|^405503|^405504|^405550|^405551|^405552|^405553|^405554|^415928|^424604|^424604|^427533|^4288|^443085|^4484|^4485|^4486|^4715|^4716|^4804/) )
					{cc_type_id = 'VISA PURCHASING';}
				if (ccno.match(/^490300|^490301|^49031|^49032|^490330|^490331|^490332|^490333|^490334|^49034|^49035|^49036|^49037|^49038|^49039|^49040|^490419|^490451|^490459|^490467|^490475|^490476|^490477|^490478|^4905|^491103|^491104|^491105|^491106|^491107|^491108|^491109|^49111|^49112|^49113|^49114|^49115|^49116|^491170|^491171|^491172|^491173|^491183|^491184|^491185|^491186|^491187|^491188|^491189|^49119|^4928|^4987/) )
					{cc_type_id = 'VISA_ATM';}
				if (ccno.match(/^60/) )
					{cc_type_id = 'DISCOVER';}
				if (ccno.match(/^63345|^63346|^63347|^63348|^63349|^6767/) )
					{cc_type_id = 'SOLO';}
				if (ccno.match(/^490302|^490303|^490304|^490305|^490306|^490307|^490308|^490309|^490335|^490336|^490337|^490338|^490339|^491101|^491102|^491174|^491175|^491176|^491177|^491178|^491179|^491180|^491181|^491182|^4936|^564182|^63330|^63331|^63332|^63333|^63334|^6759/) )
					{cc_type_id = 'SWITCH';}
				if (ccno.match(/^34|^37/) )
					{cc_type_id = 'AMEX';}
				if (ccno.match(/^3528|^3529|^353|^354|^355|^356|^357|^358|^2131|^1800/) )
					{cc_type_id = 'JCB';}
				if (ccno.match(/^300|^301|^302|^303|^304|^305|^36|^380|^381|^382|^383|^384|^385|^386|^387|^388/) )
					{cc_type_id = 'DINERS CLUB';}
				if (ccno.match(/^389/) )
					{cc_type_id = 'CARTE BLANCHE';}
				if (ccno.match(/^2014|^2149/) )
					{cc_type_id = 'ENROUTE';}
				if (cc_type_id == 'AMEX' || cc_type_id == 'DINERS CLUB')
				{
					alert('We apologize, but NYU does not accept American Express credit cards as a method of payment.\nPlease select Discover, Mastercard, or Visa.');
					return false;			
				}
			} 
			else
			{
				alert('It does not appear you have entered a valid credit card number.\nPlease check it and try again.');
				return false;
			}
		}	
	}	 

function EnableCC() {
	
   document.forms.frmSelectCourse.cctype.disabled  = false;
   document.forms.frmSelectCourse.ccno.disabled    = false;
   document.forms.frmSelectCourse.expdate.disabled = false;
   document.forms.frmSelectCourse.csc.disabled = false;

   document.forms.frmSelectCourse.pox.disabled     = true ;
}

function EnablePO() {
   document.forms.frmSelectCourse.cctype.disabled  = true;
   document.forms.frmSelectCourse.ccno.disabled    = true;
   document.forms.frmSelectCourse.expdate.disabled = true;
   document.forms.frmSelectCourse.csc.disabled = true;
   
   document.forms.frmSelectCourse.pox.disabled     = false;
}

function EnableInv() {
   document.forms.frmSelectCourse.cctype.disabled  = true;
   document.forms.frmSelectCourse.ccno.disabled    = true;
   document.forms.frmSelectCourse.expdate.disabled = true;
   document.forms.frmSelectCourse.csc.disabled = true;

   document.forms.frmSelectCourse.pox.disabled     = true ;
}

function correctPrice(iOriginalPrice) {
	var iAmount = $("Amount").value;
	if (iAmount != iOriginalPrice) {		
		Element.update("displayAmount", (iAmount + '.00'));	
		$("btnDiscount").value = "Discount Applied";
		$("btnDiscount").disabled = true;		
		$("discountcode").disabled = true;				
	}
}
