<!-- Programseven start -->
  var stl_strprotocol='http';
  if(window.location.href.substring(0,5)=='https'){stl_strprotocol='https'};
  var sevenStr = '<'+'script language="javascript" src="'+stl_strprotocol+'://stl.p.a1.traceworks.com/prod/reg_scripts/reg_466642-1.js"><'+'/script>';
  document.write(sevenStr);
<!-- Programseven end -->

function submit(formName) {
	frmSub = eval(document.forms[formName]);
	frmSub.submit();
}

function submitFormName(formName, newFormName) {
	//Set the new name to the form, then submit it.
	eval(document.forms[formName]).bmForm.value = newFormName;
	eval(document.forms[formName]).submit();
}

function submitFormWithAction(formName, actionValue) {
	//Set the action property of the form, then submit it.
	var strAction = eval(document.forms[formName]).action;
	var strLast4Chars = strAction.substring(strAction.length, strAction.length - 4);
	if (strLast4Chars != '.jsp') {
			// Replace the ? with and &
			actionValue = '&' + actionValue.substring(actionValue.length,1);
	}
	eval(document.forms[formName]).action = eval(document.forms[formName]).action + actionValue;
	eval(document.forms[formName]).submit();
}

function submitFormWithSubRequests(formName, request) {
	var strAction = eval(document.forms[formName]).action;
	var strLast4Chars = strAction.substring(strAction.length, strAction.length - 4);

	if (strAction.indexOf(";")>0) {
	    // there is a jsessionid in the path and a ? is already there
	    if (strAction.indexOf("?")>0) {
    		var paramIdentifier = '&';
    	} else {
    		var paramIdentifier = '?';
    	}
	} else
	if (strLast4Chars != '.jsp') {
		// Replace the ? with and &
		var paramIdentifier = '&';
	} else {
		var paramIdentifier = '?';
	}
	eval(document.forms[formName]).bmSubmit.value = request;
	eval(document.forms[formName]).action = eval(document.forms[formName]).action + paramIdentifier + request + '=' + request;
	eval(document.forms[formName]).submit();
}

function submitFormWithActionAndHiddenField(formName, actionValue, hiddenFieldName, hiddenFieldValue) {
  txt = 'document.' + formName + '.' + hiddenFieldName+ '.value=\''  + hiddenFieldValue + '\'' ;
  eval(txt);
  submitFormWithAction(formName, actionValue);
}

function submitFormWithActionAndHiddenField2(formName, actionValue, hiddenField1Name, hiddenField1Value, hiddenField2Name, hiddenField2Value) {
  txt1 = 'document.' + formName + '.' + hiddenField1Name+ '.value=\''  + hiddenField1Value + '\'' ;
  txt2 = 'document.' + formName + '.' + hiddenField2Name+ '.value=\''  + hiddenField2Value + '\'' ;
  eval(txt1);
  eval(txt2);
  submitFormWithAction(formName, actionValue);
}

function submitWithParam1(nameofForm, nameofParam, valueofParam)
{
  var txt = "document." + nameofForm + "." + nameofParam + ".value ='" + valueofParam + "'";
  eval(txt);
  document.forms[nameofForm].submit();
}

function submitWithParam2(nameofForm, nameofParam1, valueofParam1, nameofParam2, valueofParam2 )
{
  var txt1 = "document." + nameofForm + "." + nameofParam1 + ".value ='" + valueofParam1 + "'";
  var txt2 = "document." + nameofForm + "." + nameofParam2 + ".value ='" + valueofParam2 + "'";
  eval(txt1);
  eval(txt2);
  document.forms[nameofForm].submit();
}


// Check if it's an Internet Explorer browser
// returns a boolean
function isIE()
{
	
    return (navigator.userAgent.indexOf("MSIE") != -1);
}

// Check if it's a Netscape / Mozilla browser
// returns a boolean
function isNS()
{
    return ((navigator.userAgent.indexOf("Mozilla") != -1) &&
        (navigator.userAgent.indexOf("Gecko") != -1));
}


// calculates and sets the new height for the_iframe
// returns nothing
function calcIFrameHeight()
{
    // Set the header height for all browsers.
    var headerHeight = 137; //126=headerheight
    
    // Set the header for Mozilla if necessary.
    if (isNS())
    {
    	headerHeight = 145; //126=headerheight 
    }
    
    var the_height;
    
    // check if the document runs in strict mode
    if (document.compatMode=="CSS1Compat")
    {
        the_height = document.documentElement.clientHeight - headerHeight;
    }
    else
    {
        // find the height of the internal page
        the_height = document.body.clientHeight - headerHeight;
    }
    
    // check if the the_iframe element exists
    if (document.getElementById('the_iframe'))
    {
        // check wether to use internet explorer or mozilla DOM
        if (isNS())
        {
            // change the height of the iframe.
            document.getElementById('the_iframe').height = the_height;
        }
        else
        {
            document.getElementById('the_iframe').style.height = the_height;
        }
    }
}

