//Accordian
jQuery(document).ready(function(){
	
	// web281 stuff
	if(typeof init == 'function'){
	   init(); 
	   initRegGroup();
	   printList(0);
	}
	
	jQuery('.report-list').hide();
	jQuery('.reports .report-list:first').show()
	jQuery('.reports h2').click(function(ev){				
		jQuery(this).addClass('selected');
		var el = jQuery(ev.target).next(".reports .report-list");
		var els= jQuery('.reports .report-list'); /*get a reference to all products*/
		var hds=jQuery('.reports h2'); /*get a reference to all headings*/
		var open=true;
		if(jQuery(el).css("display")=="block"){
		 open=false
		}
		
		/*close all open accordion panels*/
		for (i=0;i<els.length;i++){
			if (jQuery(els[i]).css("display")=="block") {
				jQuery(els[i]).slideToggle('fast');
				jQuery(hds[i]).removeClass('selected');
			}
		}
	
		if(open){
			/*slide the selected product open*/
			el.slideToggle('fast');
		}
		
		if(jQuery.trim(jQuery(this).next().html())==''){ // not to fetch data everytime even for the data that has already been fetched.
			var listId = jQuery(this).next().attr("id");
			var arrayExploded=listId.split("-");		
			var year=arrayExploded[1];
			var month=arrayExploded[2];
			jQuery.ajax({
				type: "GET",
				url: "/wb_get_archive.php?year="+year+"&month="+month,
				beforeSend:function(){				
					jQuery("#"+listId).html("<div class='loading'>&nbsp;</div>");
					},
				success:function(returnedHTML){
					jQuery("#"+listId).html(returnedHTML);
					}
				}); // end of ajax	
		}
		
		
	});
	
});


//css change for browser and mobile
jQuery(document).ready(function(){	
	if(jQuery.browser.mobile){
		jQuery("head").append('<link rel="stylesheet" type= "text/css" href="/system/layout/css/meeting-selector-mobile.css"/>');	
	}
	else{
		jQuery("head").append('<link rel="stylesheet" type= "text/css" href="/system/layout/css/meeting-selector.css"/>');
	}
})
