﻿$(document).ready(function(){

    $("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	
	$("ul.topnav li span").hover(function() { //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").stop().slideDown('fast').show('slow', function(){
			$(this).height("auto");
		}); //Drop down the subnav on click


		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").stop().slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
    
    
    $('#slides2').slides({
				preload: true,
				preloadImage: 'img/loading.gif',
				play: false,
				pause: 2500,
				hoverPause: true,
				generatePagination: true,
				next: 'slidesNext',
				prev: 'slidesPrev'
				
			});
    
    
    $("img.navimages")
        .mouseover(function() { 
            var src = $(this).attr("src").match(/[^\.]+/) + "_over.gif";
            $(this).attr("src", src);
        })
        .mouseout(function() {
            var src = $(this).attr("src").replace("_over", "");
            $(this).attr("src", src);
        });
        
    var pathname = location.href.substring(location.href.lastIndexOf('/')+1);
    
    switch(pathname)
    {
        case "corporate.aspx" :
        case "corporatePreview.aspx" :
        case "management.aspx" :
        case "managementPreview.aspx" :
        case "board.aspx" :
        case "scientificadvisoryboard.aspx" :
        case "scientificstaff.aspx" :
        case "boardPreview.aspx" :
        case "scientificadvisoryboardPreview.aspx" :
        case "scientificstaffPreview.aspx" :
        case "presentations.aspx" :
        case "presentationsPreview.aspx" :
        
        
        $("#lnkAboutUs").css("background-image","url(topnav_hoversm.gif)");
        $("#lnkAboutUs").css("background-repeat","repeat-x");
        break;
        
        case "immunotherapy.aspx" :
        case "platforms.aspx" :
        case "immunotherapyPreview.aspx" :
        case "platformsPreview.aspx" :
        case "intellectualproperty.aspx" :
        case "intellectualpropertyPreview.aspx" :
        
        $("#lnkTechnology").css("background-image","url(topnav_hoversm.gif)");
        $("#lnkTechnology").css("background-repeat","repeat-x");
        break;
        
        case "publications.aspx" :
        case "publicationsPreview.aspx" :
        
        $("#lnkPublications").css("background-image","url(topnav_hoversm.gif)");
        $("#lnkPublications").css("background-repeat","repeat-x");
        break;
        
        case "pipeline.aspx" :
        case "pipelinePreview.aspx" :
        
        $("#lnkPipeline").css("background-image","url(topnav_hoversm.gif)");
        $("#lnkPipeline").css("background-repeat","repeat-x");
        break;
        
        case "clinicaltrials.aspx" :
        case "clinicaltrialsPreview.aspx" :
        
        $("#lnkClinical").css("background-image","url(topnav_hoversm.gif)");
        $("#lnkClinical").css("background-repeat","repeat-x");
        break;
        
        case "news.aspx" :
        case "newsPreview.aspx" :
        
        $("#lnkNews").css("background-image","url(topnav_hoversm.gif)");
        $("#lnkNews").css("background-repeat","repeat-x");
        break;
        
        case "collaborations.aspx" :
        case "collaborationsPreview.aspx" :
        
        $("#lnkGrants").css("background-image","url(topnav_hoversm.gif)");
        $("#lnkGrants").css("background-repeat","repeat-x");
        break;
        
        
    }
   
   $(".accordion").addClass("ui-accordion ui-widget ui-helper-reset ui-accordion-icons")
.find("h3")
        .addClass("ui-accordion-header ui-helper-reset ui-corner-bottom ui-corner-top ui-state-default")
        .hover(function() { $(this).toggleClass("ui-state-hover"); })
        .prepend('<span class="ui-icon ui-icon-triangle-1-e"/>')
        .click(function() {
            $(this).toggleClass("ui-accordion-header-active").toggleClass("ui-state-active")
                .toggleClass("ui-state-default").toggleClass("ui-corner-bottom")
                .find("> .ui-icon").toggleClass("ui-icon-triangle-1-e").toggleClass("ui-icon-triangle-1-s")
                .end().next().slideToggle().toggleClass("ui-accordion-content-active");
            return false;
        })
        .next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").hide();
   
   
    /*$("#accordion").multiAccordion();
    
    //$(".accordion").accordion({autoHeight: false, active:false}); 
    //$("#accordion").accordion({autoHeight: false, active:false});   
    $(".accordion").addClass("ui-accordion ui-accordion-icons ui-widget ui-helper-reset")
    .find("h3")
    .addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom")
    .hover(function() { $(this).toggleClass("ui-state-hover"); })
    .prepend('<span class="ui-icon ui-icon-triangle-1-e"></span>')
    .click(function() {
      $(this)
        .toggleClass("ui-accordion-header-active ui-state-active ui-state-default ui-corner-bottom")
        .find("> .ui-icon").toggleClass("ui-icon-triangle-1-e ui-icon-triangle-1-s").end()
        .next().toggleClass("ui-accordion-content-active").slideToggle();
      return false;
    })
    .next()
      .addClass("ui-accordion-content  ui-helper-reset ui-widget-content ui-corner-bottom")
      .hide();
    */
	$(".subnav td").hover(
         function() {$(this).find("a").css('color', '#fff')},
         function() {$(this).find("td").css('background-color', '')}
      );
      //$("a[title]").tooltip({effect: 'slide'});
    
    
    $.fn.qtip.styles.mystyle = { // Last part is the name of the style
       width: 300,
       background: '#e9e4d3',
       color: 'black',
       textAlign: 'left',
       border: {
          width: 1,
          radius: 4,
          color: '#000000'
       },
       tip: 'topLeft',
       name: 'dark' // Inherit the rest of the attributes from the preset dark style
    }
    
    
    $.fn.qtip.styles['defaults'].background=undefined;
    $.fn.qtip.styles['defaults'].color=undefined;
    $.fn.qtip.styles['defaults'].tip.background=undefined;
    $.fn.qtip.styles['defaults'].title.background=undefined;
    $.fn.qtip.styles['defaults'].title.fontWeight = undefined;
     
    $.fn.qtip.styles.themeroller = {
       border: {
           width: 5,
           radius: 3
       },
       classes: {
           tooltip: 'ui-widget',
           tip: 'ui-widget',
           title: 'ui-widget-header',
           content: 'ui-widget-content'
       },
       width: {
           min:"300",
           max:"300"
       }
};
    
    $('a[title]').qtip(
        {
        style: 'themeroller',
        
        }
       )

});

