
/**
 * @class StockNotification_Class, shows stock notification bubble and and adds it
 * 
 */
Core.StockNotification_Class=function() {
   this.StockNotificationID="StockNotification_MainContainerID";
   this.Html_Email_CtrlID="StockNotification_Email";
   this.PreviousPopUpControlID=null;
   this.Code="";
   
   //
   this.AddStockNotification=function() {
         
         var notificationEmail="";
         var objemail=$get(this.Html_Email_CtrlID);
         if (objemail!=null) {
             if (objemail.value!="") {
                notificationEmail=objemail.value;
                 if (checkemail(notificationEmail)) {
                    _CoreModalPopUp.Hide();
                  _WebServiceAPI.ProductStockNotificationSave(notificationEmail, this.Code, this.AddStockNotificationOnComplete);
                }
                else {
                alert('The email address supplied is invalid.');
                }
             }
         }
       
   }
   
   this.AddStockNotificationOnComplete=function(result) {
       DoDefault();
      _StockNotification.DoComplete(result);
 
   }
   
    this.DoComplete=function(result) {
     
        _CoreModalPopUp.Hide();
        if (this.PreviousPopUpControlID!=null) {
          _CoreModalPopUp._PopupControlID=this.PreviousPopUpControlID;
          _CoreModalPopUp.ShowModal();
        }
          if (result.ActivityStatus==true) {
           alert('Your email has been stored in our database.');
         }
       else  {
       
        alert(result.ErrorString);
                
        }
 
   }
   
   
   //
   this.ShowBubble=function() {
    
    // this.Code=_code;
     // alert( this.Code);
     // MM_showHideLayers(this.StockNotificationID,'','show','StockNotification_MainContainerID');
     
    // if (preserveModal) {
    //   _CoreModalPopUp.Hide();
    //    this.PreviousPopUpControlID=_CoreModalPopUp._PopupControlID;
    // }
    // else {
    //    this.PreviousPopUpControlID=null;
    // }
     _CoreModalPopUp._PopupControlID=this.StockNotificationID;
     _CoreModalPopUp.ShowModal();
   
   }


  this.Close=function() {
       _CoreModalPopUp.Hide();
        if (this.PreviousPopUpControlID!=null) {
          _CoreModalPopUp._PopupControlID=this.PreviousPopUpControlID;
          _CoreModalPopUp.ShowModal();
        }
  
  
  
  }

}
 if (IsTypeDefined) { Core.StockNotification_Class.registerClass('Core.StockNotification_Class'); }

