jQuery(document).ready(function(){
    
jQuery('.group-name').bind('click', toggle_group);
jQuery('#expander').bind('click', expand_all);
jQuery('#expand_insert').bind('click', expand_insert);
 
});



function expand_all() {

    if (jQuery('#expander').html() == "Hide Subcategories") {
	jQuery('.cats_subcatul').toggle();
	jQuery('#expander').html('Show Subcategories');
  } else if (jQuery('#expander').html() == "Show Subcategories") {
	jQuery('.cats_subcatul').toggle();
	jQuery('#expander').html('Hide Subcategories');
  }

   
  
    if (jQuery('#expander').html() == "Collapse All") {
   
	jQuery('.cats_subcatul').toggle();
	jQuery('#expander').html('Expand All');
  } else if (jQuery('#expander').html() == "Expand All") {
 
	jQuery('.cats_subcatul').toggle();
	jQuery('#expander').html('Collapse All');
  }
}



function expand_insert() {
  if (jQuery('.categories_insert').is(':hidden')) {
    jQuery('.categories_insert').show();
    jQuery('#expand_insert').html('Hide Categories');
 
  } else {
    jQuery('.categories_insert').hide();
    jQuery('#expand_insert').html('Show All Categories');
 
  }
 
}

function toggle_group() {
  var group_id = '';
  var second_group_id_array;
  for (attribute in this.attributes) {
    if (this.attributes[attribute]) {
      if (this.attributes[attribute].name == 'group_id') {
        group_id = this.attributes[attribute].value;
        second_group_id_array = group_id.split('-');
      }
    }
  }
  if (second_group_id_array.length > 1) {
    second_group_id = second_group_id_array[1];
  } else {
    second_group_id = 'my-' + group_id;
  }
  if (jQuery('#'+group_id ).is(':hidden')) {
    jQuery('#'+group_id).show();
    jQuery('#'+second_group_id).show();
  } else {
    //jQuery('#'+group_id).hide();
	//jQuery('#'+second_group_id).hide();
  }
  if (jQuery('.categories').is(':hidden')) {
    jQuery('#expander').html('Expand All');
 
  } else {
    jQuery('#expander').html('Collapse All');
 
  }
 
}

function show_group(group_id){
  if (jQuery('#'+group_id).is(':hidden')) {
    jQuery('#'+group_id).show();
  }
}


jQuery(document).ready(function(){ 
// run effects
	 
	jQuery(".detailViewButton").click(function(){
	 	pos = this.id;
		if (pos == 'detailViewButton1' )
			jQuery('#detailView1').slideToggle('slow');
		if (pos == 'detailViewButton2' )
			jQuery('#detailView2').slideToggle('slow');
		if (pos == 'detailViewButton3' )
			jQuery('#detailView3').slideToggle('slow');
		if (pos == 'detailViewButton4' )
			jQuery('#detailView4').slideToggle('slow');
		if (pos == 'detailViewButton5' )
			jQuery('#detailView5').slideToggle('slow');
		return false;
	});

});

jQuery(document).ready(function(){ 
// run effects
	 
		jQuery(".detailViewLink").click(function(){
		 	pos = this.id;
			if (pos == 'detailViewLink1' )
				jQuery('#detailView1').slideToggle('slow');
			if (pos == 'detailViewLink2' )
				jQuery('#detailView2').slideToggle('slow');
			if (pos == 'detailViewLink3' )
				jQuery('#detailView3').slideToggle('slow');
			if (pos == 'detailViewLink4' )
				jQuery('#detailView4').slideToggle('slow');
			if (pos == 'detailViewLink5' )
				jQuery('#detailView5').slideToggle('slow');
			return false;
		});
	 
	 
	 	jQuery(".portfolio_list").click(function () {
			jQuery('html, body').animate({scrollTop: jQuery(".heardable_main").offset().top}, 500);
 			jQuery("#selectedPortfolio").html(this.title);
 			pos = this.id;
  
 			var portfolios_urls = jQuery("#portfolio_urls" + pos).attr("value");
 			
 			jQuery("#redo-link").html('<a id="redo" href="/comparison_score.php?task=multiscan&name=' + this.title + '&portfolio_urls=' + portfolios_urls + '">Redo Brand Comparison</a>');
 				 
		});		
	 
});

jQuery(document).ready(function() {

//jQuery(".download_now").tooltip({ effect: 'slide'});

});


