//HandySoft.com Main JavaScript Resource

//TOP LINK BAR ... LOCATIONS
$(document).ready(function(){
	$("li#geography > ul#locations").hide();
	
	$("li#geography").hover(
		//over
		function() {
			//$(this).children("#locations").slideDown("fast");
			$(this).children("#locations").show();
		}, 
		//out
		function() {
			//$(this).children("#locations").slideUp("slow");	
			$(this).children("#locations").hide();	
		}
	);

});
//END TOP LINK BAR

//TOP & SIDE NAVIGATION ... 
$(document).ready(function(){
	//hide the overview nav link
	//$("#nav > #appMenuBar > #appMenuTop > ul > #overview_nav").hide();
	
	
	//add a closer to the top navigation collection
	$("#nav > #appMenuBar > li > ul").append('<li class="closer">&nbsp;</li>');
	
	//add a bottom class to the next to last element in secondary navigation
	$("div.secondaryNav > ul > li:last").addClass("bottom");
});
//END TOP & SIDE NAVIGATION ...

//DOWNLOADS 
$(document).ready( function() {
	//hide all descriptions that are not the first element in the collection
	$("ul.downloads > li:not(:first-child) > div.information").hide();
	
	//turn on first in each download section
	$("ul.downloads > li:first-child > div.title > a:first-child").addClass("collapse");
		
	$("ul.downloads > li > div.title > a:first-child").click(function() {
		$(this).parent().siblings("div.information").slideToggle("fast");
		$(this).toggleClass("collapse");
		return false;
	});
	

});
//END DOWNLOADS 

//TAB NAVIGATION
$(document).ready(function() {
	//select the "first" tab -- actually second li b/c of the leftCorner item
	$("ul.tabMenu > li:eq(1)").addClass("selected");
	//turn off all tab content except first
	$("div.tabContent:gt(0)").hide();
	//toggle tabContent based on tab selection

	$("ul.tabMenu > li:gt(0) > a").click(function() {
		var ON_CLASS = "selected";
        if (!$(this.parentNode).is('.' + ON_CLASS)) {
            var re = /([_\-\w]+$)/i;
            var target = $('#' + re.exec(this.href)[1]);
            if (target.size() > 0) {
                $('div.tabContent:visible').hide();
                target.show();
                $('ul.tabMenu>li').removeClass(ON_CLASS);
                $(this.parentNode).addClass(ON_CLASS);
            } else {
                alert('There is no such container.');
            }
		}

		//hide the current tab (visible content)
		//$("div.tabContent:visible").slideUp("fast", function() {
		//	$new_tab_content.slideDown("fast");
		//});
		
		return false;
	});
});
//END TAB NAVIGATION

//SFDC Web2Lead FORM SUBMISSION
$(document).ready(function() {
	$("#ContactFormSubmitBttn").click(function() {
		//get the form!
		var $form = $("#ContactForm");
		if (Validate()) {
		  if (typeof __konSubmit == 'function'){
        __konSubmit();
      }
			$form.submit();
		} else {
			return false;
		}
	});

});
//END SFDC Web2Lead FORM SUBMISSION

//SFDC Taskit Registration FORM SUBMISSION
$(document).ready(function() {
	$("#RegistrationFormSubmitBttn").click(function() {
		//get the form!
		var $form = $("#RegistrationForm");
		if (Validate()) {
			$form.submit();
		} else {
			return false;
		}
	});

});
//END SFDC Web2Lead FORM SUBMISSION

//MINI CONTACT FORM SUBMISSION
$(document).ready(function() {
	$("#MiniContactSubmitBttn").click(function() {
	  if (typeof __konSubmit == 'function'){
      __konSubmit();
    }
		$("#MiniContactForm").submit();
	});

});

//END MINI CONTACT FORM SUBMISSION


//START VIEW DEMO CLICK HANDLING
$(document).ready(function() {

	$(".viewDemo").click(function() {
		var $demo = $(this).attr("demo") || null;
		if ($demo == null) {
			return ShowBizFlowDemoSelection();
		} else {
			ShowBizFlowDemo($demo);
		}
		return false;
	});

});


function ShowBizFlowVideo() {
		//return tb_show('What is BizFlow<sup>&reg;</sup>','/whatisbizflow?KeepThis=true&TB_iframe=true&height=410&width=600');
		ShowBizFlowDemoSelection();
}
function ShowBizFlowDemoSelection() {
	window.location="/whatisbizflow";
	return false;
}

function ShowBizFlowDemo(demo) {
		return tb_show('What is BizFlow<sup>&reg;</sup>','/whatisbizflow/'+demo+'?KeepThis=true&TB_iframe=true&height=420&width=600');
}


//PRINT Job Page function
$(document).ready(function() {
	//attach print function to all print links
	$('.print_me').click(function() {
		//someone clicked a print link
		print_this_page();
	})
});

function print_this_page() {
	window.print();
}
//END VIEW DEMO CLICK HANDLING	
