

// =====================================================
// Signum Systems Corp.
// All contents copyright. All rights reserved.
// =====================================================
// common.js

// colors for bg change when hovering
   oncolor  = "#ddddd4";			// stripecell
   offcolor = "#ffffff";			// plaincell

//==============
// Swap images (simple rollover).
// Usage:
// <a href="a.htm" onmouseout="PicOff('pname','image1.gif');" onmouseover="PicOn('pname','image2.gif');"><img name="pname" src="sth.gif"></a>
//==============
  function PicOn(picname, image)   { document.images[picname].src=image; }
  function PicOff(picname, image)  { document.images[picname].src=image; }

//=============
// Email address scrambler
// The goal: <a href="mailto:addressee@domain.com?subject=Via your web page" onMouseOver="window.status='Click to mail.'; return true;" onMouseOut="window.status=''">Visible Text or Image</a>
// who: receipient user name (the part before the monkey)
// sho: what, txt or img,  the visitor sees (image require '<img src=\"images\myimage.gif\" alt="Click to email." border="0">'
// sub: text to appear in the Subject field
// Usage 1: pta('kris', 'Keep in touch', 'Via your web page')
// Usage 2: pta('kris', 'Keep in touch')
// Usage 3: pta('kris', '<img src="images\contact.gif" alt="Click to email." border="0">', 'Via your web page')
//=============
function pta(who, show, sub){
  beg  = '<a href=\"mai';
  beg += 'lto:';
  who += '&#';
  who += '64;signum.com';

  // make it possible to omit the last argument
  subject = (sub == undefined) ? '' : '&#63;subject=' + sub;

  onmouse  = '\" onMouseOver=\"window.status=\'Click to email.\';return true;\" onMouseOut=\"window.status=\'\';\">';
  end      = '</a>';

  document.write(beg + who + subject + onmouse + show + end);
}

//=============
// Better email address scrambler (replace pta() with this one)
// The goal: <a href="mailto:addressee@domain.com?subject=Via your web page" onMouseOver="window.status='Click to mail.'; return true;" onMouseOut="window.status=''">Visible Text or Image</a>
//
// who:  receipient user name (the part of the addres before the monkey)
// dom:  domain name (the part of the address on the right of the monkey)
// show: text or img the visitor sees (image: '<img src=\"myimage.gif\" alt="Email." border="0" width="10" height="5">'
// sub:  subject field text
//
// Usage : yubin('joe', 'joesdomain.name', '<img src="mail.gif">', 'Subject text')
//         <script>yubin('joe','signum.com', '<img src="images/em.gif" width="19" height="10" border="0" align="absbottom"> email', 'Your press release of June 23, 2010')</script>
//         <script>yubin('joe','signum.com', 'SELF', 'Your last press release')</script>
//=============
function yubin(/* who, dom, show, sub */){
  beg      = '<a href=\"mai';	// break up to mislead automated search for the protocol keyword
  beg     += 'lto:';
  monkey   = '&#';			    // break up the decimal version of the monkey char
  monkey  += '64;';
  onmouse  = '\" onMouseOver=\"window.status=\'Click to email.\';return true;\" onMouseOut=\"window.status=\'\';\">';
  end      = '</a>';

  if (arguments.length == 4) {  
    who     = arguments[0] + monkey + arguments[1];
    show    = arguments[2];
      if (show == 'SELF') { show = who; }
    subject = '&#63;subject=' + arguments[3];           // the ? char etc.
  }
  else {					// oops!
    alert ("Incorrect number of arguments in yubin()\nPlease notify the webmaster.");
    exit;
  }

  document.write(beg + who + subject + onmouse + show + end);
} // yubin


//==============
// Define my own error handler--for Navigator 3.0 and higher only.
// The page must be in main directory and jserror.htm in _private.
// To fail silently:	self.onerror = function() { return true };
// To get bug report:   self.onerror = report_error;
// To test:			Call a nonexistent func;
//==============

var error_count = 0;	// Ensure that each error window is unique.

function report_error(msg, url, line) {
  var w = window.open("_private/jserror.htm", "JSerr" + error_count++, "no,status,width=320,height=250");
  w.error_msg = msg; 	// communicate values between this and jserror window
  w.file = url;
  w.line = line;
  return true;		// this gags Navigators's native error handler
}

self.onerror = function() { return true };


