
jQuery(function($) {	
	var browser = jQuery.browser;
	var version = jQuery.browser.version;
		
	if(browser = 'msie' && version == 6.0) {		
		// Removes jQuery generated 'Rounded Corners' on IE6 due to issues
		$('#topnav li ul').each(function() {
			$(this).find('ul.roundedBtm').removeClass('roundedBtm');
			$('div#registerNow').removeClass('roundedBtm');
		});
		
		$('#dropTabs').each(function() {
			$('span.roundedBtm').removeClass('roundedBtm');
		});
	}
	
});

// Text Resize
jQuery(function($) {
	var originalFontSize = $('body').css('font-size');   
    	
  	// Increase Font Size
  	$(".increaseFont").click(function() {
    	var currentFontSize = $('body').css('font-size');
    	var currentFontSizeNum = parseFloat(currentFontSize, 10);
    	var largestFontSize = 16;
    	
    	if(currentFontSizeNum < largestFontSize){
    		var newFontSize = Math.floor(currentFontSizeNum + 2);
    		$('body').css('font-size', newFontSize);
    	}
    	
    	else {
    		$('body').css('font-size', largestFontSize);
    	}
    	return false;
  	});
  	// Decrease Font Size
  	$(".decreaseFont").click(function() {
    	var currentFontSize = $('body').css('font-size');
    	var currentFontSizeNum = parseFloat(currentFontSize, 10);    	
    	var smallFontSize = 12;   	
    	
    	if(currentFontSizeNum > smallFontSize){
    		var newFontSize = Math.floor(currentFontSizeNum - 2);
    		$('body').css('font-size', newFontSize);
    	}
    	
    	else {
    		$('body').css('font-size', smallFontSize);
    	}
    	return false;
	});
});

// Main Navigation
jQuery(function($) {
	//$('#topnav li ul').hide();

	$('#topnav li').hover(function() {
		$('ul', this).fadeIn('fast');
		$(this).addClass('navHover');
	}, function() {
		$('ul', this).fadeOut('fast');
		$(this).removeClass('navHover');
	});	
});

// Alternate Site Dropdowns
jQuery(function($) {
	$('#drop1, #drop2').hide();
	
	$('#dropTabs p').toggle(function() {
		var content = $(this).find('a').attr('href');
		$('#dropTabs p').find('a').addClass('selected');
		$(this).siblings().css({'visibility':'hidden'});
		$(this).parent('#dropTabs').addClass('dropOpen');
		$(content).slideDown();
	}, function() {
		var content = $(this).find('a').attr('href');
		
		$('#dropTabs p').find('a').removeClass('selected');
		$(content).slideUp('fast');
		$('#dropTabs p').css({'visibility':'visible'});
		$(this).parent('#dropTabs').removeClass('dropOpen');
	});
	return false;
});

// Image Gallery by Galleria

var overlayImg = new Array(4);

jQuery(function($) {
				
	$('.gallery_nostyle').addClass('imageGallery'); // adds new class name to maintain degradability
	
	$('ul.imageGallery').galleria({
		history   : false, // activates the history object for bookmarking, back-button etc.
		clickNext : false, // helper for making the image clickable
		insert    : '#largeImage', // the containing selector for our main image
		onImage   : function(image,caption) { // let's add some image effects for demonstration purposes
			
			// fade in the image & caption
			if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
				image.css('display','none').fadeIn(1000);
			}
			caption.css('display','none');
			
			// adding Lightbox 'view larger' link to image container			
			var imgSrc = $('li.active').children('img').attr('id');
			var imgLength = imgSrc.length;
			var imgID = imgSrc.substring(imgLength-1);
			var imageTitle = $('li.active').children('img').attr('title');
			$('.galleria_wrapper').append('<!--<a href="'+ overlayImg[imgID-1] +'" title="' + imageTitle + '">View Larger +</a>-->');
			
			// Lightbox Activation for Gallery
			$('.galleria_wrapper a').lightBox();
		}

	});
});

// Show/Hide
jQuery(function($) {
	$('#signInBox, #languageBox, #shareBox, #emailBox, #addToCart, #addProduct, #forgetPassBox, #faqsAnswers p, .categoryGroup').hide();

	$('.showHide').click(function() {
		var toggleBox = $(this).attr('href');
	 	$(toggleBox).fadeIn();
	 	$(toggleBox).hover(function() {
	 		$(this).show();
	 	}, function() {
	 		$(this).fadeOut();
	 	});
	 	return false;
	});
	
	$('.showClose').click(function() {
		var toggleBox = $(this).attr('href');
	 	$(toggleBox).fadeIn();
	 	return false;		
	}); 
	
	$('.closeThis').click(function() {
		var toggleBox = $(this).attr('href');
		$(toggleBox).fadeOut();
		return false;
	});
	
	$('.faqsShowHide').click(function() {
		var toggleBox = $(this).attr('href');
		$(toggleBox).slideToggle();
		return false;
	});
	
	$('.closeAnswer').click(function() {
		$(this).parent().parent().slideToggle();
		return false;
	});
	
	$('.forgetPass').click(function() {
		var toggleBox = $(this).attr('href');
		$('#signInBox').hide();
	 	$(toggleBox).fadeIn();
	 	return false;		
	});
		
	$('.closePassFind').click(function() {
		var toggleBox = $(this).attr('href');
		$('#forgetPassBox').fadeOut();
	 	return false;		
	});
		
});

