/* Last published on : 17-Nov-09 11:02:52 */
/*
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2.7.0
*/
YAHOO.util.Connect={_msxml_progid:["Microsoft.XMLHTTP","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP"],_http_headers:{},_has_http_headers:false,_use_default_post_header:true,_default_post_header:"application/x-www-form-urlencoded; charset=UTF-8",_default_form_header:"application/x-www-form-urlencoded",_use_default_xhr_header:true,_default_xhr_header:"XMLHttpRequest",_has_default_headers:true,_default_headers:{},_isFormSubmit:false,_isFileUpload:false,_formNode:null,_sFormData:null,_poll:{},_timeOut:{},_polling_interval:50,_transaction_id:0,_submitElementValue:null,_hasSubmitListener:(function(){if(YAHOO.util.Event){YAHOO.util.Event.addListener(document,"click",function(C){var B=YAHOO.util.Event.getTarget(C),A=B.nodeName.toLowerCase();if((A==="input"||A==="button")&&(B.type&&B.type.toLowerCase()=="submit")){YAHOO.util.Connect._submitElementValue=encodeURIComponent(B.name)+"="+encodeURIComponent(B.value);}});return true;}return false;})(),startEvent:new YAHOO.util.CustomEvent("start"),completeEvent:new YAHOO.util.CustomEvent("complete"),successEvent:new YAHOO.util.CustomEvent("success"),failureEvent:new YAHOO.util.CustomEvent("failure"),uploadEvent:new YAHOO.util.CustomEvent("upload"),abortEvent:new YAHOO.util.CustomEvent("abort"),_customEvents:{onStart:["startEvent","start"],onComplete:["completeEvent","complete"],onSuccess:["successEvent","success"],onFailure:["failureEvent","failure"],onUpload:["uploadEvent","upload"],onAbort:["abortEvent","abort"]},setProgId:function(A){this._msxml_progid.unshift(A);},setDefaultPostHeader:function(A){if(typeof A=="string"){this._default_post_header=A;}else{if(typeof A=="boolean"){this._use_default_post_header=A;}}},setDefaultXhrHeader:function(A){if(typeof A=="string"){this._default_xhr_header=A;}else{this._use_default_xhr_header=A;}},setPollingInterval:function(A){if(typeof A=="number"&&isFinite(A)){this._polling_interval=A;}},createXhrObject:function(F){var E,A;try{A=new XMLHttpRequest();E={conn:A,tId:F};}catch(D){for(var B=0;B<this._msxml_progid.length;++B){try{A=new ActiveXObject(this._msxml_progid[B]);E={conn:A,tId:F};break;}catch(C){}}}finally{return E;}},getConnectionObject:function(A){var C;var D=this._transaction_id;try{if(!A){C=this.createXhrObject(D);}else{C={};C.tId=D;C.isUpload=true;}if(C){this._transaction_id++;}}catch(B){}finally{return C;}},asyncRequest:function(F,C,E,A){var D=(this._isFileUpload)?this.getConnectionObject(true):this.getConnectionObject();var B=(E&&E.argument)?E.argument:null;if(!D){return null;}else{if(E&&E.customevents){this.initCustomEvents(D,E);}if(this._isFormSubmit){if(this._isFileUpload){this.uploadFile(D,E,C,A);return D;}if(F.toUpperCase()=="GET"){if(this._sFormData.length!==0){C+=((C.indexOf("?")==-1)?"?":"&")+this._sFormData;}}else{if(F.toUpperCase()=="POST"){A=A?this._sFormData+"&"+A:this._sFormData;}}}if(F.toUpperCase()=="GET"&&(E&&E.cache===false)){C+=((C.indexOf("?")==-1)?"?":"&")+"rnd="+new Date().valueOf().toString();}D.conn.open(F,C,true);if(this._use_default_xhr_header){if(!this._default_headers["X-Requested-With"]){this.initHeader("X-Requested-With",this._default_xhr_header,true);}}if((F.toUpperCase()==="POST"&&this._use_default_post_header)&&this._isFormSubmit===false){this.initHeader("Content-Type",this._default_post_header);}if(this._has_default_headers||this._has_http_headers){this.setHeader(D);}this.handleReadyState(D,E);D.conn.send(A||"");if(this._isFormSubmit===true){this.resetFormState();}this.startEvent.fire(D,B);if(D.startEvent){D.startEvent.fire(D,B);}return D;}},initCustomEvents:function(A,C){var B;for(B in C.customevents){if(this._customEvents[B][0]){A[this._customEvents[B][0]]=new YAHOO.util.CustomEvent(this._customEvents[B][1],(C.scope)?C.scope:null);A[this._customEvents[B][0]].subscribe(C.customevents[B]);}}},handleReadyState:function(C,D){var B=this;var A=(D&&D.argument)?D.argument:null;if(D&&D.timeout){this._timeOut[C.tId]=window.setTimeout(function(){B.abort(C,D,true);},D.timeout);}this._poll[C.tId]=window.setInterval(function(){if(C.conn&&C.conn.readyState===4){window.clearInterval(B._poll[C.tId]);delete B._poll[C.tId];if(D&&D.timeout){window.clearTimeout(B._timeOut[C.tId]);delete B._timeOut[C.tId];}B.completeEvent.fire(C,A);if(C.completeEvent){C.completeEvent.fire(C,A);}B.handleTransactionResponse(C,D);}},this._polling_interval);},handleTransactionResponse:function(F,G,A){var D,C;var B=(G&&G.argument)?G.argument:null;try{if(F.conn.status!==undefined&&F.conn.status!==0){D=F.conn.status;}else{D=13030;}}catch(E){D=13030;}if(D>=200&&D<300||D===1223){C=this.createResponseObject(F,B);if(G&&G.success){if(!G.scope){G.success(C);}else{G.success.apply(G.scope,[C]);}}this.successEvent.fire(C);if(F.successEvent){F.successEvent.fire(C);}}else{switch(D){case 12002:case 12029:case 12030:case 12031:case 12152:case 13030:C=this.createExceptionObject(F.tId,B,(A?A:false));if(G&&G.failure){if(!G.scope){G.failure(C);}else{G.failure.apply(G.scope,[C]);}}break;default:C=this.createResponseObject(F,B);if(G&&G.failure){if(!G.scope){G.failure(C);}else{G.failure.apply(G.scope,[C]);}}}this.failureEvent.fire(C);if(F.failureEvent){F.failureEvent.fire(C);}}this.releaseObject(F);C=null;},createResponseObject:function(A,G){var D={};var I={};try{var C=A.conn.getAllResponseHeaders();var F=C.split("\n");for(var E=0;E<F.length;E++){var B=F[E].indexOf(":");if(B!=-1){I[F[E].substring(0,B)]=F[E].substring(B+2);}}}catch(H){}D.tId=A.tId;D.status=(A.conn.status==1223)?204:A.conn.status;D.statusText=(A.conn.status==1223)?"No Content":A.conn.statusText;D.getResponseHeader=I;D.getAllResponseHeaders=C;D.responseText=A.conn.responseText;D.responseXML=A.conn.responseXML;if(G){D.argument=G;}return D;},createExceptionObject:function(H,D,A){var F=0;var G="communication failure";var C=-1;var B="transaction aborted";var E={};E.tId=H;if(A){E.status=C;E.statusText=B;}else{E.status=F;E.statusText=G;}if(D){E.argument=D;}return E;},initHeader:function(A,D,C){var B=(C)?this._default_headers:this._http_headers;B[A]=D;if(C){this._has_default_headers=true;
}else{this._has_http_headers=true;}},setHeader:function(A){var B;if(this._has_default_headers){for(B in this._default_headers){if(YAHOO.lang.hasOwnProperty(this._default_headers,B)){A.conn.setRequestHeader(B,this._default_headers[B]);}}}if(this._has_http_headers){for(B in this._http_headers){if(YAHOO.lang.hasOwnProperty(this._http_headers,B)){A.conn.setRequestHeader(B,this._http_headers[B]);}}delete this._http_headers;this._http_headers={};this._has_http_headers=false;}},resetDefaultHeaders:function(){delete this._default_headers;this._default_headers={};this._has_default_headers=false;},setForm:function(M,H,C){var L,B,K,I,P,J=false,F=[],O=0,E,G,D,N,A;this.resetFormState();if(typeof M=="string"){L=(document.getElementById(M)||document.forms[M]);}else{if(typeof M=="object"){L=M;}else{return;}}if(H){this.createFrame(C?C:null);this._isFormSubmit=true;this._isFileUpload=true;this._formNode=L;return;}for(E=0,G=L.elements.length;E<G;++E){B=L.elements[E];P=B.disabled;K=B.name;if(!P&&K){K=encodeURIComponent(K)+"=";I=encodeURIComponent(B.value);switch(B.type){case"select-one":if(B.selectedIndex>-1){A=B.options[B.selectedIndex];F[O++]=K+encodeURIComponent((A.attributes.value&&A.attributes.value.specified)?A.value:A.text);}break;case"select-multiple":if(B.selectedIndex>-1){for(D=B.selectedIndex,N=B.options.length;D<N;++D){A=B.options[D];if(A.selected){F[O++]=K+encodeURIComponent((A.attributes.value&&A.attributes.value.specified)?A.value:A.text);}}}break;case"radio":case"checkbox":if(B.checked){F[O++]=K+I;}break;case"file":case undefined:case"reset":case"button":break;case"submit":if(J===false){if(this._hasSubmitListener&&this._submitElementValue){F[O++]=this._submitElementValue;}J=true;}break;default:F[O++]=K+I;}}}this._isFormSubmit=true;this._sFormData=F.join("&");this.initHeader("Content-Type",this._default_form_header);return this._sFormData;},resetFormState:function(){this._isFormSubmit=false;this._isFileUpload=false;this._formNode=null;this._sFormData="";},createFrame:function(A){var B="yuiIO"+this._transaction_id;var C;if(YAHOO.env.ua.ie){C=document.createElement('<iframe id="'+B+'" name="'+B+'" />');if(typeof A=="boolean"){C.src="javascript:false";}}else{C=document.createElement("iframe");C.id=B;C.name=B;}C.style.position="absolute";C.style.top="-1000px";C.style.left="-1000px";document.body.appendChild(C);},appendPostData:function(A){var D=[],B=A.split("&"),C,E;for(C=0;C<B.length;C++){E=B[C].indexOf("=");if(E!=-1){D[C]=document.createElement("input");D[C].type="hidden";D[C].name=decodeURIComponent(B[C].substring(0,E));D[C].value=decodeURIComponent(B[C].substring(E+1));this._formNode.appendChild(D[C]);}}return D;},uploadFile:function(D,N,E,C){var I="yuiIO"+D.tId,J="multipart/form-data",L=document.getElementById(I),O=this,K=(N&&N.argument)?N.argument:null,M,H,B,G;var A={action:this._formNode.getAttribute("action"),method:this._formNode.getAttribute("method"),target:this._formNode.getAttribute("target")};this._formNode.setAttribute("action",E);this._formNode.setAttribute("method","POST");this._formNode.setAttribute("target",I);if(YAHOO.env.ua.ie){this._formNode.setAttribute("encoding",J);}else{this._formNode.setAttribute("enctype",J);}if(C){M=this.appendPostData(C);}this._formNode.submit();this.startEvent.fire(D,K);if(D.startEvent){D.startEvent.fire(D,K);}if(N&&N.timeout){this._timeOut[D.tId]=window.setTimeout(function(){O.abort(D,N,true);},N.timeout);}if(M&&M.length>0){for(H=0;H<M.length;H++){this._formNode.removeChild(M[H]);}}for(B in A){if(YAHOO.lang.hasOwnProperty(A,B)){if(A[B]){this._formNode.setAttribute(B,A[B]);}else{this._formNode.removeAttribute(B);}}}this.resetFormState();var F=function(){if(N&&N.timeout){window.clearTimeout(O._timeOut[D.tId]);delete O._timeOut[D.tId];}O.completeEvent.fire(D,K);if(D.completeEvent){D.completeEvent.fire(D,K);}G={tId:D.tId,argument:N.argument};try{G.responseText=L.contentWindow.document.body?L.contentWindow.document.body.innerHTML:L.contentWindow.document.documentElement.textContent;G.responseXML=L.contentWindow.document.XMLDocument?L.contentWindow.document.XMLDocument:L.contentWindow.document;}catch(P){}if(N&&N.upload){if(!N.scope){N.upload(G);}else{N.upload.apply(N.scope,[G]);}}O.uploadEvent.fire(G);if(D.uploadEvent){D.uploadEvent.fire(G);}YAHOO.util.Event.removeListener(L,"load",F);setTimeout(function(){document.body.removeChild(L);O.releaseObject(D);},100);};YAHOO.util.Event.addListener(L,"load",F);},abort:function(E,G,A){var D;var B=(G&&G.argument)?G.argument:null;if(E&&E.conn){if(this.isCallInProgress(E)){E.conn.abort();window.clearInterval(this._poll[E.tId]);delete this._poll[E.tId];if(A){window.clearTimeout(this._timeOut[E.tId]);delete this._timeOut[E.tId];}D=true;}}else{if(E&&E.isUpload===true){var C="yuiIO"+E.tId;var F=document.getElementById(C);if(F){YAHOO.util.Event.removeListener(F,"load");document.body.removeChild(F);if(A){window.clearTimeout(this._timeOut[E.tId]);delete this._timeOut[E.tId];}D=true;}}else{D=false;}}if(D===true){this.abortEvent.fire(E,B);if(E.abortEvent){E.abortEvent.fire(E,B);}this.handleTransactionResponse(E,G,true);}return D;},isCallInProgress:function(B){if(B&&B.conn){return B.conn.readyState!==4&&B.conn.readyState!==0;}else{if(B&&B.isUpload===true){var A="yuiIO"+B.tId;return document.getElementById(A)?true:false;}else{return false;}}},releaseObject:function(A){if(A&&A.conn){A.conn=null;A=null;}}};YAHOO.register("connection",YAHOO.util.Connect,{version:"2.7.0",build:"1799"});
/*
 *	2009-07-15 Iteration 4
 *	2009-07-17 Thijs, Added support for fb logon relative urls, with rewrite to https.
 *	2009-07-24 Thijs, Changed the way the login works.
 *	2009-07-27 Tycho, added defensive check on value assignments oSuccessUrl & oActionUrl
 *	2009-08-03 Thijs, SessionID and EngineID now are available through the Customer Context, cookie is no longer available.
 *	2009-08-10 Thijs, Implemented new errorhandler that can use forms.
 *	2009-08-10 Thijs, Implemented localized errors.
 *	2009-08-10 Thijs, Username prefill for form.
 *	2009-08-24 Thijs, Added check for SuccessUrl GET parameter, as the parameter has a typo (succesUrl).
 *	2009-08-27 Thijs, Fixed successUrl (Defect 699)
 *	2009-09-09 Migration
*/

