// this is not being used. This will be removed
 function ShowVideoModal(id)
    { 
            var widgetDiv = document.createElement('DIV');		
		widgetDiv.id = 'bannerWidgetDiv';
		document.body.insertBefore( widgetDiv, document.body.firstChild );
        showModalWidget(widgetDiv.id,'',1, -1, -1,'', id, 642, 410,'','','','','');  
    }
    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);  
    }    
    
    // this was being used from top videos flash but for a viewoffer bug fix, flash 
    // output is modified to accept 3 blank parameter to call the 5 parameter function 
    function ShowVideoModalWithList(id,rssFeedUrl)
    {   
//        alert("2 parameters");
        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 );
//		 alert(viewOffersURL);
//		 debugger;
        showModalWidget(widgetDiv.id,'',1, -1, -1,'','', 781, 383,escapeRssFeedUrl,'','','','');        	 
    }
    
    function ShowVideoModalWithList(id,rssFeedUrl,sessionToken,transactionId,viewOffersURL)
    {      
        //alert("5 parameters");
        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 );
        //alert(viewOffersURL);
       //debugger;
        showModalWidget(widgetDiv.id,'',1, -1, -1,'widget','', 781, 420,escapeRssFeedUrl,sessionToken,transactionId,570,viewOffersURL);        	 
    }
    
    
	function closeDiv(divOuter,divInner)
    {     
		document.getElementById(divInner).style.display = 'none';
	    document.getElementById(divOuter).style.display = 'none';
		var divInner = document.getElementById(divInner);
		var divOuter = document.getElementById(divOuter);
		if(navigator.appName =='Netscape')
				 {
					divOuter.removeChild(divInner);
				 }
				 else if (navigator.appName =='Microsoft Internet Explorer')
				 {
					divInner.removeNode(true);
					divOuter.removeNode(true);
				 }
					//document.documentElement.style.overflow=document.body.style.overflow='auto'
			}


function ShowMoreDiv(hideDiv,showDiv,moreButtonID,btnID,mediaType)
 {  
 	 var contentPanelForTopVideos=document.getElementById(hideDiv); 
	 var contentPanelForFiftyVideos=document.getElementById(showDiv);	 
	 var moreImage=document.getElementById(btnID);	
	 var moreButton =document.getElementById(moreButtonID); 
			 if(contentPanelForFiftyVideos.style.display == 'none')
		 {
			contentPanelForFiftyVideos.style.display ='block';
			contentPanelForTopVideos.style.display ='none';
			moreImage.setAttribute("src", "../../PublishingImages/Voyage/less.gif");
			moreImage.setAttribute("onmouseout", "this.src='../../PublishingImages/Voyage/less.gif'");
            moreImage.setAttribute("onmouseover", "this.src='../../PublishingImages/Voyage/less_over.gif'");
            moreImage.setAttribute("title", "Click here to view original list...");
            moreButton.setAttribute("title", "Click here to view original list...");									
		}
		 else
		 {
			contentPanelForFiftyVideos.style.display ='none';
			contentPanelForTopVideos.style.display ='block';            
			 moreImage.setAttribute("src", "../../PublishingImages/Voyage/more.gif");			
			 moreImage.setAttribute("onmouseout", "this.src='../../PublishingImages/Voyage/more.gif'");
             moreImage.setAttribute("onmouseover", "this.src='../../PublishingImages/Voyage/more_over.gif'");
             moreImage.setAttribute("title", "Click here to view more details...");
             moreButton.setAttribute("title", "Click here to view more details...");
		}
} 


