﻿var iPopUpCount = 0;
function SetCollapsableBehaviour(panelId)
{
    var panelElement=document.getElementById(panelId);        
    if(panelElement.style.display == "none")
    {
        panelElement.style.display = "block";
        panelElement.style.height = "100%";
        panelElement.style.overflow = "visible";
        panelElement.style.visibility = "visible";
    }
    else
    {
        panelElement.style.display = "none";
        panelElement.style.height = "0px";
        panelElement.style.overflow = "hidden";
        panelElement.style.visibility = "hidden";
    }
}
//panelId in CSV format, boolean value(show:true,hide:false)
function SetCollapsableBehaviourForPanels(hiddenConrolId, showOrHide)
{
    var hiddenElementValue = document.getElementById(hiddenConrolId).value;    
    var ids = hiddenElementValue.split(',');
    var panelElement;
    for(var i=0; i<ids.length-1;i++)
    {
        if(ids[i] != '')
        {
            panelElement=document.getElementById(ids[i]);
            if(showOrHide)
            {
                panelElement.style.display = "block";
                panelElement.style.height = "100%";
                panelElement.style.overflow = "visible";
                panelElement.style.visibility = "visible";
            }
            else
            {
                panelElement.style.display = "none";
                panelElement.style.height = "0px";
                panelElement.style.overflow = "hidden";
                panelElement.style.visibility = "hidden";
            }
                
        }
    }    
}

/************* Popups *****************/
openWins = new Array();
curWin = 0;
function OpenPopupInCenterPage(page, width, height) 
{ 
	var w = width, h = height;
	 
	if (document.all) 
	{
	   /* the following is only available after onLoad */
	   w = document.body.clientWidth;
	   h = document.body.clientHeight;
	}
	else if (document.layers) 
	{
	   w = window.innerWidth;
	   h = window.innerHeight;
	}
	 
	var popW = width, popH = height;
	 
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;

	openWins[curWin++] = window.open(page,'_blank', 'width=' + popW + ',height='+popH+',top='+topPos+',left='+leftPos + ',toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=0, copyhistory=No'); 
}
function OpenPopupWithScrollbar(page, width, height, top, left) 
{
    openWins[curWin++] = window.open(page,'windowURL', 'width=' + width + ',height='+height+',top='+top+',left='+left + ',toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=0, copyhistory=No',true); 
}
function OpenPopup(page, width, height, top, left) 
{ 
	openWins[curWin++] = window.open(page,'_blank', 'width=' + width + ',height='+height+',top='+top+',left='+left + ',toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=0, copyhistory=No'); 
}
function closeAll() {
    for(i=0; i<openWins.length; i++) if (openWins[i] && !openWins[i].closed) openWins[i].close();
}
/**************  Popup - End ***********************/

/************* jQuery Popups *****************/
function Open630pxPopup(divId) {
    divId = "div#" + divId;
    jQuery(divId).dialog
    ({ bgiframe: true,
        width: 630,
        modal: true,
        stack: true,
        position: 'center',
        autoOpen: false,
        resizable: false,
        zIndex: 100009,
        closeOnEscape: false,
        create: function (event, ui) {jQuery(".ui-widget-header").hide();},
        open: function (type, data) {jQuery(this).parent().appendTo('form');}
    });
    jQuery(divId).dialog("open")
    iPopUpCount = 2;
}

function Change621PopUpBgColor() {
    jQuery('#Page-dialog-overlay').show();
    jQuery('#Body-dialog-overlay').show();
    jQuery('#Body-dialog-overlay-white').css({ 'background-color': '#0083D7', 'opacity': 0.8 });
    jQuery('#Body-dialog-overlay').height(jQuery('#Body').height());
    jQuery('#Page-dialog-overlay').height(jQuery('#Body').height());
}

function OpenBigjQueryPopup(divId) {
    divId = "div#" + divId;
    jQuery(divId).dialog
    ({ bgiframe: true,
        width: 956,
        modal: true,
        stack: true,
        position: 'center',
        autoOpen: false,
        resizable: false,
        zIndex: 100009,
        closeOnEscape: false,
        create: function (event, ui) {jQuery(".ui-widget-header").hide();},
        open: function (type, data) {jQuery(this).parent().appendTo('form');}
    });

    jQuery(divId).dialog("open");
    iPopUpCount = 1;
}

function Change941PopUpBgColor() {
    jQuery('#Body-dialog-overlay-white').show();
    jQuery('#Body-dialog-overlay-white').height(jQuery('#Body').height());
}

