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

/*
 * returns JSF generated ID
 *
 */
function getActualComponentId(obj)
{
	var objId;
	var elementsArray = document.forms[0].elements;
	for(var i=0;i<elementsArray.length;i++)
	{
	   var object = elementsArray[i];
	   if(object.id.indexOf(obj)!=-1)
	   {
	     objId = object.id;
	     break;
	   }
	}
	return objId;
}

/**
 * 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";
	}
}

/*
 * 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 = "-";
		}
		var decim;		var decimalPrice = ""; 
		if(priceText.indexOf(".")!=-1){
		  var priceSpl = priceText.split(".");
		  priceText = priceSpl[0];
		  decimalPrice = "."+priceSpl[1];
		}
		var strLength = priceText.length;
		if(displayCurrency=="Rs." || displayCurrency=="INR")
		{
			if(strLength==4){
				displPrice = priceText.substring(0,1)+","+priceText.substring(1);
			}else if(strLength==5){
				displPrice = priceText.substring(0,2)+","+priceText.substring(2);
			}else if(strLength==6){
				displPrice = priceText.substring(0,1)+","+priceText.substring(1,3)+","+priceText.substring(3);
			}else if(strLength==7){
				displPrice = priceText.substring(0,2)+","+priceText.substring(2,4)+","+priceText.substring(4);
			}else if(strLength==8){
				displPrice = priceText.substring(0,1)+","+priceText.substring(1,3)+","+priceText.substring(3,5)+","+priceText.substring(5);
			}else{
				displPrice = priceText;
			}
		}
		else
		{
			if(strLength==4){
				displPrice = priceText.substring(0,1)+","+priceText.substring(1);
			}else if(strLength==5){
				displPrice = priceText.substring(0,2)+","+priceText.substring(2);
			}else if(strLength==6){
				displPrice = priceText.substring(0,3)+","+priceText.substring(6,3);
			}else if(strLength==7){
				displPrice = priceText.substring(0,1)+","+priceText.substring(1,4)+","+priceText.substring(4);
			}else if(strLength==8){
				displPrice = priceText.substring(0,2)+","+priceText.substring(2,5)+","+priceText.substring(5);
			}else{
				displPrice = priceText;
			}
		}
		displPrice = minus+displPrice;
		displPrice = displPrice+decimalPrice;
		return displPrice;
	}

	
// function for calling fare rule in dhtml window
function dhtmlFareRule(flightId,fareBasis,rbd,dirIndicatorID,segmentID,startPt,endPt,marketingAirlineCode,departureDate){
	pleaseWaitPopupWindow();
	var fareRulePopup = dhtmlmodal.open ("fareRulesDiv",'iframe','fareRules.jsp?ID='+flightId+'&FareBasis='+fareBasis+'&RBD='+rbd+'&dirIndicatorID='+dirIndicatorID+'&segmentID='+segmentID+'&startPt='+startPt+'&endPt='+endPt+'&marketingAirlineCode='+marketingAirlineCode+'&departureDate='+departureDate,'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 openInvoicePopup(w,h){
	invoiceWindow = dhtmlmodal.open('invoiceDetailPopup', 'div', 'invoiceDetailPopupDiv', 'Invoice Details', 'title=1,close=1,drag=1,width='+w+'px,height='+h+'px,left=100px,top=100px,resize=1,scrolling=1,center=1')
}


/*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=440,left=150px,top=100px,resize=1,scrolling=1,center=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(x,y,h){
	publishFaresWindow = dhtmlmodal.open('publishFaresPopup', 'div', 'publishFares', 'Published Fare Details ', 'title=1,drag=0,close=0,width=300px,height='+h+'px,left='+x+'px,top='+y+'px,resize=1,scrolling=1')
}

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

function openCompareFlightspopup(){
	CompareFlightsWindow = dhtmlmodal.open('CompareFlightsPopup', 'div', 'compareDiv', 'Compare Flights', 'title=1,drag=1,close=1,width=700px,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 openFareSummarypopup(h){
	FareSummaryWindow = dhtmlmodal.open('fareSummaryPopup', 'div', 'fareSummaryPopupDiv', 'Fare Summary', 'title=1,drag=1,close=1,width=420px,height='+h+'px,left=150px,top=100px,resize=1,scrolling=1,center=1')
}

function ccDetailspopup(){
	CCDetailsWindow = dhtmlmodal.open('ccDetailsPopup', 'div', 'ccDetailsPopupDiv', 'CC Details', 'title=1,drag=1,close=0,width=330px,height=220px,left=150px,top=100px,resize=1,scrolling=1,center=1')
}

function openTermsNCon(){
	termsNConWindow = dhtmlmodal.open ('termsNConditionsPopup','iframe','termsNConditions.jsp','Terms & Conditions','title=1,close=0,drag=1,width=595px,height=350px,resize=1,scrolling=1,center=1,left=100px,top=50px');
}

function openPassthrough(){
	passthroughWindow = dhtmlmodal.open ('openpassthroughPopup','iframe','passthrough.jsp','What is Pass Through?','title=1,close=1,drag=1,width=450px,height=180px,resize=1,scrolling=1,center=1,left=100px,top=50px');
}

function iataDiscountPopup(t1,t2,w,h){
	iatadiscountWindow = dhtmlmodal.open ('iataDiscountPopup','div','iataDiscountPopupDiv', t1+' for '+t2 ,'title=1,close=1,drag=1,width='+w+'px,height='+h+'px,resize=1,scrolling=1,center=1,left=100px,top=50px');
}

function pleaseWaitPopupWindow(){
	var searchProgressBarDiv = document.getElementById('searchProgressBar')
	if (!searchProgressBarDiv){
		searchProgressBarDiv = document.createElement('div');
		searchProgressBarDiv.id = 'searchProgressBar'
		searchProgressBarDiv.style.display='block'
		searchProgressBarDiv.innerHTML = '<br><div align="center"><span class="waitProgress">Please wait....</span><br><br> <img src=\"'+resourceRoot+'/images/arrtan_e0.gif\"></div>'
		document.body.appendChild(searchProgressBarDiv);
	}

	searchPopupWindow=dhtmlmodal.open('searchbar', 'div', 'searchProgressBar', 'Wait...', 'title=1,drag=0,close=0,width=250px,height=100px,resize=0,scrolling=0,center=1')
//	searchPopupWindow = dhtmlmodal.open('searchbar','iframe',getContextPath()+'/jsp/searchProgress.jsp','Please Wait...','title=1,width=300,height=110px,center=1');

}

function mailtopopup(){
	mailtoWindow = dhtmlmodal.open('mailtoPopup', 'div', 'mailDiv', '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=230px,height=135px,left=150px,top=100px,resize=0,scrolling=0,center=1')
}

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

function editPassengerPopup(header,width,height){
	AlertWindow = dhtmlmodal.open('editPassengerPopup', 'div', 'editPassengerPopupDiv', header, 'title=1,drag=1,close=1,width='+width+'px,height='+height+'px,left=150px,top=100px,resize=1,scrolling=1,center=1');
}

		
function cancelTicketPopup(header){
	CancelTicketWindow = dhtmlmodal.open('CancelTicketPopup', 'div', 'cancelTicketPopupDiv', header, 'title=1,drag=1,close=1,width=520px,height=330px,left=150px,top=100px,resize=1,scrolling=1,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=\"'+resourceRoot+'/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){
	if(ary.length > 0)
	{
		var errObj =  document.getElementById(errorPanelId);
		var errTable = "<a name=''></a><table width='100%' border='0' class='tableborder_tips' cellspacing='2' cellpadding='2'><tr><td class='NormalText_12B_white' colspan='2' bgcolor='red'>"+ary.length+" Error(s) found</font></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="#";
	}
}


function showSuccessMessages(successPanelId,ary){
	var successObj =  document.getElementById(successPanelId);
	var successTable = "<table width='100%' border='0' class='tableborder_success' cellspacing='2' cellpadding='2'><tr><td class='NormalText_12B_white' 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 && obj.type != 'button' && (obj.type == 'select-one' || obj.style.borderColor.indexOf('red') != -1)){
		if(obj.type == 'select-one')
		{
			if($obj(obj.id + "_WrapDiv"))
				$obj(obj.id + "_WrapDiv").style.border= "none";
		}
		else
		{
			obj.style.border = 'solid 1px #dcdddf';
			if(obj.parentNode && obj.parentNode.id=="addErrorHighLightDiv")
				obj.parentNode.style.background="#FFFFFF"; 			
		}
  	}
}

function addErrorHighlight(obj){
	if(obj && obj.type != 'button'){
		if(obj.type == 'select-one')
		{
			if($obj(obj.id + "_WrapDiv"))
			{
				$obj(obj.id + "_WrapDiv").style.border= "solid red 1px";
				$obj(obj.id + "_WrapDiv").style.height = obj.offsetHeight;
				$obj(obj.id + "_WrapDiv").style.width = obj.offsetWidth;
				$obj(obj.id + "_WrapDiv").style.cssFloat = "left";
			}
			else
			{
				var _pContainer = document.createElement('div');
				_pContainer.id = obj.id + "_WrapDiv";
				_pContainer.style.border= "solid red 1px";
				_pContainer.style.height = obj.offsetHeight;
				_pContainer.style.width = obj.offsetWidth;
				_pContainer.style.cssFloat = "left";
				obj.parentNode.insertBefore(_pContainer, obj);
				_pContainer.appendChild(obj);
			}
		}
		else
		{
			obj.style.border = 'solid red 1px';
		}
		if(obj.parentNode && obj.parentNode.id=="addErrorHighLightDiv"){
			obj.parentNode.style.background="#ff0000"; 
			obj.parentNode.style.padding = "1";
		}
	}
}

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

function clearErrorDivMessage(divName,divId)	{
	if(document.getElementById(divName))
	{
		document.getElementById(divName).style.display = "none";
	}
	var elements = document.getElementById(divId).getElementsByTagName('*');
	for(var i=0;i<elements.length;i++){
		if(elements[i].type == 'text'  || elements[i].type == 'password' || elements[i].type == 'select-one' || elements[i].type == 'textarea')	{
			removeErrorHighlight(elements[i])
		}
	}
	
}

//editAgencyDetails

function clearDivForm(divId) {
        var elements = document.getElementById(divId).getElementsByTagName('*');
        for (i = 0; i < elements.length; i++) {
            if (elements[i].type != "button") {
                if (elements[i].type == "password" ||
                    elements[i].type == "text" ||
                    elements[i].type == "select-one") {
                    elements[i].value = "";
                }
            }
        }
    }


/*
* 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 validateEmail()
{

	clearErrorMessage("errorMessage");
	
	var validate="true";
	
	var noOfErrors=0;
	var displayHeaderString="<table width=\"100%\" border=\"0\" class=\"tableborder_tips\" cellspacing=\"2\" cellpadding=\"2\"><tr class=\"NormalText_12B_white\"><td colspan=\"2\" bgcolor=\"red\"><font color='white'>";
	var displayErrorString="";

	var eMailId=document.getElementById('mailTo').value;

	var mailStr=new String(eMailId);

	if(validator.isEmpty(eMailId))
	{
		noOfErrors++;
		displayErrorString=displayErrorString+"<tr class=\"FormErrorTips\"><td>"+noOfErrors+".</td><td>To field must be filled.</td></tr>";
		validate="false";
	}
	else
	{
		if(!validator.isEmail(eMailId)){     
			noOfErrors++;
			displayErrorString=displayErrorString+"<tr class=\"FormErrorTips\"><td>"+noOfErrors+".</td><td>Valid email-Id must be filled.</td></tr>";
			validate="false";
		}
	}

	var eMailsubj=document.getElementById('mailSubject').value;

	if(validator.isEmpty(eMailsubj))
	{
		noOfErrors++;

		displayErrorString=displayErrorString+"<tr class=\"FormErrorTips\"><td>"+noOfErrors+".</td><td>Subject field must be filled.</td></tr>";
		validate="false";
	}

	if(validate=="false")
	{
		var errorMessageDiv = document.getElementById("mailErrorDiv");
		var errorString = displayHeaderString+"Please fill the required fields</td></tr>"+displayErrorString+"</table>";
		errorMessageDiv.innerHTML=errorString;
		showDiv("mailErrorDiv");
		return false;
	}	  

	return true;
}


function keygetter(event){
	key = 27;
	try{
		if (!event && window.event) event = window.event;
		if (event) key = event.keyCode;
		else key = event.which;
	}catch(err){}//try catch written to remove js error 
    return key;
}



/** Function to trim the space in the  string
*@ Nasir Sayyad
*@ date 01- Oct - 08
*/
/*function trim(s) {
   var temp = s;
   return temp.replace(/^\s+/,'').replace(/\s+$/,'');
}*/
function trim(value){
	
	if(typeof(value)=="string") {
		return value.replace(/^\s+|\s+$/g,""); 
	}else {
		return value;
	}
}

