﻿function ShowCertificateDetails(domainName) {
    window.open('https://seal.verisign.com/splash?form_file=fdf/splash.fdf&type=GOLD&sealid=0&dn=' + domainName + '&lang=en', 'VeriSign', 'menubar=no,scrollbars=yes,height=450,width=550,titlebar=no,resizeable=yes')
}
/* Video Player */
function ShowVideoModal(id, sessionToken, transactionId, viewOffersURL) {   
    var widgetDiv = document.createElement('DIV');
    widgetDiv.id = 'bannerWidgetDiv';
    document.body.insertBefore(widgetDiv, document.body.firstChild);
    showModalWidget(widgetDiv.id, '', 1, -1, -1, 'widget', id, 642, 451, '', sessionToken, transactionId, 435, viewOffersURL);
}

function ValidateRestool(deptDateID, retrnDateID, actUrl, vend, pkg, promo, Plcode, hasOrg, HotelCode,lblErrorID,errorMessage) {

    
    var OStartDate = new Date(offerStartDate).getTime();
    var OEndDate = new Date(offerEndDate).getTime();
    var deptDatetxt = new Date(document.getElementById(deptDateID).value).getTime();
    var retrnDatetxt = new Date(document.getElementById(retrnDateID).value).getTime();
    var deptCheck = false;
    var retrnCheck = false;
    if (OStartDate <= deptDatetxt && deptDatetxt < OEndDate) {
            deptCheck = true;
        }
        if (OStartDate < retrnDatetxt && retrnDatetxt <= OEndDate) {
            retrnCheck = true;
        }

        if (deptCheck && retrnCheck) {
            PostToSearchUsingResTool(actUrl, vend, pkg, promo, Plcode, hasOrg, HotelCode);
        }
        else {
            var labelError = document.getElementById(lblErrorID);
            if (labelError != null) {
                labelError.innerHTML = errorMessage;
                return false;
            }       
        }
    }

function ShowVideoModalWithList(id, rssFeedUrl, sessionToken, transactionId, viewOffersURL) {
    var widgetDiv = document.createElement('DIV');
    widgetDiv.id = 'bannerWidgetDiv';
    document.body.insertBefore(widgetDiv, document.body.firstChild);
    showModalWidget(widgetDiv.id, '', 1, -1, -1, 'widget', id, 642, 451, '', sessionToken, transactionId, 435, viewOffersURL);
    
//    var selectedVideoID = id;
//    rssFeedUrl = rssFeedUrl + '&selectedMediaID=' + selectedVideoID
//    var escapeRssFeedUrl = escape(rssFeedUrl);
//    var widgetDiv = document.createElement('DIV');
//    widgetDiv.id = 'playlistWidgetDiv';
//    document.body.insertBefore(widgetDiv, document.body.firstChild);    
//    showModalWidget(widgetDiv.id, '', 1, -1, -1, 'widget', '', 781, 420, escapeRssFeedUrl, sessionToken, transactionId, 570, viewOffersURL);
}





/* NOTE:  THE ONLY FUNCTIONS THAT SHOULD BE CALLED DIRECTLY FROM THE PAGE ARE showModal(), hideModal()
and hideAllModals().  ALL OTHER FUNCTIONS ARE INTERNAL.*/

//Global variables (values are set the first time showModal() is hit per page)
var modalParentDiv;
var modalIframeDiv;
var modalContentDiv;
var modalPopupExtender;
var enableModalLegacyScript = false;

