function detectAcrobatVersion()
	{
		var acrobat = new Object();	
		acrobat.installed = false;
		acrobat.version = '0.0';
		
		if (navigator.plugins && navigator.plugins.length)
		{
			for ( var x = 0, l = navigator.plugins.length; x < l; ++x ) 
			{				
				if (navigator.plugins[x].description.indexOf('Adobe Acrobat') != -1 || navigator.plugins[x].description.indexOf('Adobe PDF Plug-In') != -1)
				{
					acrobat.version = 8;
					if(navigator.plugins[x].description.split('Version ')[1]){
						acrobat.version=parseFloat(navigator.plugins[x].description.split('Version ')[1]);
					}
					if (acrobat.version.toString().length == 1) acrobat.version +='.0';
					acrobat.installed = true;
					break;
				}
			}
		}
		else 
		if (window.ActiveXObject)
		{
			for (x=2; x<10; x++)
			{
				try
				{
					oAcro = eval("new ActiveXObject('PDF.PdfCtrl."+ x +"');");
					if (oAcro)
					{
						acrobat.installed = true;
						acrobat.version = x + '.0';
					}
				}
				catch(e) {}
			}
		
			try
			{
				oAcro4 = new ActiveXObject('PDF.PdfCtrl.1');
				if (oAcro4)
				{
					acrobat.installed = true;
					acrobat.version = '4.0';
				}
			}
			catch(e) {}
		
			try
			{
				oAcro7 = new ActiveXObject('AcroPDF.PDF.1');
				if (oAcro7)
				{
					acrobat.installed = true;
					acrobat.version = '7.0';
				}
			}
			catch(e) {}
		}
		
		if (acrobat.installed == true)
		{			
			if (parseFloat(acrobat.version) < 7.0)
			{
				//alert(<fmt:message key='pnr.confirmAcrobatVersion'/>);
				alert("You should install Acrobat Reader 7 or more than to view the reports correctly");
				return false
			}
			return true;
		}
		else
		{
			alert("You should install Acrobat Reader 7 or more than to view the reports correctly");
			//alert("<fmt:message key='pnr.confirmAcrobatInstallation'/>");
			return false;
		}
	}
	
function getDataProvider(autoCompleterId){
	var autoCompleter = dojo.widget.byId(autoCompleterId);
	var dataStation = autoCompleter.dataProvider.data;
    var text = autoCompleter.comboBoxValue.value;
    if(typeof(autoCompleter) != "undefined"){
	    for(var i=0;i<dataStation.length;i++){
	    	var station = dataStation[i];
	    	if(station[0].toLowerCase() == text.toLowerCase()){
	    		autoCompleter.setAllValues(station[0],station[1]);
	    		break;
	    	}else{
	    		autoCompleter.setSelectedValue(text);
	    	}
	    }
	}
}
function setDataProvider(autoCompleterId){
	var autoCompleter = dojo.widget.byId(autoCompleterId);
	var dataStation = autoCompleter.dataProvider.data;
    var text = autoCompleter.textInputNode.value;
    if(typeof(autoCompleter) != "undefined"){
	    for(var i=0;i<dataStation.length;i++){
	    	var station = dataStation[i];
	    	if(station[0].toLowerCase() == text.toLowerCase()){
	    		autoCompleter.setAllValues(station[0],station[1]);
	    		break;
	    	}
	    }
	}
}

function WindowCalender(divCalendar){
	var form = document.getElementById('directShoppingForm');
	var dateCalendar = form.datetime;
	openWindow(divCalendar,dateCalendar);
}

