function showPanel(id){
	var disp;
	var openID;
	var hideVar;
	disp = 0;
	hideVar = 0;
	if(id == 'subnav'){
		openID = 'minfo';
		hideVar = 1;
	}else if(id == 'subnav2'){
		openID = 'finfo';
		hideVar = 1;
	}else if(id == 'subnav3'){
		openID = 'sinfo';
		hideVar = 1;
	}else if(id == 'subnav4'){
		openID = 'hinfo';
		hideVar = 1;
	}else if(id == 'subnav5'){
		openID = 'rssinfo';
		hideVar = 1;
	}else if(id == 'subnav6'){
		openID = 'nlinfo';
		hideVar = 1;
	}
//	alert(id);
	if(document.getElementById(id).style.display == "block"){
		document.getElementById(id).style.display = "none";
		disp = 1;
	}
	hidePanels(hideVar);
	if((document.getElementById(id).style.display == "none") && (disp == 0)){
		document.getElementById(id).style.display = "block";
		if(hideVar == 1){
			if(openID == 'minfo'){
				document.getElementById('sub1').className = 'subOpen';
//				document.getElementById('sub1').style.color = '#FFCC00';
			}else if(openID == 'nlinfo'){
				document.getElementById('sub6').className = 'subOpen';
//				document.getElementById('sub2').style.color = '#FFCC00';
			}else if(openID == 'finfo'){
				document.getElementById('sub2').className = 'subOpen';
//				document.getElementById('sub2').style.color = '#FFCC00';
//			}else if(openID == 'sinfo'){
//				document.getElementById('sub3').className = 'subOpen';
//				document.getElementById('sub3').style.color = '#FFCC00';
			}else if(openID == 'hinfo'){
				document.getElementById('sub4').className = 'subOpen';
//				document.getElementById('sub4').style.color = '#FFCC00';
			}else if(openID == 'rssinfo'){
				document.getElementById('sub5').className = 'subOpen';
//				document.getElementById('sub5').style.color = '#FFCC00';
			}
		}
	}
	if(hideVar > 0){
		document.getElementById(openID).style.height = "auto";
		document.getElementById(id).style.marginTop = "4px";
	}
}

function hidePanels(hid){
	if(hid > 0){
		if(document.getElementById('subnav') != null){
			document.getElementById('subnav').style.display = "none";
		}
		if(document.getElementById('subnav2') != null){
			document.getElementById('subnav2').style.display = "none";
		}
//		document.getElementById('subnav3').style.display = "none";
		if(document.getElementById('subnav4') != null){
			document.getElementById('subnav4').style.display = "none";
		}
		if(document.getElementById('subnav5') != null){
			document.getElementById('subnav5').style.display = "none";
		}
		if(document.getElementById('subnav6') != null){
			document.getElementById('subnav6').style.display = "none";
		}
		if(document.getElementById('sub1') != null){
			document.getElementById('sub1').className = 'subClose';
		}
		if(document.getElementById('sub2') != null){
			document.getElementById('sub2').className = 'subClose';
		}
//		document.getElementById('sub3').className = 'subClose';
		if(document.getElementById('sub4') != null){
			document.getElementById('sub4').className = 'subClose';
		}
		if(document.getElementById('sub5') != null){
			document.getElementById('sub5').className = 'subClose';
		}
		if(document.getElementById('sub6') != null){
			document.getElementById('sub6').className = 'subClose';
		}
/*
		document.getElementById('sub1').style.color = '#FFFFFF';
		document.getElementById('sub2').style.color = '#FFFFFF';
		document.getElementById('sub3').style.color = '#FFFFFF';
		document.getElementById('sub4').style.color = '#FFFFFF';
		document.getElementById('sub5').style.color = '#FFFFFF';
*/
	}else{
		document.getElementById('bookaroom').style.display = "none";
		document.getElementById('bookashow').style.display = "none";
	}
}

