/* === Navigation === */

jQuery(document).ready(function($) {

	// get active page
	$(".current-page-ancestor a span").css({opacity: 1});
	$(".current-menu-item a span").css({opacity: 1});
	$(".current-page-ancestor").addClass('active');
	$(".current-menu-item").addClass('active');
	
	$("#divMenu a").hover(
		function() {
			var title = $(this).find('div').html();
			if (title.length > 10) {
				title = title.substr(0, 7) + '...';
			}
			$("#divMenuTitle").html(title);
			$(this).find("span").animate({opacity: 1}, "fast");
		},
		function() {
			$("#divMenuTitle").html('');
			$(this).find("span").stop().animate({opacity: 0}, "normal");
		}
	);

	$("#divMenu .active a").hover(function() {
		$(this).find("span").stop();							  
	});
	
	$("#divSubMenu li").hover(
		function() {
			$(this).css({fontSize: "24px"});
		},
		function() {
			$(this).animate({fontSize: "16px"}, "fast");
		}
	);
	
	$("#divSubMenu li.current_page_item").hover(function() {
		$(this).stop();
	})
	
//	try {
		var os = getOS();
		if (os == "mac") {
			$("#qs").attr('href', 'http://www.sog-ict.nl/wp-content/uploads/2011/08/TeamViewerQS.dmg');
		} else if (os == "windows") {
			$("#qs").attr('href', 'http://www.sog-ict.nl/wp-content/uploads/2011/08/TeamViewerQS.exe');
		} else if (os == "linux") {
			$("#qs").hide();
		} else if(os == "mobile") {
			$("#qs").hide();
		}
//	}
//	catch(e) {}

});

function getOS()  {
	if (navigator.platform.toLowerCase().indexOf("win") > -1)
		return "windows";
	else if (navigator.platform.toLowerCase().indexOf("mac") > -1)
		return "mac";
	else if (navigator.userAgent.toLowerCase().indexOf("ipod") > -1 || navigator.userAgent.toLowerCase().indexOf("iphone") > -1 || navigator.userAgent.toLowerCase().indexOf("ipad") > -1 || navigator.userAgent.toLowerCase().indexOf("android") > -1)
		return "mobile";
	else if  (navigator.platform.toLowerCase().indexOf("linux") > -1)
		return "linux";
	else
		return "windows";
}

function SetDownloadUrls(macQS, macFull) {
	try {
		var os = GetOS();
		if (os == "mac") {
			document.getElementById("dlQS").href = macQS;
		} else if (os == "linux") {
			document.getElementById("dlQS").parentNode.parentNode.style.display = "none";		
		} else if(os == "mobile") {
			document.getElementById("dlQS").parentNode.parentNode.style.display = "none";
		}
	}
	catch(e) {}
}


