function submitSearch()
{
	var url ="<ptl:createPortalPageChangeURL pageName='search' doRedirect='false'/>";
	var intxt = document.bannersearch.search.value;
	var tempurl = url+"&param="+intxt
	if(intxt==""){
		alert("Please enter the search term.");
	}else{
		self.location=tempurl;
	}
}


function leaveSite(obj){
	var tempLink = $(obj).attr('href');
    tempLink.indexOf("extSite=") != -1 ? tempLink = tempLink.substr(tempLink.indexOf("extSite="), tempLink.length) : null;     
    
	if(tempLink.indexOf('http://' || 'https://') >-1){
	
		var warningmsg1 = "You have clicked on a link that will take you out of this website";
		var warningmsg2 = "You have clicked on a link that will take you out of the MSActiveSource.com website";
		var warningmsg3 = "You are leaving MSActiveSource.com. This link will take you to a website that is outside the control of Biogen Idec. We provide links as a public service and for informational purposes only. We do not make or imply any endorsement of external web sites.";
		
		// The order of these if statments matters!
		if (tempLink.indexOf("www.biogenidec.com")>-1){
			return confirm(warningmsg1);
		} else if (tempLink.indexOf("www.msleadersofhope.com")>-1){
			return confirm(warningmsg1);
		} else if(tempLink.indexOf("boss.streamos.com")>-1){
			return true;
		} else if(tempLink.indexOf("www.avonex.com")>-1){
			return confirm(warningmsg2);
		} else if(tempLink.indexOf("https://www.msactivesource.com")>-1){
			return confirm(warningmsg2);
		} else if(tempLink.indexOf("www.tysabri.com")>-1){
			return confirm(warningmsg2);
		} else if(tempLink.indexOf("msas/home")>-1){
			return confirm(warningmsg2);
		} else if(tempLink.indexOf("www.mymsyoga.com")>-1){
			return confirm(warningmsg2);
		} else{
			return confirm(warningmsg3);
		}
	}else{
		return true;
	}
	
}


//from msas.js 
 function doFramesBuster()
{
  if ( top.location != self.location )
	breakFrames();
}

function breakFrames()
{
	setTimeout( "top.location.href = sThisURL", 1.5*1000 );
}

$(document).ready(function(e) {
    doFramesBuster();
});

/***** qTip init ******/

$(document).ready(function(e) 
{
   // Use the each() method to gain access to each elements attributes
   $('.tip-it').each(function()
   {
	   $(this).click(function(ev) {ev.preventDefault();});
	   
	   var tipElem = '#' + $(this).attr('rel');
	   
      $(this).qtip(
      {
         content: $(tipElem)
            // Set the text to an image HTML string with the correct src URL to the loading image you want to use
            //url: $(this).attr('rel') // Use the rel attribute of each element for the url to load
         ,
         position: {
            corner: {
               target: 'topMiddle', // Position the tooltip above the link
               tooltip: 'bottomMiddle'
            }
         },
         show: { 
            when: 'click', 
            solo: true, // Only show one tooltip at a time
			ready: false
         },
         hide: false,
         style: {
            tip: true, // Apply a speech bubble tip to the tooltip at the designated tooltip corner
            border: {
               width: 0,
               radius: 4,
			   color: '#398bd1'
            },
            name: 'light', // Use the default light style
            width: 122,
			padding: 0
         },
		 api:{
			 onShow : function(){
				var closeDiv = document.getElementById('close');
				closeDiv.style.left = this.elements.tooltip.width() + this.elements.tooltip.position().left - 15 +'px';
				closeDiv.style.top = this.elements.tooltip.position().top - 10 + 'px';
				closeDiv.style.display = "block";
			 },
			 onHide : function(){
				var closeDiv = document.getElementById('close');
				closeDiv.style.display = "none";
			 }
		 }
      })
   });
});
function closeTip(){
	$('.tip-it').qtip("hide");
}


/*****************************************************
***  minislides:  fades in divs and attaches a url 
***  to a link value in each called "slidehref"    
*****************************************************/

	/** Slide Show Settings **/
	var slides = 4;
	var fdelay = 4000;		// delay time between slides w/fading
	var edelay = 5000;		// delay time between slides without fading (ie)
	var ftime  = 1000;		// slide fade-in time
	var fpause = 8000;		// time to pause on user interaction
	var s = 1;				// current slide count holder
	var ns = 1;				// next slide count holder
	var ls = 1;				// link switch for learnmore button setting
	var pauseit;			// holds pause if evoked

