$(document).ready(function()
{		
$.localScroll();

$('.boxgrid.slidedown').hover(function(){
		$(".cover", this).stop().animate({ opacity: 0},{queue:false,duration:1000});
	}, function() {
		$(".cover", this).stop().animate({opacity: 1.0},{queue:false,duration:600});
	});

$('.boxgridNew.slidedown').hover(function(){
		$(".cover", this).stop().animate({ opacity: 0},{queue:false,duration:1000});
	}, function() {
		$(".cover", this).stop().animate({opacity: 1.0},{queue:false,duration:600});
	});

$('td#campaignTop').click(
function()
{
        window.location.href= $(this).attr("url");
	//	window.open($(this).attr("url"));
        return false;
   
 /*   window.location = $(this).attr("url"); */
});

function addMega(){
        $(this).addClass("hovering");
		var getTabId = "." + $(this).attr("id");
		$(getTabId).addClass("tabOver");
        }
 
      function removeMega(){
        $(this).removeClass("hovering");
		var getTabId = "." + $(this).attr("id");
		$(getTabId).removeClass("tabOver");
        }
 
    var megaConfig = {
         interval: 100,
         sensitivity: 4,
         over: addMega,
         timeout: 100,
         out: removeMega
    };
	
	function addMegaFlags(){
        $(this).addClass("hovering");
        }
 
      function removeMegaFlags(){
        $(this).removeClass("hovering");
        }
 
    var megaConfigFlags = {
         interval: 200,
         sensitivity: 4,
         over: addMegaFlags,
         timeout: 500,
         out: removeMegaFlags
    };
	    
	//$("li.flagsTop").hoverIntent(megaConfigFlags);
	    
	$("li.mega").hoverIntent(megaConfig);
	
		$("#product_type").change(function(){
		check_science_server();
	});
	check_science_server();
	
	$("#number_of_licenses").change(function(){
		check_values_shop();										 
	});
	
	$("#product_type").change(function(){
		check_values_shop();										 
	});	

	$('.tx_comment li:even').addClass("alt_comments");
    $('#download_mlst').hide();
    $('.download_plugin').hide();  
    $('.show_download_mlst').click(function(){
    	$('#download_mlst').show('slow');
    });  
    $('.show_download_plugin').click(function(){
    	$('.download_plugin').show('slow');  
    });
	$('#reseller_levels_header').click(function(){
		$('#reseller_levels').toggle('slow');												
	});
	$('#reseller_currency_header').click(function(){
		$('#reseller_currency').toggle('slow');												
	});
	$('#reseller_new_product_header').click(function(){
		$('#reseller_new_product').toggle('slow');												
	});
	$('#reseller_product_prices_header').click(function(){
		$('#reseller_product_prices').toggle('slow');												
	});
	$('.hmmr_table tr:not(:first):not(:last)').mouseover(function(){
		$(this).addClass("table_hover");}).mouseout(function()
		{$(this).removeClass("table_hover");
		});
	
	$('#toggle_rawdata').click(function(){
		$('#raw_data').toggle();									
		  });
	
	var platform = $("input[name='type']:checked").val();
	var product = $("input[name='product']").val();
	var select64 = false;
	
	if (product == "CLC Genomics Server Beta" || product == "CLC Genomics Server" || product == "CLC Genomics Workbench" || product == "CLC Genomics Workbench Beta" || product == "Assembly cell" || product == "BFX cell"){
		select64 = true;
	}
	
	if (platform == "windows") {windows(select64);};
	if (platform == "linux_installer") {linux_installer(select64);};
	if (platform == "linux_installer_rpm") {linux_installer_rpm(select64);};
	if (platform == "mac") {mac(select64);};
	$('#linux_rpm:radio').click(function(){
			linux_installer_rpm(product);
			});
	$('#type-linux-installer:radio').click(function(){
			linux_installer(product);
			});
	$('#type-windows:radio').click(function(){
			windows(product);	
		  });
	$('#type-mac:radio').click(function(){
			mac(product);
		  });
	function linux_installer(select64){
		  $('#64bit_linux').attr('disabled', false);
		  $('#64bit_linux_rpm').attr('disabled', true).attr('checked', false);
		  $('#64bit_windows').attr('disabled', true).attr('checked', false);
		  $('#64bit_mac').attr('disabled', true).attr('checked', false);		  
		  $('.64bit_linux').css({ color: "#fff"});
		  $('.64bit_windows').css({ color: "#cccccc"});
		  $('.64bit_linux_rpm').css({ color: "#cccccc"});
		  $('.64bit_mac').css({ color: "#cccccc"});
		  if (select64) {
	  		  $('#64bit_linux').attr('checked', true);
		  }	
		}
	function linux_installer_rpm(select64){
		  $('#64bit_linux_rpm').attr('disabled', false);
		  $('#64bit_mac').attr('disabled', true).attr('checked', false);		  
		  $('#64bit_windows').attr('disabled', true).attr('checked', false);
		  $('#64bit_linux').attr('disabled', true).attr('checked', false);
		  $('.64bit_linux').css({ color: "#cccccc"});
		  $('.64bit_linux_rpm').css({ color: "#fff"});
		  $('.64bit_windows').css({ color: "#cccccc"}); 
		  if (select64) {
	  		  $('#64bit_linux_rpm').attr('checked', true);
		  }		  
		}
	function windows(select64){
		  $('#64bit_mac').attr('disabled', true).attr('checked', false);	
		  $('#64bit_windows').attr('disabled', false);
		  $('#64bit_linux').attr('disabled', true).attr('checked', false);
		  $('#64bit_linux_rpm').attr('disabled', true).attr('checked', false);
		  $('.64bit_linux').css({ color: "#cccccc"});
		  $('.64bit_linux_rpm').css({ color: "#cccccc"});
		  $('.64bit_windows').css({ color: "#fff"});
		  $('.64bit_mac').css({ color: "#cccccc"});		  
		  if (select64) {
	  		  $('#64bit_windows').attr('checked', true);
		  }
	}
	function mac(select64){
		  $('#64bit_mac').attr('disabled', false);
		  $('#64bit_windows').attr('disabled', true).attr('checked', false);
		  $('#64bit_linux').attr('disabled', true).attr('checked', false);
		  $('#64bit_linux_rpm').attr('disabled', true).attr('checked', false);
		  $('.64bit_linux').css({ color: "#cccccc"});
		  $('.64bit_linux_rpm').css({ color: "#cccccc"});
		  $('.64bit_windows').css({ color: "#cccccc"});
		  $('.64bit_mac').css({ color: "#fff"});	
		  if (select64) {
			  $('#64bit_mac').attr('checked', true);
		  }		  
	}
	
});
	
function check_values_shop(){
		var value = $("#number_of_licenses").val();
		var wb = $("#product_type").val();
		if (((value == 1) || (value == 2)) && ((wb == "DNA Workbench") || (wb == "RNA Workbench")  || (wb == "Protein Workbench")  || (wb == "Main Workbench") )){
			$("#link_to_shop").show("slow");
		}
		else{
			$("#link_to_shop").hide();		
		}
}

function check_science_server(){
		if ($("#product_type").val() == "Science Server"){
			$("#number_of_licenses").val("Other");
			$("#number_of_licenses").attr("disabled","disabled");
		}
		else {
			if ($("#number_of_licenses").val() == "Other"){
				$("#number_of_licenses").val("Potential number of licenses");
				$("#number_of_licenses").removeAttr("disabled");
			}
		}	
	}