function setFareReference(index1) {
	document.getElementById("fareReference").value = index1;
}
function validateDate(){
	var form = document.getElementById('directShoppingForm');
	var date = document.getElementById("dateReservation").value;
	var dateCalendar = form.datetime.value;
	var dateHide = date.split("-");
	var dateSelect = dateCalendar.split("-");
   	if(dateSelect[0] < dateHide[0]){//year
   		return true;//Selected product must be booked at least 1 day(s) in advance
   	}else{
   		if(dateSelect[0] == dateHide[0]){//year
   			if(dateSelect[1] < dateHide[1]){//month
   				return true;
   			}else{
   				if(dateSelect[1] == dateHide[1]){//month
   					if(dateSelect[2] < dateHide[2]){//day
   						return true;
   					}
   				}	
   			}	
   		}
   	}
   	return false;
}
//// START implement change request 4 for pass shopping
function DisplayMyCart(msg,title,idDialog){		
	var index1 = document.getElementById("indexPassOption").value;
	var index2 = document.getElementById("indexPassFare").value;	
	var messCart = document.getElementById("idMessageCartHidden").value;		
	if(index1 != '' && index2 != ''){
		if(messCart != "")
		{
			initDialogDirect('',idDialog);
		}else{
			DisplayMyCartTwo(title,"");
		}	
	}else{
		alert(msg);
	}	
}
function hideMessCartDialog(title,formName){    			    			
	var inputs = document.forms[formName].elements;	
	var strValueIn = getAllValueOfInputText(inputs);			
	var idMessageCartDialog = dojo.widget.byId("idMessageCartDialog");							
	idMessageCartDialog.hide();
	DisplayMyCartTwo(title,strValueIn);	
}  
function getAllValueOfInputText(inputs){
	var strValueIn = "";
	for(i=0;i<inputs.length;i++){
		if(inputs[i].type == 'text' || inputs[i].type == 'textarea' || inputs[i].type == 'select-one'){
			if(inputs[i].value != ""){
				if(strValueIn == "")
					strValueIn = strValueIn + inputs[i].value;
				else				
					strValueIn = strValueIn + ";;" + inputs[i].value;	
			}																			
		}		
	}
	return strValueIn;
} 
function DisplayMyCartTwo(title,strValueIn){		
	//Google analytics
	pageTracker._trackPageview("<fmt:message key='analytic.bookingProcess'/>" + "<fmt:message key='analytic.passAddCart'/>");
	
	var divMiddle = dojo.widget.byId("middle");
	var divStep3 = dojo.widget.byId("paneStep3");
	var index1 = document.getElementById("indexPassOption").value;	
	var index2 = document.getElementById("indexPassFare").value;
	var fareName = document.getElementById("fareName").value;		
    //active middle tab
    window.scroll(0,0);
	//dojo.widget.byId("tab").selectChild('middle');		
	divMiddle.setUrl("AjaxMyCart.action?indexPassOption="+index1+
						"&indexPassFare="+index2+"&strValueIn="+strValueIn+"&sesId=" + get_random());	
	//call XSelling
	divStep3.setContent("Loading...");
	divStep3.setUrl("AjaxShowXSelling.action?fareName=" + fareName +
					"&title=" + title + "&sesId=" + get_random());
	submitStep2();					
}
//// END implement change request 4 for pass shopping
/*function DisplayMyCart(msg,title){
	//Google analytics
	pageTracker._trackPageview("<fmt:message key='analytic.bookingProcess'/>" + "<fmt:message key='analytic.passAddCart'/>");
	var divMiddle = dojo.widget.byId("middle");
	var divStep3 = dojo.widget.byId("paneStep3");
	var index1 = document.getElementById("indexPassOption").value;
	var index2 = document.getElementById("indexPassFare").value;
	var fareName = document.getElementById("fareName").value;
	if(index1 != '' && index2 != ''){
        //active middle tab
        window.scroll(0,0);
		//dojo.widget.byId("tab").selectChild('middle');
		divMiddle.setUrl("AjaxMyCart.action?indexPassOption="+index1+
							"&indexPassFare="+index2+"&sesId=" + get_random()); 
		//call XSelling
		divStep3.setContent("Loading...");
		divStep3.setUrl("AjaxShowXSelling.action?fareName=" + fareName +
						"&title=" + title + "&sesId=" + get_random());
		submitStep2();				
	}else{
		alert(msg);
	}
}*/
function validateMessageCart(idDialog){
	var messCart = document.getElementById("idMessCartPTPHidden").value;
	if(messCart == ''){
		addToCart('','');
	}else{
		initDialogDirect('',idDialog);
	}
}
//screen mycart   
function DisplayMyCartDirectPTP(fareRef,fareRefInbound,JourneyIndex,
								JourneyIndexInbound,productName,
								title,isPTPDirect,paramSpecialReq,
								paramSeating,paramCompartment,strValueIn){
	//Google analytics
	pageTracker._trackPageview("<fmt:message key='analytic.bookingProcess'/>" + "<fmt:message key='analytic.pointtopointAddCart'/>");
																								
	var specialReq;
	var seating;
	var compartmentType;
	var divMiddle = dojo.widget.byId("middle");
	var divStep3 = dojo.widget.byId("paneStep3");
	if(isPTPDirect == 'true'){
		fareRef = document.getElementById("fareRef").value;
		specialReq = document.getElementById("lblSpecialRequests").value;
		seating = document.getElementById("lblSeating").value;
		compartmentType = document.getElementById("lblCompartmentType").value;
	}else{
		specialReq = paramSpecialReq;
		seating = paramSeating;
		compartmentType = paramCompartment;
	}
    //active middle tab
	//dojo.widget.byId("tab").selectChild('middle');
	divMiddle.setUrl("AjaxMyCartDirectPTP.action?fareRef=" + fareRef + 
					"&fareRefInbound=" + fareRefInbound + "&JourneyIndex=" + JourneyIndex + 
					"&JourneyIdxInbound=" + JourneyIndexInbound + "&specialReq=" + specialReq + 
					"&seating=" + seating + "&compartmentType=" + compartmentType +
					"&isPTPDirect=" + isPTPDirect + "&strValueIn=" + strValueIn + "&sesId=" + get_random()); 
	//call XSelling
	divStep3.setUrl("AjaxShowXSelling.action?fareName=" + productName +
						"&title=" + title + "&sesId=" + get_random());
	if(isPTPDirect == 'true'){
		directStep3();
	}
}
//screen mycart
/*function DisplayMyCartDirectPTP(fareRef,fareRefInbound,JourneyIndex,
								JourneyIndexInbound,productName,
								title,isPTPDirect,paramSpecialReq,paramSeating,paramCompartment){			
	//Google analytics
	pageTracker._trackPageview("<fmt:message key='analytic.bookingProcess'/>" + "<fmt:message key='analytic.pointtopointAddCart'/>");
							
	var specialReq;
	var seating;
	var compartmentType;
	var divMiddle = dojo.widget.byId("middle");
	var divStep3 = dojo.widget.byId("paneStep3");
	if(isPTPDirect == 'true'){
		fareRef = document.getElementById("fareRef").value;
		specialReq = document.getElementById("lblSpecialRequests").value;
		seating = document.getElementById("lblSeating").value;
		compartmentType = document.getElementById("lblCompartmentType").value;
	}else{
		specialReq = paramSpecialReq;
		seating = paramSeating;
		compartmentType = paramCompartment;
	}
    //active middle tab
	///dojo.widget.byId("tab").selectChild('middle');
	divMiddle.setUrl("AjaxMyCartDirectPTP.action?fareRef=" + fareRef + 
					"&fareRefInbound=" + fareRefInbound + "&JourneyIndex=" + JourneyIndex + 
					"&JourneyIdxInbound=" + JourneyIndexInbound + "&specialReq=" + specialReq + 
					"&seating=" + seating + "&compartmentType=" + compartmentType +
					"&isPTPDirect=" + isPTPDirect + "&sesId=" + get_random()); 
	//call XSelling
	//divStep3.setContent("Loading...");
	divStep3.setUrl("AjaxShowXSelling.action?fareName=" + productName +
						"&title=" + title + "&sesId=" + get_random());
	if(isPTPDirect == 'true'){
		directStep3();
	}
}*/
//screen xSelling
function BuyProductX(productX,isMore){
	//active middle tab
	///dojo.widget.byId("tab").selectChild('treeLeft');
	if(isMore == 'true'){
		selectItem(productX,'rightInformation');
	}else{
		selectItem(productX);
	}
	return false;
}

