var ADULT_CODE_OTA = "ADT";
var CHILD_CODE_OTA = "CHD";
var INFANT_CODE_OTA = "INF";
var SENIOR_CODE_OTA = "SRC";
var searchPopupWindow= null;

var TRUE = "true";
var FALSE = "false";


function getContextPath()
	{
		var pathname = window.location.pathname;
		var contextPath = pathname.substring( 0, pathname.indexOf("/faces"))+"/faces";
		return contextPath;
	}


/**
 * Read the JavaScript cookies tutorial at:
 *   http://www.netspade.com/articles/javascript/cookies.xml
 *
 *   http://www.netspade.com/2005/11/16/javascript-cookies/
 */

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 *
 *
 *
 */
function setCookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	// if the expires variable is set, make the correct expires time, the
	// current script below will set it for x number of days, to make it
	// for hours, delete * 24, for minutes, delete * 60 * 24
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	//alert( 'today ' + today.toGMTString() );// this is for testing purpose only
	var expires_date = new Date( today.getTime() + (expires) );
	//alert('expires ' + expires_date.toGMTString());// this is for testing purposes only

	document.cookie = name + "=" +/*escape( value )*/value +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}



/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return /*unescape*/(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


function showDiv(obj)
{
	if(document.getElementById(obj))
	{
		document.getElementById(obj).style.visibility="visible";
		document.getElementById(obj).style.display="block";
	}
}

function hideDiv(obj)
{
	if(document.getElementById(obj))
	{
		document.getElementById(obj).style.visibility="hidden";
		document.getElementById(obj).style.display="none";
	}
}

function hideShow(obj) {
	if (document.getElementById(obj))
	{
		document.getElementById(obj).style.display =
		(document.getElementById(obj).style.display=='none') ? 'block':'none';
	}
}

/*
*	For Divs which are hidden on load
*/
function showHide(obj) {
	if (document.getElementById(obj))
	{
		document.getElementById(obj).style.display =
		(document.getElementById(obj).style.display=='block') ? 'none':'block';
	}
}
/*
 * Create a HTML Component
 */
function createRequiredComponent(comptype,type,idv,valuev,innerhtmv,parentNode){
	if(document.getElementById(idv)){
		custComp = document.getElementById(idv)
	}else{
    	custComp = document.createElement(comptype);
    	custComp.id = idv;
    	if(type)
		custComp.type=type;
	}
	if(valuev)
		custComp.value = valuev;
	if(innerhtmv)
		custComp.innerHTML = innerhtmv;
	if(!document.getElementById(idv)){
		if(parentNode)
			parentNode.appendChild(custComp);
		else
			document.body.appendChild(custComp);
	}
}

	 /**
	  * Returns formatted Price  ;
	  * 
	  */
	function getPriceFormat(priceText,displayCurrency){
		var displPrice;
		priceText = priceText+"";
		var minus = "";
		if(priceText.substring(0,1)=="-")
		{
			priceText = priceText.substring(1);
			minus = "-";
		}

		if(priceText.indexOf(".")!=-1){
		  var priceSpl = priceText.split(".");
		  priceText = priceSpl[0];
		}
		var strLength = priceText.length;
		if(displayCurrency=="Rs." || displayCurrency=="INR")
		{
			if(strLength==4){
				displPrice = priceText.substring(1,0)+","+priceText.substring(4,1);
			}else if(strLength==5){
				displPrice = priceText.substring(2,0)+","+priceText.substring(5,2);
			}else if(strLength==6){
				displPrice = priceText.substring(1,0)+","+priceText.substring(3,1)+","+priceText.substring(6,3);
			}else if(strLength==7){
				displPrice = priceText.substring(2,0)+","+priceText.substring(5,2)+","+priceText.substring(7,5);
			}else{
				displPrice = priceText;
			}
		}
		else
		{
			if(strLength==4){
				displPrice = priceText.substring(1,0)+","+priceText.substring(4,1);
			}else if(strLength==5){
				displPrice = priceText.substring(2,0)+","+priceText.substring(5,2);
			}else if(strLength==6){
				displPrice = priceText.substring(3,0)+","+priceText.substring(6,3);
			}else if(strLength==7){
				displPrice = priceText.substring(1,0)+","+priceText.substring(4,1)+","+priceText.substring(7,4);
			}else{
				displPrice = priceText;
			}
		}
		displPrice = minus+displPrice;
		return displPrice;
	}


	/**
	  * Returns Price in INR format ie "Rs. 00,00,000";
	  * 
	  */
	function getInrFormat(priceText){
		var displPrice;
		if(priceText.indexOf(".")!=-1){
		  var priceSpl = priceText.split(".");
          priceText = priceSpl[0];
		}
        var strLength = priceText.length;
		if(strLength==4){
		    displPrice = priceText.substring(1,0)+","+priceText.substring(4,1);
		}else if(strLength==5){
		    displPrice = priceText.substring(2,0)+","+priceText.substring(5,2);
		}else if(strLength==6){
		    displPrice = priceText.substring(1,0)+","+priceText.substring(3,1)+","+priceText.substring(6,3);
		}else if(strLength==7){
		    displPrice = priceText.substring(2,0)+","+priceText.substring(5,2)+","+priceText.substring(7,5);
		}else{
			displPrice = priceText;
		}
        return displPrice;
	}


	
// function for calling fare rule in dhtml window
function dhtmlFareRule(flightId,sectorId,segmentId,fareDescription,tariffNo){
		pleaseWaitPopupWindow();
	var fareRulePopup = dhtmlmodal.open ('fareRulesDiv','iframe','fareRules.jsp?ID='+flightId+'&sectorId='+sectorId+'&segmentId='+segmentId+'&fareDescription='+fareDescription+'&tariffNo='+tariffNo,'Fare Rule','title=1,close=1,drag=1,width=500px,height=300px,resize=1,scrolling=1,center=1');
	if(document.getElementById("fareRulesDiv"))
		hideDiv("fareRulesDiv");
}

/*function dhtmlSeatMap(flightId,adult,child,infant){
	var seatMapWindow = dhtmlmodal.open (flightId,'iframe','seatMap.jsp?ID='+flightId+'&ADT='+adult+'&CHD='+child+'&INF='+infant,'Seat Map','title=1,close=1,drag=1,width=600px,height=410px,left=185px,top=390px,resize=1,scrolling=1,center=1');
}*/


function openFarepopup(){
	fareRuleWindow = dhtmlmodal.open('fareRulePopup', 'div', 'fareRule', 'Fare Rule', 'title=1,drag=1,width=300px,height=150px,left=150px,top=100px,resize=1,scrolling=1,center=1"')
}
function searchpopup(){
	searchWindow = dhtmlmodal.open('DetailItineraryPopup', 'div', 'searchDiv', 'Search', 'title=1,close=1,drag=1,width=600px,height=420,left=150px,top=100px,resize=1,scrolling=1,center=1"')
}
function showtermsAndCondition(){
	var tnc = dhtmlmodal.open('termsandcondition','div','terms_conditions','Terms and condition','title=1,close=1,drag=1,width=600,height=300,center=1,scrolling=1');
}
/**
 * Converts a valid DOM to XML String
 */
function XMLtoString(elem){
   var serialized;
   try {
		   // XMLSerializer exists in current Mozilla browsers
		serializer = new XMLSerializer();
		serialized = serializer.serializeToString(elem);
	} catch (e) {
	// Internet Explorer has a different approach to serializing XML
	serialized = elem.xml;
	}
	//alert(serialized);
	
	return serialized;
}


function openpublishFarespopup(){
	publishFaresWindow = dhtmlmodal.open('publishFaresPopup', 'div', 'publishFares', 'Published Fare Details ', 'title=1,drag=1,close=1,width=300px,height=180px,left=150px,top=100px,resize=1,scrolling=1,center=1')
}

function openDetailedItinerarypopup(){
	DetailedItineraryWindow = dhtmlmodal.open('DetailedItineraryPopup', 'div', 'detailedItinerary', 'Detailed Itinerary ', 'title=1,drag=1,close=1,width=900px,height=420,left=150px,top=100px,resize=1,scrolling=1,center=1')
}

function openCompareFlightspopup(){
	CompareFlightsWindow = dhtmlmodal.open('CompareFlightsPopup', 'div', 'compareDiv', 'Compare Flights', 'title=1,drag=1,close=1,width=808px,height=450px,left=150px,top=100px,resize=1,scrolling=1,center=1')
}

function paymodeDiscountpopup(){
	paymodeDiscountWindow = dhtmlmodal.open('paymodeDiscountPopup', 'div', 'paymodeDiscount', 'Paymode Discount', 'title=1,drag=1,close=1,width=400px,height=150px,left=150px,top=100px,resize=1,scrolling=1,center=1')
}

function openSearchInProgressPopupWindow(){
	var searchProgressBarDiv = document.getElementById('searchProgressBar')
	if (!searchProgressBarDiv){
		searchProgressBarDiv = document.createElement('div');
		searchProgressBarDiv.id = 'searchProgressBar'
		var sbox = document.createElement('div')
		sbox.style.padding='20px;'
		sbox.innerHTML = '<br>Please wait, search in progress...<br><br><img title="searching progress bar" align="center" style="padding:20px;display:block;" src=\"'+getContextPath()+'/images/searchprogress.gif\"><br>'
		searchProgressBarDiv.appendChild(sbox);
		document.body.appendChild(searchProgressBarDiv);
	}

	searchPopupWindow=dhtmlmodal.open('searchbar', 'div', 'searchProgressBar', 'Searching....', 'title=1,width=250px,height=100px,resize=0,scrolling=0,center=1')
}

function pleaseWaitPopupWindow(){
	var searchProgressBarDiv = document.getElementById('searchProgressBar')
	if (!searchProgressBarDiv){
		searchProgressBarDiv = document.createElement('div');
		searchProgressBarDiv.id = 'searchProgressBar'
		searchProgressBarDiv.style.display='block'
		searchProgressBarDiv.innerHTML = '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Please wait ...<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <img src=\"'+getContextPath()+'/images/searchprogress.gif\"><br>'
		document.body.appendChild(searchProgressBarDiv);
	}

	searchPopupWindow=dhtmlmodal.open('searchbar', 'div', 'searchProgressBar', 'Wait...', 'title=1,width=250px,height=100px,resize=0,scrolling=0,center=1')
}

function mailtopopup(){
	mailtoWindow = dhtmlmodal.open('mailtoPopup', 'div', 'mailto', 'Email', 'title=1,drag=1,close=1,width=520px,height=310,left=150px,top=100px,resize=0,scrolling=1,center=1')
}

function alertPopup(header){
	AlertWindow = dhtmlmodal.open('AlertPopup', 'div', 'alertDiv', header, 'title=1,drag=1,close=1,width=200px,height=120px,left=150px,top=100px,resize=0,scrolling=0,center=1')
}

function fareRuleOMS(){
	var fareRulePopupWindow = dhtmlmodal.open ('fareRulePopup','div','fareRulesPopupDiv','Fare Rule','title=1,drag=1,close=1,width=500px,height=300px,resize=1,scrolling=1,center=1');
}


var updatePopupWindow = null;

function openUpdateInProgressPopupWindow(){
	var updateProgressBarDiv = document.getElementById('updateProgressBar')
	if (!updateProgressBarDiv){
		updateProgressBarDiv = document.createElement('div');
		updateProgressBarDiv.id = 'updateProgressBar'
		updateProgressBarDiv.style.display='none'
		updateProgressBarDiv.innerHTML = '<b>Update in progress</b><br>Please wait...<img src="../../images/myloader4327.gif"><br>'
		document.body.appendChild(updateProgressBarDiv);
		
	}
	updatePopupWindow=dhtmlmodal.open('updatebar', 'div', 'updateProgressBar', 'Updating....', 'title=1,width=250px,height=100px,resize=0,scrolling=0,center=1')
}


function showErrorMessages(errorPanelId,ary){
	var errObj =  document.getElementById(errorPanelId);
	var errTable = "<a name='errorBox'></a><table width='100%' border='0' class='tableborder_tips' cellspacing='2' cellpadding='2'><tr class='NormalText_12B_white'><td colspan='2' bgcolor='red'>"+ary.length+" Error(s) found</tr>";
	var errorsText="";
	for (x=0;x<ary.length ;x++ ){
		errorsText += "<tr class='FormErrorTips'><td>"+(x+1)+". "+ary[x]+"</td></tr>";
	}
	errorsText = errTable + errorsText + "</table>";
	errObj.innerHTML = errorsText;
	showDiv(errorPanelId);
	location.href="#errorBox";	
}


function showSuccessMessages(successPanelId,ary){
	var successObj =  document.getElementById(successPanelId);
	var successTable = "<table width='100%' border='0' class='tableborder_tips' cellspacing='2' cellpadding='2'><tr class='NormalText_12B_white'><td colspan='2' bgcolor='#1A61A9'>Message</tr>";
	var successText=""
	for (x=0;x<ary.length ;x++ ){
		successText += "<tr class='FormErrorTips'><td>"+ary[x]+"</td></tr>"
	}
	successText = successTable + successText + "</table>"
	successObj.innerHTML = successText;
	showDiv(successPanelId);
}
function removeErrorHighlight(obj){
	if(obj.type != 'button' && obj.style.borderColor.indexOf('red') != -1){
		obj.style.border = 'solid 1px #dcdddf';
		if(obj.parentNode && obj.parentNode.id=="addErrorHighLightDiv")
			obj.parentNode.style.background="#FFFFFF"; 			
  	}
}

function addErrorHighlight(obj){
	if(obj.type != 'button'){
		obj.style.border = 'solid red 1px';
		if(obj.parentNode && obj.parentNode.id=="addErrorHighLightDiv"){
			obj.parentNode.style.background="#ff0000"; 
			obj.parentNode.style.padding = "1";
		}
	}
}

function removeErrorHighlightSelect(obj){
	if(obj.type != 'button'){
		if(obj.parentNode && obj.parentNode.id=="addErrorHighLightDiv")
			obj.parentNode.style.background="#FFFFFF"; 			
  	}
}

function addErrorHighlightSelect(obj){
	if(obj.type != 'button'){
		if(obj.parentNode && obj.parentNode.id=="addErrorHighLightDiv"){
			obj.parentNode.style.background="#ff0000"; 
			obj.parentNode.style.padding = "1";
		}
	}

}


function clearErrorMessage(divName)	{
	document.getElementById(divName).style.display = "none";
	
	var elements = document.forms[0].elements;
	//var elements = document.forms[0].getElementsByTagName('input');
	
	for(i=0;i<elements.length;i++){
		if(elements[i].type == 'text' || elements[i].type == 'select')	{
			removeErrorHighlight(elements[i])
		}
	}
}

/*
* For clearing success & error message on updation
*/
function clearMess(obj1,obj2)
{
		hideDiv(obj1);
		hideDiv(obj2);
}


/*
 * Remove Starting and Trailing Spaces Of Calling String.
 */
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

 
/*
 * Remove Starting Spaces Of Calling String.
 */
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}

 
/*
 * Remove Trailing Spaces Of Calling String.
 */
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

 
/*
 * Converts the Calling String to Sentence Case.
 */

