
//helper function to create the form
function getNewSubmitForm(){
 var submitForm = document.createElement("FORM");
 submitForm.setAttribute("target","_blank");
 document.body.appendChild(submitForm);
 submitForm.method = "POST";
 return submitForm;
}

//helper function to add elements to the form
function createNewFormElement(inputForm, elementName, elementValue){
 //var newElement = document.createElement('<input type="text" name="' + elementName + '" />');
 var newElement = document.createElement("input");
 newElement.setAttribute("type", "hidden");
 newElement.setAttribute("name", elementName);
 newElement.setAttribute("value", elementValue);
 
 inputForm.appendChild(newElement);
 newElement.value = elementValue;
 return newElement;
}

//function that creates the form, adds some elements
//and then submits it
function createFormAndSubmit(arrival_daymonthyear,departure_daymonthyear,adults,children1){
 var submitForm = getNewSubmitForm();
 createNewFormElement(submitForm, "arrival_daymonthyear", arrival_daymonthyear);
 createNewFormElement(submitForm, "departure_daymonthyear", departure_daymonthyear);
 createNewFormElement(submitForm, "rooms", "1");
 createNewFormElement(submitForm, "adults", adults);
 createNewFormElement(submitForm, "children1", children1);
 createNewFormElement(submitForm, "children2", "0");
 createNewFormElement(submitForm, "customercode", "");
 createNewFormElement(submitForm, "vouchernumber", "");
 createNewFormElement(submitForm, "currency_select", "1");
 createNewFormElement(submitForm, "button", "SUBMIT");
 
 submitForm.action= "http://anemi.hermeshotelia.com/html/booking_availability.php";
 submitForm.submit();
}
