﻿var paging_total = 0;
//////////////////////////////////////////////////////////////////////////////////////////////////
function init_default_map() {
    // if browser is compatible
	if ( GBrowserIsCompatible() ) {
        // get container
        //var map = new GMap2( document.getElementById("map_canvas") );
        var map = new GMap2( document.getElementById("vmaps") );
        // set map type
        //map.addControl( new GMapTypeControl() );
        // small zoom control
        map.addControl( new GSmallZoomControl() );
        // draw map
        map.setCenter( new GLatLng( 25,55) , 7 );
        
        
	}
}
window.onload = function(){ init_default_map(); tabs(); };
//////////////////////////////////////////////////////////////////////////////////////////////////
//create the ajax obj
function createRequestObject() {
    var req;
    if(window.XMLHttpRequest){
        // Firefox, Safari, Opera...
        req = new XMLHttpRequest();
    } else if(window.ActiveXObject) {
        // Internet Explorer 5+
        req = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        // There is an error creating the object,
        // just as an old browser is being used.
        alert('Problem creating the XMLHttpRequest object');
    }
    return req;
}
// Make the XMLHttpRequest object
var http = createRequestObject();
//////////////////////////////////////////////////////////////////////////////////////////////////
function over( id ){
	document.getElementById(id).style.background = '#76A8DB';
	document.getElementById(id).style.color = '#FFFFFF';
}
//////////////////////////////////////////////////////////////////////////////////////////////////
function out( id ){
	document.getElementById(id).style.background = '';
	document.getElementById(id).style.color = '';
}
//////////////////////////////////////////////////////////////////////////////////////////////////
function setValue( id , oDiv , control , as , lat , lon ){//alert('mostafa');

	selectedValue = document.getElementById( "sx" + oDiv + id ).innerHTML;
	document.getElementById( control ).value = selectedValue;
	document.getElementById(oDiv).style.display = 'none';
	
	if(! as ){//put this if we r not in advanced search
	
	    //write the nearby
	    var nearby = document.getElementById( control + '_nearby' );
	    nearby.className = 'show';
	    if( document.getElementById( 'fna_desc' ) ){
	        //alert('exists');
	        document.getElementById( 'fna_desc' ).style.display = 'block';
	    }//else alert('not exist');
	        
	    //save lon,lat and other data in temp arrays
	    saveToTempArray( id , oDiv );
	    
	    //set textbox flags to 1
	    document.getElementById( control + '_suggest' ).value = 1;
	}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
var tempIDArrayFrom = new Array();
var tempIDArrayTo = new Array();
function saveToTempArray( id , div ){
    //save the JSON ids to call them l8r by this id to get lon , lat...
    //take only last 2
    //alert(div.indexOf('from'));
    if(div.indexOf('from')==0){
        //alert('From');
        tempIDArrayFrom[0] = response.airports[id].airport.code;
        tempIDArrayFrom[1] = response.airports[id].airport.lon;
        tempIDArrayFrom[2] = response.airports[id].airport.lat;
        tempIDArrayFrom[3] = response.airports[id].airport.city;
        tempIDArrayFrom[4] = response.airports[id].airport.country;
        tempIDArrayFrom[5] = response.airports[id].airport.desc;
    }else if(div.indexOf('to')==0){
        //alert('To');
        tempIDArrayTo[0] = response.airports[id].airport.code;
        tempIDArrayTo[1] = response.airports[id].airport.lon;
        tempIDArrayTo[2] = response.airports[id].airport.lat;
        tempIDArrayTo[3] = response.airports[id].airport.city;
        tempIDArrayTo[4] = response.airports[id].airport.country;
        tempIDArrayTo[5] = response.airports[id].airport.desc;
    }
    //alert(tempIDArrayFrom[0]);
    //alert(tempIDArrayFrom.length);
    //alert(tempIDArrayTo.length);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//send the ajax request
function sendRequestAuctionsSearch() {


    var fetchType = document.getElementById( 'fetch_type' ).value;
    var loc = document.getElementById( 'ctl00_content_txt_From' ).value;
    var dest = document.getElementById( 'ctl00_content_txt_To' ).value;
    var dir = document.getElementById( 'dir' ).value;
    var criteria = document.getElementById( 'criteria' ).value;
    var page = document.getElementById( 'page' ).value;
    
    //sync paging with content when clicking back
    var paging_control = document.getElementById('get_from_cache_when_click_back');
    paging_control.value = 1;

    var params = '?FetchType='+fetchType+'&From='+loc+'&To='+dest+'&SortDirection='+dir+'&SortCriteria='+criteria+'&PageNo='+page + '&Op=0';
    
    //page number will be sent as:
    // 1st time: the hdn's value will be 1
    // every other call: clicking on the paging will execute 2 things:
        // 1. change the hdn's value
        // 2. send the ajax call 
    
    //when sorting: 
    // 1. after clicking the link, set the criteria hdn with the new data
    // 2. send the ajax call
    
    
    http.open( 'get', 'AuctionCode.aspx' + params , true );
    http.onreadystatechange = function (){ handleResponseAuctionsSearch() };
	http.send( null );

}
//////////////////////////////////////////////////////////////////////////////////////////////////
function handleResponseAuctionsSearch(){


    if(http.readyState == 4 && http.status == 200){
        
        //response is JSON-enabled object
        start = http.responseText;
        try{ 
        if( start == '' ){
            response = '';
        }else{
            response = eval('('+start+')');
        }       
        if( response != '' ){
        
            var count = response.PagesCount;
            if( count > 0 ) {
            
                //change fetch_type value to anything other than 'recent'
                //create pages count [paging]
                //repeat results box n times
                var fetchType = document.getElementById( 'fetch_type' );
                fetchType.value = 'done';

                //clear the [loading] identifier
                document.getElementById('r_').innerHTML = '';
                
                //show sorting
                document.getElementById('sorting_criteria').style.display = 'block';
                
                //build the result DIVs
                for( i=0 ; i<response.auctions.length ; i++ ){
                
                    //needle
                    var g = response.auctions[i].auction;
                    
                    //prepare items to be populated
                    type = g.type;
                    Location = g.location;
                    destination = g.destination;
                    travel_date = g.flight_date;
                    date_posted = g.sub_date;
                    img_path = g.img_path;
                    operator = g.operator;
                    highest_price = g.highest_price;
                    num_bids = g.num_bids;
                    num_seats = g.num_seats;
                    exp_date = g.exp_date;
                    time_left = g.time_left;
                    leg_id = g.leg_id;
                    reqType = g.requestType;
                    
                    reqOp = response.ReqOp;
                    //unit structure
                    
                    unit( Location , destination , travel_date , date_posted , img_path , operator , highest_price , num_bids , num_seats , exp_date , time_left , type , leg_id, reqType, reqOp);
                          
                }
                
                //build paging
                renderPagingMain( response.PagesCount );
                
            //write no results
            }else{
                document.getElementById('r_').innerHTML = 'No results found.';
                document.getElementById('sorting_criteria').style.display = 'none';
                document.getElementById('paging').style.display = 'none';
                //document.getElementById('paging').innerHTML = '';
                //document.getElementById('paging').style.display = 'none';
            }
        
        }
        }catch(e){
            alert('Error: [' + e.name + '] in the received results!');
            $('r_').innerHTML = 'Please select another option..'; 
        }
    }
    
}
//////////////////////////////////////////////////////////////////////////////////////////////////
function renderPagingMain( count ){
    var counterLength = count;
    var pagingDiv = document.getElementById('paging');
    pagingDiv.style.display = 'block';
    //clear the paging area
    pagingDiv.innerHTML = '';
                
    if( counterLength > 1 ){
        for( j=0 ; j<counterLength ; j++ ){
            paging( j+1 );
        }
                                
        //store num of pages to use it when clearing the highlight effect
        paging_total = j;
                  
        //highlight the first link
        var p = document.getElementById('page');
        if( p.value == 1 ){
            document.getElementById('1').className = 'auctionsLink_over';
        }else{
            document.getElementById( p.value ).className = 'auctionsLink_over';
        }
    }
}
//******************************************************
function getHost() {

    //url
    var url_ = window.location.href;
    //split http
    var nohttp = url_.split('//')[1];
    //split url parts
    var pathname_array = nohttp.split('/');
    //url parts length
    lastIndex = pathname_array.length;
    //return page name
    p = pathname_array[ lastIndex-1 ];
    
    return p;   
}
//******************************************************
//////////////////////////////////////////////////////////////////////////////////////////////////
//send the ajax request
function sendRequestAuctionsPageLoad() {

    //alert('Here');
    //alert(getHost());
    if (getHost().toLowerCase() == "userviewdeadlegs.aspx?r=0")
        var params = '?FetchType=recent&From=&To=&SortDirection=&SortCriteria=&PageNo=1&Op=0';
    else
        var params = '?FetchType=recent&From=&To=&SortDirection=&SortCriteria=&PageNo=1&Op=1';            
    var hdn_flag = document.getElementById('get_from_cache_when_click_back').value;
    
    if( hdn_flag == 0 ){
        //alert('Sending call...');
        http.open( 'get', 'AuctionCode.aspx' + params , true );
        http.onreadystatechange = function (){ handleResponseAuctionsPageLoad() };
    	http.send( null );
	}else sendRequestAuctionsSearch();

}
function handleResponseAuctionsPageLoad(){

    if(http.readyState == 4 && http.status == 200){
        
        //response is JSON-enabled object
        start = http.responseText;
        try{
        if( start == '' ){
            response = '';
        }else{
            response = eval('('+start+')');
        }
                
        if( response != '' ) {
            
            //change fetch_type value to anything other than 'recent'
            //create pages count [paging]
            //repeat results box n times
            var fetchType = document.getElementById( 'fetch_type' );
            
            //clear the [loading] identifier
            document.getElementById('r_').innerHTML = '';
            
            //build the result DIVs
            for( i=0 ; i<response.auctions.length ; i++ ){
            
                //needle
                var g = response.auctions[i].auction;
                
                //prepare items to be populated
                type = g.type;
                Location = g.location;
                destination = g.destination;
                travel_date = g.flight_date;
                date_posted = g.sub_date;
                img_path = g.img_path;
                operator = g.operator;
                highest_price = g.highest_price;
                num_bids = g.num_bids;
                num_seats = g.num_seats;
                exp_date = g.exp_date;
                time_left = g.time_left;
                leg_id = g.leg_id;
                reqType = g.requestType;
                
                reqOp = response.ReqOp;
                //alert(reqOp);    
                //unit structure
                unit( Location , destination , travel_date , date_posted , img_path , operator , highest_price , num_bids , num_seats , exp_date , time_left , type , leg_id, reqType, reqOp);
                    
            }
            
            //build paging
            renderPagingMain( response.PagesCount );
            
            //hide paging if we r in PageLoad
            //if( fetchType.value == 'recent' ){
               // pagingDiv.style.display = 'none';
            //}else{
              //  pagingDiv.style.display = 'block';
            //}
            
            //get out of the first load
            fetchType.value = 'done';
            
        }else{
                document.getElementById('r_').innerHTML = '<img src="SiteImages/loading.gif" /> Loading...';
                document.getElementById('sorting_criteria').style.display = 'none';
                //document.getElementById('paging').innerHTML = '';
                //document.getElementById('paging').style.display = 'none';
        }
        }catch(e){
            alert('Error: [' + e.name + '] in the received results!');
            $('r_').innerHTML = 'Please select another option..'; 
        }
    }
    
}
//////////////////////////////////////////////////////////////////////////////////////////////////
function resetPaging(){
    //reset all highlights
    for( i=1 ; i<=paging_total ; i++ ){
        document.getElementById( i ).className = 'auctionsLink';
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//when clicking the search button
function search(){

    var departure = document.getElementById('ctl00_content_txt_From').value;
    //alert(departure);
    var arrival = document.getElementById('ctl00_content_txt_To').value;
    //alert(arrival);
    if( departure == '' && arrival != '' ){
        alert('Please enter a valid departure airport.');
    }else{
        //reset to defaults, then, send call
        document.getElementById('page').value = 1;
        document.getElementById('criteria').value = 'SubmissionDate';
        document.getElementById('dir').value = 'down';
        
        //alert(document.getElementById('paging').style.display);
        if( document.getElementById('paging').style.display == 'block' && document.getElementById('page').value != 1 ){
            resetPaging();
            document.getElementById('1').className = 'auctionsLink_over';
        }
        
        //check if boxes values r selected from the suggest menu
        //flags
        f_ = document.getElementById('ctl00_content_hdn_From');
        t_ = document.getElementById('ctl00_content_hdn_To');
        
        //real boxes values
        from_ = document.getElementById('ctl00_content_txt_From');
        to_ = document.getElementById('ctl00_content_txt_To');
        
        //alert(from_.value);
        //alert(to_.value);
        
        if( from_.value != to_.value ){
            if( f_.value == 0 ){
                error = true;
                f_.style.border = '1px solid #FF0000';
                //msg = 'Please select airport from list.';
                alert('Please enter a valid departure airport.');
            }else{
                f_.style.border = '1px solid #AFAFAF';
                document.getElementById('r_').innerHTML = 'Loading...';
                sendRequestAuctionsSearch();
            }
        }
        else if (from_.value == '')
        {
            alert('Please Select at least a Departure Airport');
        }
        else
        {    //alert(f_.value);
            //alert(t_.value);
            alert('Departure airport should not be the same as Arrival airport.');
        }
    }
    
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//create paging after search
function paging( linkID ){
    document.getElementById('paging').innerHTML += '<a id="'+linkID+'" href="#" class="auctionsLink" onclick="pagingGo(this.id);return false;">'+linkID+'</a> ';
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//when click on paging item
function pagingGo( pageID ){
    //show loading
    $('r_').innerHTML = '<img src="SiteImages/loading.gif" /> Loading...';
    //change [page] value, then, send call
    document.getElementById('page').value = pageID;
    //reset paging
    resetPaging();
    //highlight the clicked value
    document.getElementById(pageID).className = 'auctionsLink_over';
    //send the call
    sendRequestAuctionsSearch();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
function unit( location , destination , travel_date , date_posted , img_path , operator , highest_price , num_bids , num_seats , exp_date , time_left , divColor , leg_id , reqType, reqOp){

    //green: #03AF03
    //red: 
    if( divColor == 'Auction' ){
        divColor = '#03AF03';
        bid_book = 'Bid';
        highest = 'Bid';
        bid_book_url = 'AuctionCode.aspx?lid=' + leg_id;
        bid_book_class = 'green-button';
    }else{
        divColor = '#DE010A';
        bid_book = 'Book';
        highest = 'Price';
        bid_book_url = 'PaymentForm.aspx?lid=' + leg_id;
        bid_book_class = 'red-button';
    }
    
    if (reqType == 1)
        imageSource = 'Images/Aircraft.gif';
    else if (reqType == 2)
        imageSource = 'Images/Ambulance.gif';
    else if (reqType == 3)
        imageSource = 'Images/Cargo.gif'; 
    else
        imageSource = '';       
    
    var flight_details = 'UserViewDeadLegDetails.aspx?lid=' + leg_id;

    //alert(reqOp);
    if (reqOp == "1")
    {
        //document.getElementById('r_').innerHTML += '<!--Single unit--><div style="border-bottom:3px solid '+divColor+'; width:97%; height:150px; background-color:#F7F7F7;"><!--Header--><div style="border:0px solid red; background-color:'+divColor+'; height:15px; padding:10px; color:#FFF;"><div style="float:left; font-weight:bold;"><span id="ap1">'+location+'</span> --> <span id="ap2">'+destination+'</span></div><div style="border:0px solid red; float:right;"><span style="font-weight:bold;">Date Posted:</span><span id="DP"> '+date_posted+'</span></div></div><!--Body--><div style="border:0px solid red; width:20px; height:80px; float:left;"></div><div style="border:0px solid red; width:110px; height:80px; float:left;"><br /><span id="img"><img src="'+img_path+'" width="75" height="75" /></span><br /><span id="op">'+operator+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Travel date</span><br /><span id="td">'+travel_date+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Price per flight</span><br /><span id="hp">'+highest_price+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Number of bids</span><br /><span id="nob">'+num_bids+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Available seats</span><br /><span id="nos">'+num_seats+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Expiry date</span><br /><span id="ed">'+exp_date+'</span><br /></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Time left to '+bid_book+'</span><br /><span id="tl">'+time_left+'</span><br /></div><div style="border:0px solid red; width:97%; text-align:right; height:30px; clear:left;"><input type="button" value="Flight details" style="width:110px; height:20px;" onclick="location.href=\''+flight_details+'\';" />&nbsp;<input type="button" value="'+bid_book+'" style="width:90px; height:20px;" onclick="location.href=\''+bid_book_url+'\'" /></div></div><!--End single unit--><br />';
        document.getElementById('r_').innerHTML += '<!--Single unit--><div style="border-bottom:3px solid '+divColor+'; width:97%; height:150px; background-color:#F7F7F7;"><!--Header--><div style="border:0px solid red; background-color:'+divColor+'; height:20px; padding:10px; color:#FFF;"><div style="float:left; font-weight:bold;border:0px solid red;"><span id="ap1">'+location+'</span> ==> <span id="ap2">'+destination+'</span></div><div style="border:0px solid red;float:right;"><span style="font-weight:bold;">Date Posted:</span><span id="DP"> '+date_posted+'</span></div></div><!--Body--><div style="border:0px solid red; width:20px; height:80px; float:left;"></div><div style="border:0px solid red; width:110px; height:80px; float:left;"><br /><span id="img"><img src="'+img_path+'" width="75" height="75" /></span><br /><span id="op">'+operator+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Travel date</span><br /><span id="td">'+travel_date+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Price per flight</span><br /><span id="hp">'+highest_price+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Number of bids</span><br /><span id="nob">'+num_bids+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Available seats</span><br /><span id="nos">'+num_seats+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Expiry date</span><br /><span id="ed">'+exp_date+'</span><br /></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Time left to '+bid_book+'</span><br /><span id="tl">'+time_left+'</span><br /></div><div style="float:left"><img src="' + imageSource + '" /></div><div style="border:0px solid red; width:97%; text-align:right; height:30px; clear:left;"><a href="#" class="black-button" onclick="location.href=\''+flight_details+'\';return false;">Flight Details</a>&nbsp;<a href="#" class="'+bid_book_class+'" onclick="location.href=\''+bid_book_url+'\';return false;">'+bid_book+'</a></div></div><!--End single unit--><br />';
    }
    else if (reqOp == "0")
    {
        
        //document.getElementById('r_').innerHTML += '<!--Single unit--><div style="border-bottom:3px solid '+divColor+'; width:97%; height:150px; background-color:#F7F7F7;"><!--Header--><div style="border:0px solid red; background-color:'+divColor+'; height:15px; padding:10px; color:#FFF;"><div style="float:left; font-weight:bold;"><span id="ap1">'+location+'</span> --> <span id="ap2">'+destination+'</span></div><div style="border:0px solid red; float:right;"><span style="font-weight:bold;">Date Posted:</span><span id="DP"> '+date_posted+'</span></div></div><!--Body--><div style="border:0px solid red; width:20px; height:80px; float:left;"></div><div style="border:0px solid red; width:110px; height:80px; float:left;"><br /><span id="img"><img src="'+img_path+'" width="75" height="75" /></span><br /><span id="op">'+operator+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Travel date</span><br /><span id="td">'+travel_date+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Price per flight</span><br /><span id="hp">'+highest_price+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Number of bids</span><br /><span id="nob">'+num_bids+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Available seats</span><br /><span id="nos">'+num_seats+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Expiry date</span><br /><span id="ed">'+exp_date+'</span><br /></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Time left to '+bid_book+'</span><br /><span id="tl">'+time_left+'</span><br /></div><div style="border:0px solid red; width:97%; text-align:right; height:30px; clear:left;"><input type="button" value="Flight details" style="width:110px; height:20px;" onclick="location.href=\''+flight_details+'\';" />&nbsp;<input type="button" value="'+bid_book+'" style="width:90px; height:20px;" onclick="location.href=\''+bid_book_url+'\'" /></div></div><!--End single unit--><br />';
        document.getElementById('r_').innerHTML += '<!--Single unit--><div style="border-bottom:3px solid '+divColor+'; width:97%; height:150px; background-color:#F7F7F7;"><!--Header--><div style="border:0px solid red; background-color:'+divColor+'; height:20px; padding:10px; color:#FFF;"><div style="float:left; font-weight:bold;border:0px solid red;"><span id="ap1">'+location+'</span> ==> <span id="ap2">'+destination+'</span></div><div style="border:0px solid red;float:right;"><span style="font-weight:bold;">Date Posted:</span><span id="DP"> '+date_posted+'</span></div></div><!--Body--><div style="border:0px solid red; width:20px; height:80px; float:left;"></div><div style="border:0px solid red; width:110px; height:80px; float:left;"><br /><span id="img"><img src="'+img_path+'" width="75" height="75" /></span><br /><span id="op">'+operator+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Travel date</span><br /><span id="td">'+travel_date+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Price per flight</span><br /><span id="hp">'+highest_price+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Number of bids</span><br /><span id="nob">'+num_bids+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Available seats</span><br /><span id="nos">'+num_seats+'</span></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Expiry date</span><br /><span id="ed">'+exp_date+'</span><br /></div><div style="border:0px solid red; width:110px; height:80px; float:left; text-align:center;"><br /><span style="font-weight:bold;">Time left to '+bid_book+'</span><br /><span id="tl">'+time_left+'</span><br /></div><div style="float:left"><img src="' + imageSource + '" /></div><div style="border:0px solid red; width:97%; text-align:right; height:30px; clear:left;"><a href="#" class="black-button" onclick="location.href=\''+flight_details+'\';return false;">Flight Details</a></div></div><!--End single unit--><br />';    
    }
    
    
}
//////////////////////////////////////////////////////////////////////////////////////////////////
function sort( val ){
    
    //change [criteria] value, change [dir] value, then, send call
    var c = document.getElementById('criteria');
    var d = document.getElementById('dir');

    if( c.value == val ){//switch case
        
        if( d.value == 'up' ) d.value = 'down';
        else d.value = 'up';
        
    }else{//use [up]
        
        d.value = 'up';   
        
    }
    
    c.value = val;
        
    //show loading
    $('r_').innerHTML = '<img src="SiteImages/loading.gif" /> Loading...';
    
    sendRequestAuctionsSearch();
}
//////////////////////////////////////////////////////////////////////////////////////////////////


