/* Declare a namespace for the site */
var Site = window.Site || {};

(function($) {
	
	$(function() {		
		//table styling
		$(".productspecs tr:even").addClass("even");
		$("table.productspecs tr td:nth-child(2)").addClass("td_shadow");
		$("table.productspecs thead tr th:first").addClass("border_left");
		//breadcrumbs
		$("#breadcrumb-nav ul li:last").addClass("lastcrumb");
		$("#breadcrumb-nav ul li:first").addClass("firstcrumb");
		//document file type icons
		$(".sideblock a[href$='.pdf']").addClass("pdf");
		$(".sideblock li a[href$='.pdf']").parent().addClass("pdfli");
		$(".sideblock a[href$='.xls']").addClass("xls");
		$(".sideblock li a[href$='.xls']").parent().addClass("xlsli");
		$(".sideblock a[href$='.doc'], .sideblock a[href$='.txt'], .sideblock a[href$='.rft']").addClass("doc");
		$(".sideblock li a[href$='.doc']").parent().addClass("docli");
		//popup window for addthis
		$(".addthis_button_linkedin").popupWindow({ 
			height:	450, 
			width:	600, 
			top:	50,  
			left:	50   
		}); 
		//accordion for FAQ
        $("#accordion").accordion({
            autoHeight: false,
            navigation: true
        });
		//modal window
        $(".modallink").fancybox({
            //'overlayShow'	: false,
			'showNavArrows':  	true,
			'autoDimensions':  	false,
			'width'         : 	840,
			'height'        : 	480,
            'transitionIn'	: 	'elastic',
            'transitionOut'	: 	'elastic'
        });

	    
		$(".modallink-vid").fancybox({
            //'overlayShow'	: false,
			'showNavArrows':  	true,
			'autoDimensions':  	false,
			'width'         : 	680,
			'height'        : 	460,
            'transitionIn'	: 	'elastic',
            'transitionOut'	: 	'elastic'
        });
		$(".modallink-pdf").fancybox({
            //'overlayShow'	: false,
			'showNavArrows':  	true,
			'autoDimensions':  	false,
			'width'         : 	420,
			'height'        : 	460,
            'transitionIn'	: 	'elastic',
            'transitionOut'	: 	'elastic'
        });
		$(".modallinkForm").fancybox({
            //'overlayShow'	: false,
			'showNavArrows':  	true,
			'autoDimensions':  	false,
			'width'         : 	560,
			'height'        : 	700,
            'transitionIn'	: 	'elastic',
            'transitionOut'	: 	'elastic',
            'titleShow'     :   false
        });

		$(".modallinkReset").fancybox({
            //'overlayShow'	: false,
			'showNavArrows':  	true,
			'autoDimensions':  	true,
            'transitionIn'	: 	'elastic',
            'transitionOut'	: 	'elastic'
        });
		
		//PDF Viewer for Resource Library
        $('.media-pdf').media({
			width: 400,
			height: 400
		});
		$('.media-vid').media({
			width: 660,
			height: 400
		});
		
		//feature boxes
		$('#slider').nivoSlider({
			effect: 'fade',
			slices:1,
			animSpeed:300, 
			pauseTime:5000,
			directionNav:false
		});

        $("a.galleryslide").attr('rel', 'gallery').fancybox({

					'titlePosition' : 'inside'

				});

        $('.stage').cycle({
			fx: 'scrollHorz',
			timeout: 0,
			slideExpr: '.conveyor',
			startingSlide: 0,
			prev: '.product-slider-prev-btn',
			next: '.product-slider-next-btn'
		});
		$('.stage-vert').cycle({
			fx: 'scrollVert',
			timeout: 0,
			slideExpr: '.conveyor',
			startingSlide: 0,
			prev: '.product-slider-btn-up',
			next: '.product-slider-btn-down'
		});

	    $('#log-out').click(function() {
	        Logout();
	    });
	    

	});
	
	
	//DOWNLOADS PAGE
	$('.emailadd').click(function(){
		//alert("test");
		$(this).addClass('active');
	});

	
	

})(jQuery);

//popup for footer twitter link
function tweetthis(url) {
 	var width  = 500;
 	var height = 300;
 	var left   = (screen.width  - width)/2;
 	var top    = (screen.height - height)/2;
	var params = 'width='+width+', height='+height;
 	params += ', top='+top+', left='+left;
 	params += ', directories=no';
 	params += ', location=no';
 	params += ', menubar=no';
 	params += ', scrollbars=no';
 	params += ', status=no';
 	params += ', toolbar=no';
 	newwin=window.open(url,'windowname5', params);
 	if (window.focus) {newwin.focus()}
 	return false;
}

$(document).ready(function () {
    $('a[href^="http"]')
        .not('[href*="bardmedical.com"]')
        .not('[href*="crbard.com"]')
        .not('[href*="statlock.com"]')
        .not('[href*="bardurological.com"]')
        .not('[href*="bardendo.com"]')
        .not('[href*="bardendourology.com"]')
        .not('[href*="takeeveryprecaution.com"]')
            .click(function () {
        return confirm('You are now leaving the Bard Medical Website: Any links or references to other Internet sites (hyperlinks) are provided by Bard merely as a convenience to users of this Internet site. Any hyperlink to such other Internet site does not imply an endorsement or recommendation by Bard or its Affiliates. Please see our Terms of Use Section for additional information. Before acting on any advice or information related to your healthcare that you find at the following or any other website, contact a Healthcare professional.');
    });


	$(".resourceLibrary .sideblock a.tooltip-link").tooltip({
		position: "center left"
	});
            
});

    function ShowVideo(id, videoUrl, imageUrl, width, height) {
        jwplayer("video-player").setup({
            flashplayer: "/jwplayer/player.swf",
            controlbar: "bottom",
            file: videoUrl,
            image: imageUrl,
            width: width,
            height: height
        });

        $('.video-listing').removeClass('plain');
        $('#' + id).addClass('plain');
        $(".video-listing").hover(
			function () {
			    $(this).addClass("video-listing-hover");
			},
			function () {
			    $(this).removeClass("video-listing-hover");
			}
		);
}

function Logout() {
    $.post('/Services/Logout.aspx', function (data) {
        window.location.reload(true);
    });
}


function launchFullScreen(url) {
    aw = screen.availWidth - 8;
    ah = screen.availHeight - 26;
    if (navigator.appName == "Netscape") {
        window.open(url, "popup", "width=" + aw + ",height=" + ah + ",screenx=0,screeny=0,resizable");
    } else {
        aw = screen.width - 8;
        ah = screen.height - 50;
        window.open(url, "popup", "width=" + aw + ",height=" + ah + ",left=0,top=0");
    }
}

function Modal(cssSelector, width, height) {

    		$(cssSelector).fancybox({
            //'overlayShow'	: false,
			'showNavArrows':  	true,
			'autoDimensions':  	false,
			'width'         : 	width,
			'height'        : 	height,
            'transitionIn'	: 	'elastic',
            'transitionOut'	: 	'elastic'
        });
}
