﻿/* Remove JavaScript is off warning */
$(function(){
	$('.warning').remove();
});
/* Change opactiy for social media icons. */
$(function(){
	$('#social img').animate({
		"opacity" : .8
	});
	$('#social img').hover(function(){
		$(this).stop().animate({
			"opacity" : 1
		});
	}, function() {
		$(this).stop().animate({
			"opacity" : .8
		});
	});
});
/* Change opacity for other images with class of faded */
$(function(){
	$('img.faded').animate({
		"opacity" : .5
	});
	$('img.faded').hover(function(){
		$(this).stop().animate({
			"opacity" : 1
		});
	}, function() {
		$(this).stop().animate({
			"opacity" : .5
		});
	});
});
/*Search box focus*/
$(document).ready(function(){
	var searchBoxtext = $(".text");
	var searchBox = $("#searchbox");
	var searchBoxDefault = "Search...";
	searchBoxtext.focus(function(e){
		$(this).addClass("active");
	});
	searchBoxtext.blur(function(e){
		$(this).removeClass("active");
	});
	searchBox.focus(function(){
		if($(this).attr("value") == searchBoxDefault) $(this).attr("value", "");
	});
	searchBox.blur(function(){
		if($(this).attr("value") == "") $(this).attr("value", searchBoxDefault);
	});
});
/*Every second table row striped*/
$(function() {
	$("table tr:nth-child(odd)").addClass("striped");
});
/*Accordian content*/
$(function(){
	$('<style media="screen, projection"> #content .hidden {display: none}</style>').appendTo('head'); 
});
$(function(){
	$('a#link1').click(function(c){
		c.preventDefault();	
		c.stopPropagation();
		$('#element1').toggle(750);
		$(this).toggleClass("spacey-open").toggleClass("spacey-closed").next().toggle();
	});
	$('a#link2').click(function(c){
		c.preventDefault();	
		c.stopPropagation();
		$('#element2').toggle(750);
		$(this).toggleClass("spacey-open").toggleClass("spacey-closed").next().toggle();

	});
});
/* Clinical Trial Results -- Hover and click through table rows*/
$(function() {
	$('#ctresults tbody tr').hover(function() { 
		$(this).toggleClass('zebrahover');
	});
});
$(function() {
	$("#ctresults tbody tr").click(function(){
		window.location = $(this).attr("url");
	});
});
/*Every second table row striped*/
$(function() {
	$("table.basic tr:nth-child(odd)").addClass("darkerrow");
});
/* Expanding submenus - ABL adaptation of Simple JQuery menu - Copyright 2008 by Marco van Hylckama Vlieg web: http://www.i-marco.nl/weblog/ email: marco@i-marco.nl */
function initMenus() {
	$('ul.menu ul').hide();
	$.each($('ul.menu'), function(){
		$('#' + this.id + '.expandfirst ul.expanded').show();
	});
	$('ul.menu li a').click(
		function() {
			var checkElement = $(this).next();
			var parent = this.parentNode.parentNode.id;

			if($('#' + parent).hasClass('noaccordion')) {
				$(this).next().slideToggle('normal');
				return false;
			}
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				if($('#' + parent).hasClass('collapsible')) {
					$('#' + parent + ' ul:visible').slideUp('normal');
				}
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				return false;
			}
		}
	);
}
$(document).ready(function() {initMenus();});
// for Clnician Contact Information
$(function(){
	$('<style media="screen, projection"> #content .contactinfo {display: none} ul a.contactlink {border-bottom: 1px solid #999; font-weight: normal; } #content p a.contactlink {display: inline;} </style>').appendTo('head'); 
});

$(function(){
	$('a#contactlink-ct').click(function(c){
		c.preventDefault();		
		c.stopPropagation();
		$('#contactinfo-ct').toggle(750);
	});
	$('a#contactlink-phone').click(function(c){
		c.preventDefault();	
		c.stopPropagation();
		$('#contactinfo-phone').toggle(750);
	});
	$('a#contactlink-fax').click(function(c){
		c.preventDefault();	
		c.stopPropagation();
		$('#contactinfo-fax').toggle(750);
	});
	$('a#contactlink-addr').click(function(c){
		c.preventDefault();	
		c.stopPropagation();
		$('#contactinfo-addr').toggle(750);
	});
	$('a#contactlink-prof').click(function(c){
		c.preventDefault();	
		c.stopPropagation();
		$('#contactinfo-prof').toggle(750);
		$('#profile-excerpt').toggle(0);
	});
});