String.prototype.toSentenceCase = function (){
	var strArray = this.split('.')
	for (x=0;x<strArray.length;x++){
		strArray[x] = strArray[x].trim().substr(0,1).toUpperCase()+strArray[x].trim().substr(1).toLowerCase()
	}
	return strArray.join('. ')
}

/*
*  Converts XML in String format to Dom format
*/
function parseStringResponse(result)
{
	var xmlDoc;
	if(document.implementation && document.implementation.createDocument) {
	//Mozilla
		var domParser = new DOMParser();
		xmlDoc = domParser.parseFromString(result, "text/xml");
	} else if (window.ActiveXObject){
	//IE
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async="false";
		xmlDoc.loadXML(result);
	}
	return xmlDoc;
}

function setClass(element,className){
	element.setAttribute('class',className);
	element.setAttribute('className',className); //<iehack>
}
function fillDropOffloc(obj){
	
	if(obj && obj.id.indexOf("pickupLocation")!=-1){
		if(document.getElementById(getActualComponentId(":pickupLocation")).value!=""){
			document.getElementById(getActualComponentId(":dropoffLocation")).value=document.getElementById(getActualComponentId(":pickupLocation")).value;
		}
	}
	
}

function trim(value){
	return value.replace(/^\s+|\s+$/g,"");
	}

	function getXmlDom(xmlString,fileType){
	var xmlDomObj;
	var isIE;
	if (document.implementation && document.implementation.createDocument){
		xmlDomObj = document.implementation.createDocument("", "", null);
		isIE=false;
	}else if (window.ActiveXObject){
		xmlDomObj = new ActiveXObject("Microsoft.XMLDOM");
		xmlDomObj.async=false;
        isIE=true;
	}else{
		return;
	}
	if(fileType==1){ //For XML as String
	  if(isIE==false){
		  var parser=new DOMParser();
          xmlDomObj=parser.parseFromString(xmlString,"text/xml");
          }else{
			xmlDomObj.loadXML(xmlString);
	      }
	}else{ // For XML file name/path as String
	   xmlDomObj.load(xmlString);
	}
	return  xmlDomObj;
}

