//-- 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 The Log Connection.\n Please 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 viewEndSourceOLD(){
    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();
}


function viewEndSource(){
    ven = window.open('','_blank');
    var results =document.documentElement.innerHTML;
    ven.document.write("<html>");
    ven.document.write(results);
    ven.document.write("<\/html>");
    ven.document.close();
}

/***********************************************
* Drag and Drop Script: © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
//-- CALL THIS TO USE DRAGGING IN A PAGE:
//dragobject.initialize()

var dragobject={
z: 0, x: 0, y: 0, offsetx : null, offsety : null, targetobj : null, dragapproved : 0,
initialize:function(){
document.onmousedown=this.drag
document.onmouseup=function(){this.dragapproved=0}
},
drag:function(e){
var evtobj=window.event? window.event : e
this.targetobj=window.event? event.srcElement : e.target
if (this.targetobj.className=="drag"){
this.dragapproved=1
if (isNaN(parseInt(this.targetobj.style.left))){this.targetobj.style.left=0}
if (isNaN(parseInt(this.targetobj.style.top))){this.targetobj.style.top=0}
this.offsetx=parseInt(this.targetobj.style.left)
this.offsety=parseInt(this.targetobj.style.top)
this.x=evtobj.clientX
this.y=evtobj.clientY
if (evtobj.preventDefault)
evtobj.preventDefault()
document.onmousemove=dragobject.moveit
}
},
moveit:function(e){
var evtobj=window.event? window.event : e
if (this.dragapproved==1){
this.targetobj.style.left=this.offsetx+evtobj.clientX-this.x+"px"
this.targetobj.style.top=this.offsety+evtobj.clientY-this.y+"px"
return false
}
}
}
//-- CALL THIS TO USE DRAGGING IN A PAGE:
//dragobject.initialize()


// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() {
return window.innerWidth != null? 
window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       
document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
} 
function pageHeight() {
return  window.innerHeight != null?
 window.innerHeight : document.documentElement && document.documentElement.clientHeight ?
   document.documentElement.clientHeight : document.body != null? 
   document.body.clientHeight : null;
} 
function posLeft() {
return typeof window.pageXOffset != 'undefined' ? 
window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? 
document.documentElement.scrollLeft : document.body.scrollLeft ? 
document.body.scrollLeft : 0;
} 
function posTop() {
return typeof window.pageYOffset != 'undefined' ?
  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ?
   document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
   } 
function posRight() {
return posLeft()+pageWidth();
} 
function posBottom() {
return posTop()+pageHeight();
}
                    
document.getElementsByClass = function(cl) {
    var retnode = [];
    var myclass = new RegExp('\\b'+cl+'\\b');
    var elem = this.getElementsByTagName('*');
    for (var i = 0; i < elem.length; i++) {
        var classes = elem[i].className;
        if (myclass.test(classes)) retnode.push(elem[i]);
    }
    return retnode;
};
