﻿// JScript File

 function popupCalendar() { 
 var dateField = document.getElementById('dateField'); 
 // toggle the div 
 if (dateField.style.display == 'none') 
 dateField.style.display = 'block'; 
 else 
 dateField.style.display = 'none'; 
 } 
function toggleDiv(id) {
    if (document.getElementById(id).style.display == "block" || document.getElementById(id).style.display == " ")
    document.getElementById(id).style.display = "none";
  else
    document.getElementById(id).style.display = "block";
}

function togglePayment(id) {
    if (id == "creditCardPayment") {
        $("#creditCardPayment").show();
        $("#mailPayment").hide();
    }
    else if (id == "mailPayment") {
        $("#creditCardPayment").hide();
        $("#mailPayment").show(); 
    }
}

function toggleMemberPayment(id) {
    if (id == "AIRROC Member") {
        $("#member").show();
        $("#nonmember").hide();
    }
    else if (id == "Non-member") {
        $("#nonmember").show();
        $("#member").hide();
    }
}

function RegisterMember() { 
   var accountId = 300;

   var firstName = $("#firstNameTxt").val();
   var lastName = $("#lastNameTxt").val();
   var phone = $("#phoneTxt").val();
   var email = $("#emailTxt").val();

   var organizationId = $("#organizationList").val();
   var jobTitle = $("#titleTxt").val();
   var url = $("#urlTxt").val();

   var address1 = $("#address1Txt").val();
   var address2 = $("#address2Txt").val();
   var city = $("#cityTxt").val();
   var state = $("#StateList").val();
   var country = $("#CountryList").val();
   var postalCode = $("#postalCodeTxt").val();
    
   var timeStamp = $("#timeStampHidden").val();
   var status = "inactive";
   var gender = $("#genderList").val();
   var surName = $("#surNameList").val();
   var userName = "";
   var password = $("#passwordTxt").val();
   
   var mobile = "";
   var thumbnail = "";
   var fullPhoto = "";
   var dobMonth = "";
   var dobDay = "";
   var dobYear = "";
   var notes = "";
   var agreesToTerm = "";
   var featured = "";
   var tagLine = "";
   var lastUpdate = "";
   var guid = "";
   
   var successUrl = "../registration/complete.aspx";
   var errorDiv = $("#ctl00_ContentPlaceHolder1_status");
   
   showProgress();
    
   AjaxCall_toUrl("POST", WebRoot + "ajax/calls/do_registerMember.aspx","accountId=" + accountId + "&companyId=" + organizationId + "&surName=" + surName + "&tagLine=" + tagLine + "&userName=" + userName +
            "&jobTitle=" + jobTitle + "&firstName=" + firstName + "&lastName=" + lastName + "&address1=" + address1 + "&address2=" + address2 + "&city=" + city + "&state=" + state +
            "&country=" + country + "&postalCode=" + postalCode + "&phone=" + phone + "&mobile=" + mobile + "&email=" + email + "&url=" + url + "&thumbnail=" + thumbnail + "&fullPhoto=" + fullPhoto +
            "&dobMonth=" + dobMonth + "&dobDay=" + dobDay + "&dobYear=" + dobYear + "&gender=" + gender + "&notes=" + notes + "&agreesToTerm=" + agreesToTerm + "&password=" + password + 
            "&featured=" + featured + "&timeStamp=" + timeStamp + "&lastUpdate=" + lastUpdate + "&guid=" + guid + "&status=" + status, successUrl, errorDiv);
}

