// JavaScript Document

$(document).ready(function(){
						   
	$('.login').find('span').bind('click', hoverbox);
	$('.cart').find('span').bind('click', hoverbox);
	$('.calcshipping').find('span').bind('click', hoverbox);
	
	$('.login').find('span').eq(0).find('a').click(function(){event.returnValue = false});  //IE FIX
	$('.cart').find('span').eq(0).find('a').click(function(){event.returnValue = false});  //IE FIX
	$('.calcshipping').find('span').eq(0).find('a').click(function(){event.returnValue = false});  //IE FIX
	
	$('body').bind('click', closebox2);
	
	$('.x').bind('click', closebox);
	
	$('.loginHover').hide();
	$('.cartHover').hide();
	$('.shipHover').hide();	
	
		//------------BROWSER FIXES --------------------------/

	if(navigator.appName == 'Microsoft Internet Explorer'){
		
		navWidth = $('.loginHover').width();
		navWidth -= 1;
		
		$('.loginHover').width(navWidth);
		
	}
	
	if(navigator.appName == 'Opera'){ //Opera Fixes
		
			$('.loginHover').css('top', '.6em'); //fixes gap in the loginhover tab
			
			$('.topRow').find('p').css('margin-right', '1.5em'); //fixes the cart product names so they aren't running into the edge of the tab
			
			$('.searchBox').css('padding-top', '.2em'); //vertically centers the text in the searchbox

	}
	
	//-----------------EVENT FUNCTIONS ----------------------/
						   
	function hoverbox(){

		$(this).parent().find('div').eq(0).css('left', 'auto').slideDown(200);

		return false;
   
	}
	
	function closebox() {
		
		p1 = $(this).parent().parent();

		$(p1).slideUp(200);
		setTimeout("$(p1).css('left', '-999em')", 200);
		
	}
	
	function closebox2(e) {
		
		if(e.target.className == 'cartContents' || e.target.className == 'loginForm' || e.target.className == 'topRow' || e.target.className == 'gtvc' || e.target.classname == 'regButton' || e.target.className == 'l_submit' || e.target.className == 'fpButton' || e.target == '[object HTMLInputElement]' || e.target.className == 'loginHover' || e.target.nodeName == 'LABEL' || e.target.nodeName == 'INPUT' || e.target.nodeName == 'H4' || e.target.nodeName == 'P'){
		
		}else{
		
		$('.loginHover').slideUp(200);
		$('.cartHover').slideUp(200);
		
		setTimeout("$('.loginHover').css('left', '-999em')", 200);
		setTimeout("$('.cartHover').css('left', '-999em')", 200);
		
		}
	}
	


	//------------Search Bar remove text onclick ---------/
	
	$('.searchBox').bind('click', function(){
	
		this.value ='';
	
	
	
	});

	//---------------------------------------------------
						   
});