//==============
// Process the Location object query property, the arguments that follow
// the "?" in a URL and come in comma-separated pairs as argname=value.
// Example: http://www.asite/example.htm#box?width=225,height=100
// Usage: see VisitUs frameset and how it is invoked from within TOC.
//==============
function GetArgs() {
  var args = new Object();
  var query = location.search.substring(1);
  var pairs = query.split(",");

  for (var i = 0; i < pairs.length; i++ ) {
    var pos = pairs[i].indexOf('=');
    if (pos == -1) continue;			// skip if none
    var argname = pairs[i].substring(0,pos);
    var value = pairs[i].substring(pos+1);
    args[argname] = unescape(value);
  }
  return args;
}


//============
// Extract the name of the page (killing the hash if so desired)
//============
function ThisPageName( with_or_without_bookmark ) {
  start = document.URL.lastIndexOf('/') + 1;
  if ( with_or_without_bookmark == 'with_bookmark' ) {
    end = ((query_pos = document.URL.indexOf('?')) != -1) ? query_pos : document.URL.length;
  } else {
    end = ((hash_pos = document.URL.indexOf('#')) != -1) ? hash_pos : document.URL.length;
  } 

  return document.URL.substring(start, end);
}


//==============
// May I ask who is calling?
//==============
var browser = new Object();
function getBrowser() {
  // *** brand
  if (navigator.appName.substring(0,8) == "Netscape") {
    browser.name = "Netscape";
  } else if (navigator.appName.substring(0,9) == "Microsoft") {
    browser.name = "Microsoft";
  } else {
    browser.name = navigator.appName;
  }

  // *** version & Java
  browser.java = (navigator.javaEnabled()) ? "On": "Off";
  browser.JSversion = 0.0;                                 // Test for it before using it (see index.html)
  browser.version = parseFloat(navigator.appVersion);

  //*** NT & MS can be "replaced", others need to be assigned (location)
  browser.NT = ( (browser.name == 'Netscape')  && (browser.version >= 3.0) );
  browser.MS = ( (browser.name == 'Microsoft') && (browser.version >= 4.0) );

  ie5 = (navigator.userAgent.indexOf('MSIE 5')>0) ? true : false;

  // *** operationg system
  if (navigator.appVersion.indexOf("Win95") > 0)           browser.os = "Windows 95";	// NS
  else if (navigator.appVersion.indexOf("Win98") > 0)      browser.os = "Windows 98";	// NS
  else if (navigator.appVersion.indexOf("Windows 95") > 0) browser.os = "Windows 95";	// MS
  else if (navigator.appVersion.indexOf("Windows 98") > 0) browser.os = "Windows 98";	// MS
  else if (navigator.appVersion.indexOf("Win16") > 0)      browser.os = "Windows 3.1";
  else if (navigator.appVersion.indexOf("Mac") > 0)        browser.os = "Macintosh";
  else if (navigator.appVersion.indexOf("X11") > 0)        browser.os = "UNIX";
  else if (navigator.appVersion.indexOf("Linux") > 0)      browser.os = "Linux";
  else if (navigator.appVersion.indexOf("Lynx") > 0)       browser.os = "Lynx";
  else                                                     browser.os = "UNKNOWN";
}
getBrowser();  // execute


//==============
// Safely replace URL without adding history entry.
//==============
function HopWithoutHistoryTo(address) {
  (browser.JSversion >= 1.1 || browser.NT || browser.MS) ? location.replace(address) : location.href = address;
}


//==============
// Check if the current page is displayed in the desired frame.
// If not, put the page into that frame with the query mechanism.
// Note that the frame must be able to read query arguments. See GetArgs().
// The frameset argument may be in the form of "myframeset.htm" or "myframeset.htm?p=mainpage.htm".
//==============
function forceMeIntoFrame( frameset ) {
  /* top.document.title = document.title; */			// Originally for bookmarking, but Netscape, then MS, blocked changes to "top".

  if ( parent.location.href.indexOf(frameset) == -1 ) { // Not called from the frameset or already in it
    var destination = frameset + "?p=" + ThisPageName('without_bookmark');
    top.location.replace(destination);   
}}


//==============
// Keeps the calling page out of a frame.
//==============
function keepMeOutOfFrame() {
if (top.location != self.location) {
  top.location = self.location
}}


