var isError=false;
var enableImage=new Image();
var disableImage=new Image(); 
var progressImage=new Image();
var logo=new Image(); 
var progressImg=new Image();
function preloadImage(varContextPath,locale){ 
	enableImage.src=varContextPath+"/"+locale+"/images/common/ssrselect.JPG";	
	 disableImage.src=varContextPath+"/"+locale+"/images/common/ssrselect_gray.JPG";
	 progressImage.src= varContextPath+"/"+locale+"/images/common/progressbar.gif";
	 logo.src=varContextPath+"/"+locale+"/images/common/logo.gif";
	 progressImg.src=varContextPath+"/"+locale+"/images/progressimage.gif"; 
}
function focusToTop(){
	if(isError==true){
		 document.getElementsByName("errorloc")[0].scrollIntoView(true);
		//document.location="#errorloc";	
	}
}

/**
 *	Sumit for throught flight when stops link clicked from searchresult page
 *	Attributes
 * 	@val contains the selected flight details
 *	@contPath-The web server context
 */

function submitForThroughFlight(val,contPath,el,execution,locale){
	var thrghflts = val.split("_");
	var thrghFlt = thrghflts[0]+"_"+thrghflts[1]+"_"+thrghflts[2]+"_"+thrghflts[3];
	document.forms[0].actionName.value = "viewThroughFlightDetails";
	el.href="?_eventId=viewThroughFlight&actionName=viewThroughFlightDetails&thrghFlt="+thrghFlt+"&execution="+execution;
	viewThroughFlight(contPath,locale);
}
	
var setIntervalIdThrough;
function viewThroughFlight(contxtpath,locale){		
	setIntervalIdThrough=window.setInterval("valueCheckThrough('throughFlight')",100);
	showLightbox(contxtpath,locale);
}
	
function valueCheckThrough(popupwindowId){	 
	var popupwindow=document.getElementById(popupwindowId);		
	if(popupwindow!=undefined && popupwindow.getAttribute('status')=="new"){
		window.clearInterval(setIntervalIdThrough);	
		hideLightBox();	
	}
}	
function doCancelThrough(pageContext){  	
  	if(document.getElementById("throughFlight")){
    		document.getElementById("throughFlight").disabled=false;
    		
  	}
  	closePopupWindow(document.getElementById('throughFlight'));
  	if(document.getElementById('thumb')!=null){
  	document.getElementById('thumb').parentNode.removeChild(document.getElementById('thumb'));
  	}
  }	

/**
 * The submitForSeatMap function activates when the flightnumber is clicked.
 * The method will retrieve the seat map for the flight selected.
 *
 *	Attributes
 *	@param pageContext - The web server context.
 * 	@param val - The selected flight details.
 */
 function submitForSeatMap(val,pageContext,el,locale,execution){
 	var selFlightDetls = val.split("_"); 	
 	var selectedFlights = selFlightDetls[0]+"_"+selFlightDetls[1]+"_"+selFlightDetls[2]+"_"+selFlightDetls[3]+"_"+selFlightDetls[4]+"_"+selFlightDetls[5]+"_"+selFlightDetls[6]+"_"+selFlightDetls[7]+"_"+selFlightDetls[8]+"_"+selFlightDetls[9]+"_"+selFlightDetls[10];
 	var cabinClass = document.forms[0].cabinClass.value;
 	el.href="?_eventId=seatAssign&actionName=showseatmap&selectedFlts="+selectedFlights+"&execution="+execution+"&cabinClass="+cabinClass;
 	assignSeat(pageContext,locale);
	
 }
 
 function createTarget(form) {		
	win = window.open('',form.target,form.args);
	//win.document.write(loading);	
	win.focus();
	win.moveTo(50,50);
	
	return true;
	}
	
	
  function getPos(el,position){
var posval=0;
while(el.offsetParent!=null){
	posval+=el["offset"+position];
	el=el.offsetParent;
	
}
return posval;
}