function OpenjQueryPopup(divId, w) {
    OpenjQPopup(divId, w);
}

function OpenjQPopup(divId, w, h) {
    divId = 'div#' + divId;
    jQuery(divId).dialog({
        bgiframe: true,
        height: h,
        width: w,
        modal: true,
        stack: true,
        position: 'center',
        autoOpen: false,
        resizable: false,
        zIndex: 100001,
        closeOnEscape: true,
        create: function (event, ui) {
            jQuery(".ui-widget-header").hide();
        },
        open: function (type, data) { jQuery(this).parent().appendTo('form'); },
        hide: 'fold',
        show: 'blind'
    });

    jQuery(divId).dialog('open');
}

function ClosejQueryPopup(divId) {
    divId = 'div#' + divId;
    jQuery(divId).dialog('close');
}

function PopupDivToPrint(a) {
    var divId = "div#" + a;
    jQuery(divId).jqprint();
    return true;
}

/**************  jQuery Popup - End ***********************/

/**************  BEGIN - Ticket Delivery Total Cost ***********************/
function setDeliveryOptions(selectedDeliveryOption) {
    var ddl = selectedDeliveryOption; //document.getElementById(selectedDeliveryOption.id);
    if (ddl != null) {
        var cardType;
        var cardTypeText = '';
        if (document.getElementById('dnn_ctr3252_ViewPayment_PaymentDetail_cboCreditCardType') != null) {
            var creditCard = document.getElementById('dnn_ctr3252_ViewPayment_PaymentDetail_cboCreditCardType');
            if (creditCard.options[creditCard.selectedIndex].innerHTML.match("%") != null) {
                cardType = "Credit";
                cardTypeText = creditCard.options[creditCard.selectedIndex].innerHTML;
            }
        }
        else {
            cardType = "Debit";
        }
        CallServer('Delivery Option|' + ddl.value + '|CardType|' + cardType + '|' + cardTypeText, null);
    }
}

function CoverTermsAndConditions(bottom, top, ignoreSize) {
    var location = Sys.UI.DomElement.getLocation(bottom);
    top.style.position = 'absolute';
    top.style.top = location.y + 'px';
    top.style.left = (location.x - 30) + 'px';
    if (!ignoreSize) {
        top.style.height = (bottom.offsetHeight - 10) + 'px';
        top.style.width = bottom.offsetWidth + 'px';
    }

}

function CoverPostalOptions(bottom, top, ignoreSize) {
    var location = Sys.UI.DomElement.getLocation(bottom);
    top.style.position = 'absolute';
    top.style.top = location.y + 'px';
    top.style.left = (location.x + 280) + 'px';
    if (!ignoreSize) {
        top.style.height = (bottom.offsetHeight - 10) + 'px';
        top.style.width = bottom.offsetWidth + 'px';
    }

}


function CoverFareConditions(bottom, top, ignoreSize) {
    var location = Sys.UI.DomElement.getLocation(bottom);
    top.style.position = 'absolute';
    top.style.top = (location.y + 10) + 'px';
    top.style.left = (location.x - 30) + 'px';
    if (!ignoreSize) {
        top.style.height = bottom.offsetHeight + 'px';
        top.style.width = bottom.offsetWidth + 'px';
    }

}

function PrintTermsAndConditions() {
    var disp_setting = "toolbar=no,location=no,directories=no,menubar=no,";
    disp_setting += "scrollbars=no,width=0, height=0, left=1000000, top=100000";
    var content_vlue = document.getElementById("termsAndConditionsDivToPrint").innerHTML;

    var docprint = window.open("", "", disp_setting);
    docprint.document.open();
    docprint.document.write('<html><head>');
    docprint.document.write('</head><body onLoad="self.print()"><center>');
    docprint.document.write(content_vlue);
    docprint.document.write('</center></body></html>');
    docprint.document.close(); return false;
    //docprint.focus(); 
}

function PrintFareConditions() {
    var disp_setting = "toolbar=no,location=no,directories=no,menubar=no,";
    disp_setting += "scrollbars=no,width=0, height=0, left=1000000, top=1000000";
    var content_vlue = document.getElementById("NewfareConditionsToPrint").innerHTML;

    var docprint = window.open("", "", disp_setting);
    docprint.document.open();
    docprint.document.write('<html><head>');
    docprint.document.write('</head><body onLoad="self.print()"><center>');
    docprint.document.write(content_vlue);
    docprint.document.write('</center></body></html>');
    docprint.document.close(); return false;
}
/**************  END - Ticket Delivery Total Cost ***********************/
