// june 2010

var expandSpeed = 180;

$(document).ready(function(){
	
	$.cookie('testcookie' , 'expanded')

	var count = 0;
	$('.gs_expander').each(function(){
								
		var itemCount = 0;
		$(this).find('.gs_expander_item').each(function(){	
													
			$(this).wrap('<div class="gs_expander_item_wrapper" />');
			if($.cookie('gs_Target_' + count + '_gs_Item_' + itemCount) == 1){
			$(this).before('<a style="display: none;" class="gs_show" href="#" onClick="gs_Item(\'' + count + '\' , \'' + itemCount + '\' , \'1\'); return false;">&nbsp;expand +&nbsp;</a><a style="display: inline;" class="gs_hide" href="#" onClick="gs_Item(\'' + count + '\' , \'' + itemCount + '\' , \'0\'); return false;">&nbsp;contract -&nbsp;</a><br />');
			$(this).css("display","inline");
			$(this).slideDown(expandSpeed);
			} else {
			$(this).before('<a style="display: inline;" class="gs_show" href="#" onClick="gs_Item(\'' + count + '\' , \'' + itemCount + '\' , \'1\'); return false;">&nbsp;expand +&nbsp;</a><a style="display: none;" class="gs_hide" href="#" onClick="gs_Item(\'' + count + '\' , \'' + itemCount + '\' , \'0\'); return false;">&nbsp;contract -&nbsp;</a><br />');			
			$(this).css("display","none");
			}
			itemCount ++;
		});
		count ++;
	});
});


function gs_Item(target , item , show){
    $.cookie('gs_Target_' + target + '_gs_Item_' + item , show);
	var count = 0;
	$('.gs_expander').each(function(){
		if(target == count){	
			var itemCount = 0;	
			$(this).find('.gs_expander_item_wrapper').each(function(){
				if(item == itemCount){
					if(show == 1){
						$(this).find('.gs_hide').css("display","inline");
						$(this).find('.gs_show').css("display","none");
						$(this).find('.gs_expander_item').slideDown(expandSpeed);
						$(this).siblings('a').attr('onClick' , 'gsItem(\'' + target + '\' , \'' + item + '\' , \'0\'); return false;');
					} else {
						$(this).find('.gs_hide').css("display","none");
						$(this).find('.gs_show').css("display","inline");
						$(this).find('.gs_expander_item').slideUp(expandSpeed);
						$(this).siblings('a').attr('onClick' , 'gsItem(\'' + target + '\' , \'' + item + '\' , \'1\'); return false;');
					}
				}
				itemCount ++;
			});
		}
		count ++;
	});
}