/* 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/Voyage/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/Voyage/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/Voyage/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);
  }
}

function CalendarControl() {

  var calendarId = 'CalendarControl';
  var currentYear = 0;
  var currentMonth = 0;
  var currentDay = 0;

  var selectedYear = 0;
  var selectedMonth = 0;
  var selectedDay = 0;
  var normal = false;

  var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
  var dateField = null;

  function getProperty(p_property){
    var p_elm = calendarId;
    var elm = null;

    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    if (elm != null){
      if(elm.style){
        elm = elm.style;
        if(elm[p_property]){
          return elm[p_property];
        } else {
          return null;
        }
      } else {
        return null;
      }
    }
  }

  function setElementProperty(p_property, p_value, p_elmId){
    var p_elm = p_elmId;
    var elm = null;

    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    if((elm != null) && (elm.style != null)){
      elm = elm.style;
      elm[ p_property ] = p_value;
    }
  }

  function setProperty(p_property, p_value) {
    setElementProperty(p_property, p_value, calendarId);
  }

  function getDaysInMonth(year, month) {
    return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1];
  }

  function getDayOfWeek(year, month, day) {
    var date = new Date(year,month-1,day)
    return date.getDay();
  }

  this.setDate = setDate;
  function setDate(year, month, day) {
    if (dateField) {

      //if (day < 10) {day = "0" + day;}
      
      //var mon = months[month-1].substring(0,3);
      var dateString=month+"/"+day+"/"+year
      //var dateString = day+"-"+mon+"-"+year;      
      dateField.value = dateString;
      hide();
    }
    return;
  }

  this.changeMonth = changeMonth;
  function changeMonth(change) {
    currentMonth += change;
    currentDay = 0;
    if(currentMonth > 12) {
      currentMonth = 1;
      currentYear++;
    } else if(currentMonth < 1) {
      currentMonth = 12;
      currentYear--;
    }

    calendar = document.getElementById(calendarId);
    calendar.innerHTML = calendarDrawTable();
  }

  this.changeYear = changeYear;
  function changeYear(change) {
    currentYear += change;
    currentDay = 0;
    calendar = document.getElementById(calendarId);
    calendar.innerHTML = calendarDrawTable();
  }

  function getCurrentYear() {
    var year = new Date().getYear();
    if(year < 1900) year += 1900;
    return year;
  }

  function getCurrentMonth() {
    return new Date().getMonth() + 1;
  } 

  function getCurrentDay() {
    return new Date().getDate();
  }

  function calendarDrawTable() {

    var dayOfMonth = 1;
    var validDay = 0;
    var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth);
    var daysInMonth = getDaysInMonth(currentYear, currentMonth);
    var css_class = null; //CSS class for each day

    var table = "<table cellspacing='0' cellpadding='0' border='0'>";
    table = table + "<tr class='header'>";
    table = table + "  <td colspan='1' class='previous'><a href='javascript:changeCalendarControlMonth(-1);'>&lt;</a> </td>";
    table = table + "  <td colspan='5' class='title'>" + months[currentMonth-1] + " " + currentYear + "</td>";
    table = table + "  <td colspan='1' class='next'><a href='javascript:changeCalendarControlMonth(1);'>&gt;</a></td>";
    table = table + "</tr>";
    table = table + "<tr><th>S</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th></tr>";

    for(var week=0; week < 6; week++) {
      table = table + "<tr>";
      for(var dayOfWeek=0; dayOfWeek < 7; dayOfWeek++) {
        if(week == 0 && startDayOfWeek == dayOfWeek) {
          validDay = 1;
        } else if (validDay == 1 && dayOfMonth > daysInMonth) {
          validDay = 0;
        }

        if(validDay) {
          if (dayOfMonth == selectedDay && currentYear == selectedYear && currentMonth == selectedMonth) {
            css_class = 'current';
          } else if (dayOfWeek == 0 || dayOfWeek == 6) {
            css_class = 'weekend';
          } else {
            css_class = 'weekday';
          }

          table = table + "<td><a class='"+css_class+"' href=\"javascript:setCalendarControlDate("+currentYear+","+currentMonth+","+dayOfMonth+")\">"+dayOfMonth+"</a></td>";
          dayOfMonth++;
        } else {
          table = table + "<td class='empty'>&nbsp;</td>";
        }
      }
      table = table + "</tr>";
    }

    table = table + "<tr class='header'><th colspan='7' style='padding: 3px;'><a href='javascript:hideCalendarControl();'>Close</a></td></tr>";
    table = table + "</table>";

    return table;
  }

  this.show = show;
  function show(fieldStr) {
  
    var field = document.getElementById(fieldStr);   
    if (dateField == field) {
      return;
    } else {
      dateField = field;
      
    }

    if(dateField) {
      try {
        var dateString = new String(dateField.value);
        var dateParts = dateString.split("/");
       
      
        selectedDay = parseInt(dateParts[1],10);
        selectedMonth=parseInt(dateParts[0],10);
        selectedYear = parseInt(dateParts[2],10);
        
      } catch(e) {}
    }

    if (!(selectedYear && selectedMonth && selectedDay)) {
      selectedMonth = getCurrentMonth();
      selectedDay = getCurrentDay();
      selectedYear = getCurrentYear();
    }

    currentMonth = selectedMonth;
    currentDay = selectedDay;
    currentYear = selectedYear;

    if(document.getElementById){

      calendar = document.getElementById(calendarId);
      calendar.innerHTML = calendarDrawTable(currentYear, currentMonth);

      setElementProperty('display', 'block', 'CalendarControlIFrame');
      setProperty('display', 'block');

      var fieldPos = new positionInfo(dateField);
      var calendarPos = new positionInfo(calendarId);

      var x = fieldPos.getElementLeft();
      var y = fieldPos.getElementBottom();
      x=x;
      y=y;
      setProperty('left', x + "px");
      setProperty('top', y + "px");
      setElementProperty('left', x + "px", 'CalendarControlIFrame');
      setElementProperty('top', y + "px", 'CalendarControlIFrame');
      setElementProperty('width', calendarPos.getElementWidth() + "px", 'CalendarControlIFrame');
      setElementProperty('height', calendarPos.getElementHeight() + "px", 'CalendarControlIFrame');
    }
  }

  this.hide = hide;
  function hide() {
    if(dateField) {
      setProperty('display', 'none');
      setElementProperty('display', 'none', 'CalendarControlIFrame');
      dateField = null;
    }
  }
}

var calendarControl = new CalendarControl();

function showCalendarControl(textField) {

    calendarControl.show(textField);
}

function showCalendarControl(textField,panel)
{ 
    if (document.getElementById(textField).value != "" && document.getElementById(textField).value != null)
    {    
        var txtDate =document.getElementById(textField).value.split("/");    
        if (txtDate[0] <=12)
        {
            if(panel != null)
            {
               if(panel == 'true')
                    calendarControl.show(textField);
            }
        }
        else
        {alert("Date format is: mm/dd/yyyy");}
    }
    else
    {    
        if(panel != null)
            {
               if(panel == 'true')
                    calendarControl.show(textField);
            }
    }
}

function hideCalendarControl() {
  calendarControl.hide();
}

function setCalendarControlDate(year, month, day) {
  calendarControl.setDate(year, month, day);
}

function changeCalendarControlYear(change) {
  calendarControl.changeYear(change);
}

function changeCalendarControlMonth(change) {
  calendarControl.changeMonth(change);
}

document.write("<iframe id='CalendarControlIFrame' src='javascript:false;' frameBorder='0' scrolling='no'></iframe>");
document.write("<div id='CalendarControl'></div>");


var bgsleight	= function() {

	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			}
		}
	}


	function fnLoadPngs() {
		var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
		var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
		for (var i = document.all.length - 1, obj = null; (obj = document.all[i]); i--) {
			if (itsAllGood && obj.currentStyle.backgroundImage.match(/\.png/i) != null) {
				fnFixPng(obj);
				obj.attachEvent("onpropertychange", fnPropertyChanged);
			}
		}
	}


	function fnPropertyChanged() {
		if (window.event.propertyName == "style.backgroundImage") {
			var el = window.event.srcElement;
			if (!el.currentStyle.backgroundImage.match(/transparent\.gif/i)) {
				var bg	= el.currentStyle.backgroundImage;
				var src = bg.substring(5,bg.length-2);
				el.filters.item(0).src = src;
				el.style.backgroundImage = "url(../../PublishingImages/Voyage/blank.gif)";
			}
		}
	}


	function fnFixPng(obj) {
		var bg	= obj.currentStyle.backgroundImage;
		var src = bg.substring(5,bg.length-2);
		var sizingMethod = (obj.currentStyle.backgroundRepeat == "no-repeat") ? "crop" : "scale";
		obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + sizingMethod + "')";
		obj.style.backgroundImage = "url(../../PublishingImages/Voyage/blank.gif)";
	}
	return {
		init: function() {
				if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
				addLoadEvent(fnLoadPngs);
//				var prm = Sys.WebForms.PageRequestManager.getInstance();
//				prm.add_endRequest(fnLoadPngs);
			}
		}
	}
}();

window.onload=window_onload;
if (navigator.appName == "Microsoft Internet Explorer")
{
    var version=parseFloat(navigator.appVersion.split('MSIE')[1]);    
    if (version < 7)
    { 
        window.onload=bgsleight.init();
    }
}

var prm1;
function window_onload()
{
    prm1=Sys.WebForms.PageRequestManager.getInstance();    
    prm1.add_initializeRequest(InitializeRequest);
    prm1.add_endRequest(EndRequest);    
}
function InitializeRequest(sender, args)
{   
    $get(args._postBackElement.id).style.cursor = 'wait';
    document.body.style.cursor='wait';
}
function EndRequest(sender, args)
{
    document.body.style.cursor='default';   
}

function PostToSearchFromOfferLink( actUrl, vend, pkg, origin,destination,depdate,retdate,Plcode,hasOrg,HotelCode,hotelname) {
    //debugger;
    var NumberofTraveler="";
    var agestring ="";
    var NumberofTraveler = 2 ;
     var lenghofstay=0;
     var agearray=[];
     var a = parseVaxDate(depdate.trim());
     var b = parseVaxDate(retdate.trim());
     var diff = b - a;
     if (diff > 0){lenghofstay = Math.floor(diff / 86400000);}
     
    var f = document.createElement('FORM');
    f.setAttribute("method", "POST");
    f.setAttribute("action", actUrl);
    f.appendChild( BuildHiddenField("gsVendor", vend) );
    f.appendChild( BuildHiddenField("gsVacationType", pkg));
    if (hasOrg=="true") { f.appendChild( BuildHiddenField("gsOrigin", origin) ); }
    f.appendChild( BuildHiddenField("gsDestination", destination) );
    f.appendChild( BuildHiddenField("gsDepartureDate", depdate) );
    f.appendChild( BuildHiddenField("gsReturnDate", retdate) );
    f.appendChild( BuildHiddenField("PlCode", Plcode ));
    f.appendChild( BuildHiddenField("Referrer", "" )); 
    f.appendChild( BuildHiddenField("GsPrefHotelCode", HotelCode )); 
    f.appendChild( BuildHiddenField("GsLengthOfStay", lenghofstay) );
    f.appendChild( BuildHiddenField("hoHotelName", hotelname) );
    for (var i = 0; i < 4; i++)
       {
         var gsAge="gsAge" + eval(i+1);                   
         f.appendChild( BuildHiddenField(gsAge, "|"));
       }
           
           
        f.appendChild( BuildHiddenField("gsNumberOfTravelers", NumberofTraveler ));      
        document.getElementsByTagName("BODY")[0].appendChild( f );
        document.forms[document.forms.length -1].submit();
        return false;
   
}


function BuildHiddenField(nam, val) {
    var i = document.createElement("input");
    i.setAttribute("type", "hidden");
    i.setAttribute("name", nam);
    i.setAttribute("value", val);
    return i;
}

function parseVaxDate(val) {
	generalFormats=new Array('d','y-M-d','ddMMMyyyy','dd.MM.yyyy','MM/dd/yyyy','MM/dd/yy','dMMMy','dMMM', 'MMMd','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d','M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
		
	var checkList= generalFormats;//.split("&");
	var d=null;
	for (var i=0; i<checkList.length; i++) {
			d = Date.parseLocale(val.trim(),checkList[i].trim());
			if (d != null) {
			return d; }
			
		}
	return null;
	}

var widgetLoaded=false;
var startTime="";
var description=false;
var countStarted=false;
var scrollText;
var widget;
var scrollDescription;
var scrollTitle;
var t;

function scrollTextInWidget()
{    
    if (widgetLoaded)
    {
        currentDate=new Date();
        if(!countStarted)
        {
            startTime=currentDate.getTime();
            countStarted=true;
        }
        var timeDifference=(currentDate.getTime()-startTime)/1000;
        if(timeDifference >=30)
        {
            description=true;
            scrollText=scrollDescription;
            writescrolltext();
            var marquee=document.getElementById("videomarquee");
            marquee.setAttribute('direction','left');
            marquee.setAttribute('scrollamount',5,0);            
        }        
    }
    t=window.setTimeout('scrollTextInWidget();',6000);
}
window.onload=scrollTextInWidget;

function eventCallbackFunc(id, evt)
{
    if(evt.type=="propertyChange" && evt.data=="selectedItem")
    {    
        widgetLoaded=true;        
        widget=document[id];        
        scrollDescription=widget.getComponentProperty(evt.target,"description",true)
        scrollTitle=widget.getComponentProperty(evt.target,"title",true)
        if (description)
        {
            scrollText=scrollDescription;
        }
        else
        {
            scrollText=scrollTitle;
        }
        
        writescrolltext();
    }
}

function writescrolltext()
{
    var whiteSpace="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
    var scrolldiv=document.getElementById('videoScrollTxt');       
    if (scrollText.length > 60)
    {       
        var trimText=scrollText.substring(0,60);
        if (navigator.appName == "Microsoft Internet Explorer")
        {                   
            scrolldiv.innerHTML=whiteSpace + trimText.substring(0,trimText.lastIndexOf(" "));
        }
        else
        {
            scrolldiv.innerHTML=trimText.substring(0,trimText.lastIndexOf(" "));
        }
    }
    else
    {
        if (navigator.appName == "Microsoft Internet Explorer")
        {
            scrolldiv.innerHTML=whiteSpace + scrollText;
        }
        else
        {
            scrolldiv.innerHTML= scrollText;
        }        
    }
}

function RedirectToPage(redirectURL,hotelId, destinationCode, rsCode, offerCode, offerType, airportCode)
{
    var f = document.createElement('FORM');
        f.setAttribute("method", "POST");
        f.setAttribute("action", redirectURL);
        f.appendChild( BuildHiddenField("hotelId", hotelId));
        f.appendChild( BuildHiddenField("destCode", destinationCode));
        f.appendChild( BuildHiddenField("RSCode", rsCode));        
        f.appendChild( BuildHiddenField("OfferCode", offerCode));
        f.appendChild( BuildHiddenField("OfferType", offerType));
        f.appendChild( BuildHiddenField("airportCode", airportCode));
              
        document.getElementsByTagName("BODY")[0].appendChild( f );
        document.forms[document.forms.length -1].submit();
}
function BuildHiddenField(name, value) {
    var i = document.createElement("input");
    i.setAttribute("type", "hidden");
    i.setAttribute("name", name);
    i.setAttribute("value", value);
    return i;
}