var jQ = jQuery.noConflict();
jQ(document).ready(function(){
	jQ('table.information td[rowspan]').css('border-right', '1px solid #C0C0C0');
});

jQ(function(){
 
	function megaHoverOver(){
		jQ(this).find(".sub").stop().fadeTo(10, 1).show();
			
		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				jQ(this).find("ul").each(function() {					
					rowWidth += jQ(this).width() +5; 
				});	
			};
		})(jQuery); 
		
		if ( jQ(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			jQ(this).find(".row").each(function() {							   
				jQ(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			jQ(this).find(".sub").css({'width' :biggestRow});
			jQ(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			
			jQ(this).calcSubWidth();
			//Set Width
			jQ(this).find(".sub").css({'width' : rowWidth});
			
		}
	}
	
	function megaHoverOut(){ 
	  jQ(this).find(".sub").stop().fadeTo(10, 0, function() {
		  jQ(this).hide(); 
	  });
	}
 
 
	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 //interval: 100, // number = milliseconds for onMouseOver polling interval
		 interval: 10, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 //timeout: 500, // number = milliseconds delay before onMouseOut
		 timeout: 50, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};
 
	jQ("ul#topnav li .sub").css({'opacity':'0'});
	jQ("ul#topnav li").hoverIntent(config);
 
	jQ('ul#slideGallery').simpleFadeSlideshow({
		width:620,
		forwardText: '<img src="/images/netstarter/ContentImages/right-arrow.png" width="8" height="13" alt="" />',
		backText: '<img src="/images/netstarter/ContentImages/left-arrow.png" width="8" height="13" alt="" />',
		delay               : 4000,
		animationTime       : 1000, 
		onComplete: function(){
			jQ('.sfs_nav ul').prepend(jQ('<li />').append(jQ('.sfs_wrapper span.back')));
			jQ('.sfs_nav ul').append(jQ('<li />').append(jQ('.sfs_wrapper span.forward')));
		}
		});
	
	jQ('ul#healthSlideGallery').simpleFadeSlideshow({
		width:620,
		forwardText: '<img src="/images/netstarter/ContentImages/right-arrow.png" width="8" height="13" alt="" />',
		backText: '<img src="/images/netstarter/ContentImages/left-arrow.png" width="8" height="13" alt="" />',
		delay               : 4000,
		animationTime       : 1000, 
		onComplete: function(){
			jQ('.sfs_nav ul').prepend(jQ('<li />').append(jQ('.sfs_wrapper span.back')));
			jQ('.sfs_nav ul').append(jQ('<li />').append(jQ('.sfs_wrapper span.forward')));
		}
		});
		
	jQ('.jq_dropdown_link').click(function(e){
		e.preventDefault();
		if(jQ(this).hasClass('selected'))
		{
			jQ(this).removeClass('selected');
		}else
		{
			jQ(this).addClass('selected');
		}
		jQ('.jq_dropdown_content').slideUp();
		
		jQ(jQ(this).attr('href')).slideToggle();
		});

		
		
	jQ('body').click(function(e){
		if(jQ(e.target).hasClass('jq_dropdown_link') || jQ(e.target).parents('.jq_dropdown_content').length>0) return;
		jQ('.jq_dropdown_content').slideUp(function(){
			jQ('.jq_dropdown_link').removeClass('selected');
			
			});
		
		
		});
		
		
	//font resizer
	
	jQ('.textDecrease').click(function(){
		
			
			jQ('#MainBodyLeftPane *').each(function(){
				var size = parseFloat(jQ(this).css('font-size'),10);
				jQ(this).css('font-size',(size-2)+'px');
				
				});

		
		
		});
	jQ('.textIncrease').click(function(){
		
			
			jQ('#MainBodyLeftPane *').each(function(){
				var size = parseFloat(jQ(this).css('font-size'),10);
				jQ(this).css('font-size',(size+2)+'px');
				
				});
			

		
		
		});
	
	jQ('.HeaderReference').click(function(e){
		e.preventDefault();
		(jQ(this).hasClass('down')) ? jQ(this).removeClass('down') : jQ(this).addClass('down')
		jQ(jQ(this).attr('href')).slideToggle();
		
		
		});
	
	//for Tabs
	jQ('.tabLink').click(function(e){
		jQ('.tabLink').removeClass('selected');
		jQ(this).addClass('selected');
		e.preventDefault();
		jQ('.tabContent').removeClass('selected');
		jQ(jQ(this).attr('href')).addClass('selected');
		
		});
		
	//tab expand
	jQ('.tabExpand').toggle(function(e){
		var _item = jQ(this);
		e.preventDefault();
		
		var h = 0;
		
		jQ(jQ(this).attr('href')).find('ul').each(function(){
		 h = (h<jQ(this).height()) ? jQ(this).height() : h;	
			});
		jQ(jQ(this).attr('href')).find('.tabWrapper').animate({
			height : h
		
		},function(){
			_item.addClass('collapse').text('Collapse listing');	
		});
		
		},function(e){
			var _item = jQ(this);
			e.preventDefault();
			
			var h = 320;
			
			jQ(jQ(this).attr('href')).find('.tabWrapper').animate({
				height : h
		
			},function(){
			_item.removeClass('collapse').text('Expand listing');	
			});	
			
		
		});
		
		jQ('.searchdropdown').click(function(e){
			
			jQ('.btnHelthInfo').text(jQ(this).text());
			
			});
	
	
	})
	
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

var urlAddress = "http://www.mydr.com.au"; 
var pageName = "myDr.com.au - Health and Medical Information for Australia from MIMS" ; 
function addToFavorites() { 
	if (window.sidebar) { // Mozilla Firefox
    		window.sidebar.addPanel(pageName, urlAddress, "");
	}
	else if (window.external) { // IE
    		window.external.AddFavorite(urlAddress, pageName);
	}
	else if (window.opera && window.print) {
    		window.external.AddFavorite(urlAddress, pageName);
	}
	else {
    		alert('not supported');
	}
}

