$(document).ready(function() {
	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
	var ie8 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 8.0") != -1);
	
	if (ie55 || ie6) {
		$('.product-demos').cycle({
			fx: 'fade',
			after: onAfter
		});
		$(".left-nav .nav-item").hover( function(){
			if (!$(this).hasClass("current")) {
				$(this).addClass("currentHover");
				currentItem = false;
			}
			else{
				currentItem = true; 
			}
		}, function(){
			$(this).removeClass("currentHover");
		});
	}
	else{
		$('.product-demos').cycle({
			fx: 'fade'
		});
		$('.demo-box').each( function(){
			$(".product-demos").css('margin-left', '0px');
			$(this).css('background', 'none');
		});
	}
	
	$(".right-nav .nav-item").hover(function(){
		if(!$(this).hasClass("selected")){
			$(".right-nav .nav-item").removeClass("selected");
			$(this).addClass("selected");
		}
	}, function(){
			$(".right-nav .nav-item").removeClass("selected");
	});
	
	if (ie8) {
		$('.left-nav a').each( function(){
			var parent = $(this).parent();
			parent.css("margin-bottom", "2px");
		});
	}
	
	$(".input-wrapper select").change( function(){
		var inputValue = this.value;
		var showClass = $(this).find("option[value="+inputValue+"]").attr("class");
		$(this).find("option").each( function(){
			var hideClass = $(this).attr("class");
			if(hideClass && hideClass != showClass)
				$("div."+hideClass).fadeOut("fast");
		});
		
		if(showClass){
			$(this).parent().siblings("div."+showClass).fadeIn("slow");
		}
	});
	
	$(".input-wrapper input:checkbox").change( function(){
		var showClass = $(this).attr("class");
		if (showClass) {
			if ($(this).is(':checked')) {
				$(this).parent().siblings("."+showClass).fadeIn("slow");
			}
			else{
				$(this).parent().siblings("."+showClass).fadeOut("slow");
			}
		}
	});
	
	
	$(".input-wrapper select").each( function(){
		if (this.value) {
			var showClass = $(this).find("option:selected").attr("class");
			if(showClass){
				$(this).parent().siblings("div."+showClass).fadeIn("fasts");
			}
		}
	});
	
	$(".input-wrapper input:checkbox").each( function(){
		if(this.checked){
			var showClass = $(this).attr("class");
			$(this).parent().siblings("."+showClass).fadeIn("fast");
		}
	});
	
	$(".product-table table a").each( function(){
		$(this).attr("target", "new");
	});
	
	
});
function onAfter(){
	var currentContainer = $(".product-demos .demo-box:visible");
	var src = currentContainer.find('a.product-image img').attr("src");
	var title = currentContainer.find('a.product-image img').attr("title");
	var alt = currentContainer.find('a.product-image img').attr("alt");
	
	currentContainer.find('a.product-image').html('<img src="' + src + '" alt="' + alt + '" title="' + title + '" style="max-width:205px; max-height:225px" />');
	currentContainer.find('a.product-image').css("width", "205px");
	currentContainer.find('a.product-image').css("height", "225px");
	currentContainer.find('a.product-image').css("position", "absolute");
	currentContainer.find('a.product-image').pngFix();
	
}