// JavaScript Document

$(document).ready( function() {
	
	$(".sub_navi").animate({opacity:0.8}, 0);
	
	$("#glo_navi").children("li").each( function() {
	
		$(this).hover( 
						   
				function() { 
				
					$(this).parent().children(".main_navi").children(".sub_navi").each( function() {
						$(this).hide();											 
					});
				
					$(this).children('a').addClass('active');
					var obj = $(this).children(".sub_navi");
					setTimeout( function() { obj.show(); }, 0);
				},
				function() {
					$(this).children('a').removeClass('active');
					var obj = $(this).children(".sub_navi");
					setTimeout( function() { obj.hide(); }, 300);
				}
		 );
		
	});
	
	//SUB NAVIGATION LEFT COLUMN//
	$('.content_sidenavi li a').animate( {opacity:0.2}, 0);
	$('.content_sidenavi li span').css('display', 'none');
	
	$('.content_sidenavi li a').hover( 
		function() {
			$(this).parent().children('img').removeClass('invisible'); //css('visibility', 'visible');								
		},
		function() {
			$(this).parent().children('img').addClass('invisible'); //css('visibility', 'hidden');	
		}
	);
	
	//STUDENT OVERVIEW PHOTO EFFECT
	$('.student_overview').each( function() {
										  
		$('a', this).children('span').animate( {opacity:0.8}, 0);
		$('a', this).children('span').hide();		
		
		$('a', this).hover( 
			function() {
				$(this).children('span').show();
			}, function() {
				$(this).children('span').hide();
			}
		);
												
	});
});

//GET MESSAGE FROM XML FILE FOR AJAX ACTION
function getMessage(data) {
	
	if(window.XMLHttpRequest) {
		xht = new XMLHttpRequest();
	}else{
		xht = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xht.open("GET", url+"/js/messages.xml", false);
	xht.send("");
	xmlDoc = xht.responseXML;
	
	try{
		return new Array(xmlDoc.getElementsByTagName(data)[0].childNodes[0].nodeValue, xmlDoc.getElementsByTagName(data)[0].attributes.getNamedItem('color').value);
	} 
	catch(err) {
		return new Array('Sorry, something error occured. Please try again later.', 'F00');
	}
}
