//-- TYPICAL IMAGE SWAP
function SwapImgFn (imgname, filename) {
  document.images[imgname].src = filename;
}
//-- PRELOAD IMAGES FUNCTION
function PreloadImages (srcArray) {
    var preload = new Array ();
    for (i in srcArray) {
        preload[i] = new Image();
        preload[i].src = srcArray[i];
    }
}
var preload = new Array();
function PreloadImageList () {
    for (i=0; i<PreloadImageList.arguments.length; i++) {
        preload[i] = new Image();
        preload[i].src = PreloadImageList.arguments[i];
    }
}

//-- STOCK PLAN QUICK MENU
function goPlan(fileName) {
    if (fileName) {
	   window.location.href = "/stockplan_A.php?" + fileName;
	} else {
	  return FALSE;
	}
}

//-- -------------- MENU SETUP AND FUNCTIONS -------------
var menuPrefix = 'menu_tab_div_';    //-- WHITE TABS, HIDDEN 
function MenuOverFn ( num ) {  
		document.getElementById(menuPrefix + String(num)).style.visibility='visible';
}  //--END OnLoadFn
function MenuOutFn ( num ) {  
        document.getElementById(menuPrefix + String(num)).style.visibility='hidden';
}  //--END OnLoadFn

//-- NOTE: STOCKPLAN FLOATER FUNCTIONS: Cell_Over(id) AND cell_Clear(id) ARE IN: stockplan_include_javascriptVars.php


//----------- IMAGE PROTECTION FUNCTIONS --------------------------------------------
var ImageProtectSpecialcase = ((navigator.userAgent.indexOf('Mac') != -1) || document.all)
var ImageProtectFlag = 0;
var ImageProtectMsg = This image is copyrighted by "North House".\n Do not copy it..';
var ImageProtectX,ImageProtectY,ImageProtectX1,ImageProtectY1,ImageProtectCopyAttempt;
function ImageProtectInit() {
	if (!(document.getElementById || document.all || document.layers)) return;
	for (i=0;i<document.images.length;i++) {
		document.images[i].onmousedown = ImageProtectCheckIt;
		document.images[i].onmouseup = function() {return false};
		if (ImageProtectSpecialcase) {
			document.images[i].onmousemove = ImageProtectSpecial;
			document.images[i].onclick = ImageProtectClearIt;
		}
	}
}

function ImageProtectCheckIt(e) {
	ImageProtectCopyAttempt = 0;
	if (window.Event) {
		ImageProtectX = e.screenX;
		ImageProtectY = e.screenY;
		ImageProtectButt = (e.which == 3);
	} else {
		ImageProtectX = window.event.clientX;
		ImageProtectY = window.event.clientY;
		ImageProtectButt = (window.event.button == 2);
	}
	if (ImageProtectButt) {
		ImageProtectCopyAttempt = 1;
		ImageProtectFlag = 0;
		alert(ImageProtectMsg);
		return false; // NN4 only
	}
	if (ImageProtectSpecialcase) ImageProtectFlag = 1;
	return false;
}

function ImageProtectSpecial(e) {
	theObj = '';
	if (window.Event) {
		ImageProtectX1 = e.screenX;
		ImageProtectY1 = e.screenY;
		if (e.target.parentNode) theObj = e.target.parentNode.tagName;
	} else {
		ImageProtectX1 = window.event.clientX;
		ImageProtectY1 = window.event.clientY;
		theObj = window.event.srcElement.parentElement.tagName;
	}
	var isLink = (theObj == 'A');
	if (ImageProtectFlag && (!isLink || ((Math.abs(ImageProtectX-ImageProtectX1) > 10) || (Math.abs(ImageProtectY-ImageProtectY1) > 10))))
	{
		ImageProtectCopyAttempt = 1;
		ImageProtectFlag = 0;
		alert(ImageProtectMsg);
		return false;
	}
}

function ImageProtectClearIt() {
	ImageProtectFlag = 0;
	if (ImageProtectCopyAttempt) {
		ImageProtectCopyAttempt = 0;
		return false;
	}
}

function SetOpacity(theObject, opacity) {
    opacity = (opacity == 100)?99.999:opacity;
      theObject.style.opacity = opacity/100;  // Safari 1.2, newer Firefox and Mozilla, CSS3
      theObject.style.filter = "alpha(opacity=" + opacity + ")";  // IE/Win
      theObject.style.KHTMLOpacity = opacity/100;  // Safari<1.2, Konqueror
      theObject.style.MozOpacity = opacity/100;  // Older Mozilla and Firefox
}

function clearAllTimeouts(){
    for(key in timeOutsArray ){
        clearTimeout(timeOutsArray[key]);
    }//end for
}//end function

//-- GALLERY CELL HIGHLIGHTING FUNCTION -- SHOULD BE CALLED BY body onload="" 
current_cell="";
function SetCell ( cellID, newStyleName, normalStyleName ) {	
	if (!newStyleName) {newStyleName = 'current';}
	if (!normalStyleName) {normalStyleName = 'normal';}
    old_cell = current_cell;
	current_cell = cellID;
	if ( document.getElementById(cellID) ) {
	   theCell = document.getElementById(cellID);
	   theCell.className = newStyleName;
	};
	if ( document.getElementById(old_cell) ) {
	   theCell  = document.getElementById(old_cell);
	   theCell.className = normalStyleName;
	};
}

function EchoArray (arr) {
    var str = "";
    for (i in arr) {
        str += "<b>" + i + ": " + arr[i] + "<br>";
    }
    return str;
}

function viewEndSource(){
    win = window.open('','_blank');
    var results = document.documentElement.innerHTML;
    /*var match = "<";
    var re = new RegExp("<", "g");
    var newresults = results.replace(re, "&lt;");
    win.document.write(newresults );*/
    win.document.write("<html>");
    win.document.write(results );
    win.document.write("<\/html>");
    win.document.close();
}