// Rounded Corners
jQuery(function roundedCorners($) {
	$('.rounded').corner({
		tl: { radius: 5 },
		tr: { radius: 5 },
		bl: { radius: 5 },
		br: { radius: 5 },
		antiAlias: true
	});
	$('.roundedTop').corner({
		tl: { radius: 5 },
		tr: { radius: 5 },
		bl: { radius: 1 },
		br: { radius: 1 },
		antiAlias: true
	});
	$('.roundedBtm').corner({
		tl: { radius: 1 },
		tr: { radius: 1 },
		bl: { radius: 5 },
		br: { radius: 5 },
		antiAlias: true
	});
	
	// Alternate Rounded Corners
	$('.tabModuleCopy').wrap('<div class="tl"><div class="tr"><div class="bl"><div class="br">' + '</div></div></div></div>');
	$('.widgetModuleCopy').wrap('<div class="tl"><div class="tr"><div class="bl"><div class="br">' + '</div></div></div></div>');
});

// Tabs
jQuery(function($) {
	$('#tabs a').click(function() {
		$('div.tabContent').hide().filter(this.hash).fadeIn('normal');
		
		$('#tabs a').removeClass('selected');
		$(this).addClass('selected');
			
		return false;
	}).filter(':first').click();
});


// Page Print
/*jQuery(function($) {
	$('.printPage').click(function() {
		window.print();
		return false;
	});
});*/

// Tool Tip/Product Info Bubble
jQuery(function($) {
	$('a.Hover').mouseover(function(e) {
		var popup_div = $(this).attr('rel');
		
		var tipPos = $(this).position();		
		var popx = tipPos.left;
		var popy = tipPos.top;
		
		var wordWidth = $(this).width();
		var wordHeight = $(popup_div).height();
		
		leftVal = (e.pageX+10)+"px";
		topVal = (e.pageY-28)+"px";
			
		$(popup_div).css({left:leftVal,top:topVal}).show().end();
		return false;	
	});				
	$('a.Hover').mouseout(function() {	
		var popup_div = $(this).attr('rel');
		$(popup_div).hover(function() {	
			$(this).show();
		}, function() {
			$(this).hide();
		});
		$(popup_div).hide();
	});
});

// Input Button Hover
jQuery(function($) {
	$('span.blueBdr').hover(function () {
		$(this).addClass('btnHover');
	}, function() {
		$(this).removeClass('btnHover');
	});
});

// CSS Manipulations
jQuery(function($) {		
	$('#shopRetailers').each(function() {
		$('.retailerLogo:last').css({'border-bottom':'none'});
	});
	$('#productGallery li').eq(3).addClass('last');
});
	
function roundedCorners() {
	$('.rounded').corner({
		tl: { radius: 5 },
		tr: { radius: 5 },
		bl: { radius: 5 },
		br: { radius: 5 },
		antiAlias: true
	});
	$('.roundedTop').corner({
		tl: { radius: 5 },
		tr: { radius: 5 },
		bl: { radius: 1 },
		br: { radius: 1 },
		antiAlias: true
	});
	$('.roundedBtm').corner({
		tl: { radius: 1 },
		tr: { radius: 1 },
		bl: { radius: 5 },
		br: { radius: 5 },
		antiAlias: true
	});
	
	// Alternate Rounded Corners
	$('.tabModuleCopy').wrap('<div class="tl"><div class="tr"><div class="bl"><div class="br">' + '</div></div></div></div>');
	$('.widgetModuleCopy').wrap('<div class="tl"><div class="tr"><div class="bl"><div class="br">' + '</div></div></div></div>');
}

function toolTip() {
	$('a.Hover').mouseover(function() {
		var popup_div = $(this).attr('rel');
		
		var tipPos = $(this).position();		
		var popx = tipPos.left;
		var popy = tipPos.top;
		
		var wordWidth = $(this).width();
		var wordHeight = $(this).height();
		
		leftVal = (popx + wordWidth)-10+"px";
		topVal = popy-(wordHeight*2)+"px";
			
		$(popup_div).css({left:leftVal,top:topVal}).show();
		return false;	
	});				
	$('a.Hover').mouseout(function() {	
		var popup_div = $(this).attr('rel');
		$(popup_div).hover(function() {	
			$(this).show();
		}, function() {
			$(this).hide();
		});
		$(popup_div).hide();
	});
}

// News Banner Functions
function bannerFadeIn() {
	$('#newsBanner p').fadeIn();
	setTimeout(bannerFadeOut(), 3000);
}

function bannerFadeOut() {
	$('#newsBanner p').fadeOut();
	clearTimeout();
}

