﻿var _selectedQ = null;

$(document).ready(function(){
    // hide all the answers and bind the links
    var _textColour = "#c0c0c0";
    var _bgColour = "#c0c0c0";
    
    if(_clinicType == 'gynaecology')
    {
        _textColour = "#936992";
        _bgColour = "#E9E1ED";
    }
    else if (_clinicType == 'endometriosis')
    {
        _textColour = "#E8B05B";
        _bgColour = "#EEE199";
    }
    else if (_clinicType == 'female-oncology')
    {
        _textColour = "#026E83";
        _bgColour = "#CAE6EA";
    }
    
    if($('#faq').length > 0)
    {    
        $('#faq').find('dd').hide().end().find('dt').click(function() {
            $("#faq dd:hidden").css({backgroundColor: "#ffffff"});
            var _this = $(this); 
            var answer = _this.next();
            
            if (_selectedQ && (_this.get(0) == _selectedQ)) {
                _this.animate({color: "#58585A"}, 700);
                //AnimateArrow(_this.find("img"), 11, -1, 1);
                _selectedQ = null;
            }
            else {
                if (_selectedQ != null)
                {
                    $(_selectedQ).animate({color: "#58585A"}, 700 );
                    //AnimateArrow($(_selectedQ).find("img"), 11, -1, 1);
                }
                _this.animate({color: _textColour}, 700);
                //answer
                _selectedQ = _this.get(0);
                //AnimateArrow(_this.find("img"), 1, +1, 11);
            }
            
            $("#faq dd:visible").not(answer).slideUp();
            answer.slideToggle().animate({backgroundColor: _bgColour}, 1000);
        });
    }
});

//function AnimateArrow(imageObject, count, inc, maxCount)
//{
//    console.log("hi");
//    imageObject.attr("src", "/images/interface/arrows/take-2/step-" + count + ".gif");
//   if(count != maxCount) 
//    {
//        setTimeout("AnimateArrow("+imageObject+","+ (count + inc) + "," + maxCount + ")", 100);
//    }
//}