function evenUpDivs(ad) {
	if(ad == 1){
		var col1 = document.getElementById("news-items").offsetHeight;
		/* alert('ads col1: ' + col1); */
		var col2 = document.getElementById("features").offsetHeight;
		/* alert('ads col2: ' + col2); */
		var col3 = document.getElementById("rt-int-col-ads").offsetHeight + 224;
		/* alert('ads col3: ' + col3); */
		var newHt = col1;
		/* alert('ads newHt: ' + newHt); */
		if(col2 > newHt){
			newHt = col2;
		}
		if(col3 > newHt){
			newHt = col3;
		}
		document.getElementById("news-items").style.height = String(490) + "px";
		document.getElementById("features").style.height = String(490) + "px";
		document.getElementById("rt-int-col-ads").style.height = String(newHt - 224) + "px";
	}else{
		var col1 = document.getElementById("news-items").offsetHeight;
		/* alert('col1: ' + col1); */
		var col2 = document.getElementById("features").offsetHeight;
		/* alert('col2: ' + col2); */
		var col3 = document.getElementById("blogs").offsetHeight;
		/* alert('col3: ' + col3); */
		var col4 = document.getElementById("rt-int-col-ads").offsetHeight;
		/* alert('col4: ' + col4); */
		var modHt = 0;
		var newHt = col1;
		/* alert('newHt: ' + newHt); */
		if(col2 > newHt){
			newHt = col2;
			/* alert('col2!'); */
		}
		if(col3 > newHt){
			newHt = col3;
			/* alert('col3!'); */
		}
		if(col4 > newHt){
			newHt = col4;
			/* alert('col4!'); */
		}
		document.getElementById("news-items").style.height = String(newHt) + "px";
		document.getElementById("features").style.height = String(newHt) + "px";
		document.getElementById("blogs").style.height = String(newHt - 4) + "px";
		document.setElementById("rt-int-col-ads").style.height = String(newHt) + "px";
	}
}

function pushBooka() {
	var con1 = document.getElementById("content");
	var conHt = con1.offsetHeight;

	if(conHt < 450){
		totHt = 450;
		con1.style.height = String(totHt) + "px";
	}
}

function pushBooka2() {
	var con1 = document.getElementById("content");
	var conHt = con1.offsetHeight;
	var qodR = document.getElementById("qodresults").offsetHeight;
	totHt = 150;
	con1.style.height = String(qodR + totHt) + "px";
}

function emailCheck (emailStr) {
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null) {
		alert("Invalid email address. Please check it and try again.");
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			alert("Invalid email address. Please check it and try again.");
			return false;
		}
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			alert("Invalid email address. Please check it and try again.");
			return false;
		}
	}
	if (user.match(userPat)==null) {
		alert("Invalid email address. Please check it and try again.");
		return false;
	}
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				alert("Invalid email address. Please check it and try again.");
				return false;
			}
		}
		return true;
	}
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			alert("Invalid email address. Please check it and try again.");
			return false;
		}
	}
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
		alert("Invalid email address. Please check it and try again.");
		return false;
	}
	if (len<2) {
		alert("Invalid email address. Please check it and try again.");
		return false;
	}
	return true;
}

function ratingChk(rt,sn,co,ca,eml){
	if(rt == ''){
		alert('Please select a rating.');
		return false;
	}
	if(sn == ''){
		alert('You must supply a User Name.');
		return false;
	}
	if(sn.length < 6){
		alert('Your screenname must be at least 6 characters long.');
		return false;
	}
	if(ca == ''){
	  alert('You must enter the captcha text.');
		return false;
	}
	if(ca.length < 1){
		alert('You must enter in the text that is displayed in the image.');
		return false;
	}
	if(co == ''){
		alert('You must enter a comment.');
		return false;
	}
	if(co.length < 10){
		alert('Your comment must be at least 10 characters long.');
		return false;
	}
	if(emailCheck(eml) == true){
	}else{
		return false;
	}
	return true;
}

function suggestionChk(co,ca,eml){
	if(ca == ''){
	  alert('You must enter the captcha text.');
		return false;
	}
	if(ca.length < 1){
		alert('You must enter in the text that is displayed in the image.');
		return false;
	}
	if(co == ''){
		alert('You must enter a suggestion.');
		return false;
	}
	if(emailCheck(eml) == true){
	}else{
		return false;
	}
	return true;
}

function contactChk(se,s,m){
	if(emailCheck(se) == true){
	}else{
		return false;
	}
	if(s == ''){
		alert('You must enter a subject.');
		return false;
	}
	if(m == ''){
		alert('You must enter a message.');
		return false;
	}
	if(m.length < 20){
		alert('Your message must be at least 20 characters long.');
		return false;
	}
	return true;
}

function openFull(p,n) {
	var r   = null;
	r = window.open(p,n,'width='+screen.width+',height='+screen.height+',top='+0+',left='+0+','+'fullscreen=yes,scrollbars=no,toolbar=no,location=no,status=no,menubar=no,resizable=yes,dependent=no');
	if(r!=null && window.focus) r.window.focus();
}

function chkBrowser(){
	/*
	var browserName=navigator.appName;
	var browserVer=navigator.appVersion;
	var is6 = browserVer.search(/MSIE 6/i);
	*/
	var nVer = navigator.appVersion;
	var nAgt = navigator.userAgent;
	var is6 = nAgt.indexOf("MSIE 6");
	return is6;
}

function updateBooka(fld1,fld2){
	var firForm = document.frmBookShow[fld1];
	var secForm = document.frmBookShow[fld2];
	secForm.selectedIndex = firForm.selectedIndex;
}