/** 
*  Function to round a Number i.e. 'no' upto 'places' of decimal
*/
function roundNumber(no, places) {
	return Math.round(no * Math.pow(10,places)) / Math.pow(10, places);
}

Array.prototype.getUniqueValues = function () {
	var hash = new Object();
	for (j = 0; j < this.length; j++) {hash[this[j]] = true}
	var array = new Array();
	for (value in hash) {array.push(value)};
	return array;
}


	function createDivElement$(obj,className,outerElement,styleName)
	{
		var ele = document.createElement('div');
		ele.id = obj;
		if(className!='')
			ele.className = className;
		if(styleName!='')
		{
			var styleArray = styleName.split(";");	
			for (var i=0; i < styleArray.length; i++)
			{
				var st = styleArray[i].split(":");
				if(st[0]=="width")
					ele.style.width = st[1];
				if(st[0]=="height")
					ele.style.height = st[1];
				if(st[0]=="background")
					ele.style.background = st[1];
				if(st[0]=="width")
					ele.style.width = st[1];
				if(st[0]=="position")
					ele.style.position = st[1];
				if(st[0]=="z-index")
					ele.style.zIndex = st[1];
			}
		}
		var outerDiv = $obj(outerElement);
		outerDiv.appendChild(ele);
	}

	function createImageElement$(srcName,className,outerElement,width,height)
	{
		myImage = new Image(width, height);
		myImage.src = srcName;
		if(className!='')
			myImage.className = className;
		var outerDiv = $obj(outerElement);
		outerDiv.appendChild(myImage);
	}

	function createHiddenField$(obj,afterElement)
	{
		var ele = document.createElement('input');
		ele.type = 'hidden';
		ele.id = obj;
		var afterEle = $obj(afterElement);
		afterEle.appendChild(ele);
	}


