// window.onload listener to share event with multiple functions

$(document).ready(function(){
    // Enable Tabs for elements with tabArr class
    $(".tabArr.enable a").bind("click", function(e){
	if($(this).parent().hasClass('close'))
	    return false;
	$(".tabArr a").removeClass();
	$(this).addClass("sel");
	if($(this).html().length < 12)
	    $(this).addClass("sml");
	else
	    $(this).addClass("big");

	$('.tabArrCnt').hide();
	$('.tabArrCnt.'+$(this).parent().attr("class")).show();
    });

    //Enable Jump Menu for elements with .jmpMen class
    $(":select.jmpMen").bind("change", function(e){
	if($(this).hasClass('jMemp'))
	    location.href = $(this).val();
	else if(!$(this).hasClass('jMemp') && $(this).val() != '')
	    location.href=$(this).val();
    });
	
    // Add AddThis sharing menu to all .share links
    $(".share").each(function (i) {
	if(window.addthis !== undefined)
	    addthis.button(this, {
		services_exclude:'print',
		ui_offset_top:-15
	    }, {
		url: $(this).parent().parent().parent().prev().prev().children().attr('href'),
		title: $(this).parent().parent().parent().prev().prev().children().html(),
		content:$(this).parent().parent().parent().prev().html()
	    });
    });

    // Enable iFrame for PR Single pages
    if ($("body").hasClass("prSingle") && window.cmpUri !== undefined){
	$('#publisher').append('<iframe id="cmpIfr" />');
	$('#cmpIfr').attr('src', window.cmpUri);
	$('#cmpIfr').css("clear", "right").css("width", "100%").css("height", "200px").css("border", "1px dotted #e0e0e0");
    }
});

