var _ie6OrLess=false;

jQuery.noConflict();
jQuery(document).ready(function() {
    jQuery(".jHover").mouseenter(function() {
        swapImage(jQuery(this).get(0));
    }).mouseleave(function() {
        swapImage(jQuery(this).get(0));
    }).focus(function() {
        swapImage(jQuery(this).get(0));
    }).blur(function() {
        swapImage(jQuery(this).get(0));
    }).each(function(i, element) {
        /* preload background image */
        jQuery('<img />').get(0).src = element.src.replace('.png', '_Hover.png');
    });

    if (_ie6OrLess) {
        fixIE6PNG();
    };

    if (jQuery('body.faqs').length > 0) {
        faqRearrange();
    }

    function swapImage(image) {
        if (image.src.substring(image.src.length - '_Hover.png'.length) == '_Hover.png') {
            image.src = image.src.replace('_Hover', '');
        } else {
            image.src = image.src.replace('.png', '_Hover.png');
        }
    }

    try {
        initializeCalendar();
    } catch (e) { }
});

function fixIE6PNG() {
    var sPath = 'assetsV3/';
    if (window.location.toString().indexOf('artist-template-website-samples') > 0) {
      sPath = '../../assetsV3/';
    } else if (window.location.toString().indexOf('artist-website-plans') > 0) {
      sPath = '../assetsV3/';
    }
      
    jQuery('.png').each(function(i, element) {
	    jQuery(element).css('filter', 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + element.src + '", sizingMethod="scale")')
		    .css('width', jQuery(element).width() + 'px')
		    .css('height', jQuery(element).height() + 'px')
		    .css('background-image', 'none');

	    element.src = sPath + 'spacer.gif';
    });
}

function faqRearrange() {
    var sClass;
    var sClassInline;
    var index = 0;

    jQuery('#faqDetails').css('padding-top', '8em');
    jQuery('#faqDetails').css('padding-bottom', '6em');
    jQuery('#faqDetails .category').each(function(i, element) {
        sClass = jQuery(element).attr('class');
        sClassInline = '.' + sClass.replace(' ', '.');
        jQuery('#faqSummary').append('<div class="' + sClass + '"></div>');
        jQuery(element).find('h2').each(function(i, e2) {
            jQuery('#faqSummary ' + sClassInline).append('<h2>' + jQuery(e2).text() + '</h2>');

            jQuery(element).find('h3').each(function(i, e3) {
                jQuery(e3).before('<a name="faq' + index + '"></a>');
                jQuery('#faqSummary ' + sClassInline).append('<a href="#faq' + index + '">' + jQuery(e3).text() + '</a>');
                index++;
            });

        });
    });
}
