/*
//  Created by James Collin Yeadon of 3Marketeers
//
//  This is the quick and dirty way to append the borders.  This method will make any JavaScript expert 
//  scream bloody murder but it gets the job done.  And frankly, the way it 'should' be done would only
//  increase the size of this js file. (much like my unhelpful comments)
//
*/
	var shtml1='<'+'span class="shadowT"><'+'span class="shadowB"><'+'span class="shadowL"><'+'span class="shadowR"><'+'span class="shadowBL"><'+'span class="shadowBR"><'+'span class="shadowTL"><'+'span class="shadowTR">';
	var shtml2='<'+'/span><'+'/span><'+'/span><'+'/span><'+'/span><'+'/span><'+'/span><'+'/span>';
/*
//  This function simply applys the variables packed with html that we defined above.  It cycles
//  through all of the DIV elements looking for the class imageBorder.
*/
	var blnBordersWrapped = false;
	function WrapImageBorder() {	
		if (blnBordersWrapped == true){return false};
		blnBordersWrapped = true;
		if(!document.getElementById || !document.createElement)	return(false);
		var elements=document.getElementsByTagName("div");
		var ecount=elements.length;
		for ( i=0; i < ecount; i++){
			var ele=elements[i];
			if (ele.className == 'whiteBorder'){
				ele.innerHTML = shtml1+ele.innerHTML+shtml2;
			}
		}
		/*
		// create CSS element to set up the page
		*/
			var css = document.createElement("link");
			css.setAttribute("href","/gfx/simpleBorder.css");
			css.setAttribute("rel","stylesheet");
			css.setAttribute("type","text/css");
		/*
		// attempt to add the css and then keep trying till we do
		*/
			setCSS(css);
	}

function setCSS(css) {
	try {
		/*
		// append stylesheet to alter
		*/
		document.getElementsByTagName("head")[0].appendChild(css);
	} catch (e) {
		setTimeout(function(){setCSS(css)}, 100);
	}
}

/*
//  This is an elegant way to capture the onload and other events.
*/
/*if(window.attachEvent){
	window.attachEvent("onload", WrapImageBorder);
} else {
	if(typeof window.onload == "function"){
		var fOld = window.onload;
		window.onload = function(){ fOld(); WrapImageBorder(); };
	} else {
		window.onload = WrapImageBorder;
	};
};*/

/*
// FUNCTIONS FOR FOOTER LOGIN
*/
/* function showLogin(lid){
	var obQuote = document.getElementById('randomQuote');
	var obLogin = document.getElementById('login_client');
	var obLogin2 = document.getElementById('login_client2');
	var obLink =  document.getElementById('login_link');
	var obLink2 =  document.getElementById('login_link2');

	if (lid==1) {
		if (obLogin.style.display != 'block'){
			obQuote.style.display = 'none';
			obLogin.style.display = 'block';
			obLink.style.fontWeight='bold';
			obLogin2.style.display = 'none';
			obLink2.style.fontWeight='normal';
			document.forms.login_form.p_userid.focus();
		} else {
			hideLogin(1);
		}
	} else {
		if (obLogin2.style.display != 'block'){
			obQuote.style.display = 'none';
			obLogin.style.display = 'none';
			obLink.style.fontWeight='normal';
			obLogin2.style.display = 'block';
			obLink2.style.fontWeight='bold';
		} else {
			hideLogin();
		}
	}
}
function hideLogin(){
	var obQuote = document.getElementById('randomQuote');
	var obLogin = document.getElementById('login_client');
	var obLogin2 = document.getElementById('login_client2');
	var obLink =  document.getElementById('login_link');
	var obLink2 =  document.getElementById('login_link2');
	
	obQuote.style.display = 'block';
	obLogin.style.display = 'none';
	obLink.style.fontWeight='normal';
	obLogin2.style.display = 'none';
	obLink2.style.fontWeight='normal';
} */


/*
// FUNCTIONS FOR DIV RESIZING
*/
function autoSize(idPrefix, blnHeight){
/*
// Function created by James Collin Yeadon
//
// USAGE;  autoSize('prefix',true);
*/
	var iMax = 0;
	var iHeightMax = 0;
	var obj;
	if (document.getElementById(idPrefix +'_0')==null) {
		/*
		// idPrefix doesn't exist
		*/
		return false;
	} else {
		if (blnHeight == true || blnHeight==null ){
			while (document.getElementById(idPrefix +'_'+ iMax) != null){
				obj = document.getElementById(idPrefix +'_'+ iMax);
				if (obj.offsetHeight > iHeightMax){
					iHeightMax = obj.offsetHeight;
				}
				iMax++
			}  
			if (iHeightMax > 0){
				/*
				// Set height of obj to highest value.
				*/
				for (i=0; i < iMax; i++){
					obj = document.getElementById(idPrefix +'_'+ i);
					obj.style.height = iHeightMax+'px';
				}
			}
		}
		/*
		// Success, exit.
		*/
		return iMax;
	}
}

/*
// Functions to be run.  
// Make sure this JS file is included directly above the closing body tag.
*/
WrapImageBorder();
autoSize('autosizeH', true);