// calculates and sets the new height for the Affiliate iframe
// returns nothing
function calcAffiliateIFrameHeight()
{
  var theHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    theHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    theHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    theHeight = document.body.clientHeight;
  }
  
  //subtract other header / footer / etc.
  
  theHeight = theHeight - 228;
    if (document.getElementById('the_affiliate_iframe'))
    {
        // check wether to use internet explorer or mozilla DOM
        if (isNS())
        {
            // change the height of the iframe.
            document.getElementById('the_affiliate_iframe').height = theHeight;
        }
        else
        {
            document.getElementById('the_affiliate_iframe').style.height = theHeight;
        }
    }

}

// clears the text from form text fields when clicked
 function doClear(theText) {
     if (theText.value == theText.defaultValue) {
         theText.value = ""
     }
 }

function showObject(obj)
{
	changeObjectDisplay(obj, '');
}

function hideObject(obj)
{
	changeObjectDisplay(obj, 'none');
}

function getStyleObject(objectId) {
	// Do a check for W3C, IE and Netscape DOMs.
	if (document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId).style;
	} else 
	if (document.all && document.all(objectId)) {
		return document.all(objectId).style;
	} else 
	if (document.layers && document.layers[objectId]) {
		return document.layers[objectId];
	}
	
	return false;
}

function changeObjectDisplay(objectId, newDisplay) {
	// get a reference to the cross-browser style object and make sure the object exists
	var styleObject = getStyleObject(objectId);

	if(styleObject) {
		styleObject.display = newDisplay;
		return true;
	}

	return false;
}

/* This method submits a form into a popup */
function submitFormPopup(formName, newFormName, properties) {
	// open a new popup window with target name 'newFormName'
	window.open('',newFormName,properties).focus();

	// get the form object we want to submit
	var theForm = eval(document.forms[formName]);
	
	// save the old target
	var oldTarget = theForm.target;
	
	// set the target to the new popup window
  	theForm.target = newFormName;
  	
  	// submit the form
  	submitFormName(formName, newFormName);

  	theForm.target = oldTarget;
}

/* This method sets the dayField and monthYearField from the formName form to the specified date value */
function setFormDayMonthYearFields(date, formName, dayField, monthYearField) {
	var day = date.getDate();
	var month = date.getMonth()+1;
	var year = date.getYear();
	if (day<10) day = '0'+day;
	if (month<10) month = '0'+month;

	<!-- IE returns 2004 for the year, NN returns 104 -->
	if (year<2000) year=1900+year;
	
	document[formName][dayField].value = day;
	document[formName][monthYearField].value = year+""+month;
}

/* This method sets the dayField and monthYearField from the formName form to the specified date value */
function setFormDateField(date, formName, dayField, monthYearField) {
	var day = date.getDate();
	var month = date.getMonth()+1;
	var year = date.getYear();
	if (day<10) day = '0'+day;
	if (month<10) month = '0'+month;

	<!-- IE returns 2004 for the year, NN returns 104 -->
	if (year<2000) year=1900+year;
	
	document[formName][dayField].value = day;
	document[formName][monthYearField].value = year+""+month;
}

/* This method sets the date field from the formName form to the specified date value in the dd/mm/yyyy format */
function setFormDateField(date, formName, dayMonthYearField) {
	var day = date.getDate();
	var month = date.getMonth()+1;
	var year = date.getYear();
	if (day<10) day = '0'+day;
	if (month<10) month = '0'+month;

	<!-- IE returns 2004 for the year, NN returns 104 -->
	if (year<2000) year=1900+year;
	
	document[formName][dayMonthYearField].value = day+"/"+month+"/"+year;
}

/* This method is called by the layout_portal.jsp (in the onLoad body line). */
function prefillQuickFlightDates() {
	
	var quickSearchForm = document.forms['affiliate_quick_flight'];
	
	if (quickSearchForm != null) {
		if (!quickSearchForm.elements['AFFILIATE_SEARCH_INPUT<>outboundDate'].value) {
			prefillDate(3, 'AFFILIATE_SEARCH_INPUT<>outboundDate');
			document.getElementById('AFFILIATE_SEARCH_INPUT<>nrAdults').selectedIndex=1;
		}
		if (!quickSearchForm.elements['AFFILIATE_SEARCH_INPUT<>inboundDate'].value) {
			prefillDate(10, 'AFFILIATE_SEARCH_INPUT<>inboundDate');
		}		
	}
}

/**
 * This method prefills the outbound date with 2 days after today (used for the quick flight).
 */
function prefillDate(addNoOfDays, field) {
	var date = new Date();
	date.setDate(date.getDate()+addNoOfDays);
	
	setFormDateField(date, 'affiliate_quick_flight', field);
}