function changeDropoffAirport() {
	for(i=0;i<document.getElementById('drpPickUp_Airport').length;++i)
	if(document.getElementById('drpPickUp_Airport').options[i].selected == true)
	document.getElementById('drpDropoff_Airport').options[i].selected = true;
}
function changeDropoffCity() {
	for(i=0;i<document.getElementById('drpPickup_City').length;++i)
	if(document.getElementById('drpPickup_City').options[i].selected == true)
	document.getElementById('drpDropoff_City').options[i].selected = true;
}
function changeTime () {
	for(i=0;i<document.getElementById('drpPickup_Time').length;++i)
	if(document.getElementById('drpPickup_Time').options[i].selected == true)
	document.getElementById('drpDropoff_Time').options[i].selected = true;
}
function showCustomerSaved(LanguageId) {  
    var myCSResults = document.getElementById('ltrCustomerSaved');
    var myLoadingDiv = document.getElementById('divCustomerSaved');
    myCSResults.innerHTML = "";
    myLoadingDiv.style.display = "block"
    
    //alert("test");
    
    WsCustomerSaved.getCustomerSaved(LanguageId,ShowResults);
} 
function ShowResults(result) { //evaluate values from webservice and fill results into the site
//alert(result);
    var myCSResults = document.getElementById('ltrCustomerSaved');
    var myLoadingDiv = document.getElementById('divCustomerSaved');
    myLoadingDiv.style.display = "none" 
    
    var myCSFadeIn = new AjaxControlToolkit.Animation.FadeInAnimation($get("ltrCustomerSaved"), 0.5 , 20 ,0,1);
    myCSResults.innerHTML = result.Text;
    
    myCSFadeIn.play();
    myCSFadeIn.onEnd  = function() {
        setTimeout("closeCsShowDbs("+result.LanguageId+")",10000);         
    }       
}


function closeCsShowDbs(LanguageId) {  
    var myCSFadeOut = new AjaxControlToolkit.Animation.FadeOutAnimation($get("ltrCustomerSaved"), 0.5 , 20 ,0,1);
    myCSFadeOut.play();
    myCSFadeOut.onEnd = function() {$get("ltrCustomerSaved").style.display = "none";showDBStatistic(LanguageId);}        
}
function reOpenCs(LanguageId) {  
    $get("divCustomerSaved").style.display = "block";
    $get("ltrCustomerSaved").style.display = "block";
    showCustomerSaved(LanguageId);    
}

function showDBStatistic(LanguageId) { 
//alert(LanguageId);
    var myArray = new Array(3,1,8,9,12,13); //list of Country Id's           
    WsCustomerSaved.getDBStatistics(LanguageId,myArray,showDBStatisticResult);
} 
function showDBStatisticResult(myStatisticResult) { //evaluate values from webservice and fill results into the site
    var myCSResults = document.getElementById('myContainer');
    myCSResults.innerHTML = myStatisticResult.Text;
    showStatistics(myStatisticResult.Count,1,myStatisticResult.LanguageId);//start to show the first stat-entry
}

function showStatistics(myCount,myId,LanguageId) {//show stat entries
    if(myCount == myId){reOpenCs(LanguageId);$get("myContainer").style.display="none";return false}
    $get("myContainer").style.display="block";
    $get("myDbStatisticDiv"+myId).style.display = "block";
    var myFadeIn = new AjaxControlToolkit.Animation.FadeInAnimation($get("myDbStatisticDiv"+myId), 0.5 , 20 ,0,1);
    myFadeIn.play();   
    myFadeIn.onEnd = function() {setTimeout("hideStatistics("+myCount+","+myId+","+LanguageId+")",5000);}       
} 
function hideStatistics(myCount,myId,LanguageId) {//hide stat entries, on end show next entry
    var myFadeOut = new AjaxControlToolkit.Animation.FadeOutAnimation($get("myDbStatisticDiv"+myId), 0.5 , 20 ,0,1);
    myFadeOut.play();
    myFadeOut.onEnd = function() {
        $get("myDbStatisticDiv"+myId).style.display = "none";
        myId++;    
        showStatistics(myCount,myId,LanguageId);            
    }
}



