//  jquery scripts
jQuery.noConflict(); // stops conflicts with prototype and other scripts that use '$'
var tabs = null;  // sets tabs variable
jQuery(document).ready(function () {
        jQuery(this).topNav();
        imgRlOvr();
        searchTxt();
        var url = location.pathname;
        if (url.indexOf("noFlash")=="-1"){
        jQuery('#mainTranscripts').css('display','none');
        }
        // Gathers images and calls preloader
        var imgLoad = new Array();
        jQuery("img[src$='i.png'],img[src$=i.gif],img[src$=i.jpg]").each(function(i){
            imgLoad[i] = jQuery(this).attr('src').replace(/i.png/,'o.png').replace(/i.gif/,'o.gif').replace(/i.jpg/,'o.jpg');
                 jQuery.preLoadImages(imgLoad[i]);
        });

        /*  SPF showtext   */
        jQuery('div.showtext').click(function(event){
            jQuery(this).next('div.showntext').css('visibility','visible');
            jQuery(this).find('span').css('cursor','default');
        });     
});



function changeImg(imgID,path) {
    var tempimg=document.getElementById(imgID);
    tempimg.src=path;
}

/* Sgt Star Question function */
function LaunchSgtStar(question) {
    NIT.Launch.LaunchSgtStar(question);
    window.location.replace('/ask-sgt-star.html');
}
;
jQuery(document).ready(function(){      
            jQuery('a').click(function(){
                if(jQuery(this).attr('href')=="/ask-sgt-star.html"||jQuery(this).attr('href')=="/content/goarmy/ask-sgt-star.html"
                        ||jQuery(this).attr('href')=="/goarmy/ask-sgt-star.html"){
                    var question = jQuery(this).text();
                    NIT.Launch.LaunchSgtStar(question);
                    return false;
                }       
            });
});
/* End Sgt Star Question function */



//
function searchTxt(){
var searchValue = "Site Search";
jQuery(document).ready(function(){
jQuery("#siteSearch").val(searchValue);
jQuery("#siteSearch").focus(
      function(){if(jQuery(this).val() == searchValue)jQuery(this).val('')});
jQuery("#siteSearch").blur(    
      function(){if(jQuery(this).val() == ''){jQuery(this).val(searchValue);}});
});
}

//  Change image on Rollover 'i.gif' & 'o.gif'     
function imgRlOvr(){
jQuery('.imgBtn').hover(
        function(){
            var mysrc = new Array();
            jQuery(this).find('img').each(function(i){
                mysrc[i] = jQuery(this).attr('src');
                if(mysrc[i].indexOf('pixel') >= 0){jQuery(this).iunfixpng()}
                jQuery(this).attr('src', function() {return this.src.replace(/i.gif/,'o.gif').replace(/i.png/,'o.png').replace(/i.jpg/,'o.jpg');});
                if(mysrc[i].indexOf('pixel') >= 0){jQuery(this).ifixpng()}
            });
                                 },
        function(){
            var mysrc = new Array();
            jQuery(this).find('img').each(function(i){
                mysrc[i] = jQuery(this).attr('src');
                if(mysrc[i].indexOf('pixel') >= 0){jQuery(this).iunfixpng()}
                jQuery(this).attr('src', function() {return this.src.replace(/o.gif/,'i.gif').replace(/o.png/,'i.png').replace(/o.jpg/,'i.jpg');});
                if(mysrc[i].indexOf('pixel') >= 0){jQuery(this).ifixpng()}
            });
                                 });
jQuery('.imgBtn').hover(
        function(){
            var mysrc = (jQuery(this).attr('src'));
            if(mysrc.indexOf('pixel') >= 0){jQuery(this).iunfixpng()}
            jQuery(this).attr('src', function() {return this.src.replace(/i.gif/,'o.gif').replace(/i.png/,'o.png').replace(/i.jpg/,'o.jpg');});
            if(mysrc.indexOf('pixel') >= 0){jQuery(this).ifixpng()}
                                    },
        function(){
            var mysrc = (jQuery(this).attr('src'));
            if(mysrc.indexOf('pixel') >= 0){jQuery(this).iunfixpng()}
            jQuery(this).attr('src', function() {return this.src.replace(/o.gif/,'i.gif').replace(/o.png/,'i.png').replace(/o.jpg/,'i.jpg');});
            if(mysrc.indexOf('pixel') >= 0){jQuery(this).ifixpng()}
                                    });
}


/*  Set IOM code   */
function initIom(sbc,iom) {
    var currIom=getCookie('iom')||''
    if (currIom=='' && iom!=undefined && iom!='null') {
        setCookie('sbc', sbc, null, '/');
        setCookie('iom', iom, null, '/');
    }
}
/*  function for PreLoading Images  */
(function ($){
    var cache = [];
    $.preLoadImages = function(){
        var args_len = arguments.length;
        for (var i = args_len;i--;){
            var cacheImage = document.createElement('img');
            cacheImage.src = arguments[i];
            cache.push(cacheImage);
        }
    }
})(jQuery)

/*  Open Augmented Reality Game */
function openRaceForStrength(){window.open('/home/augmented-reality-game-race-for-strength/game.html','raceForStrength','width=800,height=600');}