//screen directShoping step1
function DisplayNumberPass(){
	var triggerId = document.getElementById("lblNONAdult");
	var numberPass = triggerId.value;
	var divPassenger = dojo.widget.byId("divPassenger");
  	var target = document.getElementById("divPassenger");
	var url = target.getAttribute("href");
	getNonAdult();
	divPassenger.setUrl("AjaxShowNonAdultPass.action?numberPass=" + numberPass);
	if(document.getElementById('passengerContainer').style.display == "none"){
		document.getElementById('passengerContainer').style.display = "block";
		document.getElementById('identify').src = "images/arrowOut.gif";
	}
}
var MyNonAdult;
function getNonAdult(){
	var k=0;
	MyNonAdult = new Array();
	var child = document.getElementsByTagName('input');
    for (var i = 0; i < child.length; i++) {
        if( child[i].type == 'text') {
        	if(child[i].id == 'txtPassenger'){
            	MyNonAdult[k++] = child[i].value;
            }
        }
	}
}
function setNonAdult(){
	var k=0;
	var child = document.getElementsByTagName('input');
    for (var i = 0; i < child.length; i++) {
        if( child[i].type == 'text') {
        	if(child[i].id == 'txtPassenger'){
	       		if(k<MyNonAdult.length){
	           		child[i].value = MyNonAdult[k++];
	           	}
	        }
        }
	}
}


//screen directShoping step1
function DisplayStationOrigin(countryComboId,sDivId,actionUrl,param1,param2){
	var uicCountryCode = document.getElementById(countryComboId).value;
	var divOrigin = dojo.widget.byId(sDivId);
	divOrigin.setUrl(actionUrl + param1 + uicCountryCode + param2);
}
//screen directShoping step1
function DisplayStationDestination(countryComboId,sDivId,actionUrl,param1,param2){
	var uicCountryCode = document.getElementById(countryComboId).value;
	var divDestination = dojo.widget.byId(sDivId);
	divDestination.setUrl(actionUrl + param1 + uicCountryCode + param2);
}