function ChangePickup(id,c_dropoff_also) { // can  be removed

    //alert(id);

    var PCITY = document.getElementById('rowPickup_City');
    var DCITY = document.getElementById('rowDropOff_City');
    var PAIR = document.getElementById('rowPickUpAirport');
    var DAIR = document.getElementById('rowDropoffAirport');
    var radDropAir = document.getElementById('radDropOffType_0');
    var radDropCity = document.getElementById('radDropOffType_1');
    
    //alert(radDropAir);
    
    if(c_dropoff_also == true) {
        if(id == 1) { //city
            PCITY.style.display = "";
            DCITY.style.display = "";
            PAIR.style.display = "none";
            DAIR.style.display = "none";
            radDropAir.checked = false;
            radDropCity.checked = true;
        }
        if(id == 2) { //airport
            PCITY.style.display = "none";
            DCITY.style.display = "none";
            PAIR.style.display = "";
            DAIR.style.display = "";    
            radDropAir.checked = true;
            radDropCity.checked = false;            
        }    
    }
    if(c_dropoff_also == false) {
        if(id == 1) { //city
            DCITY.style.display = "";
            DAIR.style.display = "none";
        }
        if(id == 2) { //airport
            DCITY.style.display = "none";
            DAIR.style.display = "";    
        }    
    }
}

function addlist(listField,newText, newValue) {var len = listField.length++; listField.options[len].value = newValue; listField.options[len].text = newText;}
function fillDate() {

    var now = new Date();
    var PickUp = new Date();
    var DropOff = new Date();
    var PDay,DDay,PMonth,DMonth,PYear,DYear;
    
    var PickField = document.getElementById('txtPickupDate');
    var DropField = document.getElementById('txtDropOffDate');

    PickUp.setDate(now.getDate() + 7); 
    DropOff.setDate(now.getDate() + 21); 

    PDay = PickUp.getDate();
    DDay = DropOff.getDate();
    if(PDay < 10) { PDay = '0' + PDay}
    if(DDay < 10) { DDay = '0' + DDay}
    PMonth = PickUp.getMonth() + 1;
    DMonth = DropOff.getMonth() + 1;
    if(PMonth < 10) { PMonth = '0' + PMonth}
    if(DMonth < 10) { DMonth = '0' + DMonth}
    PYear = PickUp.getFullYear();
    DYear = DropOff.getFullYear();

    PickField.value = PDay + '.' + PMonth + '.' + PYear;
    DropField.value = DDay + '.' + DMonth + '.' + DYear;
    
    for (i = 0; i <= 23; i++) {
        for (j= 0; j <= 3; j++) {
        hour = i;
        minute = '' + 15 * j;
        if (j < 1) minute = '00';
        hour = hour +':' + minute;
        if (i <= 9) hour = '0' + hour; 
        addlist(document.getElementById('drpPickup_Time'),hour,hour);
        addlist(document.getElementById('drpDropoff_Time'),hour,hour);
        }
    }
    
    now = new Date();
    now.setHours(now.getHours());
    hour = now.getHours();
    document.getElementById('drpPickup_Time').options[48].selected = true;
    document.getElementById('drpDropoff_Time').options[48].selected = true;
}

function change_dropoff_date(id,value) {
    //alert(value);
    if(value.length != 10) {
        alert("Falsches Datumsformat. (TT.MM.JJJJ)");
        return false;
    }
    var Day = value.substr(0,2);
    var Month = value.substr(3,2);
    var Year = value.substr(6,4);
    
    var myDate = new Date();
    myLastYear = (eval(myDate.getFullYear()) + 2);
    
    if(Day < 1 || Day > 31) {
        alert("Falsches Datum!");
        return false;
    }
    if(Month < 1 || Month > 12) {
        alert("Falsches Datum!");
        return false; 
    }
    if(Year < myDate.getFullYear() || Year > myLastYear) {
        alert("Falsches Datum!");
        return false;
    }
    
    var PickUp = new Date();
    var DropOff = new Date();
    var DDay,DMonth,DYear;
    var PLimit = new Date();
    var DropField = document.getElementById('txtDropOffDate');

    PickUp.setTime(Date.parse(Month + '/' + Day + '/' + Year));
    DropOff = PickUp;

    DropOff.setDate(DropOff.getDate() + 7);
    

    $find("CalExDropOffDate").set_selectedDate(DropOff);

}

function changeNews(direction, count) {  

    var show = eval(document.getElementById('news_shown').value);
     
    if(direction == 'next') {
        if(show == (count -1)) {
            show = (count -1);
        }else {show = show + 1;}        
    }
    
    if(direction == 'previous') {
        if(show == 0) {
            show = 0;
        }else {show = show - 1;}        
    }    
    
    document.getElementById('news_shown').value = show;
    
    //alert(show);
    
    if(show > -1 && show < count) {
        for(i=0;i<count;++i) {
            var Item = document.getElementById('divNews'+i);
            var myItem = document.getElementById('divNews'+show);
            Item.style.display = "none";
            if(i==show) {
                myItem.style.display = "block";
            }
        }    
    }
}  