
var jetzt = new Date();
var Jahr = jetzt.getFullYear();
var Jahresmonat = jetzt.getMonth()+1;
var Monat = (Jahresmonat<10) ? '0' + Jahresmonat:Jahresmonat;
var Tag = (jetzt.getDate()<10) ? '0' + jetzt.getDate():jetzt.getDate();
var today = Number(Jahr + Monat + Tag);

function getLocations(obj)
{
	  pickUpBox.location.href = 'location.php?input=0&id=' + obj.options[obj.selectedIndex].value;
	  returnBox.location.href = 'location.php?input=1&id=' + obj.options[obj.selectedIndex].value;	  
} 

var datoName = false;
 
function openDato(nm)
{
	   pickupDateCalendar.location.href = 'common/date.php';
 	   returnDateCalendar.location.href = 'common/date.php';
 	   
 	   document.getElementById(nm + "Calendar").style.display = "block";
     datoName = nm;
};

function closeDato()
{
	   if(datoName != false)
 	   {
         document.getElementById(datoName + "Calendar").style.display = "none";
         datoName = false;
     }
};

function setDato(obj)
{
     document.forms["bookingForm"].elements[datoName].value = obj.name;
     document.bookingForm.elements[datoName + "1"].value = obj.id; 	
 	   document.bookingForm.elements[datoName + "Calc"].value = obj.date; 		 
     closeDato();
};
 

function selectPickUp(obj)
{
 	   var val = obj.options[obj.selectedIndex].value;
 	   var txt = obj.options[obj.selectedIndex].text;
 	   var returnIndex = document.bookingForm.CheckinLocationCode;
 	   var carIndex = document.bookingForm.VehicleType;

     if(obj.selectedIndex == 4)
     {
         returnIndex.selectedIndex = 4;
     }
     
     if(obj.selectedIndex < 4 && returnIndex.selectedIndex == 4)
     {
         returnIndex.selectedIndex = obj.selectedIndex;
     }
     
     document.getElementById("CarPrice").innerHTML = carPrice[cnr][obj.selectedIndex] + " €";  
     document.bookingForm.DailyPrice.value = carPrice[cnr][obj.selectedIndex];
}
 
function selectReturn(obj)
{
     var pickupIndex = document.bookingForm.CheckoutLocationCode;
     
    
     if(obj.selectedIndex < 4 && pickupIndex.selectedIndex == 4)
     {
     	   alert("This vehicle cannot be returned outside the Ukraine!");
         obj.selectedIndex = ri;
     }
 
     if(obj.selectedIndex == 4 && pickupIndex.selectedIndex < 4)
     {
     	   alert("This vehicle cannot be returned in addCar Kiev!");
         obj.selectedIndex = ri;
     } 
}
 
 function selectCar(nr, vType)
 { 
 	   document.bookForm.vehicleId.value = nr;
 	   document.bookForm.vehicleType.value = vType; 	   
 	   document.bookForm.submit(); 	   
 }
 
 function openPopUp(vId,ht)
 {
     var vLeft = Math.round((screen.availWidth-380)/2);
     var vTop = Math.round((screen.availHeight-400)/2);     

     popupFrame.location.href = 'popup.php?vehicle_id=' + vId + '&ht=' + ht;
     document.getElementById("PopUp").style.top = vTop + document.getElementById("TB22").scrollTop + 'px'; 
     document.getElementById("PopUp").style.left = vLeft + 'px';      	
	   document.getElementById("PopUp").style.display = "inline";
 }
 
 function closePopUp()
 {
	   document.getElementById("PopUp").style.display = "none";
 }  
 
 function openCondi()
 {
     var vLeft = Math.round((screen.availWidth-380)/2);
     var vTop = Math.round((screen.availHeight-400)/2);     

     document.getElementById("Condi").style.top = vTop + document.getElementById("TB22").scrollTop + 'px'; 
     document.getElementById("Condi").style.left = vLeft + 'px';      	
	   document.getElementById("Condi").style.display = "inline";
 }
 
 function closeCondi()
 {
	   document.getElementById("Condi").style.display = "none";
 }   
 
 function openHelp(hId)
 {
     var vLeft = Math.round((screen.availWidth-380)/2);
     var vTop = Math.round((screen.availHeight-400)/2);     

     if(hId = 'undefined')
     {
     	   var hId = document.confirmForm.CCType.selectedIndex;
     }

     helpFrame.location.href = 'help.php?help=' + hId;

     document.getElementById("Help").style.top = vTop + document.getElementById("TB22").scrollTop + 'px'; 
     document.getElementById("Help").style.left = vLeft + 'px';      	
	   document.getElementById("Help").style.display = "inline";
 } 
 
 function closeHelp()
 {
	   document.getElementById("Help").style.display = "none";
 }  
 
 

 
 function checkemail(str)
 {
    var filter=/^.+@.+\..{2,3}$/

    if (filter.test(str))
    {
         return true;
    }
    else {
         alert("Please input a valid email address!");
         return false;
    }
} 