function showForumNav() {
	var browser = chkBrowser();
	if(browser >= 1){
		if(chkObject(false,'navdropdown')){
			document.getElementById('navdropdown').style.display='inline';
			document.getElementById('navdropdown').style.visibility='visible';
		}
	}
}

function hideForumNav() {
	var browser = chkBrowser();
	if(browser >= 1){
		if(chkObject(false,'navdropdown')){
			document.getElementById('navdropdown').style.display='none';
			document.getElementById('navdropdown').style.visibility='hidden';
		}
	}
}

function chkObject(inParent,theVal) {
	if(inParent){
		if(window.opener.document.getElementById(theVal) != null){
			return true;
		}else{
			return false;
		}
	}else{
		if(document.getElementById(theVal) != null){
			return true;
		}else{
			return false;
		}
	}
}

function initAllJS(cpv,menu,hp,sp,eud,euda,pb,lb,eb,pp,fu,tn){
	if(tn > 0){
		var navID = 'tnsubnav' + tn;
		var navLnk = 'tnnav' + tn;
		showSubNav(navID,navLnk);
	}
	if(lb == 1){
		initLightbox();
	}
	if(menu == 1){
		P7_ExpMenu();
	}
	if(hp == 1){
		hidePanels('1');
	}
	if(sp != ""){
		showPanel(sp);
	}
	if(eud == 1){
		evenUpDivs(euda);
	}
	if(pb == 1){
		//pushBooka();
	}
	if(eb == 1){
		extendBio();
	}
	if(pp == 1){
		/* setTimeout("pushPools()",500); */
	}
	if(fu == 1){
		showTab('upload');
	}
	if(cpv == 1){
		createPlayer();
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function setColor(name, value, page, qrystr) {
	createCookie(name,value,1000);
/*
	var cookie_string = name + "=" + escape(value) + "; path=/";
	document.cookie = cookie_string;
*/
	if(qrystr != ''){
		page = page + '?' + qrystr;
	}
	var browser = chkBrowser();
  if(browser != -1){
		window.parent.location.reload(true);
	}else{
		document.location.href = page;
	}
/*
		window.location.reload();
*/
}

function setVisit(ip){
	createCookie('visited',ip,1000);
}

function showTab(id){
	if(document.getElementById('videoplayer') != null){
		if(document.getElementById('videoplayer').style.display == "block"){
			sendEvent('audioP','stop');
		}
	}
	if(document.getElementById(id).style.display == "block"){
		document.getElementById(id).style.display = "none";
	}
	hideTabs();
	if(document.getElementById(id).style.display == "none"){
		document.getElementById(id).style.display = "block";
		if(id == 'videoplayer'){
			document.getElementById('goback').style.display = "block";
		}
	}
}

function showTitle(title){
	document.getElementById('videotitle').innerHTML = '"' + title + '"';
}

function pushPools(isS){
	box = document.getElementById('legendbox').offsetHeight;
	document.getElementById('bigpoolwrap').style.height = String(box + 20) + "px";
}

function sendEvent(swf,typ,prm) { 
	thisMovie(swf).sendEvent(typ,prm); 
};
function getUpdate(typ,pr1,pr2,swf) {};
function thisMovie(swf) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[swf];
	} else {
		return document[swf];
	}
};

function loadFile(swf,obj,title){
	showTab('videoplayer');
	showTitle(title);
	//setTimeout("thisMovie('" + swf + "').loadFile(" + obj + ")",3000);
	setTimeout("thisMovie('audioP').loadFile({file:'/flashvideo/coolpools/Grand-Opening-of-Ditch-Fridays-at-the-Palms-Pool.flv'})",3000);
};
		
function thisMovie(movieName){
	if(navigator.appName.indexOf('Microsoft') != -1){
		return window[movieName];
	}else{
		return document[movieName];
	}
};

function createPlayer(){
	var so = new SWFObject('/flashplayer/mediaplayer.swf', 'audioP', '444', '240', '8');
			so.addParam('allowscriptaccess',      'always');
			so.addParam('allowfullscreen',        'true');
			so.addVariable('width',               '444');
			so.addVariable('height',              '240');
			//so.addVariable('file',                '/flashvideo/coolpools/Grand-Opening-of-Ditch-Fridays-at-the-Palms-Pool.flv');
			so.addVariable('backcolor',           '0x112200');
			so.addVariable('frontcolor',          '0xffffff');
			so.addVariable('lightcolor',          '0x990099');
			so.addVariable('enablejs',            'true');
			so.addVariable('javascriptid',        'audioP');
			so.addVariable('shownavigation',      'false');
			so.addVariable('showstop',            'true');
			so.addVariable('showdigits',          'false');
			so.write('videoplayer');
};



function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		ro = new XMLHttpRequest();
	}
	return ro;
}
var http = createRequestObject();

