$(document).ready(function(){
	
	$("#header-logo object").hover(
		function() {
			$(this).addClass('pointer-cursor');
		},
		function() {
			$(this).removeClass('pointer-cursor');
		}
		);
	
	$('#header-logo object').click(function(){
		window.location = "http://www.rcdtechnology.com/";
		return false;
	});
	
	// Set up accordion nav
	$('#accordion').accordion({
		autoHeight: false,
		fillSpace: true,
		active: false,
		collapsible: true,
		active: 0
	});
	
	// Set up sidebar accordion nav
	$('#sidebar-accordion').accordion({
		autoHeight:true,
		active:0
	});
	
	// Set up multi-level nav
	$('#header-navigation li').hover(
		function(e) {
			$(this).children('ul').css('visibility','visible');
		},
		function() {
			$(this).children('ul').css('visibility','hidden');
		}
	);
	
	$('#header-navigation').hover(
		function(e) {
			$('#splash, #content, #sidebar').css('z-index','-1');
		},
		function(e){
			$('#splash, #content, #sidebar').css('z-index','1');
		}
	);
	
	// Only select the 2nd level ul's
	$('#header-navigation ul ul').each(function(){
		var topPosition = $('#header-navigation').outerHeight() - $('#header-navigation ul:first-child').outerHeight(true);
		// $(this).css('padding-top', topPosition  + 'px');
	});
	
	
	// Set position for navs
	$('#header-navigation ul ul ul').each(function(){
		$(this).css('padding-top','0');
		var this_offset = $(this).offset();
		var parent_outer_height = $(this).parent('li').outerHeight();
		var parent_height = $(this).parent('li').height();
		$(this).css('left', $(this).parent('li').outerWidth() + 'px');
	});
	
	// Now hide all the subnavs
	// $('#header-navigation ul ul').hide();
	
	// Reset z-index for ul uls
	$("#header-navigation ul ul").css('z-index','100');
	
	// Assign css width/height to specially classed elements
	$("div[class*='jq-width-']").each(function(){
		var dim_data = $(this).attr('class').match(/jq\-width\-(\d+)/);
		$(this).css('width',dim_data[1]+'px');
	});

	// Assign css width/height to specially classed elements
	$("div[class*='jq-height-']").each(function(){
		var dim_data = $(this).attr('class').match(/jq\-height\-(\d+)/);
		$(this).css('height',dim_data[1]+'px');
	});
	
	// Set up form validation
	$('.req').siblings('label').append(" *");
	
	$("#contact-form").submit(function(e){
		var sErrMsg = "";
		
		$('.req').each(function(){
			if($(this).val() == "")
				{
				sErrMsg += "* Please provide your " + $(this).siblings('label').html() + "\n";	
				}
		});

		if (sErrMsg == "") {
			$(this).submit();
			return false;
		} else {
			alert(sErrMsg);
			return false;
		}
	});
	
	$('a[rel=external]').click(function(){
		window.open($(this).attr('href'));
		return false;
	});
	
});
$(window).load(function(){
	$('.grey-border').equalHeights();
	
	// Animate the partner logos on hover
	$('.partner-logo').hover(
		function(e){
			$(this).animate({
				marginLeft: "1em"
			}, 'fast', 'swing');
		},
		function(e){
			$(this).animate({
				marginLeft: "0"
			}, 'fast', 'swing');
		}
		);
	
});

function doSubmit() {
	
}