function chkCardNum(nm, num){
	if(nm == 'AMEX'){
		idx = num.substring(0,2);
		if(num.length != 15)
			temp = false;	
		else if(idx != "34" && idx != "37")
			temp = false;	
		else
			temp = true;	
	}else if(nm == 'DISC'){
		idx = num.substring(0,4);
		if(num.length != 16)
			temp = false;	
		else if(idx != "6011")
			temp = false;	
		else
			temp = true;	
	}else if(nm == 'MC'){
		idx = num.substring(0,2);
		if(num.length != 16)
			temp = false;	
		else if(idx < "51" || idx > "55")
			temp = false;	
		else
			temp = true;	
	}else if(nm == 'VISA'){
		idx = num.substring(0,1);
		if(num.length != 13 && num.length != 16)
			temp = false;	
		else if(idx != "4")
			temp = false;	
		else
			temp = true;	
	}else
		temp = true;
	return temp;
}
function checkCC(){
	var temp = false;	
	var cc = document.cc;
	var crd = cc.card_type.options[cc.card_type.selectedIndex].value;
	var exp = cc.exp_yr.value + cc.exp_mn.value;

        if(cc.x_card_num.value == ''){
                alert('Credit card number cannot be blank.');
                cc.x_card_num.focus();
        }else if(!chkCardNum(crd, cc.x_card_num.value)){
                alert('Credit card number does not match the type of card selected.');
                cc.card_type.focus();
        }else if(cc.cur_dt.value > exp){
                alert('You have entered an expired card date.');
                cc.exp_mn.focus();
        }else if(cc.x_first_name.value == ''){
                alert('Billing first name cannot be blank.');
                cc.x_first_name.focus();
        }else if(cc.x_last_name.value == ''){
                alert('Billing last name cannot be blank.');
                cc.x_last_name.focus();
        }else if(cc.x_email.value == ''){
                alert('E-Mail cannot be blank.');
                cc.x_email.focus();
	}else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(cc.x_email.value))){
		alert("Invalid E-mail Address! Please re-enter.")
                cc.x_email.focus();
	}else if(cc.x_address.value == ''){
		alert('Billing address cannot be blank.');
		cc.x_address.focus();
	}else if(cc.x_city.value == ''){
		alert('Billing city cannot be blank.');
		cc.x_city.focus();
	}else if(cc.x_state.selectedIndex == 0){
		alert('Please select a billing address state.');
		cc.x_state.focus();
	}else if(cc.x_zip.value == ''){
		alert('Billing zip cannot be blank.');
		cc.x_zip.focus();
        }else if(cc.x_ship_to_first_name.value == ''){
                alert('Shipping first name cannot be blank.');
                cc.x_ship_to_first_name.focus();
        }else if(cc.x_ship_to_last_name.value == ''){
                alert('Shipping last name cannot be blank.');
                cc.x_ship_to_last_name.focus();
	}else if(cc.x_ship_to_address.value == ''){
		alert('Shipping address cannot be blank.');
		cc.x_ship_to_address.focus();
	}else if(cc.x_ship_to_city.value == ''){
		alert('Shipping city cannot be blank.');
		cc.x_ship_to_city.focus();
	}else if(cc.x_ship_to_state.selectedIndex == 0){
		alert('Please select a shipping address state.');
		cc.x_ship_to_state.focus();
	}else if(cc.x_ship_to_zip.value == ''){
		alert('Shipping zip cannot be blank.');
		cc.x_ship_to_zip.focus();
	}else
		temp = true;
	return temp;
}
