$(document).ready(function () {

$('#sbUpGoBtn').hover(function(){$(this).attr('src','img/general/sb-btn-overlay.jpg');},function(){$(this).attr('src','img/general/sb-btn.jpg');});
    $('#sbBottomGoBtn').hover(function(){$(this).attr('src','img/general/sb-btn-overlay.jpg');},function(){$(this).attr('src','img/general/sb-btn.jpg');});
    $('#ssGoBtn').hover(function(){$(this).attr('src','img/general/sb-btn-overlay.jpg');},function(){$(this).attr('src','img/general/sb-btn.jpg');});    
    $('#sBottomGoBtn').hover(function(){$(this).attr('src','img/general/sb-btn-overlay.jpg');},function(){$(this).attr('src','img/general/sb-btn.jpg');});        

	$('#ssGoBtn').css("cursor","pointer");
	$('#sBottomGoBtn').css("cursor","pointer");
    $('#embedBtn').hover(function(){$(this).attr('src','img/interactiveslibraryreadmore/embed_btn.jpg');},function(){$(this).attr('src','img/interactiveslibraryreadmore/embed_btn_overlay.jpg');});      
	$('#embedBtn').click(function(){
	   addoverlay();
		$('#embedbox').slideToggle('normal');
	});


	$('#healthCenters').mouseover(function(){
		$('#vmIl').hide();
        $('#vmL').hide();
		$('#vmHc').show();
		$('#vmHcBcg').slideDown();
		$('#vmHcBorder').slideDown();
		$('#vmHcMother').show("500");	
		$('#vmHcOver').show();
		$('#left-col-sb').css('z-index','-1');
        $('#vmHcMother p a:first').click();
	});
	$('#vmHcMother').find("p").find("a").css("cursor","pointer");
	$('#vmHcMother').find("p").find("a").click(function(){
		$('#vmHcBorder').hide();
		$('#vmHcStretch').hide();		
		$('#vmHcStretch').show();
        $('#vmHcStretch2').hide();		
		$('#vmHcStretch2').show();
		$('#vmHcBorder').show();
		$('#vmHcChild').show();
        $('.vmColumn').show();
	});
	$('#vmHcOver').mouseover(function(){
		$('#vmHc').hide();
		$('#vmHcBcg').hide();
		$('#vmHcBorder').hide();
		$('#vmHcMother').hide();		
		$('#vmHcStretch').hide();
        $('#vmHcStretch2').hide();
		$('#vmHcBorder').hide();
		$('#vmHcChild').hide();
		$('#vmHcOver').hide();
        $('.vmColumn').hide();
		$('#left-col-sb').css('z-index','');
	});

	$('#interactivesLibrary').mouseover(function(){
        $('#vmL').hide();
		$('#vmHc').hide();
		$('#vmIl').show();
		$('#vmIlBcg').slideDown();
		$('#vmIlBorder').slideDown();
		$('#vmIlMother').show("500");	
		$('#vmIlOver').show();
        $('#vmIlMother p a:first').click();
	});
	$('#vmIlMother').find("p").find("a").css("cursor","pointer");
	$('#vmIlMother').find("p").find("a").click(function(){
		$('#vmIlBorder').hide();
		$('#vmIlStretch').hide();		
		$('#vmIlStretch').show();
        $('#vmIlStretch2').show();
		$('#vmIlBorder').show();
		$('#vmIlChild').show();
        $('.vmColumn').show();
	});
	$('#vmIlOver').mouseover(function(){
		$('#vmIl').hide();
		$('#vmIlBcg').hide();
		$('#vmIlBorder').hide();
		$('#vmIlMother').hide();		
		$('#vmIlStretch').hide();
        $('#vmIlStretch2').hide();
		$('#vmIlBorder').hide();
		$('#vmIlChild').hide();
		$('#vmIlOver').hide();
        $('.vmColumn').show(); 
	});
	
   $('#breadcrumb')
			.before('<div id="vmL" class="vmContainer"><div id="vmLBcg"><div id="vmMother" class="vmColumn" style="border:0 none !important"><p><a href="/licensing_images?lict_g=web">Images (Web Only)</a></p><p><a href="/licensing_images?lict_g=press">Images (Print and Web)</a></p><p><a href="/licensing_videos">Videos</a></p><p><a href="/licensing_interactives">Interactives</a></p></div></div><div id="vmLBorder" class="vmBorder"><img width="1" height="280" alt="" class="IEFixSB" src="img/general/vmStretchBorder.png"></div></div><div id="vmLOver"></div>')
  
    $('#licensing').mouseover(function(){
        $('#vmL').show();
		$('#vmHc').hide();
		$('#vmIl').hide();
		$('#vmLBcg').slideDown();
		$('#vmLBorder').slideDown();
		//$('#vmIlMother').show("500");	
		$('#vmLOver').show();        
    })
    $('#vmLOver').mouseover(function(){
        $('#vmL').hide();
    })

		
	
	$('#vmCatMother').find("p").css("cursor","pointer");
	$('#vmFooterVnMother').find("p").css("cursor","pointer");
	$('#vmHcFooterMother').find("p").css("cursor","pointer");


jQuery( ".textresizer a" ).textresizer({
         target: "#imageLibraryMoreBottomContentText",
         type: "fontSize",
         sizes: [ "11px", "13px", "15px", "17px" ],
         selectedIndex: 1
      });
$('#ts').click(function(){
    $('#ts').css('color','#000');
    $('#tm').css('color','#999');
    $('#tl').css('color','#999');
    $('#tx').css('color','#999');
});
$('#tm').click(function(){
    $('#tm').css('color','#000');
    $('#ts').css('color','#999');
    $('#tl').css('color','#999');
    $('#tx').css('color','#999');
});
$('#tl').click(function(){
    $('#tl').css('color','#000');
    $('#tm').css('color','#999');
    $('#ts').css('color','#999');
    $('#tx').css('color','#999');
});
$('#tx').click(function(){
    $('#tx').css('color','#000');
    $('#tm').css('color','#999');
    $('#tl').css('color','#999');
    $('#ts').css('color','#999');
});

$('#tl').click();
		
});
function rlinks(from,idc,idu){
	var i=0;
	 $('#hcReadMoreRelatedLinkResultWindow #loading').remove();
	 $('.hcReadMoreRelatedLink').remove();
	 $('.pager').empty();
	 $('#hcReadMoreRelatedLinkResultWindow').append('<div id="loading"><img src="img/loader.gif"> Loading</div>');
	 $.ajax({
                 type: "GET",
                 url: "dir/dir_hc_related.php",
                 data: "idc="+idc+"&idu="+idu,
                 dataType: "xml",
                 success: function(xml) {
                 	$('#loading').remove();
                 	$(xml).find('item').each(function(){
						if (i<from+3 && i>=from){
							$('#hcReadMoreRelatedLinkResultWindow').append('<div class="hcReadMoreRelatedLink"><div class="hcReadMoreLinkThumb"><a href="'+$(this).attr('href')+'" target="_blank"><img src="'+$(this).attr('src')+'" alt="" width="120" height="90" /></a></div><div class="hcReadMoreRelatedLinkCont"><div class="hcReadMoreRelatedLinkContTitle"><span class="textRed"><a href="'+$(this).attr('href')+'" target="_blank">'+$(this).attr('title')+'</a></span></div><div class="hcReadMoreRelatedLinksContText">'+$(this).attr('desc')+'</div></div></div>');
														
							
						}
						i++;
                 		});
                 		$('#hcReadMoreRelatedLinkResultWindow').append('<div class="clear"></div>');
                 		var num=Math.floor($(xml).find('hcr').attr('count')/3);
                 		if (num!=$(xml).find('hcr').attr('count')/3)num++;
						if ($(xml).find('hcr').attr('count')==0)$('#hcReadMoreRelatedLinksTitle').remove();
                 		var fromp=from/3+1;
					if (fromp>1){$('.pager').append('<div class="pagerArrow"><a onclick="rlinks('+((fromp>1)?(fromp-2)*3:'0')+','+idc+','+idu+')"><img src="img/general/pager-arrow-back.jpg" width="21" height="16" /></a></div>');}
 					if (fromp>1){
                     for (var b=((fromp>4)?fromp-4:1);b<((((fromp>4)?fromp+4:9)<num+1)?((fromp>4)?fromp+4:9):num+1);b++){
						
						if (b!=fromp){
						  $('.pager').append('<div class="pagerNotCurrent"><p><a onclick="rlinks('+(b-1)*3+','+idc+','+idu+')">'+b+'</a></p></div>');
                        }
						else{
						  $('.pager').append('<div class="pagerCurrent"><p><a onclick="rlinks('+(b-1)*3+','+idc+','+idu+')">'+b+'</a></p></div>');
                        }
					}
					}
					if (fromp!=num && num>1)$('.pager').append('<div class="pagerArrow"><a onclick="rlinks('+((fromp)*3)+','+idc+','+idu+')"><img src="img/general/pager-arrow.jpg" width="21" height="16" /></a></div><div class="clear"></div>');
					
					
					$('.pager a').css('cursor','pointer')
                }
            });
            


}







