/*
activateActiveX
---------------
Purpose:  Dynamically replace any elements that will be affected by the new security feature in IE6/IE7 that requires a user to click certain types of elements to activate them before use.

Usage:  Include this file in the <head></head> section of your html document using the following...
	<script language="JScript" type="text/jscript" src="activateActiveX_onload.js"></script>


Since this script is in response to a software patent lawsuit, I feel it necessary to state the following...	

License:
activateActiveX is Copyright (C) 2006 Jason Baker (therippa AT gmail.com). It is available as open source code from:
http://therippa.blogspot.com

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details http://www.gnu.org/licenses/gpl.html
*/

//trap onload event
window.onload = function () {
	//Determine browser, we only need this for Internet Explorer
	if (navigator.appName == "Microsoft Internet Explorer") {
		
		//Array of elements to be replaced
		var arrElements = new Array(3);
		arrElements[0] = "object";
		arrElements[1] = "embed";
		arrElements[2] = "applet";
	
		
		//Loop over element types
		for (n = 0; n < arrElements.length; n++) {
		
			//set object for brevity
			replaceObj = document.getElementsByTagName(arrElements[n]);
			
			//loop over element objects returned
			for (i = 0; i < replaceObj.length; i++ ) {
			
				//set parent object for brevity
				parentObj = replaceObj[i].parentNode;
				
				//grab the html inside of the element before removing it from the DOM
				newHTML = parentObj.innerHTML;
				
				//remove element from the DOM
				parentObj.removeChild(replaceObj[i]);
				
				//stick the element right back in, but as a new object
				parentObj.innerHTML = newHTML;
			
				}
			}
		}
	}
var plugin = 0;
function putInFrame()
	{
	var strPath = location.pathname;
	var strPage = strPath.substring(strPath.lastIndexOf('/') + 1);
	if (top == self)
		self.location.replace('index.htm?p=' + strPage);
	}

function hideError() {
// reload menu
   return true;
}
window.onerror = hideError;
// Get browser version
function detectBrowser()
{
	browserNS4 = (document.layers);
	browserIE4 = (document.all);  
}

// Load the current page into its frame set
function loadMeInFrame()
{	
	detectBrowser();
	var strPathBreak = '/';
	var strPath = location.pathname;
	if ((location.protocol == 'file:') && (browserIE4))
		strPath = strPath.replace(/\x5c/g, strPathBreak);
	var strPage = strPath.substring(strPath.lastIndexOf(strPathBreak) + 1);
	if (top == self)
	    self.location.replace('index.htm?p=' + strPage);
}
// Check the TOC is in the same folder as the page

function checkTOC()
{
return;
}

// Load a selected page
function loadPage(strPath, strPage)
{
	detectBrowser();
	if (strPage == '') strPage = 'main.asp';
	if (browserIE4)
	{
		parent.frames.toc.location.replace(strPath + '/toc.asp');
		parent.frames.main.location.href = strPath + '/' + strPage;
	}
	else
	{	
		parent.frames.toc.location.replace(strPath + '/toc.asp');
		parent.frames.main.location.href = strPath + '/' + strPage;
		
	}
}

// Load a selected page with a bookmark
function loadPageBkm(strPath, strPage, strBkm)
{
	detectBrowser();
	if (strPage == '') strPage = 'main.asp';
	var strPageURL = strPage;
	if (browserIE4)
	{
		if (strBkm != '')
			strPageURL = strPage + '#' + strBkm;
		parent.frames.toc.location.replace(strPath + '/toc.asp');
		parent.frames.main.location.href = strPath + '/' + strPageURL;
	}
	else
	{
		if (strBkm != '')
			strPageURL = 'p=' + strPage + '&b=' + strBkm;
		top.location.replace(strPath + '/index.htm?' + strPageURL);
	}
}


// Set window title to page title
function setWindowTitle()
{
	detectBrowser();
	if (browserIE4)
		top.window.document.title = window.document.title;
}