/*
This function will populate, position, style and display a modal popup box. Inputs:

- childDivID: [optional] The ID of the div that contains the content to be displayed in the modal.
- Specify '' for a modal with an iframe.
    
- modalDivCSSClass: The name of a CSS class to be applied to the parent modal div.
 
- mpeRepositionMode: A number 0-3 that represents when automatic repositioning of the modal popup should take
place (e.g. '3' means the modal will always stay centered in the screen whenever the browser window is scrolled or resized).
- 0: None
- 1: RepositionOnWindowResize
- 2: RepositionOnWindowScroll
- 3: RepositionOnWindowResizeAndScroll
    
- mpeX: The number of pixels over on the browser's X-axis that the modal popup should appear.
- Specify -1 to have the modal auto-center on the X-axis.
- Note: RepositionMode will only work on the X-axis if X is set to -1.
    
- mpeY: The number of pixels down on the browser's Y-axis that the modal popup should appear.
- Specify -1 to have the modal auto-center on the Y-axis.
- Note: RepositionMode will only work on the Y-axis if Y is set to -1.
    
- iframeURL: [optional] The URL of the document to load in an iframe inside the modal.
- Specify '' for a content modal with no iframe.
    
- iframeWidth: [optional] The width in pixels to be applied to the iframe.
- Specify -1 for a content modal with no iframe, or to use the default iframe width.
 
- iframeHeight: [optional] The initial height in pixels to be applied to the iframe before it is automatically
resized once the document finishes loading.
- Specify -1 for a content modal with no iframe, or to use the default iframe height.
- Note: Passing in a rough approximation will help prevent the modal from jumping around when RepositionMode is used.
*/
function showModal(childDivID, modalDivCSSClass, mpeRepositionMode, mpeX, mpeY, iframeURL, iframeWidth, iframeHeight) {
    //Set global references to page elements we need to use.
    if (modalParentDiv == undefined) {
        modalParentDiv = $get("modalParentDiv");
    }
    modalParentDiv.style.backgroundColor = "#fff";
    if (modalIframeDiv == undefined) {
        modalIframeDiv = $get("modalIframeDiv");
    }
    if (modalContentDiv == undefined) {
        modalContentDiv = $get("modalContentDiv");
    }
    if (modalPopupExtender == undefined) {
        modalPopupExtender = $find("modalPopupExtender");
    }

    //Hide the modal popup (in case we are coming from another modal and hideModal() was not called)
    modalPopupExtender.hide();

    //If we're already in a modal, save the current content before loading the next modal
    if (modalStack.count > 0) {
        var currentModal = modalStack.stack[modalStack.count - 1];
        saveModalContent(currentModal);
    }
    if (iframeURL != '') {

        loadIframewithclose(iframeURL, iframeWidth, iframeHeight, 'Close', '../../PublishingImages/VideoTravelDeals/close.gif');
    }
    else {
        loadContent(childDivID);
    }

    setModalStyleAndPosition(modalDivCSSClass, mpeRepositionMode, mpeX, mpeY);

    //Display the modal popup
    modalPopupExtender.show();

    //Add the current modal to the Modal Stack
    modalStack.pushModal(new Modal(childDivID, modalDivCSSClass, mpeRepositionMode, mpeX, mpeY, iframeURL, iframeWidth, iframeHeight));
}

function showModalwithClose(iframeURL, iframeWidth, iframeHeight, iframeclosecaption, iframecloseimgurl) {
    //Set global references to page elements we need to use.
    if (modalParentDiv == undefined) {
        modalParentDiv = $get("modalParentDiv");
    }
    if (modalIframeDiv == undefined) {
        modalIframeDiv = $get("modalIframeDiv");
    }
    if (modalContentDiv == undefined) {
        modalContentDiv = $get("modalContentDiv");
    }
    if (modalPopupExtender == undefined) {
        modalPopupExtender = $find("modalPopupExtender");
    }

    //Hide the modal popup (in case we are coming from another modal and hideModal() was not called)
    modalPopupExtender.hide();
    loadIframewithclose(iframeURL, iframeWidth, iframeHeight, iframeclosecaption, iframecloseimgurl);

    setModalStyleAndPosition('modalPopup', 3, -1, -1);

    //Display the modal popup
    modalPopupExtender.show();

    //Add the current modal to the Modal Stack
    modalStack.pushModal(new Modal('', 'modalPopup', 3, -1, -1, iframeURL, iframeWidth, iframeHeight));

}

/* Similar to showModal(), but does not save the currently displaying modal, since we are closing modals and navigating
back down the modal stack.  This function should only be called by hideModal(), not by the page itself. */
function reshowModal(childDivID, modalDivCSSClass, mpeRepositionMode, mpeX, mpeY, iframeURL, iframeWidth, iframeHeight) {
    if (iframeURL != '') {
        loadIframe(iframeURL, iframeWidth, iframeHeight);
    }
    else {
        loadContent(childDivID);
    }

    setModalStyleAndPosition(modalDivCSSClass, mpeRepositionMode, mpeX, mpeY);

    //Display the modal popup
    modalPopupExtender.show();

    //Add the current modal to the Modal Stack
    modalStack.pushModal(new Modal(childDivID, modalDivCSSClass, mpeRepositionMode, mpeX, mpeY, iframeURL, iframeWidth, iframeHeight));
}

/* Set the styling and positioning properties for the modal to be displayed */
function setModalStyleAndPosition(modalDivCSSClass, mpeRepositionMode, mpeX, mpeY) {
    //Set the modalPopupExtender's positioning properties
    modalPopupExtender.set_repositionMode(mpeRepositionMode);
    modalPopupExtender.set_X(mpeX);
    if (navigator.appName == "Microsoft Internet Explorer") {
        //Hack for IE6 and older: the toolkit already adjusts for how far the page has scrolled, so subtract that amount from the Y coordinate.
        var ieVersion = parseFloat(navigator.appVersion.split("MSIE")[1]);
        if (ieVersion < 7) {
            modalPopupExtender.set_Y(mpeY - WebForm_GetScrollY());
        }
        else {
            modalPopupExtender.set_Y(mpeY);
        }
    }
    else {
        modalPopupExtender.set_Y(mpeY);
    }

    //Give the modal div the specified CSS class
    //modalParentDiv.className = modalDivCSSClass;
}