$(function(){

	/** ### IMAGE AND CONTENT ROTATION ### **/

	/** Preliminary Settings **/
	$('#slidecontrol').fadeTo(500,.8);
	$('#slidecontrol').hover(function(){ $(this).fadeTo(200,1) }, function(){ $(this).fadeTo(200,.8) });
	
	/** scbox (number boxes) click function **/
	$('.scbox').click(function(){		
		!$(this).hasClass('scbox_on') ? jumpSlide($(this).attr('value') * 1) : null;
	});
	
	/** Image and title click function **/
	/* Comment out since its not used anywhere for now - Peter Jun 30, 2011
	$('.homeslide, .slidetitle, .slidelink').click(function(){
		slidelink = $('.slideinfo').filter(':visible').find('.slidelink');
		slidehref = $(slidelink).attr('href');		
		checkconfirm = leaveSite(slidelink);
		if(checkconfirm){ self.location.href = slidehref }
	});
	*/
	
	$('.slidelink').click(function(){
		window.clearTimeout(pauseit);
		$('img').clearQueue();
		$(':animated').stop(true);	
		$(this).hide();
		if($.support.opacity){ 
			$('.slideinfo').filter(':visible').find('.slidetext-more').fadeIn(ftime);
		}else{
			$('.slideinfo').filter(':visible').find('.slidetext-more').show();
		}
		return false;
	});
	
	
	/** Start Sideshow **/
	pushSlide(1);				
	
});
 

 
function pushSlide(s){
	
	s = (s * 1);
	ns = s;
	ls = s;
	window.clearTimeout(pauseit);
	thisslide = $('#homeslide' + s);
	ns == slides ? ns = 1 : ns = (ns + 1);
	nextslide = $('#homeslide' + ns);
	if($.support.opacity){ 
		pauseit = window.setTimeout(function(){ $(thisslide).hide(); pushBox(ns); pushInfo(ns) }, fdelay);		
		$(nextslide).delay(fdelay).fadeIn(ftime, function(){ 
			pushSlide(ns);
		});
	}else{
		pauseit = window.setTimeout(function(){ 
					$(thisslide).hide();
					pushBox(ns); 
					pushInfo(ns) 
					}, edelay);
		$(nextslide).delay(edelay).show(0, function(){ 
			pushSlide(ns);
		});
	}	
}
 
function jumpSlide(s){
	window.clearTimeout(pauseit);
	$('img').clearQueue();
	$(':animated').stop(true);	
	s = s * 1; ls = s;
	pushBox(s);
	pushInfo(s);
	jumpslide = $('#homeslide' + s);
	if($.support.opacity){
		$('.scbox').unbind('click');
		$('.slidelink').unbind('click');
		$('.slidelink').click(function(){
			return false;
		});
		$('.homeslide').hide();
		$(jumpslide).fadeIn(ftime, function(){
			$('.scbox').click(function(){		
				!$(this).hasClass('scbox_on') ? jumpSlide($(this).attr('value') * 1) : null;
			});
			$('.slidelink').unbind('click');
			$('.slidelink').click(function(){
				window.clearTimeout(pauseit);
				$('img').clearQueue();
				$(':animated').stop(true);	
				$(this).hide();
				if($.support.opacity){ 
					$('.slideinfo').filter(':visible').find('.slidetext-more').fadeIn(ftime);
				}else{
					$('.slideinfo').filter(':visible').find('.slidetext-more').show();
				}
				return false;
			});
		});
	}else{
		$('.homeslide').hide();
		$(jumpslide).show();
	}	
	pauseit = window.setTimeout(function(){ pushSlide(s) }, fpause); 
}
 
 
function pushBox(ns){
	$('.scbox').each(function(){
		$(this).attr('value') * 1 == ns  ? $(this).addClass('scbox_on') : $(this).removeClass('scbox_on');
	});
}
 
function pushInfo(ns){
	if($.support.opacity){
		$('.slideinfo').hide().each(function(){
			$(this).find('.slidelink').show();
			$(this).find('.slidetext-more').hide();
			$(this).attr('value') * 1 == ns ? $(this).fadeIn(ftime) : null;
		});
	}else{
		$('.slideinfo').hide().each(function(){
			$(this).find('.slidelink').show();
			$(this).find('.slidetext-more').hide();
			$(this).attr('value') * 1 == ns ? $(this).show() : null;
		});		
	}
}



