﻿/*
Date	   By 	Details		
2011-12-06 BZ  Adjusted positioning of zoom popup [Incident #SRX35604]
*/

    // This function is required for downloading files when used in an ajaxified control
    // uses this code here: http://www.telerik.com/community/code-library/submission/b311D-ttcbe.aspx
    function mngRequestStarted(ajaxManager, eventArgs)
    {
      if((eventArgs.EventTarget.indexOf("lnkDownloadPresentationFromMyAgenda") != -1) || (eventArgs.EventTarget.indexOf("lnkDownloadPresentationFromMyAgenda") != -1))
      {
         eventArgs.EnableAjax = false;
      }
    }


   function FlyoutActivation(strbtnFlyoutLoadClick, strupnlFlyout)
    {
        var btnFlyoutLoadClick = document.getElementById(strbtnFlyoutLoadClick);
        btnFlyoutLoadClick.click();
        //var prm = Sys.WebForms.PageRequestManager.getInstance();
        //prm._doPostBack(strupnlFlyout, '');
        return false;
    }


	function ShowRoomZoomPopup(strMS, strM, strT, strBtn, intMS, intM, intT, strlnkTitle, strpnlPopup, xOffSet, strScheduleConrol){
	    var lnk = document.getElementById(strlnkTitle);
	    /*
	    if (strScheduleControl == null)
	        strScheduleControl = "div_pnlMain";
	    */
	    //alert(findPosX(lnk));
	    var pnl = document.getElementById(strpnlPopup);
	    //moveIt(pnl, findPosY(lnk), findPosX(lnk));
    	pnl.style.position = 'absolute';
	    pnl.style.top = findPosY(lnk) + 'px';
	    var xPos = 0;
	    var BrowserWidth = findPosX(document.getElementById(strScheduleConrol)) + document.getElementById(strScheduleConrol).offsetWidth; //930; //getBrowserWindowWidth();
	    var CalendarPos = findPosX(document.getElementById(strScheduleConrol));
	    if (BrowserWidth > (findPosX(lnk) + xOffSet + 500))
	        xPos = findPosX(lnk) + xOffSet ;
	    else
	        xPos = BrowserWidth - 500;
	    if (xPos < CalendarPos)
	        xPos = CalendarPos;
	       
	    pnl.style.left = xPos + 'px';
	    pnl.style.display = 'block';
	    
	    var txtMS = document.getElementById(strMS);
	    txtMS.value = intMS;
	    var txtM = document.getElementById(strM);
	    txtM.value = intM;
	    var txtT = document.getElementById(strT);
	    txtT.value = intT;
	    var btn = document.getElementById(strBtn);
	    btn.click();
	    return false;
	}

	function HideRoomZoomPopup(strpnlPopup){
	    var pnl = document.getElementById(strpnlPopup);
	    pnl.style.display = 'none';
	}
			
    function InitializeRequest(sender, args) {
        if (prm.get_isInAsyncPostBack()) {
            args.set_cancel(true);
        }
        postBackElement = args.get_postBackElement();
        //alert(postBackElement.id);
        var Scenario = getPanelShowHideScenario(postBackElement.id);
        //alert(Scenario);
        ShowHideProgress(Scenario , true);
    }

    function EndRequest(sender, args) {
        var Scenario = getPanelShowHideScenario(postBackElement.id);
        ShowHideProgress(Scenario , false);
    }

    function ShowHideProgress(Scenario, bolShowProgress) {
    
        var pnl;
        var ShowProgress = '';
        var ShowScreen = '';
        
        if (bolShowProgress) {
            ShowProgress = 'block';
            ShowScreen = 'none';
        }else{
            ShowProgress = 'none';
            ShowScreen = 'block';
        }
        
        //alert(Scenario + ' ' + ShowProgress  + ' ' + ShowScreen);
        pnl = document.getElementById('div_uProg_upnlAgendaRoom');
        pnl.style.display = 'none'; 
        pnl = document.getElementById('div_uprog_upnlRoomView');
        pnl.style.display = 'none'; 
        
        if (Scenario == -1) {
            pnl = document.getElementById('div_uProg_upnlAgendaRoom');
            pnl.style.display = ShowProgress; 
        }
        
        if (Scenario == 1) {
            pnl = document.getElementById('pnluProg_upnlFlyout');
            pnl.style.display = ShowProgress;     
            pnl = document.getElementById('pnl_upnlFlyout');
            pnl.style.display = ShowScreen;     
            pnl = document.getElementById('div_uProg_upnlAgendaRoom');
            pnl.style.display = ShowScreen; 
        }
        
        if (Scenario == 2) {
            pnl = document.getElementById('div_uProg_upnlAgendaRoom');
            pnl.style.display = ShowProgress;     
            pnl = document.getElementById('div_pnlMain');
            pnl.style.display = ShowScreen;     
        }

        if (Scenario == 3) {
            pnl = document.getElementById('div_uprog_upnlRoomView');
            pnl.style.display = ShowProgress;     
            pnl = document.getElementById('div_upnlRoomView');
            pnl.style.display = ShowScreen;     
        }
    
        if (Scenario == 4) {
            pnl = document.getElementById('pnluProg_upnlSearchFlyout');
            pnl.style.display = ShowProgress;     
            pnl = document.getElementById('pnl_upnlSearchFlyout');
            pnl.style.display = ShowScreen;     
            pnl = document.getElementById('div_uProg_upnlAgendaRoom');
            pnl.style.display = ShowScreen; 
        }
        
        if (Scenario == 5) {
            pnl = document.getElementById('div_uProg_upnlAgendaRoom');
            //pnl.style.display = ShowScreen; 
        }
        
    }

    function getPanelShowHideScenario(strPostBackElement){
        var Scenario = -1;

        if (strPostBackElement.indexOf('btnFlyoutLoadClick') > -1)
            Scenario = 1;
        if (strPostBackElement.indexOf('lnkTitle') > -1) 
            Scenario = 2;
        if (strPostBackElement.indexOf('rtsStrip') > -1) 
            Scenario = 2;
        if (strPostBackElement.indexOf('btDoSearch') > -1) 
            Scenario = 2;
        if (strPostBackElement.indexOf('ddlDays') > -1) 
            Scenario = 3;
        if (strPostBackElement.indexOf('lnkRemoveFromYourAgenda') > -1) 
            Scenario = 3;
        if (strPostBackElement.indexOf('lnkAddMyAgenda') > -1) 
            Scenario = 5;
        if (strPostBackElement.indexOf('lnkRemoveMyAgenda') > -1) 
            Scenario = 5;
        if (strPostBackElement.indexOf('btnSearchFlyoutLoadClick') > -1)
            Scenario = 4;
        if (strPostBackElement.indexOf('lnkDownloadPresentationFromRoomZoom') > -1) 
            Scenario = 5;
                    
        return Scenario;        
    }
	
	function showDay(lngDay){
		with(document.Form1){
			actiontype.value = "day";
			day.value = lngDay;
			submit();
		}
	}
		
	function expandsection(lngSubmissionID){
		if (document.getElementById) {
			var thisMenu = document.getElementById ("sc_" + lngSubmissionID).style
			var thisImage = document.getElementById("img_" + lngSubmissionID)
			if (thisMenu.display == "block") {
				thisMenu.display = "none"
				thisImage.src = "http://www.tmforum.org/sdata/images/3378.gif"
			}
			else {
				thisMenu.display = "block" 
				thisImage.src = "http://www.tmforum.org/sdata/images/3377.gif"
			}
		}
	}

	function expandSectionPopup(lngSubmissionID){
		if (document.getElementById) {
			var thisMenu = document.getElementById ("scp_" + lngSubmissionID).style
			var thisImage = document.getElementById("imgp_" + lngSubmissionID)
			if (thisMenu.display == "block") {
				thisMenu.display = "none"
				thisImage.src = "http://www.tmforum.org/sdata/images/3378.gif"
			}
			else {
				thisMenu.display = "block" 
				thisImage.src = "http://www.tmforum.org/sdata/images/3377.gif"
			}
		}
	}
	
	function showTrack(lngTrackID){
	
	  with(document.Form1){
			actiontype.value = "track";
			track.value = lngTrackID;
			submit();
		}
	}
	

        function showModalPopupViaClient(strBehaviourID) {
            var modalPopupBehavior = $find(strBehaviourID);
            modalPopupBehavior.show();
        }
        
        function hideModalPopupViaClient(strBehaviourID) {
            var modalPopupBehavior = $find(strBehaviourID);
            modalPopupBehavior.hide();
        }


 function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
  
  function moveIt(obj, mvTop, mvLeft) {
	obj.style.position = "absolute";
	obj.style.top = mvTop;
	obj.style.left = mvLeft;
}


function getBrowserWindowWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myWidth;
}