//screen directShoping step2
var dialogDirect;
function showDialogDirect(index) {
	dialogDirect = dojo.widget.byId("directDialog");
	dialogDirect.setUrl("AjaxShowDirectShoppingStep2!loadDialog.action?fareIndex=" + index);    
	dialogDirect.show();
}
//screen directShoping step3
function initDialogDirect(e,dialog){
	dialogDirect = dojo.widget.byId(dialog);
	dialogDirect.show();
}
//screen directShoping step2
function hideDialogDirect() {
	dialogDirect.hide();
}
//Stock Control Screen
var dialogStock;
function initDialogStock(e,dialog) {
	dialogStock = dojo.widget.byId(dialog);
	dialogStock.show();
}
function hideDialogStock() {
	dialogStock.hide();
}
//Stock Control Screen Update
var dialogStockConfirm;
function initDialogStockConfirm(e,dialog) {
	dialogStockConfirm = dojo.widget.byId(dialog);
	dialogStockConfirm.show();
}
function hideDialogStockConfirm() {
	dialogStockConfirm.hide();
}

function selectItemOutstanding(){
	showLoadingDialog();
	var valueItem=document.getElementById("valueItem").value;		
	var divOutstandingPNR = dojo.widget.byId("outstandingPNR");
  	var target = document.getElementById("outstandingPNR");
	var url = target.getAttribute("href");
	divOutstandingPNR.setUrl("AjaxFilterPNRItems.action?valueItem=" + valueItem);
}
function checkedAllChk(which)
{
	var isChecked = which.checked;
	for(i=0;i<document.getElementsByName("checkId").length;i++)
	{
		//alert(document.getElementsByName("checkId")[i].value);
		document.getElementsByName("checkId")[i].checked = isChecked;
	}
}
function paySelected()
{
	var arr = new String();
	var checkId="";
	var count=0;
	for(i=0;i<document.getElementsByName("checkId").length;i++)
	{
		if(document.getElementsByName("checkId")[i].checked==true){
			if (count==0)
			{
				checkId=document.getElementsByName("checkId")[i].value;
			}
			else
				checkId=checkId+";"+document.getElementsByName("checkId")[i].value;
			count++;
		}
		
		//arr[i] = document.getElementsByName("checkId")[i].value;
	}
	if (count==0)
	{
		alert("Please select item to pay");
		return false;
	}
	var payPNR = dojo.widget.byId("managementPNR");
  	var target = document.getElementById("managementPNR");
	var url = target.getAttribute("href");	
	payPNR.setUrl("AjaxPayPNR.action?checkId="+checkId);
}

function cancelSelected(tabId,checkboxTabName)
{
	var arr = new String();
	var checkId="";
	var count=0;
	for(i=0;i<document.getElementsByName(checkboxTabName).length;i++)
	{
		if(document.getElementsByName(checkboxTabName)[i].checked==true){
			if (count==0)
			{
				checkId=document.getElementsByName(checkboxTabName)[i].value;
			}
			else
				checkId=checkId+";"+document.getElementsByName(checkboxTabName)[i].value;
			count++;
		}
		
		//arr[i] = document.getElementsByName("checkId")[i].value;
	}
	if (count==0)
	{
		alert("Please select item to cancel");
		return false;
	}
	else{
		getPenaltyFeesBookResourceValue(tabId,checkboxTabName,checkId);
		/*if(window.confirm("Penalty fee could apply !  Do you want to continue ?")){
							
			if(tabId=="outstandingPNR"){
				showLoadingDialog();
				var tabPNR = dojo.widget.byId(tabId);
			  	var target = document.getElementById(tabId);
				var url = target.getAttribute("href");
				tabPNR.setUrl("AjaxCancelOutstadingItem.action?checkId="+checkId+"&tabId="+tabId);
			}else if(tabId=="paidPNR"){
				showLoadingDialog();
				var tabPNR = dojo.widget.byId(tabId);
			  	var target = document.getElementById(tabId);
				var url = target.getAttribute("href");
				tabPNR.setUrl("AjaxCancelPaidItem.action?checkId="+checkId+"&tabId="+tabId);
			}else{
				//tabPNR.setUrl("AjaxCancelIssueItem.action?checkId="+checkId+"&tabId="+tabId);
				var voidDialog = null;
			    voidDialog = dojo.widget.byId("idCancelPNRDialog");
			    voidDialog.setUrl("AjaxCancelIssueItem.action?checkId="+checkId+"&tabId="+tabId);
			    voidDialog.show();
			}
		}*/
		
	}
}