/*
*	For show in + / - before Div which are collapsable
*/

function carErrorImage(el){
   el.src=currentContextPath+"/images/noavailable.gif";
}
function hotelErrorImage(el){
   el.src=imageFolderPath+"/noavailable.gif";
}
function plusMinus(obj,objDiv) {
document.getElementById(obj).innerHTML =
(document.getElementById(objDiv).style.display=='block') ? '+':'-';
}

function arrowImageBar(obj,objDiv) {
document.getElementById(obj).className =
(document.getElementById(objDiv).style.display=='block') ? 'arrowRightBar':'arrowDownBar';
}

function arrowImageOpenBar(obj,objDiv) {
document.getElementById(obj).className =
(document.getElementById(objDiv).style.display=='none') ? 'arrowDownBar':'arrowRightBar';
}

function arrowImage(obj,objDiv) {
document.getElementById(obj).className =
(document.getElementById(objDiv).style.display=='block') ? 'arrowRight':'arrowDown';
}

function arrowImageOpen(obj,objDiv) {
document.getElementById(obj).className =
(document.getElementById(objDiv).style.display=='none') ? 'arrowDown':'arrowRight';
}

function divVis(linkObj,divIDl){
	 
   if(linkObj.innerHTML=="[+]"){
	  linkObj.innerHTML="[-]";
	  document.getElementById(divIDl).style.display="block";
   }else{
      linkObj.innerHTML="[+]";
	  document.getElementById(divIDl).style.display="none";
   }


}
 function convertToSentenceCase(contid){
   var str = document.getElementById(contid).innerHTML;
   document.getElementById(contid).innerHTML = str.toSentenceCase();
 }

 /*
 * Trims Component value data.
 */
