function setVis(id, visibility) {
document.getElementById(id).style.display = visibility;
}


var state = 'none'; 
function showhide(divid) {
    if (state == 'block') {
        state = 'none';
    } else {
        state = 'block';
    }
    if (document.all) { //IS IE 4 or 5 (or 6 beta) 
        eval("document.all." + divid + ".style.display = state");
    }
    if (document.layers) { //IS NETSCAPE 4 or below 
        document.layers[divid].display = state;
    }
    if (document.getElementById && !document.all) {
        hza = document.getElementById(divid);
        hza.style.display = state;
    }
}


function ee(name, domain, suffix, text)
{
   var address = name + "\u0040" + domain + "." + suffix;
   var url = "mai" + "lto:" + address;

   if( ! text )
   {
      text = address;
   }

   document.write("<a href=\"" + url + "\">" + text + "</a>");
}


function el(name, domain, suffix, url)
{
	var visaddress = name + "\u0040" + domain + "." + suffix;
	var url = "http://www.justtheflight.co.uk/" + url;
	document.write("<a href=\"" + url + "\">" + visaddress + "</a>");
}


function validate_signup(frm) {
	var isError = false;
	var emailAddress = document.getElementById("Email").value;
	
	if (emailAddress == '' || emailAddress.indexOf('@') == -1) {
		alert('Please enter your email address');
		isError = true;
	}

	return !isError;
}


function clearText(thefield) {
    if (thefield.defaultValue == thefield.value) thefield.value = ""
}


function oneWay() {
	
	if (document.getElementById("onewaytrip").checked) {
	
	var returnDay = document.getElementById("returnDay")
	var returnMonthNumbers = document.getElementById("returnMonthNumbers")
	var returnDay = document.getElementById("returnDay")
	var returnMonthNumbers = document.getElementById("returnMonthNumbers")
	
	returnDay.removeAttribute("selected");
	returnMonthNumbers.removeAttribute("selected");
	
	if (returnDay.options[0].value > 0) {
		returnDay.options.add(new Option("No","0"),0);
	}
	if (returnMonthNumbers.options[0].value > 0) {
		returnMonthNumbers.options.add(new Option("Return","0"),0);
	}
	
	returnDay.selectedIndex = '0';
	returnMonthNumbers.selectedIndex = '0';	
	}
}


