// HERO IMAGE
jQuery(document).ready(function(){
	jQuery('#hero').cycle({ 
		fx:     'scrollHorz', 
		prev:   '.previousArrow', 
		next:   '.nextArrow',
		speed:    300,
		timeout: 6000,
		pause: 1
	});

// PAUSE/RESUME ON VIDEO CLICK
	jQuery('#hero').hover(function(){
		jQuery(this).cycle('pause');
	});
	jQuery('#fancy_close').click(function(){
		alert('clooooose');
	});
});

// FADE GRAYSCALE BUCKETS
jQuery(document).ready(function(){
	jQuery(".buckets").hover(function() { //On hover...
	var thumbOver = jQuery(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'

	//Set a background image(thumbOver) on the <a> tag - Set position to bottom
	jQuery(this).find(".bucketImage").css({
		'background' : 'url(' + thumbOver + ') no-repeat center bottom'
	});

	//Animate the image to 0 opacity (fade it out)
	jQuery(this).find("span").stop().fadeTo('fast', 0 , function() {
		jQuery(this).hide() //Hide the image after fade
	});

	} , function() { //on hover out...
	//Fade the image to full opacity 
	jQuery(this).find("span").stop().fadeTo('fast', 1).show();
	});
});

// FADING SOCIAL MEDIA ICONS
jQuery(document).ready(function(){
	jQuery(".socialIcons").hover(function() { //On hover...
	var thumbOver = jQuery(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'

	//Set a background image(thumbOver) on the <a> tag - Set position to bottom
	jQuery(this).find(".icon").css({
		'background' : 'url(' + thumbOver + ') no-repeat center bottom'
	});

	//Animate the image to 0 opacity (fade it out)
	jQuery(this).find("span").stop().fadeTo('slow', 0 , function() {
		jQuery(this).hide() //Hide the image after fade
	});

	} , function() { //on hover out...
	//Fade the image to full opacity 
	jQuery(this).find("span").stop().fadeTo('slow', 1).show();
	});
});


// SEARCH BAR AUTOFILL
jQuery(document).ready(function(){
	jQuery('#txtSearch').autofill({
	value: 'Search',
	defaultTextColor: '#000',
	activeTextColor: '#000'
	});
});

jQuery(document).ready(function(){
   jQuery('#subscribe').autofill({
	value: 'Enter your e-mail address',
	defaultTextColor: '#000',
	activeTextColor: '#000'
	}); 
});

//FANCY BOX
jQuery(document).ready(function(){
    jQuery(".zoomVid").click(function() {
		jQuery.fancybox({
			'overlayOpacity'	: 0.7,
			'overlayColor'		: '#000',
			'overlayShow'		: 'true',
			'padding'			: 0,
			'autoScale'		    : false,
			'transitionIn'   	: 'fade',
			'transitionOut'     : 'fade',
			'title'				: this.title,
			'width'				: 560,
			'height'			: 340,
			'href'				: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'				: 'swf',
			'swf'							: {
               'wmode'						: 'transparent',
               'allowfullscreen'  : 'false'
			}

		});
        return false;
    });

    //fix for IE that did not like a return false //line 104
    jQuery('.zoomVid').click(function(){
        jQuery.fancybox({
           'callbackOnClose'   : function(){
                jQuery('#fancy_content').empty();
            } 
        });
    });
});

function showTTabContent(id){
	jQuery('.tabContent').hide();
	jQuery('#' + id + '_tabContent').show();
}

function currentCContentBold(id) {
	jQuery('.trainLink').removeClass('activeModel');
}

/*
//FADE IN / OUT BETWEEN SHOW/HIDE --> ERRORS IN IE7
jQuery(document).ready(function(){
    jQuery('#modelInfo ul li.modelLink').click(function(){
        var schedule = jQuery(this).attr('id');

        if (schedule == 'schedule'){
            jQuery('.sidebar').fadeOut(300);
            jQuery('#one_tabContent').fadeOut(300);
            jQuery('#schedule_tabContent').fadeIn(300);
        } 
        else 
        {
            jQuery('.sidebar').fadeIn(300);
            jQuery('#one_tabContent').fadeIn(300);
            jQuery('#schedule_tabContent').fadeOut(300);
        }
    });
});*/

function showTabContent(id){
	jQuery('.tabContent').hide();
	jQuery('#' + id + '_tabContent').show();
	jQuery('#modelInfo ul li').removeClass('activeModel');
	jQuery(this).toggleClass('activeModel');
}

function currentContentBold(id) {
	jQuery('.modelLink').removeClass('activeModel');
	jQuery('#' + id).addClass('activeModel');
}

// Tabs  FIREARMS LANDING PAGE
jQuery(document).ready(function(){
	jQuery('.tabContent').hide();
	jQuery('#one_tabContent').show();
	jQuery('#modelTabs ul li#one').addClass('activeTab');
	jQuery('.tabLink').hover(function(){
		var id = $(this).attr('id');
		jQuery('.tabContent').hide();
		jQuery('#' + id + '_tabContent').show();
		jQuery('#modelTabs ul li').removeClass('activeTab');
		jQuery(this).toggleClass('activeTab');
	});

//TABS FOR INDIVIDUAL MODELS 
	jQuery('.tabContent').hide();
	jQuery('#one_tabContent').show();
	jQuery('#modelInfo ul li#one').addClass('activeModel');
	jQuery('.modelLink').click(function(){
		var id = jQuery(this).attr('id');
		jQuery('.tabContent').hide();
		jQuery('#' + id + '_tabContent').show();
		jQuery('#modelInfo ul li').removeClass('activeModel');
		jQuery(this).toggleClass('activeModel');
	});
	jQuery('.modelLink').hover(function(){
		jQuery(this).css({'color' : '#fff'});
		}, function(){
		jQuery(this).css({'color' : '#999'});
	});
});

//INTERNATIONAL AJAX INFO
jQuery(document).ready(function(){

    jQuery('#country').change(RepCountry);

    function RepCountry(){
        var sel = jQuery('#country option:selected');
        var value = "";
        if (sel.val() != 0){
            value = sel.val(); 
        }
        var sel2 = jQuery('p#content_' + value + '').html();
        jQuery('#rep').html(sel2);
    }
});

//FOR TRAINING PAGES (REMOVES activeModel class)
jQuery(document).ready(function(){
	jQuery('.tabContent').hide();
	jQuery('#one_tabContent').show();
	jQuery('#modelInfo ul li#one').addClass('activeModel');
	jQuery('.trainLink').click(function(){
		var id = jQuery(this).attr('id');
		jQuery('.tabContent').hide();
		jQuery('#' + id + '_tabContent').show();
		jQuery('#trainingInfo ul li').removeClass('activeTraining');
		jQuery(this).toggleClass('activeTraining');
	});
	jQuery('.trainLink').hover(function(){
		jQuery(this).css({'color' : '#333'});
		}, function(){
		jQuery(this).css({'color' : '#999'});
	});
});


// FIREARMS VIEW ALL PRODUCTS DROP DOWN
	var timeout = 0;
	var closetimer = 0;
	var menu_id = 0;
	var ddparent = 0;

function mopen(menu_id,link_id){
	this_menu = menu_id;
	this_link = link_id;

	//cancel close timer
	mcancelclosetime();

	//open current menu
	jQuery('#'+this_menu).css({"visibility":"visible"});

} // end mopen function

function mclose(){
	if(this_menu){
		jQuery('#'+this_menu).css({"visibility":"hidden"});
	}

	jQuery(this).addClass('hoverBG');
	jQuery('#'+this_link).removeClass('hoverBG');
}

// go close timer
function mclosetime(){
	closetimer = window.setTimeout(mclose,timeout);
}

// cancel close timer
function mcancelclosetime() {
	if(closetimer){
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

//wtf is this code
jQuery(document).ready(function(){
	jQuery('.moreNews').hide();
	jQuery('.newsBlock a.moreLink').click(function(){
		jQuery(this).toggle();
		var id = jQuery(this).attr('id');
		jQuery('#' + id + '_moreNews').show();
	});

	jQuery('.moreVids').css({'display' : 'none'});
	jQuery('a.lessLink').css({'display' : 'none'});
	jQuery('a.moreLink').click(function(){
		jQuery('.moreVids').css({'display' : 'block'});
        jQuery(this).css({'display' : 'none'});
        jQuery('a.lessLink').css({'display' : 'block'});
        jQuery('a.lessLink').click(function(){
            jQuery(this).css({'display' : 'none'});
            jQuery('.moreVids').css({'display' : 'none'});
            jQuery('a.moreLink').css({'display' : 'block'});
        });
	});

	jQuery('.moreFloats').css({'display' : 'none'});
	jQuery('a.lessLink2').css({'display' : 'none'});
	jQuery('a.moreLink2').click(function(){
		jQuery('.moreFloats').css({'display' : 'block'});
        jQuery(this).css({'display' : 'none'});
        jQuery('a.lessLink2').css({'display' : 'block'});
        jQuery('a.lessLink2').click(function(){
            jQuery(this).css({'display' : 'none'});
            jQuery('.moreFloats').css({'display' : 'none'});
            jQuery('a.moreLink2').css({'display' : 'block'});
        });
	});
});

