jQuery(function($){
	/*
	* Resistor filter
	*/
    // show hide filter options
    $('div#rfilter h3 a').click(function(e){
        e.preventDefault();
        $(this).blur();
        $(this).parent().next('ul').slideToggle();
        $(this).toggleClass('active');
    });

    // select filter options and submit form
    $('div#rfilter li a').click(function(e){
        e.preventDefault();
        // toggle checkboxes
        checkbox = $(this).prev('input:checkbox');
        if (checkbox.is(':checked')) {
            checkbox.attr('checked', false);
        } else{
            checkbox.attr('checked', true);
        }
        // submit form
        $('div#rfilter form').submit();

    });




	/**
     * make quick quote easier to click
     */
	$("#contact_quote").click(function(){ window.location = '/your-quick-quote/' });





	/**
     * initialize scrollable
     */
	$(".scrollable").scrollable({circular: true}).autoscroll(6000);



    /**
     * Use rel=external to open new windows
     */
    var externalLinksConfirmation = true;
    var externalLinksUseTitle = true;
    $('a[rel*=external]').live('click', function(e){

        e.preventDefault();

        if(externalLinksConfirmation) {

            if($(this).attr('title') != '' && externalLinksUseTitle) {
                msg = $(this).attr('title');
            }
            else {
                msg = $(this).attr('href');
            }

            if(confirm('\'' + msg + "',\nwill open in a new window/tab.\n\nDo you want to continue?")) {
                newWindow = window.open($(this).attr('href'), 'mylorWindow');
                newWindow.focus();
            }
        }
        else {
            newWindow = window.open($(this).attr('href'), 'mylorWindow');
            newWindow.focus();
        }

    });

	/*
	* Resistor quickfinder
	*/
    $('a.drop').click(function(e){
        e.preventDefault();
        $(this).blur();
        $(this).toggleClass('active');
        $(this).next('ul').slideToggle().toggleClass('divtohide');
    });

	// hide quickfinder if clicked
	$(document).bind('click', function(e) {
	 	var $clicked = $(e.target);
		if ($clicked.is('a.drop')) {
			//nothing;
		} else {
	        $(".divtohide").hide();
	        $(".divtohide").removeClass('divtohide');

		}
	});

	/**
	 * PrettyPhoto
	 */
	$("a[rel^='prettyPhoto']").prettyPhoto({
										overlay_gallery: false,
										show_title: false,
										showTitle: false,
										social_tools: false,
										theme: 'facebook',
										modal: true,
										deeplinking: false,
										opacity: 0.25
										});


});


