strBrowserName = navigator.appName;

fltBrowserVersion = parseFloat(navigator.appVersion);


/* Main Popup function, used in:
	TaskLauncher
	PopupMsg
*/

function PopUp(strURL, strWindowName, intOptions, intWidth, intHeight, intLeft, intTop) {
    // Use the option bit mask to determine window settings
    var bitToolBar = 1 & intOptions
    var bitLocation = 2 & intOptions
    var bitDirectories = 4 & intOptions
    var bitStatus = 8 & intOptions
    var bitMenuBar = 16 & intOptions
    var bitScrollBars = 32 & intOptions
    var bitResizable = 64 & intOptions

    // Open the window
    var objWindow = open(strURL, strWindowName,
        "toolbar=" + bitToolBar +
        ",location=" + bitLocation +
        ",directories=" + bitDirectories +
        ",status=" + bitStatus +
        ",menubar=" + bitMenuBar +
        ",scrollbars=" + bitScrollBars +
        ",resizable=" + bitResizable +
        ",width=" + intWidth +
        ",height=" + intHeight +
        ",left=" + intLeft +
        ",top=" + intTop)

    return objWindow;

} // End PopUp()

/* TaskLauncher function, used to launch and size task content browser window */

function TaskLauncher(w,h) {
    if (fltBrowserVersion >= 4.0) {
        intHeight = h || screen.availHeight;
        intWidth = w || screen.availWidth;
        } else {
        intHeight = h || 640;
        intWidth = w || 480;
    } // end if

    intHalfWidth = Math.round(intWidth / 2);// Set half width
    intLeftPos = Math.round(intWidth / 2);	// Set left position
    intTopPos = 0;				// Set top position
    intWindowOptions = 1 + 8 + 16 + 32;	// ToolBar, Status, MenuBar, ScrollBars
    
    if (fltBrowserVersion >= 4.0) {
        if (strBrowserName.indexOf('Netscape') != -1) {
            intHeight = intHeight - 110;
            intHalfWidth = intHalfWidth - 10;
        } else if (strBrowserName.indexOf('Microsoft') != -1) {
	    	intHeight = intHeight - 140;	// adjust height for toolbar, scrollbar, status line
	    	intHalfWidth = intHalfWidth - 10;// adjust width for scrollbar
		} else {
		// do nothing
        } // end if
    } // end if

    PopUp(strTaskURL, strTaskWindowName, intWindowOptions, intHalfWidth, intHeight, intLeftPos, intTopPos);
} // End TaskLauncher()

var objPreviewWindow

function taskPreview(strURL,w,h) {

	if (fltBrowserVersion >= 4.0) {

		intHeight = h || screen.availHeight;
		intWidth = w || screen.availWidth;

		if (intWidth <= 1024) {
			intHalfWidth = Math.round(intWidth / 2);// Set half width
			intLeftPos = Math.round(intWidth / 2);	// Set left position

			} else {

			intHalfWidth = 512;
			intLeftPos = intWidth - 512;
		}

		} else {
		intHeight = h || 480;
		intWidth = w || 640;
		intHalfWidth = 512;
		intLeftPos = intWidth - 512;
	} // end if

	intTopPos = 0;				// Set top position

	intWindowOptions = 1 + 8 + 16 + 32 + 64;	// ToolBar, Status, MenuBar, ScrollBars, Resizeable

	if (fltBrowserVersion >= 4.0) {
		if (strBrowserName.indexOf('Netscape') != -1) {
			intHeight = intHeight - 110;
			intHalfWidth = intHalfWidth - 10;
		} else if (strBrowserName.indexOf('Microsoft') != -1) {
			intHeight = intHeight - 140;	// adjust height for toolbar, scrollbar, status line
			intHalfWidth = intHalfWidth - 10;// adjust width for scrollbar
		} else {
		// do nothing
		} // end if
	} // end if
	
	selfURL=document.URL
	//alert(selfURL)
	var lang
	
	if (selfURL.toLowerCase().lastIndexOf("/ja/")>-1)
	{
		lang="JA"
	}
	else if(selfURL.toLowerCase().lastIndexOf("/fr/")>-1)
	{
		lang="FR"
	}
	else if(selfURL.toLowerCase().lastIndexOf("/de/")>-1)
	{
		lang="DE"
	}
	else if(selfURL.toLowerCase().lastIndexOf("/it/")>-1)
	{
		lang="IT"
	}
	else if(selfURL.toLowerCase().lastIndexOf("/cn/")>-1)
	{
		lang="CN"
	}
	else 
	{
		lang="EN"
	}
	
	if(strURL.toLowerCase().lastIndexOf(".htm")>-1)
	{
		objPreviewWindow = PopUp(strURL, strTaskWindowName, intWindowOptions, intHalfWidth, intHeight, intLeftPos, intTopPos);
		objPreviewWindow.focus()
	}
	else
	{
		window.parent.location.href="logDownload.asp?url=" + strURL+"&lang="+lang+"&title=" + document.title.replace("'","''");
	}	
		
} // End taskPreview()


// PopupMsg function replaces hhctrl activeX popup. 
// Requires that the variables 
// 		strBgColor - 	Background Color
// 		strFontFace -	Font Face
//		strFontColor -	Font Color
// be set in advance.

var strBgColor 		// Background Color
var strFontFace 	// Font Face
var strFontColor 	// Font Color

function setPopupVars(BgColor, FontFace, FontColor, FontSize) {

	strBgColor = BgColor; 		// Background Color
	strFontFace = FontFace; 	// Font Face
	strFontColor = FontColor; 	// Font Color
	strFontSize = FontSize;		// Font Size

}

function PopupMsg(strMsg, intX, intY, intPopupWidth, intPopupHeight) {

	msg = '<HTML><HEAD><TITLE>Popup</TITLE></HEAD><BODY onBlur="self.close()">';
	msg += '<FONT FACE=' + strFontFace + ' SIZE=' + strFontSize + '>';
	msg += strMsg; 
	msg += '</FONT></BODY></HTML>';	
	

    if (fltBrowserVersion >= 4.0) {
        intHeight = screen.availHeight;
        intWidth = screen.availWidth;
        } else {
        intHeight = 640;
        intWidth = 480;
    } // end if

	// Calculate popup location
	if (intY - intPopupHeight >= 20) {
		intTopPos = intY - intPopupHeight - 30;
		} else {
		intTopPos = 0;
	} // end if
	if (intX + (intPopupWidth / 2) <= intWidth && intX - (intPopupWidth / 2) > 0) {
		intLeftPos = intX - (intPopupWidth / 2);
		} else if (intX + (intPopupWidth / 2) > intWidth) {
			intLeftPos = intWidth - intPopupWidth - 7;
		} else {
			intLeftPos = 0;
	} // end if

	var objWindow = PopUp('','popup',0,intPopupWidth,intPopupHeight,intLeftPos,intTopPos);

	objWindow.document.open();
	objWindow.document.write(msg);
	objWindow.document.close();
	objWindow.document.bgColor = strBgColor;
	objWindow.document.fgColor = strFontColor;
}



function locateWindow(strDirection,intSize) {

    if (fltBrowserVersion >= 4.0) {
        intHeight = screen.availHeight;
        intWidth = screen.availWidth;
        } else {
        intHeight = 800;
        intWidth = 600;
    } // end if
    
    if (strDirection == 'height') {
    	intTop = Math.round((intHeight - intSize) / 2);
    	return intTop;
    
    } else {
    	intLeft = Math.round((((intWidth / 2) - intSize) / 2) + (intWidth / 2));
    	return intLeft;
    }
 }