var FFP = function(){
	//Containers
	this.oContainer = YAHOO.util.Dom.get('ffp');
	this.oTeaserBox = YAHOO.util.Dom.get('body-basic');
	this.oLoginBox = YAHOO.util.Dom.get('body-cookie');
	this.oLoggedInBox = YAHOO.util.Dom.get('body-loggedin');
	
	//Form elements
	this.oForm = YAHOO.util.Dom.get('ffp_login');
	this.oSuccessUrl = YAHOO.util.Dom.get('ffp-successUrl');
	this.oActionUrl = YAHOO.util.Dom.get('ffp-actionUrl');
	this.oUsername = YAHOO.util.Dom.get('ffp-number');
	this.oPassword = YAHOO.util.Dom.get('ffp-pincode');
	this.oRemember = YAHOO.util.Dom.get('ffp-remember');
	
	this.oButton = YAHOO.util.Dom.get('btn-login-ffp');
	this.oLoginButton = YAHOO.util.Dom.get('btn-ffp-show-login');
	this.oLogoutButton = YAHOO.util.Dom.get('btn-ffp-logout');
	
	//Placeholders
	this.oFFPHeader = YAHOO.util.Dom.get('ffp_level');
	this.oNamePH = YAHOO.util.Dom.get('ffp_name');
	this.oMilesPH = YAHOO.util.Dom.get('ffp_miles');
	
	this.oLoadingContainer = YAHOO.util.Dom.get('ffp_loading');
	this.oFlightContainer = YAHOO.util.Dom.get('customer-flight');
	
	
	this.oActionForm = YAHOO.util.Dom.get('klm-form');
	this.oActionFormLogonType = YAHOO.util.Dom.get('logonType');
	this.oActionFormSuccessUrl = YAHOO.util.Dom.get('successUrl');
	this.oActionFormActionUrl = YAHOO.util.Dom.get('actionUrl');
	this.oActionFormUsername = YAHOO.util.Dom.get('id');
	
	this.hasActionForm = false;
	
	if(!this.oActionForm){
		this.oActionForm = document.forms['klm-form'];
	}

	if(this.oActionForm && this.oActionFormSuccessUrl && this.oActionFormActionUrl && this.oActionFormLogonType){
		if(this.oActionFormLogonType.value == 'FB'){
			this.hasActionForm = true;
		}
	}
	
	this.logged_in = false;

	if(!this.oForm){
		this.oForm = document.forms['ffp_login'];
	}

	if (this.oSuccessUrl && this.oSuccessUrl.value == "") this.oSuccessUrl.value = window.location.pathname;	 
	if (this.oActionUrl && this.oActionUrl.value == "") this.oActionUrl.value = window.location.pathname;
	this.userdata = null;
	
	try{
		this.userdata = fb_customer;
	}catch(e){}
	
	this.username = YAHOO.util.Cookie.get("ffp");
	if(!this.username) this.username = "";
	
	if(this.oForm.action.indexOf('http') != 0){
		this.oForm.action = 'https://' + location.host + this.oForm.action;
	} else if(this.oForm.action.indexOf('https') != 0){
		this.oForm.action = this.oForm.action.replace('http', 'https');
	}

	if(this.oLogoutButton.href.indexOf('http') != 0){
		this.oLogoutButton.href = 'https://' + location.host + this.oLogoutButton.href;
	} else if(this.oLogoutButton.href.indexOf('https') != 0){
		this.oLogoutButton.href = this.oLogoutButton.href.replace('http', 'https');
	}

	YAHOO.util.Event.addListener(this.oButton, 'click', this.login, this);
	YAHOO.util.Event.addListener(this.oLoginButton, 'click', this.showLogin, this);
	YAHOO.util.Event.addListener(this.oLogoutButton, 'click', this.logout, this);
	YAHOO.util.Event.addListener(this.oUsername, 'keyup', this.login, this);
	YAHOO.util.Event.addListener(this.oPassword, 'keyup', this.login, this);

	this.errorHandler = new ErrorHandler({container: YAHOO.util.Dom.getElementsByClassName('c24')[0], from: this, id: 'form-error-box'});

	this.init();
	
	if(this.hasActionForm){
		this.initActionForm();
	}
}

