﻿$(document).ready(function(){
	$("#nav li").hover(
		function(){ $("ul", this).fadeIn("fast");}, 
		function() { } 
	);
	if (document.all) {
		$("#nav li").hoverClass("sfHover");
	}
	
	$("#emailform").submit(function(){
	
		var str = $(this).serialize();
		
		$.ajax({
			type: "POST",
			url: "../php/subscribe.php",
			data: str,
			success: function(msg){
				if (msg == 'OK') {
					$("#subscribe #email").val("");
					$("#subscribe #error-msg").html("thanks for joining our list!");
				} else {
					$("#subscribe #error-msg").html(msg);
				}
			},
			error: function() {
				$("#subscribe #error-msg").html("server error: try again later.");
			}
		});
		
		return false;
	});
	
});

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c); },
			function() { $(this).removeClass(c); }
		);
	});
};

function writeObjTag(url) {
	document.writeln("<OBJECT classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' width='320' height='255' codebase='http://www.apple.com/qtactivex/qtplugin.cab'><param name='src' value='" + url + "'><param name='autoplay' value='false'><param name='controller' value='true'><param name='loop' value='false'><EMBED src='../video/trailer_adipp_med.mov' width='320' height='255' autoplay='false' controller='true' loop='false' pluginspage='http://www.apple.com/quicktime/download/'></EMBED></OBJECT>");
}

function buy() {
	var url = document.forms["buy_form"].elements["buy_select"].options[document.forms["buy_form"].elements["buy_select"].selectedIndex].value;
	if (url == "") {
		alert('Please select a version ("Home Use" or "Institutional/Educational")');
	} else {
		window.open(url, "_blank");
	}
}
