// JavaScript Document

$(document).ready(function() {
	
	// Hide sub-menu
	//
	$('.level2-link').hide();
	
	// Hide transparent overlay
	$('#maskingTape').hide();
	
	// Link setup 

// I changed attr("title" to attr("titles" so that the links are only on the text not the divs
// and so that the tooltips dont look crappy. -dh 01/04/09


	$('.link').each(function() {
        var linkTitle = $(this).html();
		
		$(this).attr("titles", linkTitle);
	});
	
	// Menu hover actions
	//
	var config = {
		sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
     	interval: 0, // number = milliseconds for onMouseOver polling interval    
     	over: menuOpen, // function = onMouseOver callback (REQUIRED)    
     	timeout: 0, // number = milliseconds delay before onMouseOut    
     	out: menuClose // function = onMouseOut callback (REQUIRED)   	
	}
	//$('.level1-link').hoverIntent(config);
	
	var config2 = {
		sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
     	interval: 0, // number = milliseconds for onMouseOver polling interval    
     	over: menuOpen,
		//JUST LEVEL 2  over: maskingShow, // function = onMouseOver callback (REQUIRED)    
		out: menuClose,
     	timeout: 250 // number = milliseconds delay before onMouseOut    
     	//JUST LEVEL 2  out: maskingHide // function = onMouseOut callback (REQUIRED)   	
	}
	
	$('#menu-main').hoverIntent(config2);
	
	var config3 = {
		sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
     	interval: 200, // number = milliseconds for onMouseOver polling interval    
     	over: level2Highlight, // function = onMouseOver callback (REQUIRED)    
     	timeout: 500, // number = milliseconds delay before onMouseOut    
     	out: level2unHighlight // function = onMouseOut callback (REQUIRED)   	
	}
	$('.level2-link .link').hoverIntent(config3);
	
	// menu click actions
	//
	$('nothing').click(function() {
		var str = $(this).html();
		var splitStr = str.split(" ");
		var section = splitStr[0];
		
		alert('level 1');
		/*window.location.href = section;*/
    });
	
	$('.link', '.level2-link').click(function() {	
		var parentStr = $(this).parent().parent().childre('.link').html();
		var str = $(this).html();
		var splitStr = str.split(" ");
		var subSection = splitStr[0];
		
		alert('level 2');
		
		/*if (splitStr[1] == 'Bio' || splitStr[2] == 'Market') {
			if ( splitStr[1] == 'Bio') {
				window.location.href = 'http://abylity.stcassociates.com/about/bio';
			} else {
				window.location.href = 'http://abylity.stcassociates.com/applications/market';
			}}
			else {
		window.location.href = 'http://abylity.stcassociates.com/' + subSection;
			}*/
    });
	$(function(){
		$.superbox();
	});
	
		var configHover = {
		sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
     	interval: 0, // number = milliseconds for onMouseOver polling interval    
     	over: bottomHoverOn,
		//JUST LEVEL 2  over: maskingShow, // function = onMouseOver callback (REQUIRED)    
		out: bottomHoverOff,
     	timeout: 0 // number = milliseconds delay before onMouseOut    
     	//JUST LEVEL 2  out: maskingHide // function = onMouseOut callback (REQUIRED)   	
	}
	
	// Bottom box hover text
	$('.hoverLink').hoverIntent(configHover);
	
	
	
	
	//QueryString video open and close on finished (marketing link)
	
	var query = $.getQueryString({ ID: "v" });
	switch (query) {
        case 'd1cc':
            $('#hook').click();
            break;
		default:
			break;
	}
});

function menuOpen() {
		//$(this).children('.level2-link').show();
		$('.level2-link').show();
		if (!((navigator.appName == "Microsoft Internet Explorer") && (navigator.appVersion.indexOf('MSIE 8.0') < 1))) {
		    $('#maskingTape').show();
		}		
}
function menuClose() {
		//$(this).children('.level2-link').hide();
		$('.level2-link').hide();
		$('#maskingTape').hide();
}

function maskingShow() {
		$('#maskingTape').show();	
}
function maskingHide() {
		$('#maskingTape').hide();	
}

function level2Highlight() {
//		$(this).effect( "highlight", { color: 'blue' }, 2000);	
}
function level2unHighlight() {
}
function bottomHoverOn() {
	$(this).children('.bottom-tab-hover').show('normal');	
}
function bottomHoverOff() {
	$(this).children('.bottom-tab-hover').hide('normal');	
}


