$(document).ready(function() {
	$('.button_download_show').click(function(){
		if ($.browser.msie && $.browser.version.substr(0,1)<7) {
			$('#opp_competition_id, #opp_team_id, .squarebox .section select').hide();
		}
		$('.popupbox').hide(400);
		$('#'+$(this).attr('id').split('_',1)+'_download_box').show(400);
		
		return false;
	});

	$('.button_download_hide').click(function(){
		$('#'+$(this).attr('id').split('_',1)+'_download_box').hide(400);
		if ($.browser.msie && $.browser.version.substr(0,1)<7) {
			$('#opp_competition_id, #opp_team_id, .squarebox .section select').show(400);
		}
		return false;
	});

$('.button_email_box').hide();


$('.button_email_show').click(function(){
    if ($.browser.msie && $.browser.version.substr(0,1)<7) {
      $('#opp_competition_id, #opp_team_id').hide();
    }
    $('.popupbox').hide(400);
    $('#'+$(this).attr('id').split('_',1)+'_email_box').show(400);
    return false;
});

$('.button_email_hide').click(function(){
    $('#'+$(this).attr('id').split('_',1)+'_email_box').hide(400);
    if ($.browser.msie && $.browser.version.substr(0,1)<7) {
      $('#opp_competition_id, #opp_team_id').show(400);
    }
    return false;
});

$('.button_share_show').click(function(){
    if ($.browser.msie && $.browser.version.substr(0,1)<7) {
      $('#opp_competition_id, #opp_team_id').hide();
    }
    $('.popupbox').hide(400);
    $('#'+$(this).attr('id').split('_',1)+'_share_box').show(400);
    return false;
});

$('.button_share_hide').click(function(){
    $('#'+$(this).attr('id').split('_',1)+'_share_box').hide(400);
    if ($.browser.msie && $.browser.version.substr(0,1)<7) {
      $('#opp_competition_id, #opp_team_id').show(400);
    }
    return false;
});

$('#ranking .button_embed_show').click(function(){
	$('#'+$(this).attr('id').split('_',1)+'_share_box').hide(400);
	return false;
});
$('#ranking .button_embed_show').click(function(){
	$('#'+$(this).attr('id').split('_',1)+'_share_box').show(400);
	return false;
});

$('.rightbuttons .button_embed_show').live('click', function(){
	$('.popupbox').hide(400);
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		$('.squarebox .section select').hide();
	}
	
    $('#'+$(this).attr('id').split('_',1)+'_embed_box').show(400);
    return false;
});

$('.rightbuttons .button_embed_hide').live('click', function(){
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		$('.squarebox .section select').show();
	}
    $('#'+$(this).attr('id').split('_',1)+'_embed_box').hide(400);
    return false;
});

$('.widget .button_embed_show').live('click', function(){
	$('.popupbox').hide(400);
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		$('.widget select:hidden').show();
		if ($(this).parents('.widget')) {
			var widget_id = $(this).parents('.widget').attr('id');
			$('#' + widget_id + ' select:visible').hide();
		}
	}
	
    $('#'+$(this).attr('id').split('_',1)+'_embed_box').show(400);
    return false;
});

$('.widget .button_embed_hide').live('click', function(){
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		if ($(this).parents('.widget')) {
			var widget_id = $(this).parents('.widget').attr('id');
			$('#' + widget_id + ' select:hidden').show();
		}
	}
    $('#'+$(this).attr('id').split('_',1)+'_embed_box').hide(400);
    return false;
});



	 // hides the slickbox as soon as the DOM is ready
	 // (a little sooner than page load)
	 $('#slickbox').hide();
	 
	 // share button and text on menu bar
	 $('a#slick-show_menu1, a#slick-show_menu2, #wc10-share-control').click(function() {
		 if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		 	$('#select-question').hide();
		 }
		 $('#slickbox_menu').show(400).css('z-index','50');
		 return false;
	 });
	 
	 // hides the Menu share box
	 $('a#slick-hide').click(function() {
		 $('#slickbox_menu').hide(400);
		 if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		 	if($('#slickbox_title').is(':hidden')) {
				$('#select-question').show();
			}
		 }
		 return false;
	 });
	 
	   // Title Bar button in utils.php include
	 $('a#slick-show_title').click(function() {
		 if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		 	$('#select-question').hide();
		 }
		 $('#slickbox_title').show(400);
		 return false;
	 });
	 $('a#slick-show_title1').click(function(){
	     	$('#slickbox_title1').show(400);
		return false;
	 });
	 $('a#slick-show_title2').click(function(){
	     	$('#slickbox_title2').show(400);
		return false;
	 });
	 
	 // hides the Title share box
	 $('a#slick-hide_title').click(function() {
		 $('#slickbox_title').hide(400);
		 if ($.browser.msie && $.browser.version.substr(0,1)<7) {
			if($('#slickbox_menu').is(':hidden')) {
				$('#select-question').show();
			}
		 }
		 return false;
	 });
	 $('a#slick-hide_title1').click(function(){
	     	$('#slickbox_title1').hide(400);
		return false;
	 });
	 $('a#slick-hide_title2').click(function(){
	     	$('#slickbox_title2').hide(400);
		return false;
	 });
	 
	 // toggles the slickbox on clicking the noted link
	 $('a#slick-toggle').click(function() {
		 $('#slickbox').toggle(400);
		 return false;
	  });
	  
	  
     // hides the slickbox as soon as the DOM is ready
	 // (a little sooner than page load)
	 $('#emailbox').hide();
	 $('#emailbox1').hide();
	 
	 // shows the slickbox on clicking the noted link
	 $('a#email-show').click(function() {
		 $('#emailbox').show(400);
		 return false;
	 });
	 $('a#email-show1').click(function(){
	     	$('#emailbox1').show(400);
		return false;
	 });
	 
	 // hides the email box
	 $('a#email-hide').click(function() {
		 $('#emailbox').hide(400);
		 return false;
	 });
	 $('a#email-hide1').click(function(){
	     	$('#emailbox1').hide(400);
		return false;
	 });
	 
	 // toggles the slickbox on clicking the noted link
	 $('a#email-toggle').click(function() {
		 $('#emailbox').toggle(400);
		 return false;
	  });
	 $('a#email-toggle1').click(function(){
	     	$('#emailbox1').toggle(400);
		return false;
	 });
});
