
jQuery(document).ready(function(){
    /* open the contact us lightbox */
    jQuery('.contact_us').colorbox({width:"520px", inline:true, href:"#lightbox", title: "Aeropostale: Contact Us" });
    jQuery('.newsletter').colorbox({width:"520px", inline:true, href:"#newsletter_lightbox", title: "Aeropostale: e-newsletter" });
    /* open the vote thanks lightbox */
    //jQuery('.lightbox_thanks').colorbox({width:"520px", inline:true, href:"#lightbox_thanks"});
}); // END: jquery function

//////////////////////////////////////////////////////////////////////////////////
// general popup function
    function popup( url, name, w, h, x, y, scroll, status )
    {   if( ( name == "" ) || ( name == null ) )
        {   var Winname = "ALLOY_POPUP";
        }
        else
        {   var Winname = name;
        }
        if( ( scroll == "" ) || ( scroll == null ) )
        {   var scrollBar = "auto";
        }
        else
        {   var scrollBar = scroll;
        }
        if( ( status == "" ) || ( status == null ) )
        {   var statusBar = "auto";
        }
        else
        {   var statusBar = status;
        }
        window.open( url, Winname, 'resizable=yes,menubar=no,toolbar=no,location=no,status='+statusBar+',scrollbars='+scrollBar+',width='+w+',height='+h+',left='+x+',top='+y );
    }
//////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////
    function launchSendToFriend( earl )
    {   if( ( contextPath == "" ) || ( contextPath == null ) )
        {   contextPath = "";
        }
        if( ( earl == "" ) || ( earl == null ) )
        {   popup( contextPath + "/friends/email/sendto/" + escape( document.location.href ) + "/" + document.title, "FRIEND_POPUP", 425, 500, 100, 100 );
        }
        else
        {   popup( contextPath + "/friends/email/sendto/" + escape( earl ) + "/" + document.title, "FRIEND_POPUP", 425, 500, 100, 100 );
        }
    }
    function launchSendToFriend()
    {   if( ( contextPath == "" ) || ( contextPath == null ) )
        {   contextPath = "";
        }
        popup( contextPath + "/friends/email/sendto/" + escape( document.location.href ) + "/" + document.title, "FRIEND_POPUP", 425, 500, 100, 100 );
    }
    function openInviteFriend()
    {   //popup( contextPath + "/friends/invite/email", "STF", 500, 570, 50, 100, 0, 1 )
        document.location = contextPath + "/friends/invite/email";
    }
    function openerInviteFriend()
    {   //popup( contextPath + "/friends/invite/email", "STF", 500, 570, 50, 100, 0, 1 )
        window.opener.document.location = contextPath + "/friends/invite/email";
    }
    function openInviteContest() {
        //popup( contextPath + "/contests/invite/index.htm", "STF", 560, 570, 50, 100, 0, 1 )
        popup( contextPath + "/contests/invite/index.htm", "STF", 560, 400, 50, 100, 0, 1 )
    }
//////////////////////////////////////////////////////////////////////////////////


// ////////////////////////////////////////////////////////////////////////////////
// ajax form validation
function combineDob() {
    var dobMonth = jQuery( "#dobMonth" ).val();
    var dobDay = jQuery( "#dobDay" ).val();
    var dobYear = jQuery( "#dobYear" ).val();
    if( (dobMonth != null && dobMonth != "") && (dobDay != null && dobDay != "") && (dobYear != null && dobYear != "") ) {
        jQuery( "#birthDate" ).val( dobMonth + "/" + dobDay + "/" + dobYear );
    }
}
function combinePhone() {
    var areaCode = jQuery( "#areaCode" ).val();
    var first3Digits = jQuery( "#first3Digits" ).val();
    var last4Digits = jQuery( "#last4Digits" ).val();
    if( (areaCode != null && areaCode != "") && (first3Digits != null && first3Digits != "")
            && (last4Digits != null && last4Digits != "") ) {
        jQuery( "#phoneNumber" ).val( areaCode + "-" + first3Digits + "-" + last4Digits );
    }
}
function combineAndSubmit( theForm ) {
    combineDob();
    combinePhone();
    theForm.submit();
}
function setUsernameAsEmail() {
    jQuery( "#username" ).val( jQuery( "#email" ).val() );
}

function swapImage( imageId, newSrc ) {
    jQuery( "#" + imageId ).attr( "src", newSrc );
}
// ////////////////////////////////////////////////////////////////////////////////