function AddOrganizationMember() {
    var loopCt = document.getElementById('loopCt').value;

    // alert(loopCt);

    for (x=0;x<=loopCt;x++)
    {
       var orgId = document.getElementById('orgId').value;
       
       var primaryFirstName = document.getElementById('primaryFirstName_' + x).value;
       
       var primaryLastName = document.getElementById('primaryLastName_' + x).value;

       var primaryPhone = document.getElementById('primaryPhone_' + x).value;

       var primaryEmail = document.getElementById('primaryEmail_' + x).value;
       
       var successDiv = document.getElementById('memberStatus');
       
       var errorDiv = $("#ctl00_ContentPlaceHolder1_status");
       
       showProgress();

       AjaxCall_toDiv("POST",WebRoot + "ajax/calls/do_Add_Organization_Member.aspx","orgId=" + orgId + "&firstName=" + primaryFirstName + "&lastName=" + primaryLastName + "&phone=" + primaryPhone + "&email=" + primaryEmail, successDiv, errorDiv);
       
       loopCt = 0;
    }
}

function AddOrganization() {

   var accountId = 300;
   var OrgName = $("#orgNameTxt").val();
   var address1 = $("#address1Txt").val();
   var address2 = $("#address2Txt").val();;
   var city = $("#cityTxt").val();
   var state = $("#ctl00_ContentPlaceHolder1_StateList").val();
   var country = $("#ctl00_ContentPlaceHolder1_CountryList").val();
   var postalCode = $("#postalCodeTxt").val();
   
   var elementID = "orgId"; //Hidden form element ID
   
   var errorDiv = $("#ctl00_ContentPlaceHolder1_status");
   
   showProgress();

   AjaxCall_toHiddenElement("POST",WebRoot + "ajax/calls/do_AddOrganization.aspx","orgName=" + OrgName + "&address1=" + address1 + "&address2=" + address2 + "&city=" + city + "&state=" + state +
            "&country=" + country + "&postalCode=" + postalCode, elementID, errorDiv);
}
function EventRegister() {

   var eventId = $("#eventId").val();
   var orgName = $("#orgNameTxt").val();
   var name = $("#nameTxt").val();
   var email = $("#emailTxt").val();
   var guest = $("#guestTxt").val();
   var comment = $("#commentTxt").val();
  
   var successDiv = $("#eventRegistrationResponse");
   
   var errorDiv = $("#ctl00_ContentPlaceHolder1_status");
   
   showProgress();

   AjaxCall_toDiv("POST",WebRoot + "ajax/calls/do_EventRegister.aspx","eventId=" + eventId + "&orgName=" + orgName + "&name=" + name + "&email=" + email + "&guest=" + guest + "&comment=" + comment, successDiv, errorDiv);
}

function AddUserResume() {
   var fullName = $("#fullNameTxt").val();
   var email= $("#emailTxt").val();
   var phone = $("#phoneTxt").val();;
   var city = $("#cityTxt").val();
   var state = $("#stateList").val();
   var country = $("#countryList").val();
   
   var position = $("#positionList").val();
   var category = $("#categoryList").val();
   
   var resumeFileName = $("#resumeNameHidden").val();
   var coverLetterFileName = $("#coverLtrHidden").val();
   var coverLetterFullText = $("#coverLtrFullUpload").val();
   
   var successUrl = WebRoot + "careers/resumes/complete.aspx";
   var errorDiv = $("#status");

   showProgress();

   AjaxCall_toUrl("POST",WebRoot + "ajax/calls/do_Add_User_Resume.aspx","fullName=" + fullName + "&email=" + email + "&phone=" + phone + "&city=" + city + "&state=" + state +
            "&country=" + country + "&position=" + position + "&category=" + category + "&resumeFileName=" + resumeFileName + "&coverLetterFileName=" + coverLetterFileName +
            "&coverLetterFullText=" + coverLetterFullText, successUrl, errorDiv);
}
function LoginMember() {
   var unameval = $("#usernameTxt").val();
   var passwordval = $("#passwordTxt").val();
   var successDiv = $("#loginSummary");
   var errorDiv = $("#loginError");

   showProgress();
   
   AjaxCall_toDiv("POST",WebRoot + "ajax/calls/do_login.aspx","userName=" + unameval + "&passWord=" + passwordval, successDiv, errorDiv);

   $(".memberLogin").fadeOut("fast");
  // $("#loggedIn").fadeIn("fast");

}
function Logout() {
   var AjaxResponseDiv = $("#loginSummary");
   var errorDiv = $("#loginError");
   
   AjaxCall_toDiv("POST",WebRoot + "ajax/calls/do_Logout.aspx","", AjaxResponseDiv, errorDiv);
   
   $("#loggedIn").fadeOut("slow");
}
function CheckEmail(){ 
    var emailAddress = $("#emailTxt").val();
    var successDiv = $("#emailStatus");
    var errorDiv =  $("#emailStatus");
    
    showProgress();

    AjaxCall_toDiv("POST",WebRoot + "ajax/calls/do_CheckUserEmail.aspx","email=" + emailAddress, successDiv, errorDiv);
}
function SendPassword(){ 
    var emailAddress = $("#userEmailTxt").val();
    var successDiv = $("#emailStatus");
    var errorDiv =  $("#emailStatus");
    //alert(emailAddress);
    //showProgress();

    AjaxCall_toDiv("POST",WebRoot + "ajax/calls/do_PasswordReminder.aspx","email=" + emailAddress, successDiv, errorDiv);
}
function CheckUser(){ 
    var username = $("#userNameTxt").val();
    var successDiv = $("#userNameStatus");
    var errorDiv =  $("#userNameStatus");
    
    showProgress();

    AjaxCall_toDiv("POST",WebRoot + "ajax/calls/do_CheckUsername.aspx","username=" + username, successDiv, errorDiv);
    
}