/* Create or find an iframe based on the parameters and add it to the modal */
function loadIframe(iframeURL, iframeWidth, iframeHeight) {
    var thisIframe;
    var savedIframe = $get("modalIframe" + modalStack.count);

    if (savedIframe != undefined) {
        //If we have this iframe saved, redisplay it
        savedIframe.id = "modalIframe";   //Change ID back to standard so it can always be found inside the modal
        savedIframe.style.display = "block";
    }
    else {
        //If we don't have this iframe saved, create it
        thisIframe = document.createElement("iframe")
        thisIframe.id = "modalIframe";
        thisIframe.marginHeight = "0px";
        thisIframe.marginWidth = "0px";
        thisIframe.frameBorder = "0";
        thisIframe.scrolling = "auto";
        thisIframe.src = "javascript:;";

        //Set the iframe's dimensions, if specified
        if (iframeWidth != -1) {
            thisIframe.style.width = iframeWidth + "px";
        }
        if (iframeHeight != -1) {
            thisIframe.style.height = iframeHeight + "px";
        }

        //Add the iframe to the modal div
        modalIframeDiv.appendChild(thisIframe);

        //Find the iframe we just added and set its source (done AFTER adding iframe to page to avoid IE6 display bugs with dynamically loaded iframes)
        $get("modalIframe").src = iframeURL;
    }
}



/* Create or find an iframe with close based on the parameters and add it to the modal */
function loadIframewithclose(iframeURL, iframeWidth, iframeHeight, closecaption, closeimgurl) {

    modelTable = document.createElement('table');
    modelTable.id = 'modalIframe'; //'modelTableIframe';   
    modelTable.cellSpacing = '0px';
    modelTable.cellPadding = '0px';
    rows1 = modelTable.insertRow(-1);
    cells1 = rows1.insertCell(-1);
    cells1.id = 'cells1';
    modelInnerTable1 = document.createElement('table');
    modelInnerTable1.id = 'modelInnerTable1Iframe';
    modelInnerTable1.cellSpacing = '0px';
    modelInnerTable1.cellPadding = '0px';
    modelInnerTable1.style.width = "100%";
    cells1.appendChild(modelInnerTable1);
    modelInnerTable1rows = modelInnerTable1.insertRow(-1);
    modelInnerTable1rows.colspan = "2";
    modelInnerTable1rows.bgColor = "#fff";
    modelInnerTable1rows.style.height = "25px";
    //modelInnerTable1cells1 = modelInnerTable1rows.insertCell(-1);
    //modelInnerTable1cells1.style.width = "84%";
    modelInnerTable1cells2 = modelInnerTable1rows.insertCell(-1);

    createCloseDiv = document.createElement('div');
    createCloseDiv.id = 'close_Div';
    createCloseDiv.style.textAlign = "right";
    createCloseDiv.style.height = "25px";
    createCloseDiv.style.backgroundColor = "#fff";

    createCloseCaption = document.createElement('a');
    createCloseCaption.href = "javascript:;";
    createCloseCaption.onclick = function() { parent.hideModal(); };
    createCloseCaption.innerHTML = closecaption;
    createCloseCaption.className = "modalClose"
    createCloseDiv.appendChild(createCloseCaption);

    createCloseCaptionImg = document.createElement('a');

    createImg = document.createElement('img');
    //                createImg.style.width = "16%"; 
    //                createImg.style.height = "16%"; 
    //                createImg.style.border = "0px";
    createImg.className = "btnClose";
    createImg.alt = "";
    createImg.src = closeimgurl;
    createImg.onclick = function() { parent.hideModal(); };
    createCloseCaptionImg.appendChild(createImg);
    createCloseDiv.appendChild(createCloseCaptionImg);

    modelInnerTable1cells2.appendChild(createCloseDiv);


    rows2 = modelTable.insertRow(-1);
    cells2 = rows2.insertCell(-1);
    cells2.id = 'cells2';

    createIframe = document.createElement('iframe');
    createIframe.id = 'newIframe';
    createIframe.scrolling = "auto";
    createIframe.marginheight = "0px";
    createIframe.marginwidth = "0px";
    createIframe.setAttribute("frameBorder", 0);
    createIframe.src = "javascript:;"
    createIframe.style.height = iframeHeight + "px";
    createIframe.style.width = iframeWidth + "px";
    cells2.appendChild(createIframe)
    modalIframeDiv.appendChild(modelTable);

    var ifrm = $get("newIframe");
    //        if(iframeURL.indexOf("?")>0)
    //        {iframeURL=iframeURL + "&rsl=" + pagesslenabled;
    //        }
    //        else
    //        {iframeURL=iframeURL + "?rsl=" + pagesslenabled;
    //        }
    ifrm.src = iframeURL;
    //locationrefresh=1;
}

function FindWinScrX() {
    return self.pageXOffset ? self.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body ? document.body.scrollLeft : 0;
}

function FindWinScrY() {
    return self.pageYOffset ? self.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body ? document.body.scrollTop : 0;
}



