/*
 *------------------------------------------------------------------
 * appsui.js --  Applications User Interface Utilities
 *
 * March 2002, 
 *
 * Copyright (c) 2003 by cisco Systems, Inc.
 * All rights reserved.
 *------------------------------------------------------------------
 */

function openChildWindow( appuri, windowname ) {
 
	var appwindow = window.open( appuri , windowname, "toolbar=yes,status=yes,top=10,left=10,outerWidth=790,outerHeight=500,width=790,height=500,resizable=yes");
	appwindow.focus();
}

function closeWindow() {

	top.window.close();
}

function openPopup( popupuri, windowname ) {

	var popup = window.open( popupuri , windowname, "toolbar=no,status=no,top=100,left=200,width=300,height=190,resizable=no");
	popup.focus();
}


function openWindow(appuri, windowname) {
    var appwindow = window.open( appuri , windowname);
    appwindow.focus();
}

function launchCMS(ipAddress) {

	if (navigator.appVersion.indexOf("X11")!=-1)
	{
    		var windowname = ipAddress;
    		while(windowname.search(/[.]/) != -1) {
        		windowname = windowname.replace(/[.]/, "_");
    		}
    		windowname = 'CMS_' + windowname;
    		var appwindow = window.open( 'homepage.htm', windowname, "toolbar=no,status=no,scrollbars=yes,resizable=yes");
    		appwindow.focus();
	}
	else
	{

		if (navigator.mimeTypes && navigator.mimeTypes.length)
        	{
                	launchCmsForWindowsNetscape();
    		}
        	else
        	{
                	launchCmsForIexplorer();
        	}
	}
}

function launchCmsForWindowsNetscape(){
        var target = location.href;
        var pString = "ApplicationTarget^";
	
        var pArray = [  "appContext",target,"BootVersion",1.4 ];

        for(var i=0;i<pArray.length;i++){
        pString = pString + pArray[i] + "*";
        }
        win = window.open("", "", "width=500, height=40, top=40, left=400");
        d = win.document;
        d.write('<html><head>');
        d.write('<title>Cisco CPNM Plugin</title>');
        d.write('</head>');
        d.write('<BODY bgcolor="#FFFFFF">');
        d.write('<EMBED type=application/x-cisco-cms parameters=' + pString + ' width=600 height=300>');
        d.write('</EMBED>');
        d.write('</body></html>');
        setTimeout("win.close()",5000);
}

function launchCmsForIexplorer()
{
var target = location.href;
var pString = "";

var pArray = [          "appContext",           target
             ];

for(var i=0;i<pArray.length;i++){
        pString = pString + pArray[i] + "*";
}
win = window.open("", "", "width=500, height=100, top=40, left=400");
d = win.document;
d.write('<html><head>');
d.write('<title>Cisco CPNM Plugin</title>');
d.write('</head>');
d.write('<BODY bgcolor="#FFFFFF" onload="window.open("", "")>');
d.write('<OBJECT ID="cpnmcontrol2" CLASSID="CLSID:BA3619B7-A0E5-43F0-A015-77411B1592F8" ');
d.write('width="400" height="40">');
d.write('<PARAM NAME="ApplicationTarget" VALUE="' + pString + '">');
d.write('<h3>Cisco CPNM Plugin is not installed</h3>');
d.write('</OBJECT>');
d.write('</body></html>');
setTimeout("win.close()",5000);
}