function showProgress(hide) {

    var img = $("#imgLoading");
    if (hide)
        img.hide();
    else
        img.show();
}

function setupEmailTB(name,email)
{   
    var contactName = name;
    var contactEmail = email;
    
    var emailHidden = document.getElementById("hiddenContactEmail");
        emailHidden.value = "email";
    
    var title = document.getElementById("title");
        title.innerHTML = "Contact " + contactName;
}

var fieldCount = 0;
function additonalMember()
{   
    fieldCount++;

    document.getElementById('loopCt').value = fieldCount;  

    var form = document.getElementById('fs');
    
    form.style.display = 'block';        

    $("#fs").append("<h1>Additional Contact Information " + fieldCount + "</h1>");   
    $("#fs").append("<div class='fieldWrapper'><label>First Name</label><input id='primaryFirstName_"+ fieldCount +"' type='text' size='20'/></div>");
    $("#fs").append("<div class='fieldWrapper'><label>Last Name</label><input id='primaryLastName_"+ fieldCount +"' type='text' size='20'/></div>");
    $("#fs").append("<div class='fieldWrapper'><label>Phone</label><input id='primaryPhone_"+ fieldCount +"' type='text' size='20'/></div>");
    $("#fs").append("<div class='fieldWrapper'><label>Email</label><input id='primaryEmail_"+ fieldCount +"' type='text' size='20'/></div>");
}

function SendToFriend(){
    var userName = $("#userName").val();
    var userEmail = $("#userEmail").val();
    var friendEmail = $("#friendEmail").val();
    var message = $("#message").val();
    var title = $("#hiddenTitle").val();
    var url = $("hiddenUrl").val();
    var successDiv = $("#sendToFriendResponse");
    var errorDiv =  $("#sendToFriendResponse");
    
    showProgress();

    AjaxCall_toDiv("POST",WebRoot + "ajax/calls/do_SendToFriend.aspx","uEmail=" + userName + "&uName=" + userEmail + "&fEmail=" + friendEmail + "&message=" + message + "&title=" + title + "&url=" + url, successDiv, errorDiv);
}

