// ############################################################################
// ##
// ##  ASK AN EXPERT MODULE FUNCTIONS
// ##
// ############################################################################

// No functions at the moment

function slideAnswer(question){

    // Code added to incorporate adjustment of div height as text size is changed.
	var node, i;
	node = document.getElementById('MoreFAQs');
	if (typeof node == 'undefined') {
		node = document.getElementById('TopFAQs');
	}

	var fOffset = 1;
	var t = document.getElementsByTagName("body")[0];
	// alert(t.style.fontSize);
	switch (t.style.fontSize)
	{   case 'xx-small' : fOffset = .7 ; break;
	    case 'x-small': fOffset = .8; break;
	    case 'small': fOffset = 1.1; break;
	    case 'medium': fOffset = 1.35; break;
	    case 'large': fOffset = 1.7; break;
	    case 'x-large': fOffset = 2.6; break;
	    case 'xx-large': fOffset = 4; break;
	}

    // adjust for IE browser's
	if (navigator.appName == "Microsoft Internet Explorer" && fOffset > 1)
    {   fOffset *= 1.1;
	}
	
	// set height of expanding text, based on original heights, multiplied by offset setting
	var answers = getElementsByClassName('answer', node);
	for (i = 0; i < answers.length; i++) {
	    answers[i]._CCVheight = answers[i]._CCVOrigheight * fOffset;
	    // alert(answers[i]._CCVheight);
	    addClass(answers[i], "hideAnswer");
	}


	var answer = question._CCVanswer,
		slideTime = 1000, //1 second
		currentHeight = 0,
		onshow = question._CCVonshow,
		justHideIt = true;
	
	if (question._CCVonshow == false) {
		answer.style.display = 'block';
		document.getElementById('Footer').style.display = 'none';

        // ============================================================================================
		// Track expand event via Google Anlaytics code.
		// Use the Question Text as the event identifier.
		// Strip out the <a> tags to get the question
		var sQ = trim(question.innerHTML.substr(question.innerHTML.indexOf('>') + 1, question.innerHTML.toLowerCase().indexOf('</a>') - (question.innerHTML.indexOf('>') + 2)));
		sQ = sQ.replace(/ /g, "_"); // replace all spaces with an underscore
		sQ = sQ.replace(/\./g, ""); // drop period's from the question text.
		sQ = sQ.replace(/\?/g, ""); // drop question marks from the question text.
		// alert(sQ);

		_gaq.push(['_trackEvent', 'FAQ', 'Click', sQ]);
		
		// alert('after change');
        // pageTracker._trackPageview('/event/faq_' + sQ);
        // ============================================================================================
		
		if (justHideIt == true) {
			answer.style.height = answer._CCVheight + 'px';
		}
		else {
			function higher(){
				currentHeight++;
				answer.style.height = currentHeight + 'px';
			
				if (currentHeight < answer._CCVheight){
					setTimeout(higher, 1);
				}
			}
			
			higher();
		}
		question._CCVonshow = true;
	}
	else {

		if (justHideIt == true) {
			answer.style.display = 'none';
			answer.style.height = '0';
		}
		else {
			currentHeight = answer._CCVheight;
			function lower(){
				currentHeight--;
				answer.style.height = currentHeight + 'px';
			
				if (currentHeight > 0){
					setTimeout(lower, 1);
				}
				else {
					answer.style.display = 'none';
				}
			}
			
			lower();
		}
		question._CCVonshow = false;
	}
	
	
}

function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g, "");
}
function ltrim(stringToTrim) {
    return stringToTrim.replace(/^\s+/, "");
}
function rtrim(stringToTrim) {
    return stringToTrim.replace(/\s+$/, "");
}

