//////////////////////////
// sam JS for the twistees
//////////////////////////


window.addEvent('domready',function() {




toggleThis = function(el) {
twistie_id = 'twistie_'+el;
twister_id = 'twister_'+el;
highLt_id = 'highLt_'+el;

currDisplay = $(twistie_id).getStyle('display');
if(currDisplay=='none') { // show
// $(highLt_id).setStyle('color','#0192BF');
$(twistie_id).setStyle('display','block');
$(twister_id).setStyles({
'color':'#ffffff',
'background':'#0192bf url(/gfx/expand.gif) no-repeat left center'
});
} else { // hide
// $(highLt_id).setStyle('color','');
$(twistie_id).setStyle('display','none'); 
$(twister_id).setStyles({
'color':'#777',
'background':'#fff url(/gfx/collapse.gif) no-repeat left center'
});
}
};

expandOrCollapse = function(el) {
lng = $$('.twister').length;
str = ($(el).get('html'));
if(str.indexOf('+') > 0){
$$('.twistie').setStyle('display','block');
$(el).set('html','[<span id="vtog_minus">&ndash;</span>] <span style="color:#0192BF; font-weight:bold;" id="vtog_txt">Collapse All</span>');

for (i=0; i<lng; i++) {
// highLt_id = 'highLt_'+i;
// $(highLt_id).setStyle('color','#0192BF');
twister_id = 'twister_'+i;
$(twister_id).setStyles({
'color':'#ffffff',
'background':'#0192bf url(/gfx/expand.gif) no-repeat left center'
});
}

} else {
$$('.twistie').setStyle('display','none');
$(el).set('html','[<span id="vtog_plus">+</span>] <span style="color:#0192BF; font-weight:bold;" id="vtog_txt">Expand All</span>');

for (i=0; i<lng; i++) {
// highLt_id = 'highLt_'+i;
// $(highLt_id).setStyle('color','');
twister_id = 'twister_'+i;
$(twister_id).setStyles({
'color':'#777',
'background':'#fff url(/gfx/collapse.gif) no-repeat left center'
});
}
}
};




    $$('.twister').setStyle('cursor','pointer'); 

$$('.twister').addEvents({
'mouseenter':function() {
var tmp = $(this).get('id');
temp = tmp.split('_');
el = 'twistie_'+temp[1];
// alert ($(el).getStyle('display'));
if($(el).getStyle('display')=='none') {
this.setStyle('color','#0192BF'); 
}
}, 'mouseleave':function() {
var tmp = $(this).get('id');
temp = tmp.split('_');
el = 'twistie_'+temp[1];
// alert ($(el).getStyle('display'));
if($(el).getStyle('display')=='none') {
this.setStyle('color','#777777');
}
} 
});

}); // DOM