// ------------------------------------------------------------------------
// MC_START_REQUESTER.JS
// Copyright: © 1998-2006 Maintenance Connection, Inc. All rights reserved.
// ------------------------------------------------------------------------

function startup_requester()
{
	if (self.parent != null && self.parent.document != null && self.parent.mcsubmit != null)
	{
		var wh = parent;
		var system = false;
	}
	else
	{
		var wh = self;
		var system = true;
	}

	apppath_requester = mcurl_r;

	// force SSL
	var prefix;
	var suffix;
	
	prefix = securepageprotocol + location.host;
	suffix = '';

	//window.wh.location.replace(apppath_requester + 'default.asp?i=y');
	//setCookie('mcinuse','Y',1);
	//window.wh.location.replace(apppath_requester + 'default.asp?i=y');
	//return;

	if (self.windowmax != null && self.windowmax == false)	   
	{			
		aW = 1024-10;
		aH = 768-30;	
	}
	else
	{
		// for when using window.open
		aW = self.screen.availWidth-10;
		aH = self.screen.availHeight-30;	
	
		// for when using window.showmodeless or window.showmodal
		// aW = self.screen.availWidth;
		// aH = self.screen.availHeight;	
		   
		if (aW >= ((1024*2)-50) || aH >= ((768*2)-50))
		{
		 	// Using dual montior display
		 	if (aW >= ((1024*2)-50))
		 	{
		 		aW = aW / 2;
		 	}
		 	else
		 	{
		 		aH = aH / 2;
		 	}
		}
	}
		
	if (wh.mcrappwindow != null)
	{
		//try
		//{			
		//	// now turn off the loading stuff
		//	wh.loadingcomplete();
		//	wh.mcrappwindow.focus();
		//	return;
		//}
		//catch(e)
		//{
		//}

		try
		{
			if (wh.mcrappwindow != null)
			{
				wh.mcrappwindow.close();
			}
		}
		catch(e)
		{
		}		
	}
	// below is the production one
	//alert(prefix + apppath_requester + 'default.asp?i=y');
	//return;

	// XP SP2 FIX
	try
	{	
		if (false && system == false)
		{
			wh.mcrappwindow = wh.open(prefix + apppath_requester + 'default.asp?i=y','mcrmain',"width="+aW+",height="+aH+",left=0,top=0,scrollbars=yes,resizable=yes,status=yes,toolbar=no,menubar=no,location=no,directories=no");				
			wh.mcrappwindow.focus();
		}
		else
		{

			if (self.aotfmode != null && self.aotfmode != '')
			{
			    if (self.addontheflyid != null && self.addontheflyid != '')
			    {
				    suffix += '&aotfid='+self.addontheflyid;							    
			    }
			    else
			    {
				    suffix += '&aotfpk='+self.addontheflypk;			
				}
			}		
		
			wh.location.replace(prefix + apppath_requester + 'default.asp?i=y'+suffix);	
		}
	}
	catch(e)
	{
		alert('Maintenance Connection could not launch because the Internet Explorer Pop-up Blocker is turned on.\n\n AFTER clicking the OK button below, Click Tools Menu > Pop-up Blocker > Always Allow Pop-ups from This Site...');
	}
		
	// below is the development one
    //wh.location.href = apppath_requester + 'default.asp?i=y';

	//==============================================================================	
	// Other Ways to Start the Application	
	//==============================================================================	
	//var param = new Object();
    //param.caller = wh;
    
    // modal way (maybe for demos)        
    // retval = wh.showModalDialog(apppath_requester + 'default.asp?i=y', param,'dialogHeight: ' + aH + 'px; dialogWidth: ' + aW + 'px; dialogTop: 0px; dialogLeft: 0px; center: No; help: No; resizable: Yes; status: No; scroll: No' );
    
    // non-modal way (if we can minimize somehow)
    //wh.mcrappwindow = wh.showModelessDialog(apppath_requester + 'default.asp?i=y', param,'dialogHeight: ' + aH + 'px; dialogWidth: ' + aW + 'px; dialogTop: 0px; dialogLeft: 0px; center: No; help: No; resizable: Yes; status: No; scroll: No' );
    //wh.mcrappwindow = wh.showModelessDialog(apppath_requester + 'default.asp?i=y', param,'dialogHeight: ' + aH + 'px; dialogWidth: ' + aW + 'px; dialogTop: 0px; dialogLeft: 0px; center: No; help: No; resizable: Yes; status: No; scroll: No' );	
}

