// JavaScript Document
function bindwarnings(){
	//add the warning infront of the button
	$('.dowarning').before('<div class="warningMessage"> \
						   <a href="stihl.php" title="More Information"> \
						   Attention: Restricted Availability. Click here for more info. \
						   </a></div>');
	//bind all the warning button	
	$('.dowarning').each(function(i) {
    	var doWarningButton = $(this).attr('name');
		var sPath = window.location.pathname;
		var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
		$(this).replaceWith('<div id="stihlWarning'+i.toString()+'"></div>');
		$('#stihlWarning'+i.toString()).load('stihlWarning.php?name='+doWarningButton+'&returnURL='+sPage);
	});
	}
//bind all the do warning buttons
$(document).ready(bindwarnings);
$(document).ready(function(){
							//now we should work out if the form has been shown before
							if(!GetAFCookie("showStihlForm")){
							var basketTableHtml= "";
							//if we are on the basket
							basketTableHtml = $('#basketTable').html();
							//convert to lowercase
							if(basketTableHtml!=null){
								basketTableHtml = basketTableHtml.toLowerCase();
								//have we bought a stihl
								if(basketTableHtml.indexOf('stihl') > -1){
						   		//bind custom handler as the update button needs to ignore the validation								
						   		$("input[name='ACTION_UPDATE']").click(function(){
																		   //remove the required class from the three selectors
																		   $('#StihlQ1_0').removeClass('required');
																		   $('#StihlQ2_2').removeClass('required');
																		   $('#StihlQ3_4').removeClass('required');
																		   });
						   		//the checkou
						   		//right bring the box in after the table
						   		$('#shoppingBasketTable').after('<div id="stihlFormContainer">here it is</div>');
						   		$('#stihlFormContainer').load('stihlForm.php');
						   		//now add the extra validation
						   		$('#pageContainer').after('<div id="scriptContainer"></div>');
						   		$('#scriptContainer').load('include/validateInjectedForm.php');
						   	}
							}
						   }
						   });
