/*
	DATE		MODIFIER	COMMENTS
	2010-12-13	MRB			Added tooltip "Demo" field of demo signup form.
*/

$(document).ready(function () {

    // Initialize the drop-down menu
    $("ul.sf-menu").supersubs({
            minWidth:    12,   // minimum width of sub-menus in em units
            maxWidth:    27,   // maximum width of sub-menus in em units
            extraWidth:  1     // extra width can ensure lines don't sometimes turn over
                               // due to slight rounding differences and font-family
        }).superfish({
			autoArrows:    false,
			dropShadows:   false
		});

	// Initialize any accordions
//	$(".accordion").accordion({active: false, autoHeight: false, collapsible: true, header: "h3"});

	// Open the feedback form in a modal window
	$("#feedbackButton").click(function () {

		$.fn.colorbox({
						href: "#feedbackForm",
						inline: true,
						innerWidth: "550px",
						onCleanup: function () { $("#feedbackForm").hide(); },
						onOpen: function () { $("#feedbackForm").show(); },
						opacity: 0.65,
						open: true,
						scrolling: false,
						slideshow: false,
						width: "565px"
		});

	});

	// Update anti-SPAM field in the contact, feedback, and signup forms
	$("#contactForm input[name='_i_hate_spam_'], #feedbackForm input[name='_i_hate_spam_'], #signupForm input[name='_i_hate_spam_']").val("14");

	// Open the testimonial, demo, or non-OI/RI demo videos in a modal window
	$("a[rel='testimonial']").colorbox({current: "", iframe: true, innerHeight: "385px", innerWidth: "480px", opacity: 0.65});
	$("a[rel='demo']").colorbox({current: "", iframe: true, innerHeight: "581px", innerWidth: "900px", opacity: 0.65, rel: "nofollow"});
	$("a[rel='otherDemo']").colorbox({current: "", iframe: true, innerHeight: "650px", innerWidth: "760px", opacity: 0.65, rel: "nofollow"});

	// Add tooltips to The iMod Difference imagemap
	$("#imod_difference_map area").each(function () {

		$(this).qtip({
			content: {
				title: {text: $(this).attr("title")},
				text: $(this).attr('alt')
			},
			hide: {
				event: false,
				inactive: 2000
			},
			position: {
				my: 'top left',
				at: 'left center',
				adjust: {x: 50, y: 0}
			},
			style: {
				classes: "ui-tooltip-dark",
				tip: {
					corner: true,
					border: 1,
					width: 14,
					height: 14
				},
				widget: false
			}
		});
	});
	
	// Add tooltips to RI and OI options on the demo sign-up form
	$("#signupForm label[title]").each(function () {

		$(this).qtip({
			content: {
				title:	{text: $(this).attr("title")},
				text:	$(this).attr('alt')
			},
			hide: {
				event: 'mouseleave',
				fixed:	true
			},
			position: {
				my: 'top center',
				at: 'bottom center',
				adjust: {x: 0, y: 0}
			},
			show: {
				event:	'mouseenter',
				ready:	false,
				solo:	true
			},
			style: {
				classes: "ui-tooltip-dark",
				tip: {
					corner: true,
					border: 1,
					width: 14,
					height: 14
				},
				widget: false
			}
		});
	});

	// Clear the search field on focus/blur
	$("#keyword").focus(function (e) {

		if ('Search' == this.value)
			this.value = '';
	});

	$("#keyword").blur(function (e) {

		if ('' == this.value)
			this.value = 'Search';
	});

});
