function processOrder(){
	var alrt = '';
	var task;
	//alert(document.myform.firstname.value);
	if(document.myform.name.value == ''){
		alrt = 'Attention is blank.'
	}
	if(document.myform.address.value == ''){
		alrt = alrt + '\nAddress is blank.'
	}
	if(document.myform.city.value == ''){
		alrt = alrt + '\nCity is blank.'
	}
	if(document.myform.state.value == ''){
		alrt = alrt + '\nState is blank.'
	}
	if(document.myform.pcode.value == ''){
		alrt = alrt + '\nPostcode is blank.'
	}
	if(document.myform.email.value != ''){
		checkEmail(document.myform.email.value,'Email');
	}else{
		alrt = alrt + '\nEmail is blank.';
	}
	if(document.myform.phone.value == ''){
		alrt = alrt + '\nTelephone is blank.'
	}
	if(alrt){
		alert(alrt + '\n\nPlease correct these errors before submiting the form.');
	}else{
		document.myform.submit();
	}
}

function isExpiryDate(cmonth,cyear) {
	if((!cmonth)|(!cyear)){
		return false;
	} else {
		today = new Date();
		expiry = new Date('20' + cyear, cmonth);
		
		if (today.getTime() > expiry.getTime()){
			return true;
		} else {
			return false;
		}
	}
}

function checkEmail(email,position) {
	var err = true;
    if (email != '') {
		invalidChars = ' /:,;'
		for(j=0; j<invalidChars.length; j++) {
			badChar = invalidChars.charAt(j)
			if (email.indexOf(badChar,0) != -1) {
                alert('The e-mail address you entered \nfor ' + position + 'contains one or more invalid characters.')
                err = false
			}
		}

		atPos = email.indexOf('@',1)
        if (atPos == -1) {
			alert('The e-mail address you entered for ' + position + '\nis missing its @ sign.')
			err = false
		}

		if (email.indexOf('@',atPos+1) != -1) {
			alert('The e-mail address you entered for ' + position + '\ncontains too many @ signs.')
			err = false
		}

		periodPos = email.indexOf('.',atPos)
		if (periodPos == -1) {
			alert('The e-mail address you entered for ' + position + '\nis missing its extension.')
			err = false
		}

		if (periodPos+3 > email.length){
			alert('The e-mail address you entered for ' + position + 'appears\nto use an invalid extension.')
            err = false
		}
	}
	if (err) {
		return true
	}else {
		return false
	}
}

function checkCard(Str,card){

        failed=false
        newStr=''

		//alert(card);        
		
        for (var k = 0; k < Str.length; k++){
			var oneChar = Str.charAt(k)
			if ((oneChar != " ") && (oneChar != "-")) {
				newStr += Str.charAt(k)    
			}
        }
                
        for (var k = 0; k < newStr.length; k++){
                var oneChar = newStr.charAt(k)
                if (oneChar < "0" || oneChar > "9") {
                        failed = true;
                }
        }
        
        // Update the form with newStr so that the trimmed value is submitted to the
        // next page
        
        document.myform.cc_num.value=newStr
        
        if (newStr.length ==0){
                failed = true;
        }

        if(card == 1){
			//visa
                if((newStr.length != "13") && (newStr.length != "16")){
                        failed = true;
                }
		if(newStr.charAt(0) != 4){
			failed = true;
		}

        }

        if(card == 2){
			//mastercard
                if(newStr.length != "16"){
                        failed = true;
                }
		if((newStr.charAt(0) != 5) || (newStr.charAt(1) >5) || (newStr.charAt(1) ==0)){
			failed = true;
			}
        }

        if(card == 5){
				//bankcard
                if(newStr.length != "16"){
                        failed = true;
                }
                if((newStr.charAt(0) != 5) || (newStr.charAt(1) != 6) || (newStr.charAt(2) != 1) || (newStr.charAt(3) != 0)){
					failed = true;
				}
        }

		if(card == 3){
				//amex
                if(newStr.length != "15"){
                        failed = true;
                }
                if((newStr.charAt(0) != 3)){
					failed = true;
				}
        }
		
		if(card == 4){
				//diners
                if(newStr.length != "14"){
                        failed = true;
                }
                if((newStr.charAt(0) != 3)){
					failed = true;
				}
        }

        if (!failed){
			//alert(failed);
        	return false
        } else {
			//alert(failed);
			return true
		}        
}