// JavaScript Document

function determineTicketPackage(){
    
	//api_form.close();
	
	var sXML = "/plan-your-visit/data/ZipandIncomeAtlanta.xml";
	
    //How long can you spend at the Aquarium?
	var timeAvailable = document.getElementById('how-long-stay').value;
    if(timeAvailable == 'partOfDay' || timeAvailable == 'allDay'){
        var timeSpan = 'long';
    } else{
        var timeSpan = 'short';
    }
     
    
    //Do you plan to visit other attractions?
    var otherAttractions = false;
    if(document.getElementById('otherAttractionsYes').checked === true){
        otherAttractions = true;
    }
    
    //Any children under age 12?
    var childrenPresent = false;
     if(document.getElementById('childrenYes').checked === true){
        childrenPresent = true;
    }
     
    //Enter ZIP code
	var zip_code = document.getElementById("zip-box").value;	
	  
	var postal_exists = postalCodeLookup(sXML, zip_code);
	var high_income = postalCodeLevel(sXML, zip_code);

	//alert("Time Available: " + timeAvailable + "\r\nVisit Other Attractions: " + otherAttractions + "\r\nChildren Under 12: " + childrenPresent + "\r\nZIP Code: " + zip_code + "\r\nPostal Exists: " + postal_exists + "\r\nHigh Income: " + high_income);

    var ticketPackageIndex = 0;
    
    if(postal_exists === false && childrenPresent === false){
    //Out of town / no children
        
        if(timeSpan == 'short' && otherAttractions === true){
            //Short time / other attractions
            ticketPackageIndex = 1;   
        }else if(timeSpan == 'short' && otherAttractions === false){
            //short time /  no other attractions
            ticketPackageIndex = 2;
        }else if(timeSpan == 'long' && otherAttractions === true){
            //long time / other attractions
            ticketPackageIndex = 3;
        }else if(timeSpan == 'long' && otherAttractions === false){
            //Long time / no other attractions
            ticketPackageIndex = 4;
        }
        
    }else if(postal_exists === false && childrenPresent === true){
    //Out of town / children
    
        if(timeSpan == 'short' && otherAttractions === true){
            //Short time / other attractions
            ticketPackageIndex = 5;   
        }else if(timeSpan == 'short' && otherAttractions === false){
            //short time /  no other attractions
            ticketPackageIndex = 6;
        }else if(timeSpan == 'long' && otherAttractions === true){
            //long time / other attractions
            ticketPackageIndex = 7;
        }else if(timeSpan == 'long' && otherAttractions === false){
            //Long time / no other attractions
            ticketPackageIndex = 8;
        }
        
    }else if(postal_exists === true && childrenPresent === true){
    //In town / children
    
        if(timeSpan == 'short' && otherAttractions === true){
            //Short time / other attractions
            ticketPackageIndex = 9;   
        }else if(timeSpan == 'short' && otherAttractions === false){
            //short time /  no other attractions
            ticketPackageIndex = 10;
        }else if(timeSpan == 'long' && otherAttractions === true){
            //long time / other attractions
            ticketPackageIndex = 11;
        }else if(timeSpan == 'long' && otherAttractions === false){
            //Long time / no other attractions
            ticketPackageIndex = 12;
        }
        
    }else if(postal_exists === true && childrenPresent === false){
    //In town / no children
    
        if(timeSpan == 'short' && otherAttractions === true){
            //Short time / other attractions
            ticketPackageIndex = 13;   
        }else if(timeSpan == 'short' && otherAttractions === false){
            //short time /  no other attractions
            ticketPackageIndex = 14;
        }else if(timeSpan == 'long' && otherAttractions === true){
            //long time / other attractions
            ticketPackageIndex = 15;
        }else if(timeSpan == 'long' && otherAttractions === false){
            //Long time / no other attractions
            ticketPackageIndex = 16;
        }
        
    }
        
    //Load proper ticket package into lightbox
   window.location = '/plan-your-visit/tickets-wizard.aspx?pkg=' + ticketPackageIndex;
	 
}



