function toggleflyMHKcontent(divname) {
	if (document.getElementById(divname).style.display=="none") {
		document.getElementById(divname).style.display='block';
	}
	else {
		document.getElementById(divname).style.display='none';
	}
}


/********************/
/* Community Slider */
/********************/

$(document).ready(function () {
    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;

    //Get random start slide
    var numSlides = jQuery('#listed').children().size();
    var startSlide = Math.floor(Math.random() * numSlides)

    //start the show
    jQuery('#listed').cycle({
        fx: 'scrollHorz',
        timeout: 0,
        speed: 1000,
        next: '#next-butn',
        prev: '#prev-butn',
        startingSlide: startSlide
    });

    jQuery('#ftrsignupbox').watermark('Enter Email Address', { className: 'watermark', useNative: false });


    jQuery('#emailform').submit(function (e) {
        if (!emailPattern.test(jQuery('#ftrsignupbox').val())) {
            e.preventDefault();
            alert('Please provide a valid email address.');
        };
    });

    jQuery('#signupmodal').click(function (e) {
        e.preventDefault();
        jQuery.getScript('/includes/js/validateEmail.js');
        jQuery('<form method="post" action="/EmailSignup.ashx" id="formemailsubmit"><div style="width: 216px; padding: 25px; background: #fff;"><div style="width:212px; background-image:url(../../images/forms/leftside-bkgd-001.jpg); background-repeat:no-repeat; background-position:left bottom; font-size:12px; line-height:13px;"><img src="../../images/forms/news-header.gif" width="212" height="41" alt="Sign up for News"><table id="uiSignUpEmail" width="199" border="0" cellpadding="0" cellspacing="0" style="margin-left:4px; margin-top:12px; height:30px;"><tbody><tr><td width="43" align="right"><label for="email">E-mail:</label></td><td width="156" style="background-image:url(../../images/forms/email-box-001.gif); background-repeat:no-repeat; background-position:center;"><input name="ftrsignup" type="text" id="emailsignupinput" size="18" style="margin-left:13px; background:none; border:none;"></td></tr></tbody></table><table id="uiSignUpForm" width="135" border="0" cellpadding="0" cellspacing="0" style="margin-left:65px; margin-top:6px;"><tbody><tr><td>&nbsp;</td><td><input type="image" src="../../images/forms/smaller-submit.png" onclick="" style="margin-left:10px; margin-top:13px; margin-bottom:25px;"></td></tr></tbody></table></div></div></form>').modal({ position: ["20%"], close: true, overlayClose: true, onShow: function (dialog) {
            jQuery('#formemailsubmit').submit(function (e) {
                if (!validateEmail(jQuery('#emailsignupinput').val(), true)) {
                    e.preventDefault();
                }
            });
        }
        });
    });
});

function trackLowCostFare(obj) {
    window.open(obj.href, "_blank");
	try {
        var pageTracker = _gat._getTracker("UA-9607465-1");
        pageTracker._trackEvent("Low Cost Fare", obj.hostname);
//        setTimeout('', 100)
    } catch (err) {
//        document.location = obj.href;
    }
}

function trackBookFlight(callback) {
    try {
        var pageTracker = _gat._getTracker("UA-9607465-1");
        pageTracker._trackEvent("Book A Flight", document.location.pathname);
		if (callback && typeof(callback) === "function") {
			// execute the callback, passing parameters as necessary
			setTimeout(function () { callback(); }, 100)
		}
        
    } catch (err) {
        if (callback && typeof(callback) === "function") {
			// execute the callback, passing parameters as necessary
			callback();
		}
    }
}
