// All Javascript procedures for garbertravel.com should be located here
//------------------------------------------------------
//-------------DATE FOR TIME VARIABLE-------------------
//------------------------------------------------------

var d = new Date();
var monthname = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
//Ensure correct for language. English is "January 1, 2004"
var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();


//------------------------------------------------------
//---------------DATES FOR SEARCH BOX-------------------
//------------------------------------------------------

function populateSearchBox() {
    var i;
    var year = d.getFullYear();
    var month = d.getMonth() + 1;

    for (i = 0; i < 24; i++) {
        if (month < 10)
            document.write('<option value="' + 0 + month + '*' + year + '*">' + monthname[month - 1] + ' ' + year + '</option>');
        else
            document.write('<option value="' + 0 + month + '*' + year + '*">' + monthname[month - 1] + ' ' + year + '</option>');
        if (month == 12) {
            year++;
            month = 1;
        } else month++;
    }
}

//------------------------------------------------------
//---------------SPECIAL OFFERS WINDOW------------------
//------------------------------------------------------

function specialoffersWin() {
    var email = document.getElementById("emailAddress");
    if (email.value.length > 75) {
        window.alert("Please limit your email address to 75 characters in length.");
        return false;
    } else {
        if (checkEmail(email)) {
            specialoffersWindow = window.open("specialoffers_thankyou.asp?email=" + email.value, "specialoffersWin", "toolbar=0,scrollbars=no,directories=0,location=0,statusbar=0,menubar=0,resizable=no,width=300,height=375,left = 180,top = 85");
            specialoffersWindow.focus();

        }
    }
}
function checkRemove(form) {
    if (form.email.value == "") {
        form.email.focus();
        alert("Please enter your E-mail Address.");
        return false;
    }
}

function checkRequest(form) {
    if (form.email.value == "") {
        form.email.focus();
        alert("Please enter your E-mail Address.");
        return false;
    }
    if (form.first.value == "") {
        form.first.focus();
        alert("Please enter your First Name.");
        return false;
    }
    if (form.last.value == "") {
        form.last.focus();
        alert("Please enter your Last Name.");
        return false;
    }
    if (form.address1.value == "") {
        form.address1.focus();
        alert("Please enter your Address.");
        return false;
    }


    if (form.city.value == "") {
        form.city.focus();
        alert("Please enter your City.");
        return false;
    }
    if (form.state.value == "") {
        form.state.focus();
        alert("Please enter your State.");
        return false;
    }
    if (form.zip.value == "") {
        form.zip.focus();
        alert("Please enter your Zip Code.");
        return false;
    }

    return true;
}
function checkEmail(email) {
    //if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email.value)){
    return true;
    //}
    //email.focus();
    //alert("Invalid E-mail Address! Please re-enter.");	
    //return false;
}
//------------------------------------------------------
//------------SPECIAL OFFERS POP-UP---------------------
//------------------------------------------------------
//JK Popup Window Script (version 3.0)- By JavaScript Kit (http://www.javascriptkit.com)
//Visit JavaScriptKit.com for free JavaScripts
//This notice must stay intact for legal use
//Creates Pop-up to sign up for special offers

function openpopup(popurl) {
    var winpops = window.open(popurl, "", "width=300,height=650,status")
}
//------------------------------------------------------
//--------ROTATING HOME PAGE SIDE BANNERS---------------
//------------------------------------------------------

var theImages = new Array()
// To add more image files, continue with the
// pattern below, adding to the array.

theImages[0] = '<a href="contactus.asp"><img src="images/tagline.jpg" alt="Click to Email Garber Travel" width="160" height="300" border="0"></a>'
theImages[1] = '<a href="http://deals.garbertravel.com/ci/ltonclct.asp?distributorcode=GAR&distributoraccount=Honeymoon&searchid=16336"><img src="images/honeymoonsidead.jpg" alt="Click to View Great Honeymoon Packages" width="160" height="300" border="0"></a>'
theImages[2] = '<a href="http://deals.garbertravel.com/ci/ltonclct.asp?distributorcode=GAR&amp;distributoraccount=RotateAll-Inclusive&amp;searchid=16332"><img src="images/all-inclusiveSideAd.jpg" alt="Click to All-Inclusive Packages" width="160" height="300" border="0"></a>'

