jQuery(document).ready(function($) {

	//***************************************************************************************************
	// set 'display:block' for modal windows
	//***************************************************************************************************
	
	modalId = '';
	$('a[id=modal]').click(function(e) {  
	 	e.preventDefault();  
	 	modalId = $(this).attr('href');  
	 	/*var maskHeight = $(window).height();  
	 	var maskWidth = $(window).width();
	 	$('#mask').css({'width':maskWidth,'height':maskHeight}); */
		$('#mask').css('filter','alpha(opacity=10)').show()
	 	if ($.browser.msie) {
	 		$(modalId).show(); 
	 	} else {
	 		$(modalId).fadeIn(500); 
	 	} 
	});  
     
	$('#boxes .modalCloseButton').click(function (e) {  
	 	e.preventDefault();
	 	var kids = $('div[id=boxes]').children();
	 	$(kids).hide(); 
	 	$('#mask').hide(); 
	});    
      
	$('#mask').click(function () {  
	 	if (modalId != '#shadowOneModalMono'){
	 		$(this).hide();  
	 		var kids = $('div[id=boxes]').children();
	 		$(kids).hide(); 
	 	}  
	});
	
	//***************************************************************************************************
	// Accordion
	//
	// DOCUMENT: includes/javascript.js
	// DEVELOPED BY: Ryan Stemkoski
	// COMPANY: Zipline Interactive
	// EMAIL: ryan@gozipline.com
	// PHONE: 509-321-2849
	// DATE: 2/26/2009
	//***************************************************************************************************
	
	/*$('div.accordionButton').click(function() {
		$('div.accordionContent').slideUp('normal');	
		$(this).next().slideDown('normal');
		//$("div.accordionButtonSelected").removeClass().addClass("accordionButton");
		//$(this).removeClass().addClass("accordionButtonSelected");
	});*/
	
	$('div.accordionButton p').hover(
  		function () {
    		$(this).css("font-style","italic");
    		$(this).css ("color","black");
  		},
  		function () {
    		$(this).css("font-style","normal");
    		$(this).css ("color","#595959");
  		}
	);
	//$('div.accordionButton p').mouseover(function () {
    //$(this).attr("style","color:red;");
  //});

	$('div.accordionButton').click(function() {
 
		if($(this).next().is(':visible')) {
			$('div.accordionContent').slideUp(0);
		} else {
			$('div.accordionContent').slideUp(0);	
			$(this).next().slideDown(0);
		}
		//$("div.accordionButtonSelected").removeClass().addClass("accordionButton");
		//$(this).removeClass().addClass("accordionButtonSelected");
	});
 
	$("div.accordionContent").hide(); // closes all divs on page load
	$("#open").trigger('click'); // opens the div that is assigned with the id open 

	//***************************************************************************************************
	// show cart
	//***************************************************************************************************

	var bagFlag = document.getElementById('showCartFlag');
	if (bagFlag != null){
		//document.getElementById('shadowOneModalCart').style.display = 'block';
		//var mask = document.getElementById('mask');
		//h = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
		//w = (typeof window.innerWidth != 'undefined' ? window.innerWidth : document.body.offsetWidth);
		//mask.style.width = w + 'px';
		//mask.style.height = h + 'px';
		//mask.style.display = 'block';  
	 	
		var maskHeight = $(window).height();  
	 	var maskWidth = $(window).width();
	 	$('#mask').css({'width':maskWidth,'height':maskHeight});  
		$('#mask').css('filter','alpha(opacity=10)').show()
	 	//if ($.browser.msie) {
	 		$('div#shadowOneModalCart').show(); 
	 	//} else {
	 	//	$('div#shadowOneModalCart').fadeIn(500); 
	 	//} 
		
				
		bagFlag.parentNode.removeChild(bagFlag);
	}
	
	//***************************************************************************************************
	// attach cat hash to URLs of pages that have back functionality
	//***************************************************************************************************

	$('a.attachCatHash').click(function() {
		if (typeof goBackHash != 'undefined' && goBackHash > ' ' ) {
			var href = $(this).attr('href');
			if ( $(this).attr('href').indexOf('?') < 0 ) $(this).attr('href', href += '?gobackHash=' + goBackHash);  
			else $(this).attr('href', href += '&gobackHash=' + goBackHash);
			return;
		}
	});
	
	//***************************************************************************************************
	// increment cart quantity 
	//***************************************************************************************************
/*	
	$("p.cartQuantityButton").click(function() {
        var button = $(this);
        var buttonText = button.text().substring(0,1);
        var i = button.text().substring(1);
		  var oldValue = $("p#cartQuantityValue" + i).text();		  		
        if (buttonText == "+") {
        		if (oldValue <= 98) var newVal = parseFloat(oldValue) + 1;
        	} else {
        		if (oldValue >= 2) var newVal = parseFloat(oldValue) - 1;
        	}
     	  $("p#cartQuantityValue" + i).text(newVal);
    	  $('input#cartQuantity' + i).val(newVal);
    	  $('input.updateLineButton' + i).attr('src', 'images/graphics/SB-goButtonPink.png');

    });
 */   
	//***************************************************************************************************
	// hover effect for form submit buttons
	//***************************************************************************************************

    $("div.fadeHover").hover(function () {
			ta = $(this).attr('class').split(' ');
			//alert ('-' + ta[1] + '-');
			//alert (  $('div.' + ta[1] + ' input:first-child').attr('src'));
			$('div.' + ta[1] + ' input:first-child').css('visibility', 'hidden');
		}, function () {
			$('div.' + ta[1] + ' input:first-child').css('visibility', 'visible'); 
		}
	 );
	
});
