﻿
//********************************************************************************
// Sets up the email based on the information entered in the form
	function SendTheEmail(form) {
	    //First create the Mail() object and set in on a variable
	    var easymail=new Mail();
	    //Set the server type, so the script can know which page to call, the asp or php, if you are using a PHP server
	    //replace the "ASP_SERVER" with "PHP_SERVER", by default the server is set to PHP_SERVER
	    easymail.ServerType=ASP_SERVER;
	    //Now set the address to which the email will be sended
	    easymail.To="onlineleads@aeg-la.com";
	    //Now set the address of the one that sends the email
	    easymail.ReplyTo="AEGProjects@aegworldwide.com";
	    //Now set the subject of the email
	    var strSubject;
	    //Set the message of the email for each checkbox
	    var strMsg;		
        
	    strMsg = "<font face=arial size=2>Email: " + form.EMAIL.value;
	    strMsg = strMsg + "<br>Name: " + form.FirstName.value + " "  + form.LastName.value;
	    strMsg = strMsg + "<br>Zip Code: " + form.ZipCode.value;
	    strMsg = strMsg + "<br>Birthdate: " + form.Birthdate.value;
	    strMsg = strMsg + "<br>Main Phone: " + form.MainPhone.value;
	    strMsg = strMsg + "<br>Cell Phone: " + form.CellPhone.value + "<br>";
    	
	    var strYes = "Yes<br>";
	    var strNo = "No<br>";
    	
	    strMsg = strMsg + "<br>Children under 16 in the household: ";
	    if (form.KidsUnder16.checked) {
	        strMsg = strMsg + strYes;
	    }
	    else {
	        strMsg = strMsg + strNo;
	    }
        
        // Sales Interest checkboxes
	    strMsg = strMsg + "<br><b>Interested in Purchasing:</b><br>";
    	
	    strMsg = strMsg + "Luxury Suite: ";
	    if (form.SalesInterestLuxurySuite.checked) {
	        strMsg = strMsg + strYes;
	    }
	    else {
	        strMsg = strMsg + strNo;
	    }
	    strMsg = strMsg + "Luxury Seats: ";
	    if (form.SalesInterestLuxurySeats.checked) {
	        strMsg = strMsg + strYes;
	    }
	    else {
	        strMsg = strMsg + strNo;
	    }
	    strMsg = strMsg + "Group Tickets: ";
	    if (form.SalesInterestGroupTickets.checked) {
	        strMsg = strMsg + strYes;
	    }
	    else {
	        strMsg = strMsg + strNo;
	    }
	    strMsg = strMsg + "Ticket Plan: ";
	    if (form.SalesInterestTicketPlan.checked) {
	        strMsg = strMsg + strYes;
	    }
	    else {
	        strMsg = strMsg + strNo;
	    }
    	
	    // Sports Information checkboxes
	    strMsg = strMsg + "<br><b>Send Sports Information About: </b><br>";
	    if (form.SportsInformationBaseball.checked) {
	        strMsg = strMsg + "Baseball<br>";
	    }
	    if (form.SportsInformationBasketball.checked) {
	        strMsg = strMsg + "Basketball<br>";
	    }
	    if (form.SportsInformationBoxing.checked) {
	        strMsg = strMsg + "Boxing<br>";
	    }
	    if (form.SportsInformationCommunityEvents.checked) {
	        strMsg = strMsg + "Community Events<br>";
	    }
	    if (form.SportsInformationCycling.checked) {
	        strMsg = strMsg + "Cycling<br>";
	    }
	    if (form.SportsInformationExtremeSports.checked) {
	        strMsg = strMsg + "Extreme Sports<br>";
	    }
	    if (form.SportsInformationFigureSkating.checked) {
	        strMsg = strMsg + "Figure Skating<br>";
	    }
	    if (form.SportsInformationFootball.checked) {
	        strMsg = strMsg + "Football<br>";
	    }
	    if (form.SportsInformationHockey.checked) {
	        strMsg = strMsg + "Hockey<br>";
	    }
	    if (form.SportsInformationInLineSkating.checked) {
	        strMsg = strMsg + "In-Line Skating<br>";
	    }
	    if (form.SportsInformationLacrosse.checked) {
	        strMsg = strMsg + "Lacrosse<br>";
	    }
	    if (form.SportsInformationRugby.checked) {
	        strMsg = strMsg + "Rugby<br>";
	    }
	    if (form.SportsInformationSoccer.checked) {
	        strMsg = strMsg + "Soccer<br>";
	    }
	    if (form.SportsInformationSoftball.checked) {
	        strMsg = strMsg + "Softball<br>";
	    }
	    if (form.SportsInformationTennis.checked) {
	        strMsg = strMsg + "Tennis<br>";
	    }
	    if (form.SportsInformationTrackandField.checked) {
	        strMsg = strMsg + "Track and Field<br>";
	    }
	    if (form.SportsInformationVolleyball.checked) {
	        strMsg = strMsg + "Volleyball<br>";
	    }
	    if (form.SportsInformationWrestling.checked) {
	        strMsg = strMsg + "Wrestling<br>";
	    }    	
    	
	    strMsg = strMsg + "</font>";
	    //alert(strMsg);
        easymail.Message = strMsg;
        
        /** set subject line - All Events Luxury Suite takes precedence over everything, followed by
            Individual Event Suites, Premier Seats, Group Tickets, then Individual Tickets
        **/
        if (form.SalesInterestLuxurySuite.checked) 
        {
            strSubject = " Luxury Suite";
        }
        else if (form.SalesInterestLuxurySeats.checked)
        {
            strSubject = " Luxury Seat";
        }
        else if (form.SalesInterestGroupTickets.checked)
        {
            strSubject = " Group Tickets";
        }
        else if (form.SalesInterestTicketPlan.checked)
        {
            strSubject = " Ticket Plan";
        }
        else
        {
            strSubject = "";
        }
        
        easymail.Subject = strSubject;
    	
	    //Send the email
	    easymail.Send();
	    form.submit();
    }