function loadhc(id,from){
	var i=0;
    var pager=14;
    //if (hcc!=358)$('#vmHcMother p a:first').css('color','#000000');
	 $('#vmHcChild').empty();
	 $('#vmHcChild').append('<div id="loading"><img src="img/loader.gif"> Loading</div>');
     $('#vmHcMother p a').css('color','#000000');
     $('#hcl'+id).css('color','#CC0000');
	 $.ajax({
                 type: "GET",
                 url: "dir/dir_selected.php?idc="+id,
                 dataType: "xml",
                 success: function(xml) {
                    $('#vmHcChild').empty();
                 	$(xml).find('item').each(function(){
                 		$('#loading').remove();
						if (i<from+pager && i>=from){
							$('#vmHcChild').append('<p><a href="'+$(this).attr('href')+'" onmouseover="loadhcr('+$(this).attr('id')+')">'+$(this).attr('title')+' '+'('+$(this).attr('num')+')</a></p>')
							
						}
						i++;
                 		});
                    $(xml).find('right').each(function(){
                 		$('#vmHcStretch2 #vmHcChild').empty().append('<p><a href="'+$(this).attr('href')+'"><strong>'+$(this).attr('title')+'</strong><br><br><img src="'+$(this).attr('image')+'" style="padding-bottom:2px"></a><br>'+$(this).attr('desc')+'...</p>');
                 		});    
                        
                 		var num=$(xml).find('menu').attr('count');
						if (from>0){
							$('#vmHcChild').prepend('<div class="vmBtn" id="vmCatChildPrevBtn"><a onclick="loadhc('+id+','+(from-pager)+')"><img src="img/general/vm_prev_btn.png" width="30" height="15" /></a></div>');
							$('#vmHcChild #vmCatChildPrevBtn').css('display','block');
							$('#vmHcChild #vmCatChildPrevBtn').css('cursor','pointer');
                 		}
                 		if (from+pager<num){
							$('#vmHcChild').append('<div class="vmBtn" id="vmCatChildNextBtn"><a onclick="loadhc('+id+','+(from+pager)+')"><img src="img/general/vm_next_btn.png" width="30" height="15" /></a></div>');
							$('#vmHcChild #vmCatChildNextBtn').css('display','block');
							$('#vmHcChild #vmCatChildNextBtn').css('cursor','pointer');
						}
                }
            });
}
function loadhcr(id){
	 $.ajax({
                 type: "GET",
                 url: "dir/dir_selected.php?idc="+id,
                 dataType: "xml",
                 success: function(xml) {
                    $(xml).find('right').each(function(){
                 		$('#vmHcStretch2 #vmHcChild').empty().append('<p><a href="'+$(this).attr('href')+'"><strong>'+$(this).attr('title')+'</strong><br><br><img src="'+$(this).attr('image')+'" style="padding-bottom:2px"></a><br>'+$(this).attr('desc')+'...</p>');
                 		});    
                }
            });
    
}
function loadhc2(id,from){
	var i=0;
	 $('#vmCatChild').empty();
	 $('#vmCatChild').append('<div id="loading"><img src="img/loader.gif"> Loading</div>');
	 $.ajax({
                 type: "GET",
                 url: "dir/dir_selected.php?idc="+id,
                 dataType: "xml",
                 success: function(xml) {
                    $('#vmCatChild').empty();
                 	$(xml).find('item').each(function(){
                 		$('#loading').remove();
						if (i<from+8 && i>=from){
							$('#vmCatChild').append('<p><a href="'+$(this).attr('href')+'">'+$(this).attr('title')+' '+'('+$(this).attr('num')+')</a></p>')
							
						}
						i++;
                 		});
                 		var num=$(xml).find('menu').attr('count');
						if (from>0){
							$('#vmCatChild').prepend('<div class="vmBtn" id="vmCatChildPrevBtn"><a onclick="loadhc2('+id+','+(from-8)+')"><img src="img/general/vm_prev_btn.png" width="30" height="15" /></a></div>');
							$('#vmCatChild #vmCatChildPrevBtn').css('display','block');
							$('#vmCatChild #vmCatChildPrevBtn').css('cursor','pointer');
                 		}
                 		if (from+8<num){
							$('#vmCatChild').append('<div class="vmBtn" id="vmCatChildNextBtn"><a onclick="loadhc2('+id+','+(from+8)+')"><img src="img/general/vm_next_btn.png" width="30" height="15" /></a></div>');
							$('#vmCatChild #vmCatChildNextBtn').css('display','block');
							$('#vmCatChild #vmCatChildNextBtn').css('cursor','pointer');
							
						}
                }
            });
}
function loadhc3(id,from){
	var i=0;
	 $('#vmFooterVnChild').empty();
//	 $('#vmFooterVnChild').append('<div id="loading"><img src="img/loader.gif"> Loading</div>');
	 $.ajax({
                 type: "GET",
                 url: "dir/dir_selected.php?idc="+id,
                 dataType: "xml",
                 success: function(xml) {
                    $('#vmFooterVnChild').empty();
                 	$(xml).find('item').each(function(){
//                 		$('#loading').remove();
						if (i<from+8 && i>=from){
							$('#vmFooterVnChild').append('<p><a href="'+$(this).attr('href')+'">'+$(this).attr('title')+' '+'('+$(this).attr('num')+')</a></p>')
							
						}
						i++;
                 		});
                 		var num=$(xml).find('menu').attr('count');
						if (from>0){
							$('#vmFooterVnChild').prepend('<div class="vmBtn" id="vmCatChildPrevBtn"><a onclick="loadhc3('+id+','+(from-8)+')"><img src="img/general/vm_prev_btn.png" width="30" height="15" /></a></div>');
							$('#vmFooterVnChild #vmCatChildPrevBtn').css('display','block');
							$('#vmFooterVnChild #vmCatChildPrevBtn').css('cursor','pointer');
                 		}
                 		if (from+8<num){
							$('#vmFooterVnChild').append('<div class="vmBtn" id="vmCatChildNextBtn"><a onclick="loadhc3('+id+','+(from+8)+')"><img src="img/general/vm_next_btn.png" width="30" height="15" /></a></div>');
							$('#vmFooterVnChild #vmCatChildNextBtn').css('display','block');
							$('#vmFooterVnChild #vmCatChildNextBtn').css('cursor','pointer');							
						}
                }
            });	
}