function getTargetURL(isSecureVar){
	var isSecure;
	if(isSecureVar != 'unsecure'){
		isSecure = isDefined(isSecureVar)?window[isSecureVar]:null;
	}else{
		isSecure = null;
	}
	
	var targetHostName = window.document.location.hostname; 
	var targetConetxt;
	
	if(arguments[1]){
		targetConetxt = arguments[1];
	}else{
		targetConetxt = WS_targetContextPath;
	}
	
	if(isSecure=="secure"){
		targetProtocol = "https";
		targetPort = isDefined('WS_targetHttpsPort')?window['WS_targetHttpsPort']:'';
	}else{
		targetProtocol = "http";
		targetPort = isDefined('WS_targetHttpPort')?window['WS_targetHttpPort']:'';
	}
	
	
	if(targetConetxt!=null){
		if(targetConetxt=='index.html'){
			targetConetxt='';
		}
		retTargetURL = targetProtocol + "://" + targetHostName + ":" + targetPort+targetConetxt+"/";
	}
	else{
		retTargetURL = targetProtocol + "://" + targetHostName + ":" + targetPort+"/";
	}
	return retTargetURL;
}


function isDefined( variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}


function getBookingLnk(action){
	window.location= getTargetURL('WS_retrieve')+action;
}

function getFlifoLnk(action){
	window.location=  getTargetURL('WS_viewInfoPage')+action;
}

function popupCalendar(){
		var i=0;
			for( i=0;i<arguments.length;++i){
				var date= document.getElementById(arguments[i]);
						if(!isValidDate(date.value)){
							date.focus();						
							return false;
						}
					
				
			}
			return true;
		}
		       	function getTop(obj){     
       	return (getPos(obj,'Top')+obj.offsetHeight+143>document.documentElement.offsetHeight?
       		getPos(obj,'Top')-143-obj.offsetHeight:
       	getPos(obj,'Top')+obj.offsetHeight)
       	
       	
       	}
       	function getLeft(obj){       	 	
       return	( getPos(obj,'Left')+385>document.documentElement.offsetWidth? 
       	 getPos(obj,'Left')-385+obj.offsetWidth: getPos(obj,'Left'));
       	
       	}
       	
function extractCode(id){
	var tmpValue=document.getElementById(id).value;
	var startInd=tmpValue.lastIndexOf('(');
	var endInd=tmpValue.lastIndexOf(')')
		
	return tmpValue.substring(startInd+1,endInd);
}

   function decorateField(id,message){
   var popupdiv = document.createElement("div");
   var field = document.getElementById(id);
   	if(field.value == ""){
   		popupdiv.innerHTML=message;
   		popupdiv.style.position="absolute";
   		popupdiv.style.top=getPos(field,"Top")+field.offsetHeight+ 3+"px";
   		popupdiv.style.left=getPos(field,"Left")+"px";
   		popupdiv.style.whiteSpace="noWrap"
   		popupdiv.style.height="15px";
   		popupdiv.style.backgroundColor="#DDDFDF";
   		popupdiv.style.border="0px solid gray";
   		popupdiv.style.paddingLeft="2px";
   		popupdiv.style.paddingRight="2px";
   		popupdiv.style.color='#136684';
   		popupdiv.style.family='Verdana';
   		popupdiv.style.fontSize='11px';   		
   		document.body.appendChild(popupdiv);
   		popupdiv.id='iMessage';
   	}
   }
   
    function closeMessageWindow(){
   if(  document.getElementById("iMessage")!= null)
   document.getElementById("iMessage").parentNode.removeChild(document.getElementById("iMessage"));

   }
		
	function loginAgent(cntpath){
		window.location=cntpath+"/ibe/ibe/login";
		
	}	
	
	function changeRedirect(flow){
	//document.getElementById("spring-security-redirect").value="/ibe/ibe/"+flow;
	}
/*
 * to show flight details
 * 
 * param : boolean
 */ 
 var prevSegExp;	
function showDetails(el,contpath,locale,objId){
	var totalSegElems = document.getElementsByTagName("Div");
	var elem = document.getElementById(el);	
	var img = document.getElementById(objId);	
	var isCol = elem.isCollapsed;	
	
	if(isCol == undefined || isCol == true){
		elem.style.display='block';
		elem.isCollapsed = false;
		img.src = contpath+"/"+locale+"/images/arrow_down.png";	
		if(prevSegExp != null && prevSegExp != elem){
			prevSegExp.style.display='none';	
			prevSegExp.isCollapsed = true;	
			var prevSegExpImg = document.getElementById("img_"+prevSegExp.id);		
			prevSegExpImg.src = contpath+"/"+locale+"/images/arrow_frnt.png";				
		}		
		prevSegExp=elem;
	}
	else{	
		elem.style.display='none';	
		elem.isCollapsed = true;
		img.src = contpath+"/"+locale+"/images/arrow_frnt.png";							
	}
}