FFP.prototype.initActionForm = function(){
	this.oActionFormActionUrl.value = this.oActionUrl.value;
	this.oActionFormUsername.value = this.oUsername.value;
}

FFP.prototype.getQSVar = function(varname) {
  hu = window.location.search.substring(1);
  gy = hu.split("&");
  returnValue = null;
  for (i=0;i<gy.length;i++) {
    ft = gy[i].split("=");
    if (ft[0] == varname) {
      returnValue = ft[1];
    }
  }
  return returnValue;
}

FFP.prototype.init = function(){
	var result = this.getQSVar('result');
	if(result){
		this.errorHandler.addMessage(this.getMessage(result));
	}
	if(this.getQSVar('succesUrl') != null && this.getQSVar('succesUrl') != ''){
		this.oSuccessUrl.value = this.getQSVar('succesUrl');
		if(this.oActionFormSuccessUrl){
			this.oActionFormSuccessUrl.value = this.getQSVar('succesUrl');
		}
	}else if(this.getQSVar('successUrl') != null && this.getQSVar('successUrl') != ''){
		this.oSuccessUrl.value = this.getQSVar('successUrl');
		if(this.oActionFormSuccessUrl){
			this.oActionFormSuccessUrl.value = this.getQSVar('successUrl');
		}
	}
	if(!this.hasActionForm){
		if(this.userdata){
			this.logged_in = true;
			this.handleData();
		}else if(this.username){
			this.handleLogin();
		}else{
			this.handleTeaser();
		}
	}else{
		this.oContainer.style.display = 'none';
	}
}