function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}

	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);

	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
}
/*
 *
 * RIGHT Trims Component value data.
 */
function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";

	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	}	 
	return strTemp;
} 
/*
 *
 * LEFT Trims Component value data.
*/
function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}

	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} 
	return strTemp;
}


/******* Common To Search and Review *****/

/* returns time in the format 'hh:mm AM/PM'
 * timeToFormat - unformatted time string
 * eg. input '12:23:0Z'  returns '12:23 PM'
 *     input '21:23:0Z'  returns '9:23 PM'   
 */
function formatTimeForDisplay(timeToFormat){
   var splitArr =  timeToFormat.split(":");
   var postFix = "AM";
   var HH = parseInt(splitArr[0],10);
   if(HH>=12){
	postFix = "PM";
   }else if (HH==0){ 
	   HH = 24;
	   postFix = "AM";
   }
   if(HH>12){
      splitArr[0] = ""+(HH-12);
	   
   }
   if(splitArr[0]<10  && splitArr[0].length!=1){
	
    splitArr[0]=splitArr[0].charAt(1);

   }
   return splitArr[0]+":"+splitArr[1]+" "+postFix;
} 


/*
 * Accepts a String represntation of the time duration in long format
 * Returns a String for Displaying the flight Duration
 * eg. input - '14400000' , output - '04:00 Hrs'
 * eg. input - '2100000' , output - '35 Mins'
 */
