/**
 * Copyright 2004 Earth Resource Mapping Pty Ltd. This document contains unpublished source code of
 * Earth Resource Mapping Pty Ltd. This notice does not indicate any intention to publish the source
 * code contained herein.
 *
 * /ecwplugins/lib/Scripts/NCSConstants.js
 * Define common constants
 */

var IMAGE_WEB_SERVER_VERSION	   = "3,6,0,55"
var IMAGE_WEB_SERVER_VERSION_DOT   = "3.6.0.55"

var ECW_NETSCAPE_MIME_TYPE		   = "application/x-ImageWebServer2-ecw"
var ECW_NETSCAPE_TOOLBAR_MIME_TYPE = "application/x-ImageWebServer-toolbar"
var ECW_NETSCAPE_PROGBAR_MIME_TYPE = "application/x-ImageWebServer-progressbar"
var ECW_NETSCAPE_REG_NAME		   = "plugins/IWS/ImageViewer"
var ECW_NETSCAPE_PLUGINS_PAGE	   = "/ecwplugins/DownloadPlugin.htm"

var ECW_ACTIVEX_NAME			   = "NCSViewManager.NCSLayeredView.1"
var ECW_ACTIVEX_CODEBASE		   = "/ecwplugins/DownloadPlugin.htm"
var ECW_ACTIVEX_NCSVIEW_CLASSID    = "clsid:D147430C-86CD-4E6F-A807-93FBC496D201"
var ECW_ACTIVEX_NCSTOOLBAR_CLASSID = "clsid:79E46020-ED4B-447A-B191-AD2A63AF51A1"
var ECW_ACTIVEX_NCSPROGBAR_CLASSID = "clsid:584719E2-015C-438F-A012-0085270F8E63"
											
var ECW_JAVA_VIEWJARFILE		   = "JNCSViewS.jar,JNCSGDT.jar"
var ECW_JAVA_GUIJARFILE 		   = "JNCSGui.jar"
var ECW_JAVA_JARCODEBASE		   = "/ecwplugins"
var ECW_JAVA_APPLETCLASS		   = "com.ermapper.view.JNCSViewApplet.class"
var ECW_JAVA_TOOLBARCLASS		   = "com.ermapper.gui.JNCSToolbarApplet.class"
var ECW_JAVA_PROGBARCLASS		   = "com.ermapper.gui.JNCSProgressbarApplet.class"
var ECW_JAVA_VM_CLASSID			   = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
var ECW_JAVA_VM_APPLET_TYPE		   = "application/x-java-applet;version=1.4"
var ECW_JAVA_VM_IE_CODEBASE		   = "http://java.sun.com/update/1.6.0/jinstall-6u1-windows-i586-jc.cab#Version=6,0,010,6"
var ECW_JAVA_VM_NS_CODEBASE		   = "http://java.sun.com/products/plugin/index.html#download"

// Pointer Modes
var PM_ROAM    = 0;
var PM_ZOOM    = 1; 
var PM_POINTER = 2;
var PM_ZOOMBOX = 3;

// Geolink Modes
var GM_NONE    = 0;
var GM_WINDOW  = 1;
var GM_SCREEN  = 2;

// Mouse event callback masks
var MVK_CONTROL = 8;
var MVK_LBUTTON = 1;
var MVK_MBUTTON = 16;
var MVK_RBUTTON = 2;
var MVK_SHIFT = 4;

// Function parameter definitions for the ECWView ActiveX/Netscape/applet
var PARAM_VIEW_NONE 				  = 0;
var PARAM_VIEW_STYLE				  = 1;
var PARAM_VIEW_ONMOUSEDOWN			  = 2;
var PARAM_VIEW_ONMOUSEMOVE			  = 3;
var PARAM_VIEW_ONMOUSEUP			  = 4;
var PARAM_VIEW_ONEXTENTCHANGE		  = 5;
var PARAM_VIEW_ONPERCENTCOMPLETE	  = 6;
var PARAM_VIEW_ONPOINTERMODECHANGE	  = 7;
var PARAM_VIEW_ONLAYERRESPONSE		  = 8;
var PARAM_VIEW_ONLOAD				  = 9;
var PARAM_VIEW_BGCOLOR				  = 10;
var PARAM_VIEW_ONDRAWBEGIN			  = 11;
var PARAM_VIEW_ONDRAWEND			  = 12;
var PARAM_VIEW_WINDOWLESS			  = 13;
var PARAM_VIEW_ONERROR				  = 14;
var PARAM_VIEW_ONGEOLINKMODECHANGE	  = 15;
var NCSViewParamNames = new Array("", "", "onMouseDown", "onMouseMove", "onMouseUp", "onExtentChange", "onPercentComplete", "onPointerModeChange", "onLayerResponse", "onLoad", "bgcolor", "onDrawBegin", "onDrawEnd", "windowless", "onError", "onGeolinkModeChange");

// Error codes
var ERROR_CONNECTION_LOST			  = 75;

// Function parameter definitions for the ECWToolbar ActiveX/Netscape/applet
var PARAM_TOOLBAR_NONE				  = 0;
var PARAM_TOOLBAR_STYLE 			  = 1;
var PARAM_TOOLBAR_ONPOINTERMODECHANGE = 2;
var PARAM_TOOLBAR_ONSETEXTENTSALL	  = 3;
var PARAM_TOOLBAR_ONHELP			  = 4;
var PARAM_TOOLBAR_CELLSPACING		  = 5;
var PARAM_TOOLBAR_BGCOLOR			  = 6;
var PARAM_TOOLBAR_LAYERED			  = 7;
var NCSToolbarParamNames = new Array("", "", "onPointerModeChange", "onSetExtentsAll", "onHelp", "cellSpacing", "bgcolor", "layeredToolbar");

// Function parameter definitions for the ECWPROGBAR ActiveX/Netscape/applet
var PARAM_PROGBAR_NONE				  = 0;
var PARAM_PROGBAR_STYLE 			  = 1;
var PARAM_PROGBAR_BGCOLOR			  = 2;
var PARAM_PROGBAR_FGCOLOR			  = 3;
var PARAM_PROGBAR_SOLID 			  = 4;
var NCSProgbarParamNames = new Array("", "", "bgcolor", "fgcolor", "solid");

//Copyright notice
function WriteCopyright() {
	document.writeln("©1999-2008 <A href='http://www.leica-geosystems.com' target=_blank>Leica Geosystems</A>");
}

// Set a cookie in the browser
function setCookie(name, value) {
	setCookieIntern(name, value, null, null, null, null);
}

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments

function setCookieIntern(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + 
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

//
// Check if coolies are enabled
//
function cookiesEnabled( ) {
	var oldCookie = document.cookie;
	var bIsEnabled = true;
    document.cookie = "test=cookiesEnabled";
    var pos = document.cookie.indexOf( "test=" );
    if( pos == -1 ) {
        bIsEnabled = false;
    }
    document.cookie = oldCookie;
    return bIsEnabled;
}

// This object is used as a color list
function NCSColorList() {
}