function sndReq(div,action,param,callpg,pgNum){
	//alert('cpl: ' + callpg.length);
	if(callpg.length <= 0){
		callpg = 'ajaxrequest';
	}
	//alert('pnl: ' + pgNum.length);
	if((!pgNum) || (pgNum.length <= 0)){
		var pgNum = 1;
	}
	//alert(callpg+'.cfm?div='+div+'&action='+action+'&param='+param+'&pg='+pgNum);
	http.open('get', callpg+'.cfm?div='+div+'&action='+action+'&param='+param+'&pg='+pgNum);
	http.onreadystatechange = handleResponse;
	http.send(null);
	if(pgNum > 1){
		window.location.hash="top";
	}
}

function showLoad(div){
	//alert(div);
	offSet1 = 350;
	offSet2 = 330;
	
	document.getElementById(div).innerHTML = '<img src="/CFIDE/scripts/ajax/resources/cf/images/loading.gif" align="absmiddle"> <b>LOADING...</b>';
	var tmpHt = document.getElementById('content').offsetHeight;
	document.getElementById('content').style.height = String(tmpHt + offSet1) + "px";
	document.getElementById('qodresults').style.height = String(tmpHt + offSet2) + "px";
	document.getElementById('qodresults').style.paddingBottom = "225px";
	document.getElementById('content').style.paddingBottom = "225px";
}

function handleResponse(){
	if(http.readyState == 4){
		var response = http.responseText;
		var update = new Array();
		if(response.indexOf('|' != -1)) {
			update = response.split('|');
			if((update[0] == 'errUNameRegPg') && (update.length > 2)){
				document.getElementById('rowunamesuggest').style.display = "block";
				sndReq('unamesuggest','sugUName',update[2],'goajax','');
			}
			document.getElementById(update[0]).innerHTML = update[1];
			if(update[0] == 'qodarticle'){
				coHt = document.getElementById('content').offsetHeight - 550;
				qod = document.getElementById('qodarticle').offsetHeight;
				var offSet1 = 650;
				var offSet2 = 630;
				var offSet3 = 610;
				var nVer = navigator.appVersion;
				var nAgt = navigator.userAgent;
				var verOffset = nAgt.indexOf("Firefox");
				if(verOffset != -1){
					offSet1 = 550;
					offSet2 = 530;
					offSet3 = 510;
				}
				document.getElementById('content').style.height = String(qod + offSet1) + "px";
				document.getElementById('qodresults').style.height = String(qod + offSet2) + "px";
				document.getElementById('qodarticle').style.overflow = "visible";
				document.getElementById('qodarticle').style.height = "100%";
				document.getElementById('qodarticle').style.paddingBottom = "225px";
				if(verOffset != -1){
					if(document.getElementById('qodarticle').offsetHeight < offSet3){
						document.getElementById('qodarticle').style.height = String(qod + offSet3) + "px";
					}
//					pushBooka2();
				}
			}
		}
	}
}

function clearMssg(div){
	document.getElementById(div).innerHTML = '';
}

function chkFileUpl(){
	if((document.uplPhoto.submittedby.value == '') && (document.uplPhoto.owner.value == 0)){
		alert('You must enter your name.');
		document.uplPhoto.submittedby.select();
		document.uplPhoto.submittedby.focus();
		return false;
	}
	if(document.uplPhoto.title.value == ''){
		alert('You must enter a title.');
		document.uplPhoto.title.select();
		document.uplPhoto.title.focus();
		return false;
	}
	if(document.uplPhoto.filename.value == ''){
		alert('You must upload a file.');
		document.uplPhoto.filename.select();
		document.uplPhoto.filename.focus();
		return false;
	}
	return true;
}

function confirmDel(type){
	 if(confirm('Are you sure you want to delete this ' + type + '?')){
		 return true;
	 }else{
		 return false;
	 }
}

function showSubNav(id,lnk){
	if(id != 'tnsubnav0'){
		var disp = 0;
		if(document.getElementById(id).style.display == "block"){
			document.getElementById(id).style.display = "none";
			document.getElementById(lnk).className = 'mainlink';
			disp = 1;
		}
		hideSubNav();
		if((document.getElementById(id).style.display == "none") && (disp == 0)){
			document.getElementById(id).style.display = "block";
			document.getElementById(lnk).className = 'mainlinkon';
		}
	}
}

function hideSubNav(){
	for(var x=1; x<9; x++){
		var tnID = 'tnsubnav';
		tnID = tnID + x;
		document.getElementById(tnID).style.display = "none";
	}
	for(var i=1; i<9; i++){
		var tnLnk = 'tnnav';
		tnLnk = tnLnk + i;
		document.getElementById(tnLnk).className = 'mainlink';
	}
}

function tocWin(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}