function getDurationForDisplay(durationStr){
   var timeDiff = parseFloat(durationStr);
   var days =0;
   var hour=0;
   var mins=0;
   //days = parseInt(timeDiff / (60 * 1000 * 60 * 24));
  // timeDiff = (timeDiff % (60 * 1000 * 60 * 24));
        
   hour = parseInt(timeDiff / (60 * 1000 * 60));
   timeDiff = (timeDiff % (60 * 1000 * 60));
        
   mins = parseInt(timeDiff/(60 * 1000 ));
   var displayStr="";
  /* if(days>0){
     displayStr=getDoubleLetterdStr(days)+":"+getDoubleLetterdStr(hour)+":"+getDoubleLetterdStr(mins)+" Days";
   }else */
   if(hour>0){

    if(mins<10){
      mins= "0"+mins;
	  }
     displayStr=hour+":"+mins+"Hr";
     if(hour>1){
		displayStr = displayStr+"s";
	 }
   }else{
      displayStr= mins+"Min";
	  if(mins<10){
      displayStr= "0"+mins+"Min";
	  }
      if(mins>1){
	  displayStr = displayStr+"s";
	   }
   }
   return displayStr;
} 

function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

// Preferred Airlines:
function getParenthesisValue(obj)
{
	var val = "";
	var objVal = "";
	if(obj && obj.value!=null)
	{
		objVal = obj.value;
	}
	else
	{
		objVal = obj;
	}
	var startIndex = objVal.indexOf("(");
	var endIndex = objVal.indexOf(")");
	if(startIndex>0 && endIndex>0)
	{
		val = objVal.substring(startIndex+1,endIndex);
	}
	return val;
}

function hideWait()
{
	parent.document.getElementById('searchbar').style.display='none';
	if(parent.document.getElementById('fareRulesDiv')!=null){
		parent.document.getElementById('fareRulesDiv').style.display='block';
		parent.document.getElementById('fareRulesDiv').style.visibility='visible';
	}
	if(parent.document.getElementById('fareRulesDiv_background')!=null){
		parent.document.getElementById('fareRulesDiv_background').style.visibility='visible';
	}
}
function open_HotelDesc(url)
{
	var a=Math.random()*1000;
	var abc='BookingDetail'+a;
 hotelDetailPopup = dhtmlmodal.open(abc,'iframe',url,'HOTEL DESCRIPTION','title=1,close=1,drag=1,width=800px,height=500px,resize=1,scrolling=1,center=1');
}		
function closepopup(){  
	parent.hotelDetailPopup.hide();
}