//*** script to show/hide a div ***//
var collapseInterval = new Array();
var delta = 50;

function registerCollapse(parentId, state){
	
	var parentObj = document.getElementById(parentId);
	var childObj = document.getElementById(parentObj.getAttribute('child'));
	if(state=="co"){
		childObj.setAttribute('xheight', childObj.offsetHeight);
		childObj.style.height="0px";
		childObj.style.display="none";
		childObj.setAttribute('status','co');
		parentObj.className="rt_caption_up";
		
	}else{
	childObj.setAttribute('status','ex');
	parentObj.className="rt_caption_dwn";
	}
	parentObj.onclick = toggleShow;
	

}


function toggleShow(evt){
	var i=0;
	if(document.all)
	var el = window.event.srcElement;
	else
	var el = evt.target;
	
	while(el.getAttribute('child')==null)
	el = el.parentNode;
	
	var parentId = el.id;
	
	var childObj = document.getElementById(el.getAttribute('child'));
	childObj.style.overflow="hidden";
	window.clearInterval(collapseInterval[parentId]);
	
	var status = childObj.getAttribute('status');
	if(status=="co" || status=="stex"){
		childObj.setAttribute('status','stex');
		childObj.style.display="block";
		collapseInterval[parentId] = window.setInterval("expand('"+parentId+"')",100); 
	}else if(status=="stco" || status=="ex"){
		childObj.setAttribute('status','stco');
		var childHeight =  childObj.offsetHeight;
		childObj.setAttribute('xheight', childHeight);
		childObj.style.height = childHeight+"px";
		collapseInterval[parentId] = window.setInterval("collapse('"+parentId+"')",100); 
	}
	
	
	
}


function collapse(parentId){
	var parentObj = document.getElementById(parentId);
	var childObj = document.getElementById(parentObj.getAttribute('child'));
	
	
	var newChildHeight =  parseInt(childObj.offsetHeight) - delta;
	if(newChildHeight>0){
		childObj.style.height = newChildHeight+"px"
	}else{
		parentObj.className = "rt_caption_up";
		childObj.style.height = "0px";
		childObj.style.display = "none";
		childObj.setAttribute('status','co');
		window.clearInterval(collapseInterval[parentId]);
	}
	
}


function expand(parentId){
	var parentObj = document.getElementById(parentId);
	var childObj = document.getElementById(parentObj.getAttribute('child'));
	var xHeight = parseInt(childObj.getAttribute('xheight'));
	
	var newChildHeight =  parseInt(childObj.offsetHeight) + delta;
	if(newChildHeight<xHeight){
		childObj.style.height = newChildHeight+"px";
	}else{
		childObj.style.height = xHeight+"px";
		childObj.style.overflow = "visible";
		childObj.setAttribute('style','');
		childObj.setAttribute('status','ex');
		parentObj.className = "rt_caption_dwn";
		window.clearInterval(collapseInterval[parentId]);
	}
	
}

/*
 * to show flight details
 * 
 * param : index
 */ 
 var prevExp;
function showAdultFareDetails(index){
	var elem = document.getElementById("adult_cont_"+index);
	var isCol = elem.isCollapsed;
	if(isCol == undefined || isCol == true){
		elem.style.display='block';
		elem.isCollapsed = false;	
		if(prevExp != null && prevExp != elem){
			prevExp.style.display='none';	
			prevExp.isCollapsed = true;				
		}		
		prevExp=elem;
	}
	else{	
		elem.style.display='none';	
		elem.isCollapsed = true;						
	} 	
	
	//hiding fee details
	var feeDtlsId = document.getElementById("fee");
 	if(feeDtlsId != undefined){
 		var isFeeCol = feeDtlsId.isCollapsed;	
 		if(isFeeCol == undefined || isFeeCol == true){
							
		}else{
			feeDtlsId.style.display='none';	
			feeDtlsId.isCollapsed = true;
		}
 	}
 	
 }
 
 
 /*
 * to show flight details
 * 
 * param : index
 */ 
 function showChildFareDetails(index){
 	var elem = document.getElementById("child_cont_"+index);	
	var isCol = elem.isCollapsed;
	if(isCol == undefined || isCol == true){
		elem.style.display='block';
		elem.isCollapsed = false;	
		if(prevExp != null && prevExp != elem){
			prevExp.style.display='none';	
			prevExp.isCollapsed = true;				
		}		
		prevExp=elem;
	}
	else{	
		elem.style.display='none';	
		elem.isCollapsed = true;						
	} 	
	// hiding fee details
	var feeDtlsId = document.getElementById("fee");
 	if(feeDtlsId != undefined){
 		var isFeeCol = feeDtlsId.isCollapsed;	
 		if(isFeeCol == undefined || isFeeCol == true){
							
		}else{
			feeDtlsId.style.display='none';	
			feeDtlsId.isCollapsed = true;
		}
 	}	
}