// Imbed flash image into page
function imbedFlash(strPath, strFlash, nWidth, nHeight, strBgColour)
	{
		isIE = (document.all);
		var strWidth = nWidth.toString();
		var strHeight = nHeight.toString();
		if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)
		{
			if (navigator.plugins && navigator.plugins["Shockwave Flash"])
				plugin = 1;
		}
		else
		if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
		   && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0))
		{
			document.write('<SCRIPT LANGUAGE=VBScript\> \n');
			document.write('on error resume next \n');
			document.write('plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")))\n');
			document.write('if ( plugin <= 0 ) then plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")))\n');
			document.write('if ( plugin <= 0 ) then plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")))\n');
			document.write('</SCRIPT\> \n');
			//plugin = 1;
		}
		if (plugin && isIE)
		{
			document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
			document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=3,0,0,0" ');
			document.write(' ID='+strFlash+' WIDTH='+strWidth+' HEIGHT='+strHeight+'>');
			document.write(' <PARAM NAME=movie VALUE="'+strPath+'/'+strFlash+'.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE='+strBgColour+'> <param name="wmode" value="transparent"> '); 
			document.write(' <EMBED src="'+strPath+'/'+strFlash+'.swf" quality=high bgcolor='+strBgColour+' ');
			document.write(' swLiveConnect=FALSE WIDTH='+strWidth+' HEIGHT='+strHeight+'');
			document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
			document.write(' </EMBED>');
			document.write(' </OBJECT>');
		}
	else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0)){
			document.write('<IMG src="'+strPath+'/'+strFlash+'.gif"  BORDER=0>');
	}
}
// Opens a window for a screen shot or something
	function openWindow(box,boxtitle,boxwidth,boxheight) 
		{
			leftPos=(screen.width-boxwidth)/2;
			topPos=(screen.height-boxheight)/2;
			newWindow=window.open(box,boxtitle,"toolbar=no,scrollbars=yes,Height=" + boxheight + ",Width=" + boxwidth + ",left=" + leftPos + ",top=" + topPos +";");
	
		}
//closes the window that you opened above when you click on the applicable thing
	function closeWindow()
	{
		if(newWindow && !newWindow.closed) 
		{
			newWindow.close()
		}
	}
	
//the print thing that makes the print window open up when you click on print
	var da = (document.all) ? 1 : 0;
	var pr = (window.print) ? 1 : 0;
	var mac = (navigator.userAgent.indexOf("Mac") != -1); 
	function printThis() {
	  if (pr) { // NS4, IE5
		window.print();
	  } else if (da && !mac) { // IE4 (Windows)
		vbPrintPage();
	  } else { // other browsers
		alert("Sorry, your browser doesn't support this feature.");
	  }
	if (da && !pr && !mac) with (document) {
	  writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
	  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
	  writeln('Sub window_onunload');
	  writeln('  On Error Resume Next');
	  writeln('  Set WB = nothing');
	  writeln('End Sub');
	  writeln('Sub vbPrintPage');
	  writeln('  OLECMDID_PRINT = 6');
	  writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
	  writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
	  writeln('  On Error Resume Next');
	  writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
	  writeln('End Sub');
	  writeln('<' + '/SCRIPT>');
	}
	}
// macromedia's image swapping routine.
	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	function MM_findObj(n, d) { //v4.0
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && document.getElementById) x=document.getElementById(n); return x;
	}
	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}

//lana's new change the background colour of the table row thingie 
function cOn(td){
if(document.getElementById||(document.all && !(document.getElementById))){
td.style.backgroundColor="#DDDDDD";
}
}
function cOut(td){
if(document.getElementById||(document.all && !(document.getElementById))){
td.style.backgroundColor="#FFFFFF";
}
}
function cOnclear(td){
if(document.getElementById||(document.all && !(document.getElementById))){
td.style.backgroundColor="#cccccc";
}
}
function cOutclear(td){
if(document.getElementById||(document.all && !(document.getElementById))){
td.style.backgroundColor="";
}
}
//here is a send link function
function sendPage()
{	
var sAddress=window.parent.frames["main"].document.URL;
var daTitle=window.parent.frames["main"].document.title;
var subject = 'You have been sent a link from the ICSA Software website';
var pageOfInterest = 'This web page may be of interest to you:';
var clickOnFollowing= 'Clicking on the following link will take you to this page:';
var lineFeed='\f\n\n';
var TabChr='\t';
var doc = "mailto:"  + "?subject=" + escape(subject) + "&body="  +  escape(pageOfInterest) + escape(lineFeed) + escape(TabChr) + escape(daTitle) + escape(lineFeed) + escape(clickOnFollowing) + escape(lineFeed) + escape(TabChr) + escape(sAddress) + escape(lineFeed);
window.location = doc;
}