// An object that ties the two datePickers together 
var bookingPod = window.bookingPod = {
    // Default departure cursor date : todays date + 7
    "OUTWARD_CURSOR": 7,
    // Default return cursor date : departure date + 7
    "RETURN_CURSOR": 7,
    // Min days between departure and return dates      
    "MIN_DAYS_BETWEEN": 0,
    // Default messages
    "MESSAGES": {
        "outboundMonthNumbers": "Please select a departure date",
        "returnMonthNumbers": " Please select a return date"
    },
    // Maximum days ahead that a flight can be booked
    "MAX_DATE_LIMIT": 360,
    // Minimum days ahead that a flight can be booked
    "MIN_DATE_LIMIT": 0,

    createYYYYMMDDString: function (dt) {
        return dt ? dt.getFullYear() + String(dt.getMonth() + 1 < 10 ? "0" + (dt.getMonth() + 1) : dt.getMonth() + 1) + (dt.getDate() < 10 ? "0" + dt.getDate() : dt.getDate()) : "";
    },
    checkOutwardDate: function (cbObj) {
        // Show the date 
        bookingPod.showEnglishDate(cbObj);

        // An invalid or no outward date was entered
        if (!cbObj.date) {
            // Set the default cursor dates on the return element
            var today = new Date(),
                defaultOut = new Date(today.getFullYear(), today.getMonth(), today.getDate() + bookingPod.OUTWARD_CURSOR),
                defaultRet = new Date(defaultOut.getFullYear(), defaultOut.getMonth(), defaultOut.getDate() + bookingPod.RETURN_CURSOR),
                rangeHigh = new Date(today.getFullYear(), today.getMonth(), today.getDate() + bookingPod.MAX_DATE_LIMIT),
                rangeLow = new Date(today.getFullYear(), today.getMonth(), today.getDate() + bookingPod.MIN_DATE_LIMIT);

            // Reset the outward default ranges        
            datePickerController.setRangeHigh("returnMonthNumbers", bookingPod.createYYYYMMDDString(rangeHigh));
            datePickerController.setRangeLow("returnMonthNumbers", bookingPod.createYYYYMMDDString(rangeLow));

            // Set the outward cursor to be the default value : today's date + OUTWARD_CURSOR     
            datePickerController.setCursorDate("outboundMonthNumbers", bookingPod.createYYYYMMDDString(defaultOut));

            // If no return date set then reset the cursor position to be today's date + OUTWARD_CURSOR + RETURN_CURSOR  
            if (!datePickerController.getSelectedDate("returnMonthNumbers")) {
                datePickerController.setCursorDate("returnMonthNumbers", bookingPod.createYYYYMMDDString(defaultRet));
            };

            return;
        };

        // Set the rangeLow of the return to be the outward date + MIN_DAYS_BETWEEN                                               
        datePickerController.setRangeLow("returnMonthNumbers", bookingPod.createYYYYMMDDString(new Date(cbObj.yyyy, +cbObj.mm - 1, (+cbObj.dd + bookingPod.MIN_DAYS_BETWEEN), 5, 0, 0, 0)));

        // If no valid return date set 
        if (!datePickerController.getSelectedDate("returnMonthNumbers")) {
            // Set the return date to be departure date + RETURN_CURSOR                        
            datePickerController.setSelectedDate("returnMonthNumbers", bookingPod.createYYYYMMDDString(new Date(cbObj.yyyy, +cbObj.mm - 1, (+cbObj.dd + bookingPod.RETURN_CURSOR), 5, 0, 0, 0)));
        };
    },

    checkReturnDate: function (cbObj) {
        // Set the return cursor date if none set
        if (!cbObj.date) {
            var depDate = datePickerController.getSelectedDate("outboundMonthNumbers") || new Date();
            // Set the outward cursor to be the default value : todays date + OUTWARD_CURSOR     
            datePickerController.setCursorDate("returnMonthNumbers", bookingPod.createYYYYMMDDString(new Date(depDate.getFullYear(), depDate.getMonth(), depDate.getDate() + bookingPod.RETURN_CURSOR)));
        };

        // Show the date                 
        bookingPod.showEnglishDate(cbObj);
    },

    showEnglishDate: function (argObj) {
        // Grab the span & get a more English-ised version of the selected date
        var spn = document.getElementById(argObj.id + "-EnglishDate"),
            formattedDate = !(argObj.date == null) ? datePickerController.printFormattedDate(argObj.date, "l-cc-sp-j-S-sp-F-sp-Y", false) || bookingPod.MESSAGES[argObj.id] : bookingPod.MESSAGES[argObj.id];

        while (spn.firstChild) spn.removeChild(spn.firstChild);

        // Note: The 3rd argument to printFormattedDate is a Boolean value that 
        // instructs the script to use the imported locale (true) or not (false)
        // when creating the dates. In this case, I'm not using the imported locale
        // as I've used the "S" format mask, which returns the English ordinal
        // suffix for a date e.g. "st", "nd", "rd" or "th" and using an
        // imported locale would look strange if an English suffix was included        
        // Add a new text node containing our formatted date
        spn.appendChild(document.createTextNode(formattedDate));
    }
}

function contactAction()
{
document.contact.action="http://vibe.flybelfast.co.uk/contact.php";
document.contact.submit();
}


function barry() {
	
	var butname = 'btnGo';
	var buttext = 'Send Message'
	document.write('<inp'+'ut name="'+butname+'" type="bu'+'tton" value="'+buttext+'" onclick="contactVal(); return false" />');
	
}


function contactVal() {

    
	var frmContact = document.getElementById("frmcon");
	var firstname = document.getElementById("firstname");
	var surname = document.getElementById("surname");
	var email = document.getElementById("email");
	var phone = document.getElementById("contactnumber");
	var bookingref = document.getElementById("bookingref");
	var reason = document.getElementById("reason");
	var details = document.getElementById("details");
	var emailPattern = /^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/;
	var locatorPattern = /[A-Z]{2}[0-9A-F]{4,6}/;
	var frmaction = "http://vibe.flybelfast.co.uk/contact.php"
	
	
	if (firstname.value == "") {
        alert("Please enter your First Name");
        firstname.focus();
        return false
    }
	
	if (surname.value == "") {
        alert("Please enter your Surname");
        surname.focus();
        return false
    }
	
	if (firstname.value == surname.value) {
        alert("Your first name cannot be the same as your surname");
        surname.focus();
        return false
    }
	
	if (!emailPattern.test(email.value)) {
		alert("Please enter a valid email address");
        email.focus();
        return false
	}
	
	if (phone.value.length > 0 && phone.value.length < 9) {
		alert("Please enter a valid phone number");
        phone.focus();
        return false
	}
	
	if (reason.value == "") {
        alert("Please select a reason for contact");
        reason.focus();
        return false
    }
	
	if (details.value == "") {
        alert("Please enter message details");
        details.focus();
        return false
    }

    document.frmcon.action = frmaction;	
	frmContact.submit();

    return true
}