function framewindowload(ifrm) {

    var winheight = FindWinH();
    var winwidth = FindWinW();
    var WinScrY = FindWinScrY();
    var WinScrX = FindWinScrX();


    var iBottom = FindWinScrY() + FindWinH();
    var iLeft = FindWinScrX() + FindWinW();



    if (ifrm.contentWindow.document.body.scrollHeight > winheight) {
        ifrm.style.height = winheight - 60 + "px";
        modalParentDiv.style.top = ysDiv + 'px';

    }
    else {
        ifrm.style.height = ifrm.contentWindow.document.body.scrollHeight + "px";
        var h = ifrm.contentWindow.document.body.scrollHeight;
        var winchildheight = parseInt((winheight - h) / 2);
        modalParentDiv.style.top = FindWinScrY() + winchildheight + "px";
    }

    if (ifrm.contentWindow.document.body.scrollWidth > winwidth) {
        ifrm.style.width = winwidth - 20 + "px";
        modalParentDiv.style.left = xsDiv + 'px';

    }
    else {
        var w = ifrm.contentWindow.document.body.scrollWidth;
        var winchildwidth = parseInt((winwidth - w) / 2);
        modalParentDiv.style.top = winchildwidth + "px";
    }
    // modalParentDiv.style.position="fixed";
}


var locationrefresh = 0;


function FindWinW() {
    return self.innerWidth ? self.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body ? document.body.clientWidth : 0;
}

function FindWinH() {
    return self.innerHeight ? self.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body ? document.body.clientHeight : 0;
}


function FindWinScrX() {
    return self.pageXOffset ? self.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body ? document.body.scrollLeft : 0;
}

function FindWinScrY() {
    return self.pageYOffset ? self.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body ? document.body.scrollTop : 0;
}



/* Move the content from the specified child div into the modal div */
function loadContent(childDivID) {
    var childDiv = $get(childDivID);
    if (childDiv == undefined) {
        //If specified child div wasn't found on parent page, look for it inside each iframe page
        var frames = window.frames;
        for (var i = 0; i < frames.length; i++) {
            childDiv = frames[i].document.getElementById(childDivID);
            if (childDiv != undefined) {
                break;
            }
        }
    }
    if ((navigator.appName == "Netscape") || (!enableModalLegacyScript)) {
        var childDivContents = childDiv.removeChild(childDiv.getElementsByTagName('DIV')[0]);
        modalContentDiv.appendChild(childDivContents);
    }
    else {
        //Need to use innerHTML instead of the DOM for IE because otherwise IE doesn't maintain radio button selections 
        if (childDiv != null) {
            var childDivContents = childDiv.innerHTML;
            childDiv.innerHTML = "";
            modalContentDiv.innerHTML = childDivContents;
        }
    }
}

/* Save the current modal's content, either back to its original location (content modals) or to the iframe holding area (iframe modals) */
function saveModalContent(currentModal) {
    if (currentModal.iframeURL != '') {
        //It's an iframe modal; hide the currently displaying iframe
        var thisIframe = $get("modalIframe");
        if (thisIframe != null) {
            thisIframe.style.display = "none";
            thisIframe.id = "modalIframe" + (modalStack.count - 1);   //Change ID so they're numbered according to the modal stack count
        }
    }
    else {
        //It's a content modal; save the current content back to its original location
        var originDiv = $get(currentModal.childDivID);
        if (originDiv == undefined) {
            //If specified origin div wasn't found on parent page, look for it inside each iframe page
            var frames = window.frames;
            for (var i = 0; i < frames.length; i++) {
                originDiv = frames[i].document.getElementById(currentModal.childDivID);
                if (originDiv != undefined) {
                    break;
                }
            }
        }
        if (originDiv != null) {
            if ((navigator.appName == "Netscape") || (!enableModalLegacyScript)) {
                var childDivContents = modalContentDiv.removeChild(modalContentDiv.getElementsByTagName('DIV')[0]);
                originDiv.appendChild(childDivContents);
            }
            else {
                //Need to use innerHTML instead of the DOM for IE because otherwise IE doesn't maintain radio button selections 
                var childDivContents = modalContentDiv.innerHTML;
                modalContentDiv.innerHTML = "";
                originDiv.innerHTML = childDivContents;
            }
        }
    }
}

/* Hides the currently displaying modal popup box */
function hideModal() {
    //    window.clearTimeout(t);
    widgetLoaded = false;
    description = false;
    countStarted = false;

    //Hide the modal popup    
    modalPopupExtender.hide();

    //Remove and get a reference to the current modal from the stack
    var currentModal = modalStack.popModal();

    if (currentModal.iframeURL != '') {
        //It's an iframe modal; clear the current iframe from the modal
        if ($get("modalIframe") != null) {
            modalIframeDiv.removeChild($get("modalIframe"));

            if (locationrefresh) {
                locationrefresh = 0;
                window.location.reload(true);
            }
        }
    }
    else {
        //It's a content modal; save the contents so it remains the same when reopening
        saveModalContent(currentModal);
    }

    //Reshow the previous modal, if there was one
    if (modalStack.count > 0) {
        var prevModal = modalStack.popModal();
        reshowModal(prevModal.childDivID, prevModal.modalDivCSSClass, prevModal.mpeRepositionMode, prevModal.mpeX, prevModal.mpeY, prevModal.iframeURL, prevModal.iframeWidth, prevModal.iframeHeight)
    }
}

