jQuery.noConflict();

function form_input_classes(){
    jQuery('input[type="text"]').addClass('text');
    jQuery('input[type="password"]').addClass('text');
    jQuery('input[type="email"]').addClass('text');
    jQuery('input[type="checkbox"]').addClass('checkbox');
    jQuery('input[type="radio"]').addClass('radiobutton');
    jQuery('input[type="submit"]').addClass('submit');
    jQuery('input[type="image"]').addClass('buttonImage');
}
function fontCheck(){
    if( jQuery.fontAvailable('GillSans') || jQuery.fontAvailable('Gill Sans') || jQuery.fontAvailable('Gill Sans MT')) {
        jQuery('body').addClass('gill-sans');
    }
    else {
        jQuery('body').addClass('no-gill-sans');
    }
}
function form_labelize(){  
    if (!Modernizr.input.placeholder){
        jQuery(".labelize input.text").clearingInput(); 
        }
}
function menus(){
    jQuery('#nav').superfish({ 
                delay:       800,
                speed:       'fast',                          // faster animation speed 
                autoArrows:  false,                           // disable generation of arrow mark-up 
                dropShadows: false                            // disable drop shadows 
            }); 
}
function stackHero(){ 
    jQuery('#hero').jstacker({
        speed: 400
    });
}
function homeGalleryThumbs(){
if (jQuery('#home div.media-thumbs ul').length > 1){
    jQuery('#home div.media-thumbs').append('<a class="prev" href="#">Back</a>').append('<a class="next" href="#">Next</a>');
    jQuery('#home div.media-thumbs .thumb-wrapper').cycle({
        prev: ".media-thumbs .prev",
        next: ".media-thumbs .next",
        timeout: 0
    });
}
}
function photsetSlideshow(){
    if (jQuery('#photos #slideshow .photo').length > 1){
        jQuery('#photos #slideshow').cycle({
            activePagerClass: 'active',
            timeout: 4000,
            pager: '.thumb-wrapper',
            pagerAnchorBuilder: function(idx, slide) {
                var src = jQuery('img',slide).attr('src');
                src = src.replace(/\.jpg/, "_s.jpg");
                return '<li><a href="#"><img src="' + src + '"></a></li>';
                }
            
        });
    }
}

function lightbox(){
    var modal = jQuery.cookie('mw');
    var donateUrlRegExp = /\/page\/contribute/;
    var locationHref = document.location.href;
    if(modal != 'visited' && donateUrlRegExp.test(locationHref) !== true){
        jQuery.colorbox({
            inline: true,
            href: '#lightbox',
            innerWidth: '640px',
            innerHeight: '540px',
            opacity: 0.6,
            onCleanup: function(){
                jQuery('#lightbox-signup').data("validator").reset();
            }
        });
        jQuery('#lightbox .lightbox-close').click(function(e){
            e.preventDefault();
            jQuery.colorbox.close();
        });
        // Modernizr.input.placeholder || jQuery("#lightbox form.labelize input.text").clearingInput();
        jQuery.cookie('mw', 'visited', { expires: 10, path: '/', domain: '.myartsrising.org' });
    }
}

function lightbox_always(){
    jQuery.colorbox({
        inline: true,
        href: '#lightbox',
        innerWidth: '640px',
        innerHeight: '540px',
        opacity: 0.6,
        onCleanup: function(){
            jQuery('#lightbox-signup').data("validator").reset();
        }
    });
    jQuery('#lightbox .lightbox-close').click(function(e){
        e.preventDefault();
        jQuery.colorbox.close();
    });
    // Modernizr.input.placeholder || jQuery("#lightbox form.labelize input.text").clearingInput();
}
function validateForms(){ 
    jQuery.tools.validator.localizeFn('[required]', { en: 'This field is required.'});
    
    jQuery('#lightbox-signup').validator({
        position: 'center right',
        offset: [0,-10],
        message: '<div><span /></div>',
        messageClass: 'invalid-msg invalid-right'
        
    });
    
}

jQuery(document).ready(function() {
    form_input_classes();
    form_labelize();
    stackHero();
    menus();
    fontCheck();
    homeGalleryThumbs();
    photsetSlideshow();
    
});
