$(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");

	$('#healthCenters').mouseover(function(){
		$('#vmIl').hide();
		$('#vmHc').show();
		$('#vmHcBcg').slideDown();
		$('#vmHcBorder').slideDown();
		$('#vmHcMother').show("500");	
		$('#vmHcOver').show();
	});
	$('#vmHcMother').find("p").find("a").css("cursor","pointer");
	$('#vmHcMother').find("p").find("a").click(function(){
		$('#vmHcBorder').hide();
		$('#vmHcStretch').hide();		
		$('#vmHcStretch').show();
		$('#vmHcBorder').show();
		$('#vmHcChild').show();
	});
	$('#vmHcOver').mouseover(function(){
		$('#vmHc').hide();
		$('#vmHcBcg').hide();
		$('#vmHcBorder').hide();
		$('#vmHcMother').hide();		
		$('#vmHcStretch').hide();
		$('#vmHcBorder').hide();
		$('#vmHcChild').hide();
		$('#vmHcOver').hide();
	})

	$('#interactivesLibrary').mouseover(function(){
		$('#vmHc').hide();
		$('#vmIl').show();
		$('#vmIlBcg').slideDown();
		$('#vmIlBorder').slideDown();
		$('#vmIlMother').show("500");	
		$('#vmIlOver').show();
	});
	$('#vmIlMother').find("p").find("a").css("cursor","pointer");
	$('#vmIlMother').find("p").find("a").click(function(){
		$('#vmIlBorder').hide();
		$('#vmIlStretch').hide();		
		$('#vmIlStretch').show();
		$('#vmIlBorder').show();
		$('#vmIlChild').show();
	});
	$('#vmIlOver').mouseover(function(){
		$('#vmIl').hide();
		$('#vmIlBcg').hide();
		$('#vmIlBorder').hide();
		$('#vmIlMother').hide();		
		$('#vmIlStretch').hide();
		$('#vmIlBorder').hide();
		$('#vmIlChild').hide();
		$('#vmIlOver').hide();
	});
		
	
	$('#vmCatMother').find("p").css("cursor","pointer");
	$('#vmFooterVnMother').find("p").css("cursor","pointer");
	$('#vmHcFooterMother').find("p").css("cursor","pointer");
		
		
});


function loadhc(id,from){
	var i=0;
	 $('#vmHcChild').empty();
	 $('#vmHcChild').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) {
                 	$(xml).find('item').each(function(){
                 		$('#loading').remove();
						if (i<from+8 && i>=from){
							$('#vmHcChild').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){
							$('#vmHcChild').prepend('<div class="vmBtn" id="vmCatChildPrevBtn"><a onclick="loadhc('+id+','+(from-8)+')"><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+8<num){
							$('#vmHcChild').append('<div class="vmBtn" id="vmCatChildNextBtn"><a onclick="loadhc('+id+','+(from+8)+')"><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 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) {
                 	$(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) {
                 	$(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;
	 $('#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) {
                 	$(xml).find('item').each(function(){
                 		$('#loading').remove();
						if (i<from+8 && i>=from){
							$('#vmIlChild').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){
							$('#vmIlChild').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>');
							$('#vmIlChild #vmCatChildPrevBtn').css('display','block');
							$('#vmIlChild #vmCatChildPrevBtn').css('cursor','pointer');
                 		}
                 		if (from+8<num){
							$('#vmIlChild').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>');
							$('#vmIlChild #vmCatChildNextBtn').css('display','block');
							$('#vmIlChild #vmCatChildNextBtn').css('cursor','pointer');							
						}
                }
            });		
}
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) {
                 	$(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="loadhc3('+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="loadhc3('+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');
							
						}
                }
            });	
}