$(document).ready(function(){
    $('.nav-item img').css('visibility', 'hidden');
	
    $('.nav-item a').mouseover(function(){
        $(this).parent().children('img').css('visibility', 'visible');
    }).mouseout(function(){
        $(this).parent().children('img').css('visibility', 'hidden');
    });
        
    $("#sim_products").change(function(){
        var href = window.baseUrl + "/model/" + $(this).val();
        window.location.href = href;
    });
    $('.default-usage-select').change(function(){
        alert($(this).val());
    });
    $(".default-usage-select").selectbox().bind('change', function(){
        if($(this).val() !== "--"){
            var href = window.baseUrl + "/" + $(this).val();
            window.location.href = href;
        }
    });
    
    
    var productIds = new Array();
    var products = new Array();
    var prtpIds = new Array();
    var productType = false;
    var lasttype = "";
    $(".compare_prod").click(function(){
        products = new Array();
    	
    	
        if(!productType){
            productType = $(this).parent().parent().parent().parent().parent().parent().attr("id");
        }
        
        if ($(".compare_prod:checked").length==0) {
            productType = false;
        }
        
        $(".compare_prod:checked").each(function(){
            var mystr = $(this).attr("id");
            products[products.length] = mystr.slice(8);
            prtpIds[prtpIds.length] = $(this).parent().parent().parent().parent().parent().parent().attr("id");
        	
        });
        
        if (products.length > 4) {
            alert("Please select 4 products or less to compare");
            return false;
        }
        
        if((productType !== $(this).parent().parent().parent().parent().parent().parent().attr("id")) && productType!=false){
            alert(" You can only compare products of the same type");
            return false;
        }
        
    });
    
    $(".compare_button").click(function(){
        var url = "";
        for(var i = 0 ; i < products.length ; i++){
            url += "/productId/" + products[i];
        }
        window.location.href = window.baseUrl + "/compare/view" + url;
        return false;
    });
    
});
$(function() {
    $( "#text-section" ).tabs();
});
