$(document).ready(function() {
    // apply lightbox effect to all links in entries that link directly to an image
    var i=0;
    $(".entry").each(function(){
        i++;
        $(this).find("a[href$='.jpg'] > img, a[href$='.png'] > img, a[href$='.gif'] > img").parent().attr("rel","lightbox-"+i);

    });
    // style direct-sales paragraphs
    $("a[href*='/direct/']").parent().addClass("direct");

    // Candara renders larger than Helvetica/Arial, so we must shrink things
    d = new Detector();
	if (d.test('Candara')===false) {
		$("h2").css({'font-size': '2.25em'});
		$("h3, .sidebarPanel .big, .sidebarPanel dt").css({'font-size': '1.3em'});
		$(".productsWeLove p, .sidebarPanel dl").css({'font-size': '1em'});
	}


});

function collapseImgParagraphs() {
    $(document).ready(function() {
        // find P's that are solely used to hold one image. IE8 gives the P height which misaligns the line vs. all other browsers (including IE7)
        $("p a img:only-child").parent().parent().css({
            'float': 'right',
            'margin-top': '.15em'
        });
    })
}

// Image Promo by Dylan Wagstaff, http://www.alohatechsupport.net
// http://www.alohatechsupport.net/webdesignmaui/maui-web-site-design/easy_jquery_auto_image_promo.html

function theRotator() {
	//Set the opacity of all images to 0
	$('div#promo ul li').css({opacity: 0.0});
	//Get the first image and display it (gets set to full opacity)
	$('div#promo ul li:first').css({opacity: 1.0});
	//Call the promo function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',4000);
}

function rotate() {
	//Get the first image
	var current = ($('div#promo ul li.show')?  $('div#promo ul li.show') : $('div#promo ul li:first'));
	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#promo ul li:first') :current.next()) : $('div#promo ul li:first'));
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
};


function checkgetInTouchForm() {
    name=document.getInTouch.getInTouchName.value;
    email=document.getInTouch.getInTouchEmail.value;
    comment=document.getInTouch.getInTouchComment.value;
    // make sure nothing is blank
    if ((name=="Your Name") || (name.length<2)) {
        alert("Please enter your name.");
        document.getInTouch.getInTouchName.focus();
        return false;
    }
    email = email.toLowerCase();
    if (!(email.search(/^([a-z]+)([a-z0-9\-\_\.]{1,100})([a-z0-9]+)\@([a-z0-9]+)([a-z0-9\-\.]*)([a-z0-9]+)\.([a-z]{2,6})$/) != -1)) {
        alert("Please provide a valid email address.");
        document.getInTouch.getInTouchEmail.focus();
        return false;
    }
    if ((comment=="Your Question/Comment") || (comment.length<10)) {
        alert("Please enter a comment.");
        document.getInTouch.getInTouchComment.focus();
        return false;
    } else {
        return true;
    }
}