/*
 * currency converter
 */
 

function doCurrencySubmit(action){
	if (action =='Convert'){
		document.getElementById('valMsg').innerHTML="";
	if (currencyValidation()){
		document.getElementById('idCurrencyConverter').setAttribute("status","old");
		document.getElementById("convAmt").value=document.getElementById("amt").value;
		document.getElementById("fromCurrency").value=document.getElementById("fromCurr").value;
		document.getElementById("toCurrency").value=document.getElementById("toCurr").value;
	    document.forms[0]._eventId.value="convert";	 
	    document.forms[0].actionName.value="Convert";	     
		Spring.remoting.submitForm('Converter',document.forms[0].name, {fragments:'currency'});	
		}
		}
}
function currencyValidation(){
	var boolcheck = true;
	var fromCurr = document.getElementById("fromCurr").value;
	var toCurr= document.getElementById("toCurr").value;
	var frmAmt= document.getElementById("amt").value;
	if(fromCurr==toCurr){
	displayCurrencyErrorMessages(CRC001_001);
/*	Decor.decorateError(document.getElementById("fromCurr"));
	Decor.decorateError(document.getElementById("toCurr"));	*/
	boolcheck = false;
	}
	if(frmAmt == '0.00'){
	displayCurrencyErrorMessages(CRC001_002);
	Decor.decorateError(document.getElementById("amt"));
	boolcheck = false;
	}
	if(frmAmt == '0.0'){
	displayCurrencyErrorMessages(CRC001_002);
	Decor.decorateError(document.getElementById("amt"));
	boolcheck = false;
	}
	if(frmAmt == '0'){
	displayCurrencyErrorMessages(CRC001_002);
	Decor.decorateError(document.getElementById("amt"));
	boolcheck = false;
	}
	if(frmAmt == ''){
	displayCurrencyErrorMessages(CRC001_002);
	Decor.decorateError(document.getElementById("amt"));
	boolcheck = false;
	}
  	return boolcheck;
  }
function displayCurrencyErrorMessages(msg){
	  if(isError && document.getElementById('valMsg')){
	 /* If any server side message is present */
	 var msglabl = document.createElement('label');
	 msglabl.innerHTML=msg+"<br/>";
	 msglabl.className="valmsglabel";
	 msglabl.setAttribute('id',"lbl1"+k);
	 document.getElementById('valMsg').appendChild(msglabl); 
	 }else{
	 /* If no server side message is present */
	 
	 document.getElementById('msgDiv').style.display='block'
	 document.getElementById('msgDiv').className='msgbox';
	 var valMsgDiv = null;
	 if(document.getElementById('valMsg')){
	 valMsgDiv = document.getElementById('valMsg')
	 }else{
	 valMsgDiv=document.createElement('div');
	 } 
	 valMsgDiv.setAttribute('id',"valMsg");
	 valMsgDiv.className="valmsg";
	 
	 var msglabl = document.createElement('label');
	 msglabl.innerHTML=msg+"<br/>";
	 msglabl.className="valmsglabel";
	 msglabl.setAttribute('id',"lbl1"+k);
	 //k++;
	 valMsgDiv.appendChild(msglabl);
	 document.getElementById('msgDiv').appendChild(valMsgDiv);
	 } 
	 msg="";
	 //document.location="#errorloc";
	  document.getElementsByName("errorloc")[0].scrollIntoView(true);
	   	 
}
function convertCurr(execKey,id,fareAmt,currn){
	var amtToPass; 
	var currToPass;	
	if(fareAmt != "0"){
		amtToPass = fareAmt;
		currToPass = currn;
	}else if(totalFareAmt != undefined){
		amtToPass = totalFareAmt;//totalFareAmt global variable declared in searchscript.js
		currToPass = totalCurrn;//totalCurrn global variable declared in searchscript.js
	}else{
		amtToPass = 0.00;
		currToPass = 'Default';
	}
	id.href = "?_eventId=showCurrencyConverter&actionName=currencyConvert&execution="+execKey+"&famount="+amtToPass+"&totalCurrency="+currToPass+"";
 
}