FFP.prototype.getMessage = function(resultCode){
	var oErrorContainer = YAHOO.util.Dom.get('ffp-error-' + resultCode);
	if(!oErrorContainer){
		oErrorContainer = YAHOO.util.Dom.get('ffp-error-0');
	}
	return oErrorContainer.innerHTML;
}

FFP.prototype.login = function(e, obj){
	if ( (e.type == 'keyup' && e.keyCode == 13) || e.type == 'click' ) {
		YAHOO.util.Event.preventDefault(e);
		if(obj.oRemember.checked){
			var now = new Date();
			YAHOO.util.Cookie.set("ffp", obj.oUsername.value, { 
				path: "/",
				domain: "klm.com",
				expires: now.setYear(now.getYear() + 1)
			}); 
		}
		obj.oForm.submit();
	}
}

FFP.prototype.logout = function(e, obj){
	YAHOO.util.Event.preventDefault(e);
	obj.oForm.action = obj.oLogoutButton.href;
	YAHOO.util.Cookie.remove('jffp', {path: '/', secure: true});
	obj.oForm.submit();

}

FFP.prototype.showLogin = function(e, obj){
	YAHOO.util.Event.preventDefault(e);
	obj.handleLogin();
}

FFP.prototype.handleTeaser = function(){
	this.oTeaserBox.style.display = 'block';
	this.oLoginBox.style.display = 'none';
	if(this.oLoggedInBox) this.oLoggedInBox.style.display = 'none';
}