// do not edit anything below this line

var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++) {
    preBuffer[i] = new Image()
    preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random() * (p - 1));
function showImage() {
    document.write(theImages[whichImage]);
}

//------------------------------------------------------
//--------ROTATING HOME PAGE TOP BANNERS----------------
//------------------------------------------------------

var theBanners = new Array()

// To add more image files, continue with the
// pattern below, adding to the array.


//theBanners[0] = '<a href="http://www.garbertravel.com/disneyland.asp"><img src="images/disneyland_large.gif" alt="Disneyland Offer" width="595" height="115" border="0" align="top"/></a>'
//theBanners[1] = '<a href="http://www.garbertravel.com/waltdisneyworld.asp"><img src="images/waltdisneyworld_large.gif" alt="Walt Disney World Offer" width="595" height="115" border="0" align="top"/></a>'
//theBanners[2] = '<a href="http://www.garbertravel.com/disneycruiseline.asp"><img src="images/disneycruiseline_large.gif" alt="Walt Disney Cruise Line Offer" width="595" height="115" border="0" align="top"/></a>'
//theBanners[3] = '<a href="http://www.garbertravel.com/adventuresbydisney.asp"><img src="images/adventuresbydisney_large.gif" alt="Adventures by Disney Offer" width="595" height="115" border="0" align="top"/></a>'
theBanners[0] = '<a href="http://www.garbertravel.com/cruisesaleminisite.asp"><img src="images/Fall2009CruiseBannerLargeV2.jpg" alt="Fabulous Fall Cruise Sale" width="595" height="115" border="0" align="top"/></a>'
theBanners[1] = '<a href="http://www.garbertravel.com/quiz"><img src="images/Fall2009CruiseBannerLarge.jpg" alt="What\'s your cruise style? Take the Quiz!" width="595" height="115" border="0"  align="top"/></a>'

var jl = 0
var pl = theBanners.length;
var preBuffer = new Array()
for (i = 0; i < pl; i++) {
    preBuffer[i] = new Image()
    preBuffer[i].src = theBanners[i]
}
var whichBanner = Math.round(Math.random() * (pl - 1));

function showBanner() {
    document.write(theBanners[whichBanner]);
}
//
////------------------------------------------------------
////--------ROTATING INTERIOR BANNERS---------------------
////------------------------------------------------------
//
var theSmallBanners = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array.

//theSmallBanners[0] = '<a href="http://www.garbertravel.com/disneyland.asp"><img src="images/disneyland_small.gif" alt="Disneyland Offer" width="393" height="115" border="0" align="top"/></a>'
//theSmallBanners[1] = '<a href="http://www.garbertravel.com/waltdisneyworld.asp"><img src="images/waltdisneyworld_small.gif" alt="Walt Disney World Offer" width="393" height="115" border="0" align="top"/></a>'
//theSmallBanners[2] = '<a href="http://www.garbertravel.com/disneycruiseline.asp"><img src="images/disneycruiseline_small.gif" alt="Walt Disney Cruise Line Offer" width="393" height="115" border="0" align="top"/></a>'
//theSmallBanners[3] = '<a href="http://www.garbertravel.com/adventuresbydisney.asp"><img src="images/adventuresbydisney_small.gif" alt="Adventures by Disney Offer" width="393" height="115" border="0" align="top"/></a>'

