﻿function PopupCenter(pageURL, title, w, h, toolbar, menubar) {
    var left = (screen.width / 2) - (w / 2);
    var top = (screen.height / 2) - (h / 2);
    var targetWin = window.open(pageURL, title, 'toolbar=' + toolbar + ', location=no, directories=no, status=no, menubar=' + menubar + ', scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
}

function newsletterSignup() {

    var uEmail = $("#txtEmail").val();

    var legitEmail = checkEmailAddress(uEmail);

    if (legitEmail) {
        var loadingBlock = '<div style="width:24px; height:24px; margin:20px auto;"><img src="/resources/img/common/ajax-loader.gif" width="24" height="24" alt="loading..." /></div>';

        $('#signup').html(loadingBlock);
        $('#signup').load('/app_clientservices/newslettersignup.aspx?e=' + escape(uEmail));
    } else {
        $("#txtEmail").attr("value", "");
        $("#txtEmail").focus();
    }
}

function checkNewsletterEnter(e) {
    if (e.keyCode == 13) {
        newsletterSignup();
        return true;
    } else { return false; }
}

function checkEmailAddress(eMail) {
    var goodEmail = eMail.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

    if (!goodEmail) {
        alert('Please enter a valid e-mail address.');
        return false;
    } else { return true; }
}


//FOOTER
$(document).ready(function() {

    Cufon.replace('#locations div.title span', { fontFamily: 'DroidSerif' });

    $('a.primerib-logo').click(
			function() {
			    if ($('#locations').is(':hidden')) {
			        $('#locations').slideDown('slow');
			    }
			}
		);

    $('#locations').mouseover(
			function() {
			    $('div#restaurants a.primerib-logo').css('background-image', 'url(/resources/img/landing/img_lawrystheprimerib_hover.png)');
			    
			}
	);
		
    $("a.contact-us").fancybox({
        'width': 960,
        'height': '80%',
        'autoScale': true,
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'speedIn': 100,
        'speedOut': 100,
        'type': 'iframe',
        'scrolling': 'auto',
        'overlayShow': true,
        'overlayOpacity': 0.8,
        'overlayColor': '#000',
        'hideOnOverlayClick': false,
        'enableEscapeButton': true
    });
    
		$('#horizon').delay(1000).html('<img src="/resources/img/lawrys-noflash.jpg" style="text-align: center; overflow: hidden;" />')
});

function defaultPrimeRibLogo() {
    $('div#restaurants a.primerib-logo').css('background-image', 'url(/resources/img/landing/img_lawrystheprimerib.png)');
}
