// ***********************************************************************//
//  THESE ARE ALL NECESSARY FUNCTIONS FOR THE STJAMESSHOPPING.COM WEBSITE //
// ***********************************************************************//


// CLEAR THE NEWSLETTER FIELD
function clearNewsletter() {
    // if we have the default value then clear the field
    if (document.newsletterform.newsletter.value = "ENTER EMAIL ADDRESS") {
        document.newsletterform.newsletter.value = "";
    }
}

// CHECK NEWSLETTER AREA HAS A VALUE BEFORE SENDING
function checkForm() {
    var email = document.newsletterform.newsletter.value;

    // if the email address is empty or the default value the display message to the user
    if (email == "" || email == "ENTER EMAIL ADDRESS") {
        alert('TO SUBSCIBE FOR INFORMATION ON OFFERS AND EVENTS\nPLEASE ENTER YOUR EMAIL ADDRESS');
    } else {

        // Validate the email address
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

        if (reg.test(email) == false) {
            alert("PLEASE ENTER A VALID EMAIL ADDRESS");
        } else {
            // submit the form
            confirm("ARE YOU SURE YOU WANT TO SUBSCRIBE TO THE NEWSLETTER: " + email);
            // document.newsletterform.submit();
        }
    }
}

// OPEN NEW WINDOW
function newwin(url, w, h) {
    var features = "width=" + w + ",height=" + h + ",scrollbars=yes";
    popup = window.open(url, 'remote', features);
}

// DISPLAY A MESSAGE TO THE USER
function msg(msg) {
    //v1.0 by Tony Burgess
    alert(msg);
}

// SHOW DATE
function todaydate() {
    //v1.0 by Tony Burgess
    var today = new Date();
    document.write(cDay(today.getDay()) + ', ' + today.getDate() + ' ' + cMonth(today.getMonth()) + ', ' + (today.getFullYear() ));
}

// SHOW THE MONTH FOR THE NEWSLETTER
function newsletterMonth() {
    //v1.0 by Tony Burgess
    var today = new Date();
    document.write(cMonth(today.getMonth()));
}

// GET MONTH
function cMonth(nMonth) {
    //v1.0 by Tony Burgess
    if (nMonth == 0) return 'JANUARY';
    if (nMonth == 1) return 'FEBRUARY';
    if (nMonth == 2) return 'MARCH';
    if (nMonth == 3) return 'APRIL';
    if (nMonth == 4) return 'MAY';
    if (nMonth == 5) return 'JUNE';
    if (nMonth == 6) return 'JULY';
    if (nMonth == 7) return 'AUGUST';
    if (nMonth == 8) return 'SEPTEMBER';
    if (nMonth == 9) return 'OCTOBER';
    if (nMonth == 10) return 'NOVEMBER';
    if (nMonth == 11) return 'DECEMBER';
}

// GET DAY
function cDay(nDay) {
    //v1.0 by Tony Burgess
    if (nDay == 1) return 'MONDAY';
    if (nDay == 2) return 'TUESDAY';
    if (nDay == 3) return 'WEDNESDAY';
    if (nDay == 4) return 'THURSDAY';
    if (nDay == 5) return 'FRIDAY';
    if (nDay == 6) return 'SATURDAY';
    if (nDay == 0) return 'SUNDAY';
}

// CLOSE LAUNCHED WINDOW
function closeWin() {
    //v1.0 by Tony Burgess
    this.window.close()
}

// change the display on the page
function changePage(newLoc) {

	var categoryId = newLoc.options[newLoc.selectedIndex].value
		
	if (categoryId != 0 || categoryId != null) {
		document.location.href = "" + categoryId;
	}
}

	