function loadil(id,from){
//	$('#vmIlChild').load("dir/dir_il_text.php?idc="+id);
	var i=0;
    //if (id!=1120)$('#vmIlMother p a:first').css('color','#000000');
    $('#vmIlMother p a').css('color','#000000');
    $('#ill'+id).css('color','#CC0000');
	 $('#vmIlChild').empty();
	 $('#vmIlChild').append('<div id="loading"><img src="img/loader.gif"> Loading</div>');
	 $.ajax({
                 type: "GET",
                 url: "dir/dir_il_text.php?idc="+id,
                 dataType: "xml",
                 success: function(xml) {
                    $('#vmIlChild').empty();
                 	$(xml).find('item').each(function(){
                 		$('#loading').remove();
						if (i<from+8 && i>=from){
							$('#vmIlChild').append('<p><a href="'+$(this).attr('href')+'" onmouseover="loadilr('+$(this).attr('id')+')">'+$(this).attr('title')+' '+(($(this).attr('num')>0)?'('+$(this).attr('num')+')':'')+'</a></p>')
						}
						i++;
                 		});
	                   $(xml).find('right').each(function(){
                 		$('#vmIlStretch2 #vmIlChild').empty().append('<p><a href="'+$(this).attr('href')+'"><strong>'+$(this).attr('title')+'</strong></a><br><br><img src="'+$(this).attr('image')+'"><br>'+$(this).attr('desc')+'</p>');
                 		});                        
                 		var num=$(xml).find('menu').attr('count');
						if (from>0){
							$('#vmIlChild').prepend('<div class="vmBtn" id="vmCatChildPrevBtn"><a onclick="loadil('+id+','+(from-8)+')"><img src="img/general/vm_prev_btn.png" width="30" height="15" /></a></div>');
							$('#vmIlChild #vmCatChildPrevBtn').css('display','block');
							$('#vmIlChild #vmCatChildPrevBtn').css('cursor','pointer');
                 		}
                 		if (from+8<num){
							$('#vmIlChild').append('<div class="vmBtn" id="vmCatChildNextBtn"><a onclick="loadil('+id+','+(from+8)+')"><img src="img/general/vm_next_btn.png" width="30" height="15" /></a></div>');
							$('#vmIlChild #vmCatChildNextBtn').css('display','block');
							$('#vmIlChild #vmCatChildNextBtn').css('cursor','pointer');							
						}
                }
            });		
}
function loadilr(id){
	 $.ajax({
                 type: "GET",
                 url: "dir/dir_il_text.php?idc="+id,
                 dataType: "xml",
                 success: function(xml) {
	                   $(xml).find('right').each(function(){
                 		$('#vmIlStretch2 #vmIlChild').empty().append('<p><a href="'+$(this).attr('href')+'"><strong>'+$(this).attr('title')+'</strong></a><br><br><img src="'+$(this).attr('image')+'"><br>'+$(this).attr('desc')+'</p>');
                 		});                        
                }
            });    
}
function loadil2(id,from){
//	$('#vmFooterHcChild').load("dir/dir_il_text.php?idc="+id);
	var i=0;
	 $('#vmFooterHcChild').empty();
//	 $('#vmFooterHcChild').append('<div id="loading"><img src="img/loader.gif"> Loading</div>');
	 $.ajax({
                 type: "GET",
                 url: "dir/dir_il_text.php?idc="+id,
                 dataType: "xml",
                 success: function(xml) {
                    $('#vmFooterHcChild').empty();
                 	$(xml).find('item').each(function(){
//                 		$('#loading').remove();
						if (i<from+8 && i>=from){
							$('#vmFooterHcChild').append('<p><a href="'+$(this).attr('href')+'">'+$(this).attr('title')+' '+(($(this).attr('num')>'0')?'('+$(this).attr('num')+')':'')+'</a></p>')
							
						}
						i++;
                 		});
                 		var num=$(xml).find('menu').attr('count');
						if (from>0){
							$('#vmFooterHcChild').prepend('<div class="vmBtn" id="vmCatChildPrevBtn"><a onclick="loadil('+id+','+(from-8)+')"><img src="img/general/vm_prev_btn.png" width="30" height="15" /></a></div>');
							$('#vmFooterHcChild #vmCatChildPrevBtn').css('display','block');
							$('#vmFooterHcChild #vmCatChildPrevBtn').css('cursor','pointer');
                 		}
                 		if (from+8<num){
							$('#vmFooterHcChild').append('<div class="vmBtn" id="vmCatChildNextBtn"><a onclick="loadil('+id+','+(from+8)+')"><img src="img/general/vm_next_btn.png" width="30" height="15" /></a></div>');
							$('#vmFooterHcChild #vmCatChildNextBtn').css('display','block');
							$('#vmFooterHcChild #vmCatChildNextBtn').css('cursor','pointer');
							
						}
                }
            });	
}
function getURLVar(urlVarName) {
   var urlHalves = String(document.location).toLowerCase().split('?');
   var urlVarValue = '';
   if(urlHalves[1]){
      var urlVars = urlHalves[1].split('&');
      for(var i=0; i<=(urlVars.length); i++){
         if(urlVars[i]){
            var urlVarPair = urlVars[i].split('=');
            if (urlVarPair[0] && urlVarPair[0] == urlVarName.toLowerCase()) {
               urlVarValue = urlVarPair[1];
            }
         }
      }
   }
   return urlVarValue;
}
