﻿function purl_ControlInit(idStr)
{
   return (document.getElementById(idStr));
}

function purl_igControlInit(idStr)
{
   return (igedit_getById(idStr));
}


function PurlOpenLink(linkUrl, openInNewWindow, windowName)
{
   if (openInNewWindow)
      window.open(linkUrl,windowName,'',true);
   else
      location.href = linkUrl;
}

function __ValidateEmail (email)
{
   var emailpat = new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?");

   if(!emailpat.test(email))
      return false;

   return true;
}
function PurlClientField(fieldName) {
   this.FieldName = fieldName;
   this.InitObject = function(userInit) {
      if (typeof (igedit_getById) != "undefined") {
         this.Object = igedit_getById(this.FieldName);
         if (typeof (this.Object) != "undefined") {
            // Call the Infragistics control initialize event
            ig_fireEvent(this.Object, userInit);
         }
         return;
      }
      this.Object = document.getElementById(this.FieldName);
      if (this.Object == null)
         throw new Error(this.FieldName + ' does not exist');
   };
   /* METHODS */
   this.getValue = function() {
      if (this.Object.getValue)
         return (this.Object.getValue());
      return (this.Object.value);
   };
   this.setValue = function(val) {
      if (this.Object.setValue)
         this.Object.setValue(val);
      else
         this.Object.value = val;
   };
   this.setText = function(text) {
      if (this.Object.setText)
         this.Object.setText(text);
      else
         this.Object.value = text;
   };
   this.getText = function() {
      if (this.Object.getText)
         return (this.Object.getText());
      return (this.Object.value);
   };
}