// Initializes a new instance of the StringBuilder class

// and appends the given value if supplied

function StringBuilder(value)
{
    this.strings = new Array("");
    this.append(value);
}

// Appends the given value to the end of this instance.

StringBuilder.prototype.append = function (value)
{
    if (value)
    {
        this.strings.push(value);
    }
}

// Clears the string buffer

StringBuilder.prototype.clear = function ()
{
    this.strings.length = 1;
}

// Converts this instance to a String.

StringBuilder.prototype.toString = function ()
{
    return this.strings.join("");
}

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 displayDivAtObject(objId,leftOffset,topOffset,divId)
	{		
		var posx= getRealLeft(objId) + leftOffset;
		var posy= getRealTop(objId) + topOffset;
		var divObj = document.getElementById(divId);
		if(divObj!=null)
		{
			divObj.style.left=posx+'px' ;
			divObj.style.top=posy+'px' ;
			divObj.style.display="block";
			divObj.style.visibility="visible";	
		}
		var height = document.getElementById(divId).offsetHeight;
		if(window.screen.height - window.event.screenY > height + 80)
		{
			var posy= getRealTop(objId) + topOffset;
		}
		else
		{
			var posy= getRealTop(objId) - height;
		}
		if(divObj!=null)
		{
			divObj.style.left=posx+'px' ;
			divObj.style.top=posy+'px' ;
			divObj.style.display="block";
			divObj.style.visibility="visible";	
		}		

	}

	// this funciton will return the left position of the component //
	function getRealLeft(comid) {
		xPos = document.getElementById(comid).offsetLeft; 
		tempEl = document.getElementById(comid).offsetParent; 
		  while (tempEl != null) { 
			  xPos += tempEl.offsetLeft; 
			  tempEl = tempEl.offsetParent; 
		  } 
		return xPos; 
	} 

	// this function well return the top position of component //
	function getRealTop(comid) {
		yPos = document.getElementById(comid).offsetTop; 
		tempEl = document.getElementById(comid).offsetParent; 
		while (tempEl != null) { 
			  yPos += tempEl.offsetTop; 
			  tempEl = tempEl.offsetParent; 
		  } 
		return yPos; 
	} 

