
	function MM_openBrWindow(theURL,winName,features) { //v2.0
		window.open(theURL,winName,features);
		}

	function MM_findObj(n, d) 
		{ 
			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); return x;
		}
	
	function MM_swapImage() 
		{ 
			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 MM_swapImgRestore() 
		{
			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() 
		{ 
			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 dm(msgStr) 
		{
			window.status = msgStr;
			document.returnValue = true;
		}

	function dm1() 
		{
			window.status = "";
			document.returnValue = true;
		}

		function SetFocus(ctl)
		{ 
			if (ctl!="")
			{	if (document.getElementById)
				{
					var d=document.getElementById(ctl);
				}
				else
				{	if (document.all || document.layers)
					var d=eval('document.forms[0].'+ctl);
				}
				if (d!=null)
				{
					d.focus();
				}
			}	
		}
		
//Section for Modal Dialog simulation
	var ctlImage
	var ctlForm
	var winModalWindow
	

	function IgnoreEvents(e)
	{
		return false
	}

	function ShowWindow(link,width,height,scroll)
	{ 
		if (document.layers) 
			{
				window.top.captureEvents(Event.CLICK|Event.FOCUS)
			}
			
		var y=0
		var x=0
		
		if (window.outerWidth)
			{
			x=((window.outerWidth-width)/2)+window.screenX
			y=((window.outerHeight-height)/2)+window.screenY
			}
		else
			{
			x=((document.body.clientWidth-width)/2)+window.screenLeft
			y=((document.body.clientHeight-height)/2)+window.screenTop
			}
		window.onclick=IgnoreEvents
		window.onfocus=HandleFocus
		
		
		if (scroll == true) 
		    winModalWindow = window.open(link,"ModalChild",	"width=" + width + ",height=" + height + ",top=" + y + ",left=" + x + ",dependent=yes,toolbars=no,scrollbars=yes,status=yes,resizable=yes")
		else
		    winModalWindow = window.open(link,"ModalChild",	"width=" + width + ",height=" + height + ",top=" + y + ",left=" + x + ",dependent=yes,toolbars=no,scrollbars=no,status=no,resizable=no")
		winModalWindow.focus()
	}

	function HandleFocus()
	{ 
		window.setTimeout("HandleFocus2()", 50);
		return false
	}
	
	function HandleFocus2()
	{
		if (winModalWindow)
			{
				if (!winModalWindow.closed)
					{
						winModalWindow.focus()
					}
				else
					{
						if (document.layers) 
							{
								window.top.releaseEvents(Event.CLICK|Event.FOCUS)
							}
						window.top.onfocus=null
					}
			}
		return false
	}
	var ctl;
	var ctlPathDisplay;
	var ctlDisplayOrder
	function GetParentUI(ctlName, oPath, ParentUIID, ExcludeUIID, ItemType, AddingSubMenu,oDisplayOrder, ShowAll)
	{
		ctl= MM_findObj(ctlName);
		ctlPathDisplay = MM_findObj(oPath); 
		ctlDisplayOrder = MM_findObj(oDisplayOrder); 
		ShowWindow('ParentSelect.aspx?ParentUIID=' + ParentUIID + '&ExcludeUIID=' + ExcludeUIID + '&ItemType=' + ItemType + '&AddingSubMenu=' + AddingSubMenu + '&ShowAll=' + ShowAll, 350,420,  true)
	}
	
	function SetParent(sParent, sPath,sDisplayOrder)
    {
		ctl.value = sParent;
		ctlPathDisplay.innerText = sPath;
		if (ctlDisplayOrder!=null)
			{
			ctlDisplayOrder.value=sDisplayOrder;
			}
    }

	
	function GetDate(CtrlName,time,bShowExpiry)    
    {  
		ctl = MM_findObj(CtrlName);
		if (time==1)
			ShowWindow('calendar.aspx?bShowExpiry=' + bShowExpiry + '&sDate=' + ctl.value + '&time=' + time,300,320,false)
		else
			ShowWindow('calendar.aspx?bShowExpiry=' + bShowExpiry + '&sDate=' + ctl.value ,300,300,false)
    } 
      
    function SetDate(sDate,bShowExpiry)
    {
		ctl.value = sDate;
		if (bShowExpiry)
		{
			if (showExpiryEffect && bShowExpiry)
				showExpiryEffect(ctl);
		}
    }

    function FindInternalLink(PagePath, CtrlName, cssPath,Find)    
    {  
		var popupHeight=350
		var popupWidth=340
		
		ctl = MM_findObj(CtrlName);
		ShowWindow(PagePath + '/FindContact.aspx?Find=' + Find + '&cssPath=' + cssPath,popupWidth,popupHeight,false)
    } 
      
    function SetInternalLink(sName,iContactID)
    {
		var orgid  = ctl.id;
		ctl.value = iContactID;
		ctl = MM_findObj(ctl.id + ':Display');
		ctl.innerHtml = sName;
		ctl = MM_findObj(orgid + ':ContactName');
		ctl.value = sName;
		document.forms(0).submit();
    }
    
    function SetContact(sName,iContactID)
    {
		var ctlhd
		var ctlProcess
		
		ctlhd = MM_findObj(ctl.id + "hd");
		ctlhd.value = sName;
		
		ctlProcess = MM_findObj(ctl.id + "Process");
		if (ctlProcess!=null)
				{
				ctlProcess.value = 1;
				}
		
		ctl = MM_findObj(ctl.id + "ID");
		ctl.value = iContactID;
		
		document.forms(0).submit();
		if (ctlProcess!=null)
				{
				ctlProcess.value = 0;
				}
		
    }
    
    function FindContact(CtrlName, Find)    
    {  
		var popupHeight=450
		var popupWidth=340
		ctl = MM_findObj(CtrlName);
		ShowWindow('FindContact.aspx?Find=' + Find,popupWidth,popupHeight,false)
    } 
    
    
	// New functions added for Reporting functionality...
	function GetReportDate(CtrlName,time)    
    {  
		ctl = MM_findObj(CtrlName);
		if (time==1)
			ShowWindow('../calendar.aspx?bShowExpiry=0&sDate=' + ctl.value + '&time=' + time,300,320,false)
		else
			ShowWindow('../calendar.aspx?bShowExpiry=0&sDate=' + ctl.value ,300,300,false)
    }	