function issueSelected(tabId,checkboxTabName)
{
	if(detectAcrobatVersion()){
		var arr = new String();
		var checkId="";
		var count=0;
		for(i=0;i<document.getElementsByName(checkboxTabName).length;i++)
		{
			if(document.getElementsByName(checkboxTabName)[i].checked==true){
				if (count==0)
				{
					checkId=document.getElementsByName(checkboxTabName)[i].value;
				}
				else
					checkId=checkId+";"+document.getElementsByName(checkboxTabName)[i].value;
				count++;
			}
			
			//arr[i] = document.getElementsByName("checkId")[i].value;
		}
		if (count==0)
		{
			alert("Please select item to issue");
			return false;
		}
		showLoadingDialog();
		var tabPNR = dojo.widget.byId(tabId);
	  	var target = document.getElementById(tabId);
		var url = target.getAttribute("href");	
		tabPNR.setUrl("AjaxIssueBookResource.action?checkId="+checkId+"&tabId="+tabId);
		
		//var issuedDialog = null;
	    //issuedDialog = dojo.widget.byId("idIssuedDialog");
	    //issuedDialog.setUrl("AjaxIssueBookResource.action?checkId="+checkId+"&tabId="+tabId);
	    //issuedDialog.show();
	}
}
function voidSelected(tabId,checkboxTabName)
{
	var arr = new String();
	var checkId="";
	var count=0;
	for(i=0;i<document.getElementsByName(checkboxTabName).length;i++)
	{
		if(document.getElementsByName(checkboxTabName)[i].checked==true){
			if (count==0)
			{
				checkId=document.getElementsByName(checkboxTabName)[i].value;
			}
			else
				checkId=checkId+";"+document.getElementsByName(checkboxTabName)[i].value;
			count++;
		}
		
		//arr[i] = document.getElementsByName("checkId")[i].value;
	}
	if (count==0)
	{
		alert("Please select item to void");
		return false;
	}else	
		confirmVoidTicket(tabId,checkId);
}
function confirmVoidTicket(tabId,checkId){
	var printPNRpDialog = null;
	    printPNRpDialog = dojo.widget.byId("idCancelPNRDialog");
	    printPNRpDialog.setUrl("AjaxVoidBookResource!confirmVoidTicket.action?checkId="+checkId+"&tabId="+tabId);
	    printPNRpDialog.show();
}
function voidTicket(checkId){
	closeDialog('idCancelPNRDialog');
	if(checkId==null || checkId=="" ){		
		alert("Please select item to void");
	}else{
		var printPNRpDialog = null;
	    printPNRpDialog = dojo.widget.byId("idCancelPNRDialog");
	    printPNRpDialog.setUrl("AjaxVoidBookResource.action?checkId="+checkId+"&tabId=issuedPNR");
	    printPNRpDialog.show();
	}
}
function getCurrentPNR(curentPNR,reference){
	setValuePnrHidden("VALUE");
	document.getElementById("curentPNR").value=curentPNR;
	document.getElementById("reference").value=reference;
	
	loadCurrentPNRAction();
	var tabPNR = dojo.widget.byId("divContent");
	var target = document.getElementById("divContent");
	var url = target.getAttribute("href");
	tabPNR.setUrl("AjaxShowCurrentPNR.action?pnrLocator="+curentPNR);
}
function makeCurrentPNR(){
	for(i=0;i<document.getElementsByName("pnrId").length;i++)
	{
		if(document.getElementsByName("pnrId")[i].checked==true){
			document.getElementById("curentPNR").value=document.getElementsByName("pnrId")[i].value;
			document.getElementById("reference").value=document.getElementsByName("pnrId")[i].alt;	
			break;		
		}
	}
	
	loadCurrentPNRAction();
}
function makeCurrentPNRByAdvance(){
	for(i=0;i<document.getElementsByName("pnrIdAdvance").length;i++)
	{
		if(document.getElementsByName("pnrIdAdvance")[i].checked==true){
			document.getElementById("curentPNR").value=document.getElementsByName("pnrIdAdvance")[i].value;
			document.getElementById("reference").value=document.getElementsByName("pnrIdAdvance")[i].alt;	
			break;		
		}
	}	
	
	loadCurrentPNRAction();
}
function loadCurrentPNRAction(){
	var curentPNR = document.getElementById("curentPNR").value;
	var reference = document.getElementById("reference").value;
	
	var tabPNR = dojo.widget.byId("currentPNR");
  	var target = document.getElementById("currentPNR");
	var url = target.getAttribute("href");
	tabPNR.setUrl("AjaxMakeCurrentPNR.action?pnrLocator="+curentPNR+"&pnrReference="+reference);
	if(dojo.widget.byId("loadUpdatePNRDiv")!=null && document.getElementById("loadUpdatePNRDiv")!=null){
		var loadUpdatePNRDiv = dojo.widget.byId("loadUpdatePNRDiv");
		var targetUpdatePNR = document.getElementById("loadUpdatePNRDiv");
		var urlUpdatePNR = targetUpdatePNR.getAttribute("href");
		loadUpdatePNRDiv.setUrl("AjaxLoadSaveCurrentPNR.action?pnrLocator="+curentPNR);
	}
}

