jQuery.noConflict();

function form_input_classes(){

    jQuery('input[type="text"]').addClass('text');
    jQuery('input[type="password"]').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 lightbox(){
    var modal = jQuery.cookie('mw');
    //get the page url
    var locationHref = document.location.href;
    var bsdFrameworkUrlStructure = /\/page\//;
 
    //conditional for the modal window
    if(modal != 'visited') {

        jQuery.cookie('mw', 'visited', { expires: 30, domain: 'videogamevoters.org' });
        jQuery("#lightbox").show();
        jQuery.fn.colorbox({inline:true, href:"#lightbox", open:true, transition:"none", opacity: .75}); 
        jQuery(".cb-close").click(function () { 
            jQuery.fn.colorbox.close(); return false;
        });
        jQuery().bind('cbox_cleanup', function(){
            jQuery("#lightbox").hide();
        });
    }
}


function externalLinks(){
    var pageUri = new RegExp(window.location.hostname, 'i');

    var relativeUri = /^\//;
    var jsUri = /JavaScript:/i;
    var idUri = /^#/;
    jQuery('a, area').each(function(){

        //detect if vgvn domain or current domain is the same as the href value of the link
        if(pageUri.test(jQuery(this).attr('href')) || relativeUri.test(jQuery(this).attr('href')) || jsUri.test(jQuery(this).attr('href')) || idUri.test(jQuery(this).attr('href')) ){
            //do nothing
            
            //document.write('<!--Do nothing.-->');
        } else {

            //apply target="_blank" to open in new window
            jQuery(this).attr('target', '_blank');
        }
    });
}

function offsiteDisclaimer(){
    jQuery('.offsite-link').click(function(){
        var offsiteHref = jQuery(this).attr('href');
        jQuery('#ext-site-href').attr('href', offsiteHref);
        jQuery('#ext-site-uri').text(offsiteHref);
        jQuery('.offsite-link').colorbox({width:"50%", inline:true, href:"#offsite-disclaimer-text"});
    });
}

jQuery(document).ready(function() {

    form_input_classes();
    jQuery('.labelize input.text').clearingInput();
    externalLinks();
    //offsiteDisclaimer();

});