//==============
// Link style for MSIE.
// Links for NS are set via <body> and _private/style.htm.
//==============
function LinkStyle() {
strng = "<style TYPE='text/css'>\n"
  + "<!--\n"
  + "A:link {text-decoration:none; color:#CC6633}\n"
  + "A:visited {text-decoration:none; color:#CC6633}\n"
  + "A:active {text-decoration:none; color:#CC6633}\n"
  + "A:hover {text-decoration:underline; color:#CC6633}\n"
  + "div.specialDiv A:link {text-decoration:none; color:#CC6633}\n"
  + "div.specialDiv A:visited {text-decoration:none; color:#CC6633}\n"
  + "div.specialDiv A:active {text-decoration:none; color:#CC6633}\n"
  + "div.specialDiv A:hover {text-decoration:underline; color:#CC6633}\n"
  + ".ptrArrow {cursor:default}\n"
  + ".ptrHelp {cursor:help}\n"
  + ".ptrHand {cursor:pointer}\n"
  + ".ptrCross {cursor:crosshair}\n"
  + ".ptrMove {cursor:move}\n"
  + ".ptrText {cursor:text}\n"
  + ".ptrE {cursor:e-resize}\n"
  + ".ptrNE {cursor:ne-resize}\n"
  + ".ptrNW {cursor:nw-resize}\n"
  + ".ptrN {cursor:n-resize}\n"
  + ".ptrSE {cursor:se-resize}\n"
  + ".ptrSW {cursor:sw-resize}\n"
  + ".ptrS {cursor:s-resize}\n"
  + ".ptrW {cursor:w-resize}\n"
  + "-->\n"
  + "</style>"
document.write( strng )
}


//==============
// Usage: swapImages('img_name','img_obj');
//        in lieu of: onMouseover="document.img_name.src=img_obj.src"
//==============
function swapImages(imgName, newImg) {
  if (document.images) {
    eval('document.' + imgName + '.src = ' + newImg + '.src');
}}


//==============
// Write document houskeeping info: (c), modification date and file name.
// 1. In files created on the fly, Netscape 4.5's lastModified is Dec 31, 1969 (!) - invalid
// 2. NS and MSIE treat year differently. See D. Flanagan's JavaScript: The Defeinitive Guide, 2nd ed., p. 360-1.
// 3. Yet another evidence of how the giants care:
//		NS 4.5:		05/27/99 09:22:14
//    	NS 4.6:		Thursday, May 27, 1999 09:22:14
//    	MSIE 4 & 5:		05/27/1999 09:22:14
//==============

// Usage:     now=new Date(); year=GetYear(now);
function GetYear(today) {
    //year = today.getYear();
    //if(year < 2000) year += 1900;
    // The two lines above were for pre-javascript 1.3 browsers.
    year = today.getFullYear();
    return year;
}
// Enable local customization
if (typeof dicolor1 == 'undefined') { var dicolor1 = "#B2B29F" }
if (typeof dicolor2 == 'undefined') { var dicolor2 = dicolor1 }
if (typeof dicolor3 == 'undefined') { var dicolor3 = "#ffffff" }
if (typeof size1    == 'undefined') { var size1    = (browser.name == "Netscape") ? "7.5" : "7"; }	// NS's chars are smaller
if (typeof size2    == 'undefined') { var size2    = size1 }
if (typeof size3    == 'undefined') { var size3    = size1 }
//
function docInfo_(line1, line2, line3) {
  d = document;
  today = new Date();									// Could have used
  
  if ( Date.parse(d.lastModified) != 0) {				// valid date
    from = 0;
    to = d.lastModified.lastIndexOf(" ");
    date_kk = d.lastModified.substring(from, to);		// leave date, kill time
  } else {									// See function header, p. 1.
    year = GetYear(today); 	// See function header, p. 2.
    date_kk = (today.getMonth() + 1) + "/" + today.getDate() + "/" + year;
  }

  fontTag1 = '<font face="Verdana,Helvetica,Arial,Sans Serif" color='
             + dicolor1 + ' style="font-size:' + size1 + 'pt;">';
  fontTag2 = '<font face="Verdana,Helvetica,Arial,Sans Serif" color='
             + dicolor2 + ' style="font-size:' + size2 + 'pt;">';
  fontTag3 = '<font face="Verdana,Helvetica,Arial,Sans Serif" color='
             + dicolor3 + ' style="font-size:' + size3 + 'pt;">';

  if (line1==1) {
    firstLine = fontTag1 + '&#169;' + ' ' + GetYear(today) + ' ' + 'Signum Systems<br>tel. 1 · 805 · 383 · 3682' + '</font><br>';
  } else {			// page invoked from another page
    firstLine = '';
  }

  page = ThisPageName('without_bookmark');

  secondLine = (line2 == 1) ? fontTag2 + page + '<br>' + '</font>' : '';
  thirdLine  = (line3 == 1) ? fontTag3 + date_kk + '</font><br>' : '';

  info = fontTag1 + fontTag1	// Kludge - Netscape has problems with font-size
    + firstLine
    + secondLine
    + thirdLine
  d.write( info );
} //docInfo_()

