function getObj(name) {
	if (document.getElementById) {
		if(document.getElementById(name)) {
			this.obj = document.getElementById(name);
			this.style = document.getElementById(name).style;
		}
	}
	else if (document.all) {
		if(document.all[name]) {
			this.obj = document.all[name];
			this.style = document.all[name].style;
		}
	}
	else if (document.layers) {
		if (document.layers[name]) {
			this.obj = document.layers[name];
			this.style = document.layers[name];
		}
	}
}


function checkLen(target, targetCharsCounter, maxChars) {
	len = target.value.length;
	
	if ( len == 1 && target.value.substring(0, 1) == " " ) {
		target.value = ""; len = 0;
	}
	
	if ( len > maxChars ) {
		target.value = target.value.substring( 0, maxChars );
		charsLeft = 0;
	} else {
		charsLeft = maxChars - len;
	}
	oCounter = new getObj(targetCharsCounter);
	oCounter.obj.value = charsLeft;
}


//------ resizer
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}


function resizeContent(originalSize) {
	if(originalSize == undefined)
		iOriginalSize = null;
	else
		iOriginalSize = originalSize;
		
	//get objects
	oLeftContainer 	= new getObj('container_left');
	oRightContainer = new getObj('container_right');
	oContent 				= new getObj('alt_middle_3');
	
	//test to see if they exist
	if(oLeftContainer.obj && oRightContainer.obj && oContent.obj && oContent.style) {
		//iLeftContainerY		= findPosY(oLeftContainer.obj);
		//iRightContainerY	= findPosY(oRightContainer.obj);
		
		//get sizes
		iOffset							= 20;
		iLeftContainerSize	= oLeftContainer.obj.offsetHeight;
		iRightContainerSize	= oRightContainer.obj.offsetHeight;
		iContentSize 				= oContent.obj.offsetHeight;

		if(iOriginalSize == null)
			iOriginalSize			= iContentSize;
		
		//choose the larger one
		iSize = Math.max(iLeftContainerSize, iRightContainerSize);
		iSize = Math.max(iSize, iOriginalSize);
		
		oContent.style.height = iSize + 'px';
		if(iOriginalSize != null)
			return iOriginalSize;

		return 0;
	}
}


function resizeIndex() {
	oLeft 	= new getObj('middle_middle_1');
	oRight 	= new getObj('middle_middle_3');
	
	iLeftHeight 	= oLeft.obj.offsetHeight;
	iRightHeight 	= oRight.obj.offsetHeight;
	
	iMax = Math.max(iLeftHeight, iRightHeight) + 15;
	
	oLeft.style.height 		= iMax + 'px';
	oRight.style.height 	= iMax + 'px';
}


function bookmarksite(title, url){
	if (document.all)
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "");
}


//used on home page only

function openCommentWin(u) {
	
	html_file = u;
	
		var winl = (screen.width - 500) / 2;
		var wint = (screen.height - 300) / 2;
		winprops = 'height=300,width=500,top='+wint+',left='+winl;

		window.open(html_file,'comment',winprops);


}



function resizeIndex() {
	oLeft 	= new getObj('middle_middle_1');
	oRight 	= new getObj('middle_middle_3');
	
	iLeftHeight 	= oLeft.obj.offsetHeight;
	iRightHeight 	= oRight.obj.offsetHeight;
	
	iMax = Math.max(iLeftHeight, iRightHeight) + 15;
	
	oLeft.style.height 		= iMax + 'px';
	oRight.style.height 	= iMax + 'px';
}
	
	
function getWW() {
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			return window.innerWidth-16;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			return document.body.offsetWidth-20;
		}
	}
}


function popItUp() {
	mywidth = 300;
	myheight = 300;
	myright =	getWW();
	myright -= (25 + mywidth);
	mytop = 10;

	window.open('homepopup.php', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width = ' + mywidth + ',height = ' + myheight + ',left = ' + myright + ',top = ' + mytop);
}
	
	
function showHide( subNum ) {	
//	alert( subNum );
		oB = new getObj('sub' + subNum);
		oBox = oB.obj;
		oBoxStyle = oB.style;
	
		oF = new getObj('foot' + subNum);
		oFooter = oF.obj;
		oFooterStyle = oF.style;
		
		oI = new getObj('img' + subNum);
		oImage = oI.obj;

		if( !oBox || !oFooter )
			return false;
		

			
		if( oBoxStyle.display != 'block' ) { //box closed - open it
			oBoxStyle.display = 'block';
			oFooterStyle.display = 'none';
			//document.control.src='images/home/plus.gif';
			oImage.src =  'images/home/minus.gif';
    }
		else { //box opened - close it
			oBoxStyle.display = 'none';
			oFooterStyle.display = 'block';
			oImage.src = 'images/home/plus.gif';
		}
		
		//call the resize function each time when the box closes/opens
		resizeContent(origSize);
		adjustBoxes();
}
	
	function changeSubmit() {
		oSubmit = new getObj('submitMemberInfoID');
		oAgree = new getObj('agree');
		
		if(oSubmit.obj && oAgree.obj) {
			if(oAgree.obj.value) {
				oSubmit.obj.disabled = false;
			}
			else {
				oSubmit.obj.disabled = true;
			}
		}
		else
			return false;
	}

	function checkSubmit() {
		oSubmit = new getObj('submitMemberInfoID');
		oAgree = new getObj('agree');

		if(oSubmit.obj && oAgree.obj) {
			if(!oAgree.obj.checked) {
				oSubmit.obj.disabled = true;
				alert('You have to read the Terms of Use and Privacy Policy and agree.');
				return false;
			}
			else
				return true;
		}
		else
			return false;
	}