function checkCur(e){
		closeMessageWindow();
		return checkAmount(e);
	}
	function checkAmount(e){
		var keynum=0;	
		var retVal;	
		if(window.event){//IE	
			keynum = e.keyCode;
		}
		else if(e.which){//Netscape/Firefox/Opera		
			keynum = e.which;
		}
		if((48 <= keynum && keynum <= 57)|| (keynum == 0) 
				|| (keynum == 8) || (keynum == 32) || (!keynum == 45) ||(keynum == 46)){
			if((e.ctrlKey == true)){
				retVal=false;
			}
			else{
				retVal=true;
			}
		}
		else{
			retVal=false;
		}	
		return retVal;
	}	
		

/**
* for including the inside the fare break down inside the form
*
*/
 var setIntervalId;
 
function farebrkdwn(contxtpath){
	contextPath = contxtpath;
	setIntervalId=window.setInterval("valueCheck('fareDetails','insertIntoForm()')");
		
 }
 
 
	function valueCheck(popupwindowId,funct){	 
		var popupwindow=document.getElementById(popupwindowId);		
		if(popupwindow!=undefined && popupwindow.getAttribute('status')=="new"){
		window.clearInterval(setIntervalId)		
		eval(funct)	
		}
	}
 
 
function insertIntoForm(){
		var popupparent=document.getElementById('fareDetails').parentNode.parentNode;
		document.forms[0].appendChild(popupparent);
	
		}
		
/*
 * to showFeeDetails
 * 
 * param : index
 */ 
 function showFeeDetails(seatFe,modSeatFe){
    var elem = document.getElementById("fee");
    var isCol = elem.isCollapsed;
	if(isCol == undefined || isCol == true){
		elem.style.display='block';
		elem.isCollapsed = false;	
		if(prevExp != null && prevExp != elem){
			prevExp.style.display='none';	
			prevExp.isCollapsed = true;				
		}		
		prevExp=elem;
		calculateCartSeatAssignFee(seatFe,modSeatFe);
	}else{	
		elem.style.display='none';	
		elem.isCollapsed = true;	
	}	
	
	
 }	

/*
 * to showFeeDetails
 * 
 * param : index
 */ 
 function showExstDetails(id){
    var elemExst = document.getElementById("exst_Cont");
    var isCol = elemExst.isCollapsed;
	if(isCol == undefined || isCol == true){
		elemExst.style.display='block';
		elemExst.isCollapsed = false;	
		if(prevExp != null && prevExp != elemExst){
			prevExp.style.display='none';	
			prevExp.isCollapsed = true;				
		}		
		prevExp=elemExst;
	}else{	
		elemExst.style.display='none';	
		elemExst.isCollapsed = true;	
	}	
	
	
 }	