/* Automatically hides all modals in the current modal stack. */
function hideAllModals() {
    while (modalStack.count > 0) {
        hideModal();
    }
}

//Prototype the ModalStack class and functions
ModalStack.prototype.pushModal = pushModal;
ModalStack.prototype.popModal = popModal;
function ModalStack() {
    this.stack = new Array();
    this.count = 0;
}
function pushModal(modal) {
    this.count = this.count + 1;
    this.stack.push(modal);
}
function popModal() {
    if (this.count <= 0) {
        return "Error: empty stack"
    }
    else {
        this.count = this.count - 1;
        return this.stack.pop();
    }
}

//Prototype the Modal class
function Modal(childDivID, modalDivCSSClass, mpeRepositionMode, mpeX, mpeY, iframeURL, iframeWidth, iframeHeight) {
    this.childDivID = childDivID;
    this.modalDivCSSClass = modalDivCSSClass;
    this.mpeRepositionMode = mpeRepositionMode;
    this.mpeX = mpeX;
    this.mpeY = mpeY;
    this.iframeURL = iframeURL;
    this.iframeWidth = iframeWidth;
    this.iframeHeight = iframeHeight;
}

//Instantiate a modal stack for this page
var modalStack = new ModalStack();

function ShowWhatsToDoModalPopup(pageName, eventID, modalPopupControlID) {
    var iFrameSrc = pageName + "?eventID=" + eventID
    //var modalPopupControlClientID = "ctl00_WebPartManager_g_efbc0e0f_f445_494e_9534_59fa1f5ba4a5_modalWhatToDo" ;    
    showModal(modalPopupControlID, '', 1, -1, -1, iFrameSrc, 650, 540);
}

function ShowFrommersModalPopup(recordID, destinationID, modalPopupFrommersID) {
    var iFrameFrommersSrc = "FrommersModal.aspx?RecordID=" + recordID + "&DestinationID=" + destinationID
    showModal(modalPopupFrommersID, '', 1, -1, -1, iFrameFrommersSrc, 650, 540);
}
function ShowBlackBookModalPopup(pageName, recordID, modalPopupFrommersID) {
    var iFrameFrommersSrc = pageName + "?RecordID=" + recordID
    showModal(modalPopupFrommersID, '', 1, -1, -1, iFrameFrommersSrc, 650, 540);
}

function ShowPostCommentModalPopup(pageName, mediaId, modalPopupPostCommentControlID) {
    var iFrameSrc = pageName + "?mediaId=" + mediaId
    showModal(modalPopupPostCommentControlID, '', 1, -1, -1, iFrameSrc, 490, 330);
}

function ShowPostRatingModalPopup(pageName, mediaId, modalPopupPostRatingControlID, mediaType) {
    if (mediaType == undefined || mediaType == "") {
        mediaType = "blog";
    }
    var iFrameSrc = pageName + "?mediaId=" + mediaId + "&mediaType=" + mediaType
    showModal(modalPopupPostRatingControlID, '', 1, -1, -1, iFrameSrc, 490, 280);
}

function ShowMapInModalPopup(pageName, latitude, longitude, zoom, modalPopupControlID) {
    var iFrameSrc = pageName + "?lat=" + latitude + "&long=" + longitude + "&zoom=" + zoom + "&height=400&width=800"
    showModal(modalPopupControlID, '', 1, -1, -1, iFrameSrc, 800, 400);
}

function OpenLightBox() {
    if (navigator.appName != "Netscape") {
        $('a[@rel*=lightbox]').lightBox();
    }
}

function showModalWithResponse(firstDiv, resultDiv, childDivID, modalDivCSSClass, mpeRepositionMode, mpeX, mpeY, iframeURL, iframeWidth, iframeHeight) {
    document.getElementById(firstDiv).style.display = 'block';
    document.getElementById(resultDiv).style.display = 'none';
    showModal(childDivID, modalDivCSSClass, mpeRepositionMode, mpeX, mpeY, iframeURL, iframeWidth, iframeHeight);

}

function openLiveChatWindow(url) {
    window.open(url, null, 'height=500,width=500,status=no,menubar=0,location=no,scrollbars=no,statusbar=0')
    return false;
}

function ShowAskQuestionModalPopup(firstDiv, resultDiv, childDivID, modalDivCSSClass, mpeRepositionMode, mpeX, mpeY, iframeURL, iframeWidth, iframeHeight) {
    document.getElementById(firstDiv).style.display = 'block';
    document.getElementById(resultDiv).style.display = 'none';
    showModal(childDivID, modalDivCSSClass, mpeRepositionMode, mpeX, mpeY, iframeURL, iframeWidth, iframeHeight);
}

function RedirectToSearchResultPage(textBoxID) {
    var objSearchBox = document.getElementById(textBoxID)
    document.location.href = "SearchResult.aspx?k=" + objSearchBox.value
}

