var $j = jQuery.noConflict();
$j(function () {
			 
	$j('a.media').media( { width: 300, height: 20 } );
	
    $j('#submit-newsletter').click(function () {
        parent.$j.fn.colorbox.close();
        $j('#newsletterForm').submit()
    });
    $j('#submit-contact').click(function () {
        parent.$j.fn.colorbox.close();
        $j('#contactform').submit()
    });
    $j('a, area').filter(function () {
        return this.hostname && (this.hostname).split(":")[0] !== (location.hostname).split(":")[0] || $j(this).attr('rel') == 'external'
    }).not(':has(img, div, mailto)').addClass('external').end().click(function (e) {
        open(this.href);
        e.preventDefault()
    });
    /*$j(".signUp").colorbox({
        width: "570px",
        inline: true,
        href: "#signUpContainer"
    });
    $j(".contactUs").colorbox({
        width: "620px",
        inline: true,
        href: "#contactContainer"
    });*/
    $j("ul.tabs").tabs("div.panes > div", {
        event: 'mouseover'
    }).slideshow();
    $j("ul.tabs2").tabs("div.panes2 > div", {
        event: 'mouseover'
    });
    /*$j("ul.tabs3").tabs("div.panes3 > div", {
        event: 'mouseover'
    });*/
    $j("a.feature1 img").hover(function () {
        $j(this).attr("src", "/wp-content/themes/marriage/images/feature1-active.gif");
        $j("a.feature2 img").attr("src", "/wp-content/themes/marriage/images/feature2.gif");
        $j("a.feature3 img").attr("src", "/wp-content/themes/marriage/images/feature3.gif");
        $j("a.feature4 img").attr("src", "/wp-content/themes/marriage/images/feature4.gif")
    });
    $j("a.feature2 img").hover(function () {
        $j(this).attr("src", "/wp-content/themes/marriage/images/feature2-active.gif");
        $j("a.feature1 img").attr("src", "/wp-content/themes/marriage/images/feature1.gif");
        $j("a.feature3 img").attr("src", "/wp-content/themes/marriage/images/feature3.gif");
        $j("a.feature4 img").attr("src", "/wp-content/themes/marriage/images/feature4.gif")
    });
    $j("a.feature3 img").hover(function () {
        $j(this).attr("src", "/wp-content/themes/marriage/images/feature3-active.gif");
        $j("a.feature1 img").attr("src", "/wp-content/themes/marriage/images/feature1.gif");
        $j("a.feature2 img").attr("src", "/wp-content/themes/marriage/images/feature2.gif");
        $j("a.feature4 img").attr("src", "/wp-content/themes/marriage/images/feature4.gif")
    });
    $j("a.feature4 img").hover(function () {
        $j(this).attr("src", "/wp-content/themes/marriage/images/feature4-active.gif");
        $j("a.feature1 img").attr("src", "/wp-content/themes/marriage/images/feature1.gif");
        $j("a.feature2 img").attr("src", "/wp-content/themes/marriage/images/feature2.gif");
        $j("a.feature3 img").attr("src", "/wp-content/themes/marriage/images/feature3.gif")
    });
    /*$j("a.mcm img").hover(function () {
        $j(this).attr("src", "/wp-content/themes/marriage/images/mcm-title-on.png");
        $j("a.hea img").attr("src", "/wp-content/themes/marriage/images/hea-title-off.png")
    });
    $j("a.hea img").hover(function () {
        $j(this).attr("src", "/wp-content/themes/marriage/images/hea-title-on.png");
        $j("a.mcm img").attr("src", "/wp-content/themes/marriage/images/mcm-title-off.png")
    });*/
    $j("a.news img").hover(function () {
        $j(this).attr("src", "/wp-content/themes/marriage/images/marriage-news-tab-active.png");
        $j("a.reviews img").attr("src", "/wp-content/themes/marriage/images/book-reviews-tab.png");
        $j("a.virtues img").attr("src", "/wp-content/themes/marriage/images/marriage-virtues-tab.png")
    });
    $j("a.reviews img").hover(function () {
        $j(this).attr("src", "/wp-content/themes/marriage/images/book-reviews-tab-active.png");
        $j("a.news img").attr("src", "/wp-content/themes/marriage/images/marriage-news-tab.png");
        $j("a.virtues img").attr("src", "/wp-content/themes/marriage/images/marriage-virtues-tab.png")
    });
    $j("a.virtues img").hover(function () {
        $j(this).attr("src", "/wp-content/themes/marriage/images/marriage-virtues-tab-active.png");
        $j("a.reviews img").attr("src", "/wp-content/themes/marriage/images/book-reviews-tab.png");
        $j("a.news img").attr("src", "/wp-content/themes/marriage/images/marriage-news-tab.png")
    });
    $j('#mainNav li.headlink').hoverIntent(function () {
        $j('ul', this).fadeIn("slow")
    }, function () {
        $j('ul', this).fadeOut("slow")
    });
    $j("#mainNav img").hover(function () {
        this.src = this.src.replace("-off", "-over")
    }, function () {
        this.src = this.src.replace("-over", "-off")
    });
    $j('li.datingHover').hover(function () {
        $j('img.dating').attr("src", "/wp-content/themes/marriage/images/dating-engaged-nav-over.png")
    }, function () {
        $j('img.dating').attr("src", "/wp-content/themes/marriage/images/dating-engaged-nav-off.png")
    });
    $j('li.parentingHover').hover(function () {
        $j('img.parenting').attr("src", "/wp-content/themes/marriage/images/parenting-family-nav-over.png")
    }, function () {
        $j('img.parenting').attr("src", "/wp-content/themes/marriage/images/parenting-family-nav-off.png")
    });
    $j('li.everymarriageHover').hover(function () {
        $j('img.everymarriage').attr("src", "/wp-content/themes/marriage/images/for-every-marriage-nav-over.png")
    }, function () {
        $j('img.everymarriage').attr("src", "/wp-content/themes/marriage/images/for-every-marriage-nav-off.png")
    });
    $j('li.marriageResourcesHover').hover(function () {
        $j('img.marriageResources').attr("src", "/wp-content/themes/marriage/images/marriage-resource-center-nav-over.png")
    }, function () {
        $j('img.marriageResources').attr("src", "/wp-content/themes/marriage/images/marriage-resource-center-nav-off.png")
    });
    $j('li.catholicMarriageHover').hover(function () {
        $j('img.catholicMarriage').attr("src", "/wp-content/themes/marriage/images/about-catholic-marriage-nav-over.png")
    }, function () {
        $j('img.catholicMarriage').attr("src", "/wp-content/themes/marriage/images/about-catholic-marriage-nav-off.png")
    });
    $j('img.printPage').click(function () {
        window.print();
        return false
    })
	
	jQuery.validator.addMethod("alphanumeric", function(value, element) {
		return this.optional(element) || /^\w+$j/i.test(value);
	}, "Letters, numbers,or underscores only please");
	
	jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
		phone_number = phone_number.replace(/\s+/g, ""); 
		return this.optional(element) || phone_number.length > 9 &&
			phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
	}, "Please specify a valid phone number");

	$j("#contactform").validate();
	
});