function calculateCartSeatAssignFee(addSeatFee,modSeatFee){
		var feeDtlsTable=document.getElementById("feeDetailsTable");			
		var tbody=feeDtlsTable.getElementsByTagName("TBODY")[0];
		var seatMapDetails=document.getElementsByName("seatMapDetails");
		var i=0;
		var j=0;
		var totalFee=0;		
		var seatFee="";		
		if(document.forms[0].seatMapFee.value != null){
			seatFee = parseFloat(document.forms[0].seatMapFee.value)	
		}		
	if(modSeatFee != null && modSeatFee!=''){
			document.forms[0].totalForAllPax.value = document.forms[0].totalAmt.value;			
		}
		if(isNaN(parseFloat(seatFee))){
			seatFee="0.0";			 
		}
		var newSeatCount = 0;
		var premiumSeatCount=0;
		var totalSeatCountForaPax=0;
		var lastSseatNumberDtls="";
		var currencyPrecision=parseInt(document.forms[0].currencyPrecision.value);
		for( i=0;i<seatMapDetails.length;++i){
			var seatFeeForThidPax=0;	
			var array=new Array();
			if(new String(seatMapDetails[i].value).length==0){						
				continue;
			}
			document.forms[0].customised.value="true";
			var seatSegmentDetails=new String(seatMapDetails[i].value).split(":");			
			for(j=0;j<seatSegmentDetails.length;++j){
				if(new String(seatSegmentDetails[j]).length==0){
					continue;
				}	
				var eachSeatDetails=seatSegmentDetails[j].split("index.html");
				segment=eachSeatDetails[2];					
				if(eachSeatDetails[8] != "false" && eachSeatDetails[8]!="undefined" && eachSeatDetails[8] != null){
					totalSeatCountForaPax+=1;
					if(lastSseatNumberDtls == eachSeatDetails[3]){
						continue;
					}else{
						lastSseatNumberDtls = eachSeatDetails[3];
					}
					premiumSeatCount+=1;
					var isPrstSeat=document.getElementById("pax"+(i+1)+"_"+eachSeatDetails[7]);
					if(isPrstSeat==null){
						premiumSeatDtlsTR=document.createElement("tr");
						premiumSeatDtlsTR.setAttribute("id","pax"+(i+1)+"_"+eachSeatDetails[7])
						var seatFeeTR=document.getElementById("seatFeeTR");
						var premiumSeatDtlsTD=document.createElement("td");							
						premiumSeatDtlsTD.innerHTML=eachSeatDetails[7]+" "+eachSeatDetails[0]+"-Premium Seat Fee";
						premiumSeatDtlsTR.appendChild(premiumSeatDtlsTD);
						var seatDtlsColoncol=document.createElement("td");
						seatDtlsColoncol.innerHTML=":";
						premiumSeatDtlsTR.appendChild(seatDtlsColoncol);
						tbody.insertBefore(premiumSeatDtlsTR, seatFeeTR);
						var premiumSeatDtls=document.createElement("td");
						premiumSeatDtls.align="right";
						premiumSeatDtls.innerHTML=addseps(formatNumber(eachSeatDetails[8],currencyPrecision))+'<span>&nbsp;'+document.forms[0].defaultcurrency.value+'</span>';
						premiumSeatDtlsTR.appendChild(premiumSeatDtls);
					}
				} else{
					if(eachSeatDetails[4] == 'N'){				
						newSeatCount+=1;
						if(addSeatFee == 'YES'){
							totalSeatCountForaPax+=1;
							var seatFees=document.getElementById("seatFeeId_"+(i+1));
							var seatFeesHeader=document.getElementById("seatFeeHeaderId_"+(i+1));
							var colons=document.getElementById("colonId_"+(i+1));
							if(seatFees != undefined){
								seatFeesHeader.innerHTML=CART_005;
								colons.innerHTML=":";
								seatFees.innerHTML=addseps(formatNumber(seatFee,currencyPrecision))+'<span>&nbsp;'+document.forms[0].defaultcurrency.value+'</span>';
							 }	
							//totalFee+=seatFee;						
	//						if(seatFees != undefined){
	//							seatFees.innerHTML=addseps(formatNumberForCurrency(seatFee))+'<span class="space">'+document.forms[0].defaultcurrency.value+'</span>';
	//						}
							if(seatFeeForThidPax==0){
								seatFeeForThidPax+=1;
							}							
						}
					}
					 else if(eachSeatDetails[4] == 'O' && eachSeatDetails[5] == 'Y'){
						newSeatCount+=1;
						if(modSeatFee == 'YES'){	 					
							totalSeatCountForaPax+=1;
							var seatFees=document.getElementById("seatFeeId_"+(i+1));
							var seatFeesHeader=document.getElementById("seatFeeHeaderId_"+(i+1));
							var colons=document.getElementById("colonId_"+(i+1));
							if(seatFees != undefined){
								seatFeesHeader.innerHTML=CART_005;
								colons.innerHTML=":";
								seatFees.innerHTML=addseps(formatNumber(seatFee,currencyPrecision))+'<span>&nbsp;'+document.forms[0].defaultcurrency.value+'</span>';
							 }	
							//totalFee+=seatFee;	
	//						var seatFees=document.getElementById("seatFeeId_"+(i+1));
	//						seatFees.innerHTML=seatFee;					
							break;
						}
					}		
				}
			 }
			if(totalSeatCountForaPax > premiumSeatCount){
				totalFee=totalFee*(totalSeatCountForaPax-premiumSeatCount);
			} else {
				if(document.getElementById('seatFeeTR')){
					tbody.removeChild(document.getElementById('seatFeeTR'));					
				}
			}
		}
	}
	
	
	
	function addseps(nStr)
	{
	 nStr += '';
	 x = nStr.split('.');
	 x1 = x[0];
	 x2 = x.length > 1 ? '.' + x[1] : '';
	 var rgx = /(\d+)(\d{3})/;
	 while (rgx.test(x1)) {
	 x1 = x1.replace(rgx, '$1' + ',' + '$2');
	 }
	 return x1 + x2;
	}
	
	/*
 * to show flight details
 * 
 * param : boolean
 */ 	