function ShowFeedBackDoModalPopup() {
    var iFrameSrc = "/pages/feedback.aspx?feedbackPageName=" + pageName;
    var feebackURL = secureSiteURL + iFrameSrc
    var feedbackDiv = document.createElement('div');

    feedbackDiv.setAttribute('id', 'divFeedBack');

    //var modalPopupControlClientID = "ctl00_WebPartManager_g_efbc0e0f_f445_494e_9534_59fa1f5ba4a5_modalWhatToDo" ;    
    showModal('divFeedBack', '', 1, -1, -1, feebackURL, 510, 550);
}
function ShowCertificateDetails(domainName) {
    window.open('https://seal.verisign.com/splash?form_file=fdf/splash.fdf&type=GOLD&sealid=0&dn=' + domainName + '&lang=en', 'VeriSign', 'menubar=no,scrollbars=yes,height=450,width=550,titlebar=no,resizeable=yes')
}

function ValidateSearchRedirect(txtSearch, initialValue) {
    var searchControl = document.getElementById(txtSearch);

    if (searchControl.value == initialValue || searchControl.value.length == 0) {
        return false;
    }
    else {
        return true;
    }
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}
function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}

function expandDropDownList(elementRef) {
    elementRef.style.width = 'auto';
}

function collapseDropDownList(elementRef) {
    elementRef.style.width = '250px';
}

function showModalWidget(childDivID, modalDivCSSClass, mpeRepositionMode, mpeX, mpeY, iframeURL, selectedVideoID, videoDivWidth, videoDivHeight, escapeRssFeedUrl, sessionToken, transactionId, marqueeWidth, viewOffersURL) {


    //Set global references to page elements we need to use.
    if (modalParentDiv == undefined) {
        modalParentDiv = $get("modalParentDiv");
    }
    modalParentDiv.style.backgroundColor = "#000000";
    if (modalIframeDiv == undefined) {
        modalIframeDiv = $get("modalIframeDiv");
    }
    if (modalContentDiv == undefined) {
        modalContentDiv = $get("modalContentDiv");
    }
    if (modalPopupExtender == undefined) {
        modalPopupExtender = $find("modalPopupExtender");
    }

    //Hide the modal popup (in case we are coming from another modal and hideModal() was not called)
    modalPopupExtender.hide();

    //If we're already in a modal, save the current content before loading the next modal
    if (modalStack.count > 0) {
        var currentModal = modalStack.stack[modalStack.count - 1];
        saveModalContent(currentModal);
    }
    if (selectedVideoID == '' && escapeRssFeedUrl == '') {
        loadContent(childDivID);
    }
    else {
        loadWidgetIframewithclose(selectedVideoID, videoDivWidth, videoDivHeight, 'Close', '../../PublishingImages/VideoTravelDeals/close.gif', escapeRssFeedUrl, sessionToken, transactionId, marqueeWidth, viewOffersURL);
    }

    setModalStyleAndPosition(modalDivCSSClass, mpeRepositionMode, mpeX, mpeY);

    //Display the modal popup
    modalPopupExtender.show();

    //Add the current modal to the Modal Stack
    modalStack.pushModal(new Modal(childDivID, modalDivCSSClass, mpeRepositionMode, mpeX, mpeY, iframeURL, videoDivWidth, videoDivHeight));

}