function saveNewPNR(){
	setValuePnrHidden("");
	document.getElementById("curentPNR").value="New";
	document.getElementById("reference").value="Empty";
	document.getElementById("curentPNR").style.cursor="";
	
	//var loadUpdatePNRDiv = dojo.widget.byId("loadUpdatePNRDiv");
  	//var targetUpdatePNR = document.getElementById("loadUpdatePNRDiv");
	//var urlUpdatePNR = targetUpdatePNR.getAttribute("href");
	//loadUpdatePNRDiv.setUrl("AjaxLoadSaveCurrentPNR.action?action=newPNR");
	getAction("AjaxLoadSaveCurrentPNR.action?action=newPNR","loadUpdatePNRDiv");
}
function getProductLink(link){
	//alert(link);
	var loadUpdatePNRDiv = dojo.widget.byId("divContent");
  	var targetUpdatePNR = document.getElementById("divContent");
	var urlUpdatePNR = targetUpdatePNR.getAttribute("href");
	loadUpdatePNRDiv.setUrl(link);
}

function submitSearchProduct(){
	if (window.event && window.event.keyCode == 13) {
		event.keyCode=0;
		document.getElementById("searchSubmit").click();		
	}
}

function displayLastPNR(){
	var valueLastItem=document.getElementById("valueLastItem").value;		
	var divPNRList = dojo.widget.byId("divPNRList");
  	var target = document.getElementById("divPNRList");
	var url = target.getAttribute("href");
	divPNRList.setUrl("AjaxPNRListAction.action?valueLastItem=" + valueLastItem);
}

function deleteNote(noteId){		
	var divDialogDeleteNew = dojo.widget.byId("idDeletePNR");
	message = "Do you want to delete this notes ?";
	divDialogDeleteNew.setUrl("AlertOrConfirm!confirmDeleteNote.action?message=" + message
											+ "&noteId=" + noteId); 					
    divDialogDeleteNew.show();
    
	//if(window.confirm("Do you want to delete this notes ?")){
		//showLoadingDialog();
		//var tabPNR = dojo.widget.byId("notesList");
		//var target = document.getElementById("notesList");
		//var url = target.getAttribute("href");
		//tabPNR.setUrl("AjaxDeleteNotesItems.action?categoryId="+noteId);
	//}
}

function getAction(actionName,targetName){	
	var divContent = dojo.widget.byId(targetName);
	var target = document.getElementById(targetName);
	var url = target.getAttribute("href");
	divContent.setUrl(actionName);
}
function linkToPNRManagement(actionName,targetName){
	if(document.getElementById("curentPNR").value!="" && document.getElementById("curentPNR").value!="New"){
		setValuePnrHidden("VALUE");
		getAction(actionName,targetName);
	}
}
function showRecentPNR(){
	document.getElementById("recentPNRDiv").style.display="";
	document.getElementById("homeDiv").style.display="";
}

function confirmFullCancelPNR(){
	closeDialog('idCancelPNRDialog');
	var printPNRpDialog = null;
	    printPNRpDialog = dojo.widget.byId("idCancelPNRDialog");
	    printPNRpDialog.setUrl("AjaxFullCancel!confirmCancel.action");
	    printPNRpDialog.show();
}

function cancelPNR(){
	closeDialog('idCancelPNRDialog');
	var printPNRpDialog = null;
	printPNRpDialog = dojo.widget.byId("idCancelPNRDialog");
	printPNRpDialog.setUrl("AjaxFullCancel.action");
	printPNRpDialog.show();
}