FFP.prototype.handleLogin = function(){
	this.oTeaserBox.style.display = 'none';
	this.oLoginBox.style.display = 'block';
	if(this.oLoggedInBox) this.oLoggedInBox.style.display = 'none';
	this.oUsername.value = this.username;
}

FFP.prototype.handleData = function(){
	var sLevel = "Ivory";
	var sClass = "ivory";
	this.oTeaserBox.style.display = 'none';
	this.oLoginBox.style.display = 'none';
	if(this.oLoggedInBox){
		this.oLoggedInBox.style.display = 'block';

		if(this.userdata.Gender == "M"){
			this.oNamePH.innerHTML = 'Mr. ' + this.userdata.FirstName + ' ' + this.userdata.LastName;
		} else {
			this.oNamePH.innerHTML = 'Mrs. ' + this.userdata.FirstName + ' ' + this.userdata.LastName;
		}

		if(this.userdata.CreditMiles){
			this.oMilesPH.innerHTML = this.userdata.CreditMiles;
		}else{
			this.oMilesPH.innerHTML = 0;
		}
		
		switch(this.userdata.Tier){
			case '1': sLevel = "Ivory"; break;
			case '2': sLevel = "Silver"; break;
			case '3': sLevel = "Platinum"; break;
			case '4': sLevel = "Ivory"; break;
			case '5': sLevel = "Ivory"; break;
			case '6': sLevel = "Gold"; break;
			case '7': sLevel = "Platinum"; break;
			case 'A': sLevel = "Ivory"; break;
			case 'B': sLevel = "Silver"; break;
			case 'C': sLevel = "Platinum"; break;
			case 'J': sLevel = "Ivory"; break;
			case 'M': sLevel = "Platinum"; break;
			case 'P': sLevel = "Ivory"; break;
			case 'R': sLevel = "Gold"; break;
		}

		if (this.userdata.MemberType.toLowerCase() == 'c2') sLevel = "Club 2000";
			
		this.oFFPHeader.className = sLevel.toLowerCase().replace(' ', '');
		this.oFFPHeader.innerHTML = sLevel;
		
		YAHOO.util.Cookie.set('jffp', 'BV_SessionID=' + this.userdata.SessionID + '&BV_EngineID=' + this.userdata.EngineID + '&FBSessionID=' + this.userdata.SessionID + '&FBCloneID=' + this.userdata.EngineID, { 
			path: "/",
			domain: "klm.com",
			secure: true
		});
		
		this.getFlightInfo();
		
	}
}