function loadWidgetIframewithclose(selectedVideoID, videoDivWidth, videoDivHeight, closecaption, closeimgurl, escapeRssFeedUrl, sessionToken, transactionId, marqueeWidth, viewOffersURL) {
    modelTable = document.createElement('table');
    modelTable.id = 'modalIframe'; //'modelTableIframe';   
    modelTable.cellSpacing = '0px';
    modelTable.cellPadding = '0px';
    rows1 = modelTable.insertRow(-1);
    cells1 = rows1.insertCell(-1);
    cells1.id = 'cells1';
    modelInnerTable1 = document.createElement('table');
    modelInnerTable1.id = 'modelInnerTable1';
    modelInnerTable1.cellSpacing = '0px';
    modelInnerTable1.cellPadding = '0px';
    modelInnerTable1.style.width = "100%";
    cells1.appendChild(modelInnerTable1);
    modelInnerTable1rows = modelInnerTable1.insertRow(-1);
    modelInnerTable1rows.colspan = "2";
    modelInnerTable1rows.bgColor = "#000000";
    modelInnerTable1rows.style.height = "37px";
    modelInnerTable1cells2 = modelInnerTable1rows.insertCell(-1);

    createCloseDiv = document.createElement('div');
    createCloseDiv.id = 'close_Div';
    createCloseDiv.style.height = "37px";
    createCloseDiv.style.backgroundColor = "#000000";

    playerLogo = document.createElement('img');
    playerLogo.src = '../../PublishingImages/VideoTravelDeals/Player_Logo.gif';
    playerLogo.className = "floatLeft";
    createCloseDiv.appendChild(playerLogo);

    createCloseCaption = document.createElement('a');
    createCloseCaption.href = "javascript:;";
    createCloseCaption.onclick = function() { parent.hideModal(); };
    createCloseCaption.innerHTML = closecaption;
    createCloseCaption.className = "modalClose1"
    createCloseDiv.appendChild(createCloseCaption);

    createCloseCaptionImg = document.createElement('a');

    createImg = document.createElement('img');
    createImg.className = "btnClose";
    createImg.alt = "";
    createImg.src = closeimgurl;
    createImg.onclick = function() { parent.hideModal(); };
    //createCloseCaptionImg.appendChild(createImg);
    createCloseDiv.appendChild(createCloseCaptionImg);

    modelInnerTable1cells2.appendChild(createCloseDiv);

    rows2 = modelTable.insertRow(-1);
    cells2 = rows2.insertCell(-1);
    cells2.id = 'cells2';

    videoDiv = document.createElement('div');
    videoDiv.id = 'videoDiv';
    videoDiv.style.height = videoDivHeight + "px";
    videoDiv.style.width = videoDivWidth + "px";
    videoDiv.style.backgroundColor = "#000000";

    altContentDiv = document.createElement('div');
    altContentDiv.id = "altContentDiv";
    altContentDiv.innerHTML = '<p align="center"><font size="2px" face="Verdana" color="#ffffff">You need Adobe Flash Player 10 to view this widget.<br/><br/></font><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" border="0"/></a></p>'
    videoDiv.appendChild(altContentDiv);

    scrollDiv = document.createElement('div');
    scrollDiv.id = "scrollDiv";
    scrollDivHTML = "<div class='videoBannerBlock' style='clear:both;'>";
    if (viewOffersURL == '') {
        scrollDivHTML += "<marquee id='videomarquee' scrollamount='0' direction='right' behaviour='scroll' class='marqueeTextAuto'>";
    }
    else {
        scrollDivHTML += "<marquee id='videomarquee' scrollamount='0' style='float:left;' width=" + marqueeWidth + " direction='right' behaviour='scroll' class='marqueeTextAuto'>";
    }
    scrollDivHTML += "<span id='videoScrollTxt' style='margin;0px; padding:0px; float:left' onmouseover='document.getElementById(\"videomarquee\").setAttribute(\"scrollamount\",0,0);' onmouseout='document.getElementById(\"videomarquee\").setAttribute(\"scrollamount\",5,0);'></span>"
    scrollDivHTML += "</marquee>";
    if (viewOffersURL != '') {
        scrollDivHTML += "<div class='buttonViewOffers'>";
        scrollDivHTML += "<input class='btnViewOffers' style='float:right;' type='button' id='btnWidgetViewOffers' name='btnWidgetViewffers' onclick=\"javascript:document.location.href='" + viewOffersURL + "'\" />";
        scrollDivHTML += "</div>";
    }
    scrollDivHTML += "</div>";
    scrollDiv.innerHTML = scrollDivHTML;
    videoDiv.appendChild(scrollDiv);

    googleConversionDiv = document.createElement('div');
    googleConversionDiv.id = "googleConversionDiv";
    googleConversionDiv.innerHTML = "<img height='1' width='1' border='0' src='http://www.googleadservices.com/pagead/conversion/1036058689/?label=YBLQCKuVmwEQwYCE7gM&amp;guid=ON&amp;script=0' />";
    googleConversionDiv.innerHTML += "<img border='0' src='https://r.turn.com/r/beacon?b2=bjNM9T6eA3q3KAA2N0k_Lur78FSBmGdnrulHBwQBac-pCvLNR7kSJB1msvMnlB-q3F2GeQYJ0kpR0J1-1Cr_XQ&cid=' />";

    videoDiv.appendChild(googleConversionDiv);

    cells2.appendChild(videoDiv)
    modalIframeDiv.appendChild(modelTable);

    if (escapeRssFeedUrl == '') {
        var flashvars = { affiliateSiteId: "" + kickAppsAffiliateSiteID + "", widgetId: "" + kickAppsVideoWidgetID + "", width: '644', height: '409', revision: '13', mediaType_mediaID: "video_" + selectedVideoID + "", tid: "" + transactionId + "", st: "" + sessionToken + "", eventCallbackFunc: "eventCallbackFunc" };
        var params = { menu: "false", allowfullscreen: "true", allowscriptaccess: "always", wmode: "window" };
        var attributes = { id: "kickWidget_" + kickAppsAffiliateSiteID + "_" + kickAppsVideoWidgetID + "", name: "kickWidget_" + kickAppsAffiliateSiteID + "_" + kickAppsVideoWidgetID + "" };
        var expressInstallURL = 'http://serve.a-widget.com/kickFlash/scripts/expressInstall2.swf';
        var swfURL = 'http://serve.a-widget.com/service/getWidgetSwf.kickAction';
        swfobject.embedSWF(swfURL, 'altContentDiv', '644', '409', '9.0.28', expressInstallURL, flashvars, params, attributes);
    }
    else {
        var flashvars = { affiliateSiteId: "" + kickAppsAffiliateSiteID + "", widgetId: "" + kickAppsVideoListWidgetID + "", width: "781", height: "383", revision: "5", mediaURL: "" + escapeRssFeedUrl + "", tid: "" + transactionId + "", st: "" + sessionToken + "", eventCallbackFunc: "eventCallbackFunc" };
        var params = { menu: "false", allowfullscreen: "true", allowscriptaccess: "always", wmode: "window" };
        var attributes = { id: "kickWidget_" + kickAppsAffiliateSiteID + "_" + kickAppsVideoListWidgetID + "", name: "kickWidget_" + kickAppsAffiliateSiteID + "_" + kickAppsVideoListWidgetID + "" };
        var expressInstallURL = "http://serve.a-widget.com/kickFlash/scripts/expressInstall2.swf";
        var swfURL = "http://serve.a-widget.com/service/getWidgetSwf.kickAction";
        swfobject.embedSWF(swfURL, "altContentDiv", "781", "383", "9.0.28", expressInstallURL, flashvars, params, attributes);
    }
}

