// JavaScript Document

$(document).ready(function() {

$('.dontback').click(function() {
	$(this).fadeOut(200, function() {
								  //$(this).siblings(".doback").fadeIn(200);
								  });
	

});
	
	

$('#more_digi_info').qtip({
   content: $('#more_digi_info_box').html(),
   position: {
      corner: {
           target: 'topMiddle',

         tooltip: 'bottomMiddle'
      }
   },

   
   style: { 
  	 width: 350,
 	background: '#FFFFCC',
      color: 'black',

   	 tip: 'bottomMiddle',
   	 border: {
        width: 3,
        radius: 8
	 },

      name: 'cream' 
   },

   show: 'mouseover',
   hide: 'mouseout'
})


								
								
		 
		$('#quantity').bind('keyup blur', function () {
 
		var total_saving = Math.round(quantity * document.getElementById('hat_item_price').value);
	
		var quantity = $('#quantity').val();
		
		if (quantity > 74) {
			$('#deal').html('BULK SAVING! You save $9 <u>ON EACH CAP!</u>').fadeIn("slow");
		} else  
		if (quantity > 34) {
			$('#deal').html('BULK SAVING!! You save $8 <u>ON EACH CAP!</u>').fadeIn("slow");
		} else  
		if (quantity > 19) {
			$('#deal').html('BULK SAVING!!! You save $7 <u>ON EACH CAP!</u>').fadeIn("slow");
		}  else
		if (quantity > 10) {
			$('#deal').html('BULK SAVING!!!! You save $6 <u>ON EACH CAP!</u>').fadeIn("slow");
		}  else
		if (quantity <= 10) {
			$('#deal').html('');
		}							   						   
	});					   
						   
						   
	$(".front_cap_radio").bind('change click', function () {
		//$(".upload_logo_box").slideUp('slow');	

		if ($("#radio_upload_new:checked").val()) {
			$("#box_upload_new").slideDown('slow');	
		} else {
			$("#box_upload_new").slideUp('slow');	
		}
		
		
		if ($("#radio_on_file:checked").val()) {
			$("#box_on_file").slideDown('slow');	
		}  else {
			$("#box_on_file").slideUp('slow');	
		}

		$(this).blur();
	}); 
	
 
	$("#qtyForm").validate({
		rules: {
			quantity: "required",
			backcap: "required"
		},
		messages: {
			quantity: " &laquo;- How many caps of this style would you like?", 
			backcap: " Would you like to embroid the back of the cap? ",
			size: "Please select your cap size"
		}
	});
						   
	$("#uploadify").uploadify({
		'uploader'       : '/includes/jquery/plugins/uploadify/uploadify.swf',
		'script'         : '/includes/jquery/plugins/uploadify/uploadify.php',
		'cancelImg'      : '/includes/jquery/plugins/uploadify/cancel.png',
		'queueID'        : 'fileQueue',
		'auto'           : true,
		'multi'          : false,
		
		onSelect: function (evt, queueID, fileObj, response, data) {
        // alert("Selected: "+response);
		
		$('#submitNextBoxPaused').show();
		$('#submitNextBox').hide();
		 
      },
	  
	  onCancel: function (evt, queueID, fileObj, response, data) {
			$('#submitNextBox').show();
			$('#submitNextBoxPaused').hide();  
	  },
	  
		onComplete: function (evt, queueID, fileObj, response, data) {
        // alert("Successfully uploaded: "+response);
		if (response == '<div id="uploaderr">File type not supported, please try converting your image to .jpg or another supported format</div>') {
			$('#box_upload_new').append(response);
		} else {
			$('#box_upload_new').html(response);
			$('#submitNextBox').show();
			$('#submitNextBoxPaused').hide();
			
		}
      }
	});
});
