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 showHide(imgObj, containerId) {
	if ( !imgObj ) return;
	if ( !containerId ) return;
	
	sImgSrc = imgObj.src;
	if ( sImgSrc.indexOf("plus") > 0 ) {
		imgObj.src = sImgSrc.replace('plus', 'minus');
	}
	else if ( sImgSrc.indexOf("minus") > 0 ) {
		imgObj.src = sImgSrc.replace('minus', 'plus');
	}

	oContainer = new getObj(containerId);
	if ( !oContainer ) return;
	sDisplay = oContainer.obj.style.display;
	if ( sDisplay != 'none' ) 
		oContainer.obj.style.display = 'none';
	else 
		oContainer.obj.style.display = 'block';
}




















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 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 ) {	
		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 || !oImage )
			return false;
			
		if( oBoxStyle.display != 'block' ) { //box closed - open it
			oBoxStyle.display = 'block';
			oFooterStyle.display = 'none';
			oImage.src = _globalPathRoot + 'images/icons/btn_minus.gif';
    }
		else { //box opened - close it
			oBoxStyle.display = 'none';
			oFooterStyle.display = 'block';
			oImage.src = _globalPathRoot + 'images/icons/btn_plus.gif';
		}
		
		//call the resize function each time when the box closes/opens
		resizeContent(origSize);
		adjustBoxes();
		
		//-- fix for the flickering problem, absolute positioning
		//-- affected boxes: Weather -> 7, News -> 8, Ads Home -> 20
		if( subNum == 20 ) {
			adjustSeparator();
		}
		else if( subNum == 7 ) {

			oSeparator = new getObj('iframeSeparator');
			oSeparator.obj.style.margin = '0px';
			oSeparator.obj.style.display = 'none';

		}
		else if( subNum == 8 ) {
		}
		
}
	*/
	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;
	}

function setStyles(object) {
	object.T_BGCOLOR='#0E7982';
	object.T_BORDERWIDTH=0;
	object.T_FONTCOLOR='#C5F3F6';
	object.T_OFFSETX=-20;
	object.T_OFFSETY=20;
	object.T_FONTFACE="arial,helvetica,sans";
	object.T_FONTSIZE="11px";
	object.T_WIDTH = "150px";
	object.T_OPACITY = 85;
	object.T_PADDING = 3;
	object.T_TEXTALIGN='center';
}

function dateChanged(calendar) {
  if (calendar.dateClicked) {
    var y = calendar.date.getFullYear();
    var m = calendar.date.getMonth() + 1;     	// integer, 1..12
    m = ( m < 10 ) ? '0' + m : m;
		var d = calendar.date.getDate();      			// integer, 1..31
    d = ( d < 10 ) ? '0' + d : d;

    window.location = _globalPathRoot + 'events.php?ds=' + y + '-' + m + '-' + d;
  }
}

//--not used
function initAds() {return;
	iframe = document.getElementsByTagName("iframe");
	iframeSize = iframe[0].offsetHeight;
	oSeparator = new getObj('iframeSeparator');
	oSeparator.obj.style.marginTop = (iframeSize + 9) + 'px';
}

//--not used
function adjustSeparator() {return;
	oB = new getObj('sub20');
	oBoxStyle = oB.obj.style;

	if( oBoxStyle.display != 'block' ) { //ads has closed
		oSeparator = new getObj('iframeSeparator');
		oSeparator.obj.style.margin = '0px';
		oSeparator.obj.style.display = 'none';
	}
	else { //ads has opened
		iframe = document.getElementsByTagName("iframe");
		iframeSize = iframe[0].offsetHeight; 
		oSeparator = new getObj('iframeSeparator');
		oSeparator.obj.style.display = 'block';
		oSeparator.obj.style.marginTop = (iframeSize + 9) + 'px';
	}
}