function positionInfo(object) {

    var p_elm = object;

    this.getElementLeft = getElementLeft;
    function getElementLeft() {
        var x = 0;
        var elm;
        if (typeof (p_elm) == "object") {
            elm = p_elm;
        } else {
            elm = document.getElementById(p_elm);
        }
        while (elm != null) {
            x += elm.offsetLeft;
            elm = elm.offsetParent;
        }
        return parseInt(x);
    }

    this.getElementWidth = getElementWidth;
    function getElementWidth() {
        var elm;
        if (typeof (p_elm) == "object") {
            elm = p_elm;
        } else {
            elm = document.getElementById(p_elm);
        }
        return parseInt(elm.offsetWidth);
    }

    this.getElementRight = getElementRight;
    function getElementRight() {
        return getElementLeft(p_elm) + getElementWidth(p_elm);
    }

    this.getElementTop = getElementTop;
    function getElementTop() {
        var y = 0;
        var elm;
        if (typeof (p_elm) == "object") {
            elm = p_elm;
        } else {
            elm = document.getElementById(p_elm);
        }
        while (elm != null) {
            y += elm.offsetTop;
            elm = elm.offsetParent;
        }
        return parseInt(y);
    }

    this.getElementHeight = getElementHeight;
    function getElementHeight() {
        var elm;
        if (typeof (p_elm) == "object") {
            elm = p_elm;
        } else {
            elm = document.getElementById(p_elm);
        }
        return parseInt(elm.offsetHeight);
    }

    this.getElementBottom = getElementBottom;
    function getElementBottom() {
        return getElementTop(p_elm) + getElementHeight(p_elm);
    }
}
/* Tool Tip */
var tooltip = function() {
    var id = 'tt';
    var top = 3;
    var left = 3;
    var maxw = 300;
    var speed = 10;
    var timer = 20;
    var endalpha = 95;
    var alpha = 0;
    var tt, t, c, b, h;
    var ie = document.all ? true : false;
    return {
        show: function(v, w) {
            if (tt == null) {
                tt = document.createElement('div');
                tt.setAttribute('id', id);
                t = document.createElement('div');
                t.setAttribute('id', id + 'top');
                c = document.createElement('div');
                c.setAttribute('id', id + 'cont');
                b = document.createElement('div');
                b.setAttribute('id', id + 'bot');
                tt.appendChild(t);
                tt.appendChild(c);
                tt.appendChild(b);
                document.body.appendChild(tt);
                tt.style.opacity = 0;
                tt.style.filter = 'alpha(opacity=0)';
                document.onmousemove = this.pos;
            }
            tt.style.display = 'block';
            c.innerHTML = v;
            tt.style.width = w ? w + 'px' : 'auto';
            if (!w && ie) {
                t.style.display = 'none';
                b.style.display = 'none';
                tt.style.width = tt.offsetWidth;
                t.style.display = 'block';
                b.style.display = 'block';
            }
            if (tt.offsetWidth > maxw) { tt.style.width = maxw + 'px' }
            h = parseInt(tt.offsetHeight) + top;
            clearInterval(tt.timer);
            tt.timer = setInterval(function() { tooltip.fade(1) }, timer);
        },
        pos: function(e) {
            var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
            var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
            tt.style.top = (u - h) + 'px';
            tt.style.left = (l + left) + 'px';
        },
        fade: function(d) {
            var a = alpha;
            if ((a != endalpha && d == 1) || (a != 0 && d == -1)) {
                var i = speed;
                if (endalpha - a < speed && d == 1) {
                    i = endalpha - a;
                } else if (alpha < speed && d == -1) {
                    i = a;
                }
                alpha = a + (i * d);
                tt.style.opacity = alpha * .01;
                tt.style.filter = 'alpha(opacity=' + alpha + ')';
            } else {
                clearInterval(tt.timer);
                if (d == -1) { tt.style.display = 'none' }
            }
        },
        hide: function() {
            clearInterval(tt.timer);
            tt.timer = setInterval(function() { tooltip.fade(-1) }, timer);
        }
    };
} ();