function getPenaltyFeesValue(){
	var printPNRpDialog = null;
	    printPNRpDialog = dojo.widget.byId("idCancelPNRDialog");
	    printPNRpDialog.setUrl("AjaxFullCancel!getPenaltyFees.action");
	    printPNRpDialog.show();
}
function getPenaltyFeesBookResourceValue(tabId,checkboxTabName,checkId){
	var printPNRpDialog = null;
	    printPNRpDialog = dojo.widget.byId("idCancelPNRDialog");
	    printPNRpDialog.setUrl("AjaxFullCancel!getPenaltyFeesBookResource.action?checkboxTabName="+checkboxTabName+"&tabId="+tabId+"&checkId="+checkId);
	    printPNRpDialog.show();
}
function confirmBookResourceCancelPNR(tabId,checkboxTabName){
	closeDialog('idCancelPNRDialog');
	var printPNRpDialog = null;
	    printPNRpDialog = dojo.widget.byId("idCancelPNRDialog");
	    printPNRpDialog.setUrl("AjaxFullCancel!confirmBookResourceCancel.action?checkboxTabName="+checkboxTabName+"&tabId="+tabId);
	    printPNRpDialog.show();
}
function bookResourceCancelPNR(tabId,checkboxTabName){
	closeDialog('idCancelPNRDialog');
	var arr = new String();
	var checkId="";
	var count=0;
	for(i=0;i<document.getElementsByName(checkboxTabName).length;i++)
	{
		if(document.getElementsByName(checkboxTabName)[i].checked==true){
			if (count==0)
			{
				checkId=document.getElementsByName(checkboxTabName)[i].value;
			}
			else
				checkId=checkId+";"+document.getElementsByName(checkboxTabName)[i].value;
			count++;
		}
		
		//arr[i] = document.getElementsByName("checkId")[i].value;
	}
	if (count==0)
	{
		alert("Please select item to cancel");
		return false;
	}
	else{
		if(tabId=="outstandingPNR"){
				showLoadingDialog();
				var tabPNR = dojo.widget.byId(tabId);
			  	var target = document.getElementById(tabId);
				var url = target.getAttribute("href");
				tabPNR.setUrl("AjaxCancelOutstadingItem.action?checkId="+checkId+"&tabId="+tabId);
			}else if(tabId=="paidPNR"){
				showLoadingDialog();
				var tabPNR = dojo.widget.byId(tabId);
			  	var target = document.getElementById(tabId);
				var url = target.getAttribute("href");
				tabPNR.setUrl("AjaxCancelPaidItem.action?checkId="+checkId+"&tabId="+tabId);
			}else{				
				var voidDialog = null;
			    voidDialog = dojo.widget.byId("idCancelPNRDialog");
			    voidDialog.setUrl("AjaxCancelIssueItem.action?checkId="+checkId+"&tabId="+tabId);
			    voidDialog.show();
			}
		}
}
function newsIndex(year){
	var actionName = "AjaxNewsIndexAction.action?year="+year;
	getAction(actionName,"divContent");
}
function newsDetail(newsId){
	var actionName = "AjaxNewsDetailAction.action?newsId="+newsId;
	getAction(actionName,"divContent");
}
function showHideNewsListDiv(){
	if(document.getElementById("newsListDiv").style.display=="none"){
		document.getElementById("newsListDiv").style.display="";
		document.getElementById("arrowOutImage").style.display="";
		document.getElementById("arrowInImage").style.display="none";
	}
	else{
		document.getElementById("newsListDiv").style.display="none";
		document.getElementById("arrowOutImage").style.display="none";
		document.getElementById("arrowInImage").style.display="";
	}
}
function setValuePnrHidden(value){
	document.getElementById("pnrHidden").value=value;	
}

function printPNR(){	
	if(detectAcrobatVersion()){
		var printPNRDialog = null;
	    printPNRDialog = dojo.widget.byId("idPrintPNRDialog");
	    printPNRDialog.setUrl("AjaxPrintPnr.action");
	    printPNRDialog.show();	    
	    //window.open(link);
	}
	//window.open(window.open('http://www.pageresource.com/jscript/jex5.htm','mywindow','width=400,height=200'));
}
function reloadSaveToCurrentPNR(){
	if(dojo.widget.byId("loadUpdatePNRDiv")!=null && document.getElementById("loadUpdatePNRDiv")!=null){
		var loadUpdatePNRDiv = dojo.widget.byId("loadUpdatePNRDiv");
		var targetUpdatePNR = document.getElementById("loadUpdatePNRDiv");
		var urlUpdatePNR = targetUpdatePNR.getAttribute("href");
		loadUpdatePNRDiv.setUrl("AjaxLoadSaveCurrentPNR.action");
	}
}

function emailPNR(){
	//window.open(emailURL+"?RequestorID="+requestorID+"&PNRLocator="+pnrLocator);
	var emailPNRDialog = null;
    emailPNRDialog = dojo.widget.byId("idEmailPNRDialog");
    emailPNRDialog.setUrl("AjaxEmailPnr.action");
    emailPNRDialog.show();
}
function hideSaveMorePNRDiv(){
	if(document.getElementById("saveMorePNRDiv")!=null){
		document.getElementById("saveMorePNRDiv").style.display="none";	
	}
}
function getCurrentStockNumber(){
	var currentDialog = null;
    currentDialog = dojo.widget.byId("dialogStock");
    currentDialog.setUrl("AjaxGetCurrentStock.action");
    currentDialog.show();
}
function setCurrentStockNumber(){
	var currentDialog = null;
	var stockNumber = document.getElementById("currentStockNumber").value;
    currentDialog = dojo.widget.byId("dialogStock");
    currentDialog.setUrl("AjaxSetCurrentStock.action?currentStockNumber="+stockNumber);
    currentDialog.show();
}
function updateCurrentStockNumber() {	
	var stockNumber = document.getElementById("currentStockNumber").value;
	var divCurrentDialog = dojo.widget.byId("dialogStock");
  	var target = document.getElementById("dialogStock");
	var url = target.getAttribute("href");
	divCurrentDialog.setUrl("updateCurrentStock.action?currentStockNumber="+stockNumber);	
}
function closeDialog(idDialog){
	var divDialog = dojo.widget.byId(idDialog);
	divDialog.hide();
}
function checkCurrentStock(checkboxTabName){
	var checkId="";	
		var count=0;
		for(i=0;i<document.getElementsByName(checkboxTabName).length;i++)
		{
			if(document.getElementsByName(checkboxTabName)[i].checked==true){
				if (count==0)
				{
					checkId=document.getElementsByName(checkboxTabName)[i].value;
				}
				else
					checkId=checkId+";"+document.getElementsByName(checkboxTabName)[i].value;
				count++;
			}
		}		
		
		if (count==0)
			alert("Please select item to issue");			
		else if(detectAcrobatVersion())
			getCurrentStockNumber();
}
function confirmCurrentStock(checkboxTabName){	
	closeDialog("dialogStock");
	var stockNumber = document.getElementById("currentStockNumber").value;	
	var checkId="";	
	var count=0;	
	if(document.getElementsByName("namePNR").length>0)
		checkboxTabName="namePNR"
	for(i=0;i<document.getElementsByName(checkboxTabName).length;i++)
	{
		if(document.getElementsByName(checkboxTabName)[i].checked==true){
			if (count==0)
				checkId=document.getElementsByName(checkboxTabName)[i].value;
			else
				checkId=checkId+";"+document.getElementsByName(checkboxTabName)[i].value;
			count++;
		}
	}
	if (count==0)
	{
		alert("Please select item to issue");
		return false;
	}
	if(detectAcrobatVersion()){		
		var issuedDialog = null;
	    issuedDialog = dojo.widget.byId("idPrintPNRDialog");
	    if(checkboxTabName=="namePNR")
	    	issuedDialog.setUrl("AjaxIssueBookResource.action?currentStockNumber="+stockNumber+"&checkId="+checkId+"&page=batch");
	    else	
	    	issuedDialog.setUrl("AjaxIssueBookResource.action?currentStockNumber="+stockNumber+"&checkId="+checkId);
	    issuedDialog.show();	    	    
	}
}