function showTime(eleId)
{
		var now = new Date();
		var tHr=now.getHours();
		var tMin=now.getMinutes() + "";
		if(tMin.length < 2)
		{
			tMin = "0" + tMin;
		}
		var tSec=now.getSeconds() + "";
		if(tSec.length < 2)
		{
			tSec = "0" + tSec;
		}
		var strTime = tHr +" : "+ tMin + " : " + tSec;
		if(document.getElementById(eleId))
			document.getElementById(eleId).innerHTML =  strTime;
}
function hideTime(eleId)
{
	if(document.getElementById(eleId))
		document.getElementById(eleId).innerHTML = "";
}


var _waitWindow=null;
function showWaitInProgress(){
            _waitWindow = dhtmlmodal.open('modalwaitwindow','iframe','waitProgress.jsp','Request in Progress...','title=1,width=350,height=125,center=1');
}

function hideWaitInProgress(){
   try{
               if(_waitWindow) _waitWindow.hide();
   }catch(err){
               try{
                          if(_waitWindow) dhtmlmodal.hide(_waitWindow);
               }catch(err){
            }
   }
}

function checkInArray(val,Arr)
{
	for(var i=0; i<Arr.length; i++)
	{	
		if(val == Arr[i])
			return i;
	}
	return -1;
}