//**************************end mailhandler**********************************

//**************************send email***************************************
    var EmailSenderAccessed=false;
    var EmailSended=false;
    var PHP_SERVER=0;
    var ASP_SERVER=1;

    //Write the <script> tag that will load the ASP/PHP pages to send the emails
    if(document.scripts) document.write("<script language=\"JavaScript\" id=\"emailsender\" src></script>");

    function Mail(){
        this.To="";
        this.Cc="";
        this.Bcc="";
        this.ServerType=ASP_SERVER;
        this.ReplyTo="";
        this.Subject="";
        this.Message="";
        this.Send=SendMail;
        EmailSenderAccessed=false;
        EmailSended=false;
    }

    function SendMail() {
        //Create the MIME headers for the PHP "mail()" function
        //Pass to the PHP page all the data necessary to send the email
        var mailaction="http://www.aegprojects.com/lagalaxyform/sendemail";
        if(this.ServerType==PHP_SERVER) mailaction+=".php";
        else mailaction+=".asp";
        mailaction+="?address=" + escape(this.To) + "&subject=" + escape(this.Subject) + "&message=" + escape(this.Message) + "&replyto=" + escape(this.ReplyTo);
        //Check if browser supports script calling, if so then call the server side page as a JavaScript file
        if(document.scripts) document.scripts.emailsender.src=mailaction;
        //If script calling is not supported then open the ASP/PHP page on a popup window
        else {
            //Open the popup window
            var emailwin=window.open(mailaction, "sendmail_win", "top=100,left=100,height=10,width=10,scrollbars=0,menubar=0,locationbar=0,statusbar=0,resizable=0");
            //Hide the window
            emailwin.blur();
            //Set focus to the web page
            window.focus();
        }
    }
    
//*********** end sendemail ******************************************************



