function openAtlas(link){
    window.open(link, 'Atlas', 'menubar=yes, toolbar=yes, location=no, scrollbars=yes, resizable=no, status=no, width=700, height=470, left=100, top=100')
}


/* validate FORM onSubmit */
function validateOnSubmitSiriusAir(){
    var errs = 0;
    
    if (!checkText(document.getElementById("src_city"), 'label_src_city', true)) 
        errs += 1;
    if (!checkText(document.getElementById("dst_city"), 'label_dst_city', true)) 
        errs += 1;
    if (errs > 1) 
        alert('Wymagane pola nie zostały wypełnione.');
    if (errs == 1) 
        alert('Wymagane pole nie zostało wypełnione.');
    
    if (errs == 0) {
    
		if (document.getElementById("both_sides")) {
            if (document.getElementById("both_sides").checked) {
                flight_type = 'return';
            }
            else {
                flight_type = 'single';
            }
        }
        else {
            flight_type = 'single';
        };
	
	
        Now = new Date();
        
        dep_day = document.getElementById("dep_day").value;
        dep_month = document.getElementById("dep_month").value;
        dep_year = document.getElementById("dep_year").value;
       
        DateDep = new Date(dep_year, dep_month - 1, dep_day);
		
        if (DateDep < Now && errs == 0) {
            alert('Departure date is in the past');
            errs += 1;
        };
        
        ret_day = document.getElementById("ret_day").value;
        ret_month = document.getElementById("ret_month").value;
        ret_year = document.getElementById("ret_year").value;
        
        DateBack = new Date(ret_year, ret_month - 1, ret_day);
        
        if (flight_type == 'return' && DateBack < Now && errs == 0) {
            alert('Return date is in the future');
            errs += 1;
        };
        
        if (flight_type == 'return' && DateBack < DateDep && errs == 0) {
            alert('Return date can`t be before departure date!');
            errs += 1;
        }

		retDate = ret_day + '.' + ret_month + '.' + ret_year;
		depDate = dep_day + '.' + dep_month + '.' + dep_year;
		
		if(flight_type == 'return'){
			
		} else {
			
			retDate = depDate;
			
		}
        
        origin_long = document.getElementById("src_city").value;
        destination_long = document.getElementById("dst_city").value;
        origin_long = origin_long.toUpperCase();
        destination_long = destination_long.toUpperCase();
        
        /* BAD
        origin=WAW&depDate=02.09.2009&
		depTime=&depTimeType=after
		&destination=TLV&cabinClass=Y&
		flightType=single&carrier1=&carrier2=&carrier3=&currency=PLN
		&adt=1&chd=0&inf=0&offerType=Standard&_as=PowerPrice
        */
		
		/*  
		 origin=WAW&depDate=02.09.2009&
		 depTime=&depTimeType=after
		 &destination=TLV&retDate=02.09.2009&retTime=&retTimeType=after&cabinClass=Y&flightType=single&carrier1=&carrier2=&carrier3=&currency=PLN&promoCode=&adt=1&chd=0&inf=0&sortBy=SortPrice&maxConn=-1&arrRadius=0&depRadius=100
		
		 
		 http://sirius.amadeus.com.pl/s3air/Time4Travel/PoweredAvailability.aspx?origin=WAW&
		 depDate=05.10.2009&depTime=&depTimeType=after&destination=TLV&
		 retDate=03.11.2009&retTime=&retTimeType=after&cabinClass=Y&flightType=single&carrier1=&carrier2=&carrier3=&currency=PLN&adt=1&chd=0&inf=0&offerType=Standard&_as=PowerPrice
		 
		 */
		
		
        paxADT = document.getElementById("paxADT").value;
        bookingClass = document.getElementById("bookingClass").value;
        
        if (errs == 0) {
				location.href = 'http://sirius.amadeus.com.pl/s3air/KS03042009/PoweredAvailability.aspx?origin=' + origin_long + '&depDate=' + depDate + '&depTime=&depTimeType=after&destination=' + destination_long + '&retDate=' + retDate + '&retTime=&retTimeType=after&cabinClass=' + bookingClass + '&flightType=' + flight_type + '&carrier1=&carrier2=&carrier3=&currency=PLN&adt=' + paxADT + '&chd=0&inf=0&offerType=Standard&_as=PowerPrice';
				//	no retDate	//			location.href = 'http://sirius.amadeus.com.pl/s3air/KS03042009/PoweredAvailability.aspx?origin=' + origin_long + '&depDate=' + dep_day + '.' + dep_month + '.' + dep_year + '&depTime=&depTimeType=after&destination=' + destination_long + '&cabinClass=' + bookingClass + '&flightType=' + flight_type + '&carrier1=&carrier2=&carrier3=&currency=PLN&adt=' + paxADT + '&chd=0&inf=0&offerType=Standard&_as=PowerPrice';
        }
    }
    
};