function makePayment(paymentMethod){
	var count=0;
	var checkId="";
	var status;
	var totalPrice = 0.00;
	for(i=0;i<document.getElementsByName("checkId").length;i++)
	{
		if(document.getElementsByName("checkId")[i].checked==true){
			if (count==0)
				checkId=document.getElementsByName("checkId")[i].value;
			else
				checkId=checkId+","+document.getElementsByName("checkId")[i].value;
			count++;
			status = document.getElementsByName("productStatus")[i].value;
			if(status=="Pending Acceptance" || status=="Pending Pricing"){
				alert("Can not make payment for pending acceptance and pending pricing item");
				return false;
			}
			/* dcttrung add new line */
			totalPrice += parseFloat(document.getElementsByName("totalPrice")[i].value);
			//if(status!="Due Later" && status!="Due Now" && status!="Expire" && status!="Confirmed"){
				//alert("Can not make payment, please uncheck product "+status);
				//return false;
			//}
		}
	}
	/* dcttrung add new line */
	var result = totalPrice.toFixed(2);
	if (count==0){
		alert("Please select item to make a payment");
		return false;
	}
	
	urlAction = "makePaymentAjaxShowPaxAssignmentPayment.action?payment.paymentMethod=" + paymentMethod+ 
		"&radioCheck=sa&checkIdItem=" + checkId + "&amount=" + result;

	var tabPNR = dojo.widget.byId("divContent");
	var target = document.getElementById("divContent");
	var url = target.getAttribute("href");
	tabPNR.setUrl(urlAction);	
}

function acceptPricing(checkId){
	var count=0;
	var chkId;
	var accepted;
	for(i=0;i<document.getElementsByName("checkId").length;i++)
	{
		chkId = document.getElementsByName("checkId")[i]
		if(chkId.checked==true){
			if(document.getElementsByName("productStatus")[i].value=="Pending Acceptance"){
				count++;
				if(count==2){
					alert("Only one pending acceptance item can be accepted pricing")
					return false;
				}
				else{
					accepted = chkId;
				}
			}
			else{
				alert("Only pending acceptance item can be accepted pricing")
				return false;
			}
		}
	}
	if (count==0)
	{
		alert("Please select pending acceptance item to accept pricing");
		return false;
	}
	var printPNRDialog = null;
    printPNRDialog = dojo.widget.byId("dialogStock");
    printPNRDialog.setUrl("AjaxAcceptPricing.action?bookedResourceId="+accepted.value);
    printPNRDialog.show();
	return true;
}

function checkAddNotes(){
	if (document.getElementById("note").value=="")
	{
		alert("Please enter note");
		return false;
	}
	closeDialog('dialogStock');
	showLoadingDialog();
	
	var mainForm = document.getElementById("notesForm");
    mainForm.action = "AjaxSaveNoteAcceptPricing.action";
    
    var batchPrintListPNRs = dojo.widget.byId("divContent");
    batchPrintListPNRs.setContent("Loading...");    
    dojo.io.bind({
        load: loadDataPNRs,
        formNode: mainForm,
        mimetype: "text/plain"
    });
}
function loadDataPNRs(type, data, evt) {
    dojo.widget.byId("divContent").setContent(data);       
}

function showCancelErrorDialog() {
	var printPNRDialog = null;
    printPNRDialog = dojo.widget.byId("idCancelDialog");    
    printPNRDialog.show();
}