// General scripts and functions

// for jquery functions
$(document).ready(function() {
  $('.login').hide();
  $('div.mainContent > div.expand').hide();
  $('div.insideTwo > ul.expand').hide();
  $('div.community > ul').show();
 
 // shows the login box on clicking the noted link 
  $('a#loginShow').click(function() {
    $('.login').slideDown('fast');
    return false;
  });
 
 // hides the login box on clicking the noted link 
  $('a#loginHide').click(function() {
    $('.login').slideUp('fast');
    return false;
  });
  
  // allows content to expand
  $('div.mainContent > h3.drop').click(function() {
	$(this).toggleClass('opened').next().slideToggle('fast');
  });
  
  $('div.insideTwo > h4.drop').click(function() {
  	$(this).toggleClass('h4opened').next().slideToggle('fast');
  	
  });

});

//	Added 03.24.08
//	Scott Crutcher
//	Page: Global - Sidebar navigation
// ----------------------------------------//

function ShowDiv(vDiv) {
	if (document.getElementById('' + vDiv + '').style.display=='block') {
		document.getElementById('' + vDiv + '').style.display='none'
	} else {
		document.getElementById('' + vDiv + '').style.display='block'
	}
}

//	Added 03.24.08
//	Scott Crutcher
//	Page: Take the Challenge
// ----------------------------------------//

function ShowChalQ(vDiv) {
	// hide the triggers for each category
	document.getElementById('qtravel').style.display='none'
	document.getElementById('qrelationships').style.display='none'
	document.getElementById('qpersonal').style.display='none'
	document.getElementById('qcareer').style.display='none'
	document.getElementById('qlifestyle').style.display='none'
	document.getElementById('qadventure').style.display='none'
	// show the category selected
	document.getElementById('' + vDiv + '').style.display='block'
}

//	Added 03.25.08
//	Scott Crutcher
//	Page: Home - CAC module
// ----------------------------------------//

function ShowStep(vStep) {
	// hide the steps
	document.getElementById('stepOne').className='stepClosed'
		document.getElementById('stepOneContent').style.display='none'
		document.getElementById('stepOneForm').style.display='none'

	document.getElementById('stepTwo').className='stepClosed'
		document.getElementById('stepTwoContent').style.display='none'

	document.getElementById('stepThree').className='stepClosed'
		document.getElementById('stepThreeContent').style.display='none'

	// show the category selected
	document.getElementById('' + vStep + '').className='stepOpen'
		document.getElementById('' + vStep + 'Content').style.display='block'
		// show the form if they click step one
		if (document.getElementById('stepOne').className=='stepOpen') {
			document.getElementById('stepOneForm').style.display='block'
		}
}

//	Added 04.30.08
//	Scott Crutcher
//	Page: Member - Celebrate
// ----------------------------------------//

maxL=100;
function taLimit(taObj) {
	if (taObj.value.length==maxL) return false;
	return true;
}

function taCount(taObj,Cnt) { 
	objCnt=createObject(Cnt);
	objVal=taObj.value;
	if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
	if (objCnt) objCnt.innerText=maxL-objVal.length;
	return true;
}
function createObject(objId) {
	if (document.getElementById) return document.getElementById(objId);
	else if (document.layers) return eval("document." + objId);
	else if (document.all) return eval("document.all." + objId);
	else return eval("document." + objId);
}

function ShowWC(vDiv) {
	document.getElementById('' + vDiv + '').style.display='block'
}


//Sets height of entire window - including scrollbar content
//Then opens up Disable Form DIV - or hides it if its already open
function initDisableDiv() {            
    //var vHeight = document.body.style.height = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight) + "px";
    
    var myHeight = 0, myScrollHeight = 0, divHeight = 0;

    //Get Height with Scroll
    myScrollHeight = document.body.style.height = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);

    //Calc Height without Scroll
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible			
        myHeight = document.body.clientHeight;
    }

    //Set Div Height to Larger Number
    if (parseInt(myHeight) > parseInt(myScrollHeight)) {
        divHeight = myHeight + "px";
    }
    else {
        divHeight = myScrollHeight + "px";
    }    
    
    document.getElementById('divDisableForm').style.height=divHeight;            
    ShowDiv('divDisableForm'); 
} 

//Refreshes Parent Window from Popup
var sURL = unescape(window.location.href);
function childClose() {			
	window.focus();		
	window.location.href = sURL;			
}

//Opens popup with specific attributes
function OpenGenericWindow(vUrl, vWindowName) {			
	window.open('' + vUrl + '', '' + vWindowName + '', 'toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=yes, scrollbars=yes, width=100, height=100, top=25, left=25');
}    

//Resize Popup Window
function resizePage(w, h) {
    
    if (w=='') {
        return;
    }
    
    if (h=='') {
        return;
    }
    
    if (parseInt(navigator.appVersion)>3) {
        if (navigator.appName=="Netscape") {
            top.outerWidth=w;
            top.outerHeight=h;
        }
    else 
        top.resizeTo(w,h);
    }
}   