$(document).ready(function(){
    $('.banner_img ').cycle({
        fx: 'fade',
        timeout: 5000,
        speed: 2000
    });
		
    $('#order').click(function(){
	
        $("#enquiry_product_id").val("Enquiry for " + $(this).attr("title"));
	
        $("#enquiry_product_name").html("Product: " + $(this).attr("title"));
	
    }).colorbox({

        inline: true,
      
        href: '#popup_order'
    });

    $('#enquire').click(function(){
	
        $("#enquiry_product_id").val("Enquiry for " + $(this).attr("title"));
	
        $("#enquiry_product_name").html("Product: " + $(this).attr("title"));
	
    }).colorbox({

        inline: true,
      
        href: '#popup_enquire'
    });

    $('#enquire-contact').click(function(){
	
        $("#enquiry_product_id").val("Enquiry for " + $(this).attr("title"));
	
        $("#enquiry_product_name").html("Product: " + $(this).attr("title"));
	
    }).colorbox({

        inline: true,
      
        href: '#popup_contact'
    });


    /* swap image */
    $("ul.gallery li a").click(function() {
        var mainImage = $(this).attr("href"); //Find Image Name
        var largePath = $(this).attr("rel"); //Find Image Name
        $("#main_view img").attr({
            src: mainImage
        });
        $("#main_view a").attr({
            href: largePath
        });
        $('#main_view a').colorbox({
            href:$(this).attr("rel")
        });
        return false;
    });

    $('#sidebar_links li div').each(function(i,div){
        $(this).css("margin-top", ($(div).siblings().height() - 9) / 2);
    });

    $('.hover_wrapper').hover(mousetrap, mousetrap);

});
function mousetrap(e){
    var rel = $(this).attr("rel");
    if(e.type == "mouseenter"){
        $("a.link[rel='" + rel + "']").css("color","#0A3F42");
        $("div.arrow[rel='" + rel + "']").css("background-position","bottom");
    }
    else{
        $("a.link[rel='" + rel + "']").css("color","#008693");
        $("div.arrow[rel='" + rel + "']").css("background-position","top");
    }
}
