// JavaScript functions for ptc website

<!--
function emptyBasket(){
	if(confirm("Do you wish to empty your basket?") == true){
		document.location = "basket.php?action=empty";
	}
}

// Checks to see if form element is empty
function isEmpty( str){
    strRE = new RegExp( );
    strRE.compile( '^[s ]*$', 'gi' );
    return strRE.test( str.value );
}

// Checks to see if email address is 'valid'
function notValidEmail( str ){
    mailRE = new RegExp( );
    mailRE.compile( '^[._a-z0-9-]+@[.a-z0-9-]+[.]{1}[a-z]{2,4}$', 'gi' );
    return !(mailRE.test( str.value ));
}

// Main validation area that holds the 'alerts' and if/else statements to loop until all info is correctly entered by the user
function checkForm( form ){
// If the form is empty, display message
    if( isEmpty( form.name ) ){
        alert( 'Please specify your name.' );
        return false;
    }

// If the email address is not 'valid' display a message
    if( notValidEmail( form.email ) ){
        alert( 'You must enter a valid e-mail address!' );
        return false;
    }

    if( isEmpty( form.comments ) ){
        alert( 'Spamming is not cool, please enter a message to either spam me or to contact me about something important.' );
        return false;
    }  else {
   		return true;
	}
}
//-->