function showSeatMapDetails(contpath){
	var elem = document.getElementById("seatId");
	//var img = document.getElementById(objId);	
	var isCol = elem.isCollapsed;	
	if(isCol == undefined || isCol == true){
		elem.style.display='block';
		elem.isCollapsed = false;
			//img.src = contpath+"/images/arrow_down.png";
	}
	else{
		elem.style.display='none';	
		elem.isCollapsed = true;
		//img.src = contpath+"/images/arrow_frnt.png";
		
	}
}


//function to generate the seat details for each pax	
function populateCartSeatDetails(seatMapDetails){
	var seatTable=document.getElementById("cartSeatTable");			
	var tbody=seatTable.getElementsByTagName("TBODY")[0];
	if(tbody==undefined){
		tbody=document.createElement("TBODY");
		seatTable.appendChild(tbody);
		 tbody=seatTable.getElementsByTagName("TBODY")[0];
	} else{
		var totalRows = seatTable.rows.length;
		//deleting the seat details before rebuilding
		for ( var rowId = totalRows-1; rowId >= 0; rowId--) {
			seatTable.deleteRow(rowId);
		}
		if(document.getElementById('cartSeatDtlsLabelRow'))
			tbody.removeChild(document.getElementById('cartSeatDtlsLabelRow'));
		if(document.getElementById('cartSeatDetailsRow'))
			tbody.removeChild(document.getElementById('cartSeatDetailsRow'));
	}				
	var seatDetailsRow=document.getElementById('cartSeatDetailsRow');	
	if(seatDetailsRow==undefined||seatDetailsRow==null){
		for( i=0;i<seatMapDetails.length;++i){
			var seatSegmentDetails=new String(seatMapDetails[i].value).split(":");
			if(seatSegmentDetails != ''){
				var seatDtlslabelTR=document.createElement("tr");
				seatDtlslabelTR.setAttribute("id","cartSeatDtlsLabelRow");
				var paxDtlslabelTD=document.createElement("td");	
				paxDtlslabelTD.innerHTML = "<label class='lbl_bld'>"+PASSENGER+(i+1)+"</label>";				
				seatDtlslabelTR.appendChild(paxDtlslabelTD);
				var seatDtlsColonTD=document.createElement("td");
				seatDtlslabelTR.appendChild(seatDtlsColonTD);
				var seatNumberlabelTD=document.createElement("td");	
				seatNumberlabelTD.innerHTML = "<label class='lbl_bld'>"+SEAT+"</label>";			
				seatDtlslabelTR.appendChild(seatNumberlabelTD);					
				tbody.appendChild(seatDtlslabelTR);				
				for(j=0;j<seatSegmentDetails.length;++j){
					if(seatSegmentDetails[j] != ''){	
						var eachSeatDetails=seatSegmentDetails[j].split("index.html");
						seatDtlsTR=document.createElement("tr");
						seatDtlsTR.setAttribute("id","cartSeatDetailsRow");
						var seatDtlsDescCol=document.createElement("td");							
						seatDtlsDescCol.innerHTML=eachSeatDetails[7]+" "+eachSeatDetails[0];
						seatDtlsTR.appendChild(seatDtlsDescCol);
						var seatDtlsColoncol=document.createElement("td");
						seatDtlsColoncol.innerHTML="";
						seatDtlsTR.appendChild(seatDtlsColoncol);
						var seatDtlsCol=document.createElement("td");
						//seatDtlsCol.align='right';
						seatDtlsCol.innerHTML=eachSeatDetails[3];						
						seatDtlsTR.appendChild(seatDtlsCol);								
						tbody.appendChild(seatDtlsTR);	
						if(document.getElementById("cartSeatInfoId")){
							document.getElementById("cartSeatInfoId").className = "wth_100";
						}
					}			
				}
			}
		}
		seatTable.className="wth_100";	 
	}	
}


//variables used for creating a message box div
var MSG_OK=1;
var MSG_OKCANCEL=2;
var MSG_OKNORMAL=3;