function openMyAccTab(tabname){
	pleaseWaitPopupWindow();
	if (tabname=="agency"){
		tabtdOpen('agency');
		ownerDetail();
	}
	if (tabname=="Manage"){
		tabtdOpen('Manage'); 
		manageStaffLink();
	}
	if (tabname=="Personal"){
		tabtdOpen('Personal'); 
		
	}
	if (tabname=="Password"){
		tabtdOpen('Password'); 
		
	}
		if (tabname=="Ledger"){
		tabtdOpen('Ledger'); 
		createLedgerRequestCal();
	}
	
	clearErrorMessage('message');
	hideErrorDiv('errorDiv1');
	hideErrorDiv('errorDiv');
	clearErrorMessage('showMessage');
	clearErrorMessage('ledgerRequestErrorMessage');
	
	if (tabname=="agency"){
		showOnly('viewAgencyDetails');
	}
	if (tabname=="Manage"){
		showOnly('ListManageStaff');
	}

	if (tabname=="Personal"){
		showOnly('viewProfileDetails');
	}
	if (tabname=="Password"){
		showOnly('ChangePassword');
	}
	if (tabname=="Traveler"){
		showOnly('viewListTraveler');
	}
	if (tabname=="Ledger"){
		showOnly('searchLedgerDetails');
	}
	
	searchPopupWindow.hide();
	hideDiv("interVeil");


}


