$(document).ready(function () {
	//Event triger while click on product detail page buy now button
    $(document).on('click', '#stock-notify-varient', function () {
		var registeredUserID	=	$('#registeredUserID').val();
		var validateEmail =  $(this).validate( { form : "frmBackInStock" , field : "subscriberEmailID" , key : "required~*email" , error: errEmailID , inline:"1" , group: "", row: ""} ); 
		var validateName  =  $(this).validate( { form : "frmBackInStock" , field : "subscriberName" , key : "required" , error: errName, inline:"1" , group: "", row: ""} ); 
		if((validateEmail == false || validateName == false)&& registeredUserID == 0){
			return false;
		}
		else{
			sendNotification('varient');
		}	
	});
	$(document).on('click', '#stock-notify-combination', function () {
		var registeredUserID	=	$('#registeredUserID').val();
		var validateEmail =  $(this).validate( { form : "frmBackInStock" , field : "subscriberEmailID" , key : "required~*email" , error: errEmailID, inline:"1" , group: "", row: ""} ); 
		var validateName  =  $(this).validate( { form : "frmBackInStock" , field : "subscriberName" , key : "required" , error: errName, inline:"1" , group: "", row: ""} ); 
		if((validateEmail == false || validateName == false)&& registeredUserID == 0){
			return false;
		}
		else{
			sendNotification('combination');
		}
	});
});
function sendNotification(type){

		var registeredUserID	=	$('#registeredUserID').val();
        //Product custom options validation
		
			var emailID	=	$('#subscriberEmailID').val();
			var name	=	$('#subscriberName').val();
			if(type == 'varient'){
				var productOptionID	=	$("#selectedProductOption").val();
				var combHash			=	0;
			}
			else{
				var productOptionID	=	0;
				var combHash		=	combinationHash;
			}
			$.ajax({
				type: "POST",
				url: GLOBAL_BASE_PATH + "/product/ajaxStockNotify/",
				data:'productID='+productID+'&productOptionID='+productOptionID+'&combinationHash='+combHash+'&emailID='+emailID+'&name='+name+'&userID='+registeredUserID,
						success:function(msg) {
							$('.backInStock').html(backInStockInfo);
						}
			});
		
}