//==============
// Add some control without changing the parameter list
//==============
function docInfo()    { docInfo_(1, 1, 1); }
function docInfo011() { docInfo_(0, 1, 1); }	// no (c) & tel.
function docInfo101() { docInfo_(1, 0, 1); }	// no filename
function docInfo110() { docInfo_(1, 1, 0); }	// no date

//==============
// General Init and Cleanup handlers
//==============
function DoOnLoad() {
  document.loaded = true;				// needed for popups, rollovers &c.
}

function DoOnUnload() {					// Requires prior incl. of auxwin.js
  CloseAuxWin1();						// ...if opened.
  CloseAuxWinBare();
  CloseAuxWinBareSize();
}

//==============
// Footnotes in frames such as "Visit Us".
//==============
function showFoot(bookmark, msg) {
//var l = frames[1].location;       - if this func in parent frameset
  page = "visit_f.htm";
  var l = parent.frames[1].location;

  // if (!parent.loaded) { return; }
  // Make the "Back" button more useful--MS should work like NS does, but...
  if (browser.name == "Microsoft") {
    l.replace(page + "#" + bookmark);
  } else {
    l.replace("http://www.signum.com/" + page);
    l.hash = bookmark;
  }
  top.status = msg; // return true afterwards
} //showFoot()


//==============
// VISIBILITY
//==============
var hideimg ='http://www.signum.com/images/hide.gif';
var showimg ='http://www.signum.com/images/show.gif';

// Quick getElement reference. Returns an array of args to a func.
// Usage:
// var obj1 = document.getElementById('element1');
// var obj2 = document.getElementById('element2');
// function visitElements() {
//   var elements = $('a','b','c',obj1,obj2,'d','e');
//   for ( var i=0; i < arguments.length; i++ )
//          ... etc. ...
//
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

// Toggle the visibility of a single object.
// Usage: onclick="Toggle('myID');"
//
function Toggle(obj) {
  var obj = document.getElementById(obj);
  obj.style.display = (obj.style.display != 'none' ? 'none' : '' );
  return obj.style.display;
}

// Toggle the visibility of a single object (obj) and flip the toggle icon (imageid).
// Usage: onclick="Toggle('objectID', 'ImgID');"
//        To enforce the default state (eg.): <div style="display:none;">I'M INITIALLY HIDDEN</div>
//        While doing this, don't forget to choose the correct toggle icon.
//
function ToggleIco(obj, imageid) {
  var img = document.getElementById(imageid)
  var disp = Toggle(obj);
  img.src = (disp == 'none') ? showimg : hideimg;
}

// Toggle the visibility of multiple objects.
// Usage: onclick="ToggleMulti('ID1', 'ID2', 'ID3', ...);"
//
function ToggleMulti() {
  for ( var i=0; i < arguments.length; i++ ) {
    $(arguments[i]).style.display = ($(arguments[i]).style.display != 'none' ? 'none' : '' );
  }
}

// Toggle the visibility of a single object and flip its toggle icon.
// Usage: onclick="Toggle('iconID', 'object1_ID', 'object2_ID', 'object3_ID', ...);"
//        The master icon must be the 1st argument!
//		  The name of the Icon must be formed by appending "Ico" to name of the toggled object, like myObjIco.
//
function ToggleMultiIco() {
  var allico = $(arguments[0]);																	// "All On-Off" icon - first arg

  if (allico.src.indexOf('hide.gif') != -1) {	// "-" is displayed	
    allico.src = showimg;						// show icon that tells what WILL happen if you click it
    disp = 'none';								// hide
  } else {										// "+" is displayed
    allico.src = hideimg;
    disp = '';									// show
  }

  for ( var i=1; i < arguments.length; i++ ) {			// go over objects to toggle
    $(arguments[i]).style.display = disp;				// toggle visibility
    icoid = $(arguments[i]).id + 'Ico';					// append "Ico" to object name					
    document.getElementById(icoid).src = allico.src;	// set all icons to match the All icon
  }
}
//==============
// END VISIBILITY
//==============



// eof