FFP.prototype.getQueryValue = function(varname){
	var q = window.location.search.substring(1);
	var arrQ = q.split("&");
	var returnValue = null;
	
	for (i=0;i < arrQ.length;i++) {
		keyValuePair = arrQ[i].split("=");
		if (keyValuePair[0] == varname) {
			returnValue = keyValuePair[1];
		}
	}
	return returnValue;
}

FFP.prototype.getFlightInfo = function(){
	var request = {
		COUNTRY : countryCode,
		LANG: languageCode,
		POS: countryCode,
		type : 'mmb-traveldata',
		BV_SessionID : this.userdata.SessionID,
		BV_EngineID : this.userdata.EngineID,
		context : 'getNextBookings'
	};
	
	var widget = new Widget(request, {success: this.HandleResponse, failure: this.ErrorHandler, argument: this});
	widget.Post();
}

FFP.prototype.ErrorHandler = function(response){
	response.argument.oLoadingContainer.style.display = 'none';
}

FFP.prototype.HandleResponse = function(response){
	response.argument.oLoadingContainer.style.display = 'none';
	if(response && !response.responseText.match('</html>')){
		response.argument.oFlightContainer.innerHTML = response.responseText;
	}
}
/*
*	2009-07-15 Iteration 4
*	2009-09-09 Migration
*/

var Widget = function(request, callback){
	this.widgetBrokerUrl = '/commercial/widgetbroker/widgetbroker';
	this.request = request;
	
	this.callback = callback;
	
	this.transaction = null;
}

Widget.prototype.Get = function(){
	this.transaction = YAHOO.util.Connect.asyncRequest('GET', this.widgetBrokerUrl + '?' + this._getQueryString(), this.callback, null);
}

Widget.prototype.Post = function(){
	this.transaction = YAHOO.util.Connect.asyncRequest('POST', this.widgetBrokerUrl, this.callback, this._getQueryString());
}

Widget.prototype._getQueryString = function(){
	var queryString = "";
	var iCount = 1;
	for(var key in this.request){
		if(iCount == 1)
			queryString = key + '=' + this.request[key];
		else
			queryString = queryString + '&' + key + '=' + this.request[key];
		iCount++;
	}
	return queryString;
}