// function for displaying the message box on selecting all the oandD's for deletion
function messagebox(srcElement,message,buttonType,pagecontxt,locale){
	showLightbox(pagecontxt,locale);
	this.value="0";
	var box=document.createElement("div");
	var headerDiv = document.createElement("div");
	headerDiv.style.height="25px";
	headerDiv.className = "top_menu";
	box.appendChild(headerDiv)
	var msgArea=document.createElement("div");
	msgArea.className="msgAreaalert";
	var msgDiv=document.createElement("div");
	msgArea.appendChild(msgDiv)
	box.appendChild(msgArea)
	box.className="msgboxalert"
	box.align="center";  
	msgDiv.innerHTML="<label class='label_color lbl_bld'>"+message+"</label><br/><br/>";
	msgDiv.style.margin="10px";	
	box.style.top="200px"; 
	box.style.left="220px";    
	box.style.display='';
	document.body.appendChild(box)
	box.style.width=getPos(box,"Width")  
	createButtons(msgArea,buttonType,pagecontxt); 
	hideLightBox();
}


// function for creating buttons for the message box.
function createButton(box,buttonValue,functionName){
	var btn=document.createElement("input")     
 	btn.type="button";
	btn.value=buttonValue;
 	btn.style.position= "relative"; 
 	btn.className="buttonLL button";
 	btn.style.margin="0px 5px 5px 5px"; 	 
 	box.appendChild(btn);
 	/*adjustHeight(box.offsetParent,btn);*/
 	box.style.height=box.offsetParent.style.height;
 	btn.onclick= (functionName)
}

//function for adjusting teh height of teh box
function adjustHeight(box){
	box.style.height=getPos(box,"Height");
}


/**
* function to check the numeric value
*/
function checkNumeral(e){
	var keyvalue=0;	
	var retValue;	
	if(window.event){//IE	
		keyvalue = e.keyCode;
	}
	else if(e.which){//Netscape/Firefox/Opera		
		keyvalue = e.which;
	}
	if(((48 <= keyvalue) && (keyvalue <= 57)) || (keyvalue == 0) || (keyvalue == 8)){
		if((e.ctrlKey == true) && (keyvalue == 118)){
			retValue=false;
		}
		else{
			retValue=true;
		}
	}
	else{
		retValue=false;
	}	
	return retValue;
}	

//function to display the flight number text
function showFltNoText(srcElement,text1,text2,airlineCode){
	fltNumberInfoBox(srcElement,text1,text2,airlineCode);
}

//function to display the flight number text
function hideFltNoText(textDivId){
	var oNodeToRemove = document.getElementById(textDivId);
	if(oNodeToRemove != null)
		oNodeToRemove.parentNode.removeChild(oNodeToRemove);
}

//function to display the flight number info box
function fltNumberInfoBox(srcElement,text1,text2,airlineCode){
	//showLightbox()
	this.value="0";	
	var box=document.createElement("div");	
	var msgArea=document.createElement("div");
	//msgArea.className="msgAreaalert";	
	msgArea.style.padding="4px"
	box.appendChild(msgArea);
	msgArea.innerHTML=text1+" "+airlineCode+" "+text2+" \""+airlineCode+"\"."	
	//box.appendChild(msgDiv)
	box.className="msgboxalert";	
	//box.align="center";  
	box.style.top=getPos(srcElement,"Top")+10+"px"; 
	box.style.left=getPos(srcElement,"Left")+10+"px";     
	box.style.display='';	
	box.id="fltNumberId";	
	document.body.appendChild(box)
	//box.style.width="180px";  
}


/** 
 * function to format the number based on the currency precision.
 *
 * @param number
 * @param precision
 * @return num the formatted currency 
 */
function formatNumber(number,precision){
	var expnum=Math.pow(10,precision)
	var num=Math.round(number*expnum)/expnum;
	num=new String(num);
	var dotindex=num.indexOf(".")
	if(dotindex<0){
		if(parseInt(precision)>=1)
			num+=".";
		for(var i=0;i<parseInt(precision);++i){
			num+="0";
		}	
	}else{
		var fractionPart=num.substr(dotindex,num.length)
		for(var i=fractionPart.length-1;i<parseInt(precision);++i){
			num+="0";
	
		}
	}
	return num;  
}

/*
* funtion to check alpha numeric
*/
function alphaNumericCheck(text){
	for(var j=0; j<text.length; j++){
		var alphaa = text.charAt(j);
		var hh = alphaa.charCodeAt(0);
		if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123)){
		}else{                
			 return false;
		}
 	}
 	return true;
 } 