theSmallBanners[0] = '<a href="http://www.garbertravel.com/cruisesaleminisite.asp"><img src="images/Fall2009CruiseBannerSmallV2.jpg" alt="Fabulous Fall Cruise Sale" width="393" height="115" border="0" align="top"/></a>'
theSmallBanners[1] = '<a href="http://www.garbertravel.com/quiz"><img src="images/Fall2009CruiseBannerSmall.jpg" alt="What\'s your cruise style? Take the Quiz!" width="393" height="115" border="0"  align="top"/></a>'


// do not edit anything below this line

var js = 0
var ps = theSmallBanners.length;
var preBuffer = new Array()
for (i = 0; i < ps; i++) {
    preBuffer[i] = new Image()
    preBuffer[i].src = theSmallBanners[i]
}
var whichSmallBanner = Math.round(Math.random() * (ps - 1));

function showSmallBanner() {
    document.write(theSmallBanners[whichSmallBanner]);
}
//------------------------------------------------------
//---------------CONTACT FORM VALIDATION----------------
//------------------------------------------------------

function validate_required(field, alerttxt) {
    with (field) {
        if (value == null || value == "")
        { alert(alerttxt); return false }
        else { return true }
    }
}

function validate_form(thisform) {
    with (thisform) {
        if (validate_required(firstname, "Please enter your first name.") == false)
        { firstname.focus(); return false }
        else {
            if (validate_required(lastname, "Please enter your last name.") == false)
            { lastname.focus(); return false }
            else {
                if (validate_required(email, "Please enter a valid e-mail address.") == false)
                { email.focus(); return false }

                else {
                    if (validate_required(address1, "Please enter a valid address.") == false)
                    { address1.focus(); return false }

                    else {
                        if (validate_required(city, "Please enter a valid city.") == false)
                        { city.focus(); return false }

                        else {
                            if (validate_required(state, "Please enter a valid state.") == false)
                            { state.focus(); return false }

                            else {
                                if (validate_required(zip, "Please enter a valid zip code.") == false)
                                { zip.focus(); return false }

                                //	else{ 
                                //	if (validate_required(messagetype,"Please enter a Message Type.")==false)
                                //  	{messagetype.focus();return false}
                                //	else{ 
                                //	if (validate_required(message,"Please enter a Message.")==false)
                                //  	{message.focus();return false}
                                //	}
                                //	}
                            }
                        }
                    }
                }
            }
        }
    } 
}

//------------------------------------------------------
//-----SHOWS/HIDES DIVS BASED ON SUBMITTED CALL---------
//------------------------------------------------------

function checkBrowser() {
    this.ver = navigator.appVersion
    this.dom = document.getElementById ? 1 : 0
    this.ie5 = (this.ver.indexOf("MSIE 5") > -1 && this.dom) ? 1 : 0;
    this.ie4 = (document.all && !this.dom) ? 1 : 0;
    this.ns5 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
    this.ns4 = (document.layers && !this.dom) ? 1 : 0;
    this.bw = (this.ie5 || this.ie4 || this.ns4 || this.ns5)
    return this
}
bw = new checkBrowser()
//With nested layers for netscape, this function hides the layer if it's visible and visa versa
function showHide(div, nest) {
    obj = bw.dom ? document.getElementById(div).style : bw.ie4 ? document.all[div].style : bw.ns4 ? nest ? document[nest].document[div] : document[div] : 0;
    if (obj.visibility == 'visible' || obj.visibility == 'show') {
        obj.visibility = 'hidden';
        obj.display = 'none';
    }
    else {
        obj.visibility = 'visible';
        obj.display = 'block';
    }
}
//Shows the div
function show(div, nest) {
    obj = bw.dom ? document.getElementById(div).style : bw.ie4 ? document.all[div].style : bw.ns4 ? nest ? document[nest].document[div] : document[div] : 0;
    obj.visibility = 'visible'
}
//Hides the div
function hide(div, nest) {
    obj = bw.dom ? document.getElementById(div).style : bw.ie4 ? document.all[div].style : bw.ns4 ? nest ? document[nest].document[div] : document[div] : 0;
    obj.visibility = 'hidden'
}