function UpdateProfile() { 
   var memberId = $("#memberId").val();
   var gender = $("#genderList").val();
   var surName = $("#surNameTxt").val();
   var firstName = $("#firstNameTxt").val();
   var lastName = $("#lastNameTxt").val();
   var middleName = $("#middleNameTxt").val();
   var displayName = $("#displayNameTxt").val();

   var address1 = $("#address1Txt").val();
   var address2 = $("#address2Txt").val();
   var city = $("#cityTxt").val();
   var state = $("#stateList").val();
   var country = $("#countryList").val();
   var postalCode = $("#postalCodeTxt").val();
    
   var successDiv = "#transactionStatus";
   var errorDiv = $("#transactionStatus");
   
   showProgress();
    
   AjaxCall_toDiv("POST",WebRoot + "ajax/calls/do_UpdateProfile.aspx","memberId=" + memberId + "&gender="+ gender + "&surName=" + surName + "&displayName=" + displayName +
            "&firstName=" + firstName + "&lastName=" + lastName + "&address1=" + address1 + "&address2=" + address2 + "&city=" + city + "&state=" + state +
            "&country=" + country + "&postalCode=" + postalCode, successDiv, errorDiv);
}

function UpdateContactInfo() { 
   var memberId = $("#memberId").val();
   var phone = $("#phoneTxt").val();
   var email = $("#emailTxt").val();
   var mobile = $("#mobileTxt").val();
   var siteUrl = $("#siteUrlTxt").val();
   var vcard = "";
   var emailFormat = $("#format").val();
    
   var successDiv = "#transactionStatus";
   var errorDiv = $("#transactionStatus");
   
   showProgress();
    
   AjaxCall_toDiv("POST",WebRoot + "ajax/calls/do_UpdateContactInfo.aspx","memberId=" + memberId + "&email="+ email + "&phone="+ phone + "&siteUrl=" + siteUrl + "&mobile=" + mobile + "&vcard=" + vcard +
            "&emailFormat=" + emailFormat, successDiv, errorDiv);
}

function UpdatePassword() { 
   var memberId = $("#memberId").val();
   var password = $("#passwordTxt").val();
    
   var successDiv = "#transactionStatus";
   var errorDiv = $("#transactionStatus");
   
   showProgress();
    
   AjaxCall_toDiv("POST",WebRoot + "ajax/calls/do_UpdatePassword.aspx","memberId=" + memberId + "&password="+ password, successDiv, errorDiv);

}

function slideShow() {

    
    //Set the opacity of all images to 0
    $('#gallery a').css({ opacity: 0.0 });
    

    
    //Get the first image and display it (set it to full opacity)
    $('#gallery a:first').css({ opacity: 1.0 });

    //Set the caption background to semi-transparent
    $('#gallery .caption').css({ opacity: 0.7 });

    //Resize the width of the caption according to the image width
    $('#gallery .caption').css({ width: $('#gallery a').find('img').css('width') });

    //Get the caption of the first image from REL attribute and display it
    $('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
	.animate({ opacity: 0.7 }, 400);

    //Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
    setInterval('gallery()', 6000);

}

function gallery() {
    alert("test");
    //if no IMGs have the show class, grab the first image
    var current = ($('#gallery a.show') ? $('#gallery a.show') : $('#gallery a:first'));

    //Get next image, if it reached the end of the slideshow, rotate it back to the first image
    var next = ((current.next().length) ? ((current.next().hasClass('caption')) ? $('#gallery a:first') : current.next()) : $('#gallery a:first'));

    //Get next image caption
    var caption = next.find('img').attr('rel');

    //Set the fade in effect for the next image, show class has higher z-index
    next.css({ opacity: 0.0 })
	.addClass('show')
	.animate({ opacity: 1.0 }, 1000);

    //Hide the current image
    current.animate({ opacity: 0.0 }, 1000)
	.removeClass('show');

    //Set the opacity to 0 and height to 1px
    $('#gallery .caption').animate({ opacity: 0.0 }, { queue: false, duration: 0 }).animate({ height: '1px' }, { queue: true, duration: 300 });

    //Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
    $('#gallery .caption').animate({ opacity: 0.7 }, 100).animate({ height: '100px' }, 500);

    //Display the content
    $('#gallery .content').html(caption);


}

