﻿ActionPage = "Default.aspx";
//***********************   
function sack(file) {
	this.xmlhttp = null;
	this.resetData = function() {
		this.method = "POST";
  		this.queryStringSeparator = "?";
		this.argumentSeparator = "&";
		this.URLString = "";
		this.encodeURIString = true;
  		this.execute = false;
  		this.element = null;
		this.elementObj = null;
		this.requestFile = file;
		this.vars = new Object();
		this.responseStatus = new Array(2);
  	};

	this.resetFunctions = function() {
  		this.onLoading = function() { };
  		this.onLoaded = function() { };
  		this.onInteractive = function() { };
  		this.onCompletion = function() { };
  		this.onError = function() { };
		this.onFail = function() { };
	};

	this.reset = function() {
		this.resetFunctions();
		this.resetData();
	};

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				this.xmlhttp = null;
			}
		}
	if (! this.xmlhttp) {
			if (typeof XMLHttpRequest != "undefined") {
				this.xmlhttp = new XMLHttpRequest();
			} else {
				this.failed = true;
			}
		}
	};

	this.setVar = function(name, value){
		this.vars[name] = Array(value, false);
	};

	this.encVar = function(name, value, returnvars) {
		if (true == returnvars) {
			return Array(encodeURIComponent(name), encodeURIComponent(value));
		} else {
			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
		}
	}

	this.processURLString = function(string, encode) {
		encoded = encodeURIComponent(this.argumentSeparator);
		regexp = new RegExp(this.argumentSeparator + "|" + encoded);
		varArray = string.split(regexp);
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split("=");
			if (true == encode){
				this.encVar(urlVars[0], urlVars[1]);
			} else {
				this.setVar(urlVars[0], urlVars[1]);
			}
		}
	}

	this.createURLString = function(urlstring) {
		if (this.encodeURIString && this.URLString.length) {
			this.processURLString(this.URLString, true);
		}

		if (urlstring) {
			if (this.URLString.length) {
				this.URLString += this.argumentSeparator + urlstring;
			} else {
				this.URLString = urlstring;
			}
		}

		// prevents caching of URLString
		this.setVar("rndval", new Date().getTime());

		urlstringtemp = new Array();
		for (key in this.vars) {
			if (false == this.vars[key][1] && true == this.encodeURIString) {
				encoded = this.encVar(key, this.vars[key][0], true);
				delete this.vars[key];
				this.vars[encoded[0]] = Array(encoded[1], true);
				key = encoded[0];
			}

			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
		}
		if (urlstring){
			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
		} else {
			this.URLString += urlstringtemp.join(this.argumentSeparator);
		}
	}

	this.runResponse = function() {
		eval(this.response);
	}

	this.runAJAX = function(urlstring) {
		if (this.failed) {
			this.onFail();
		} else {
			this.createURLString(urlstring);
			if (this.element) {
				this.elementObj = document.getElementById(this.element);
			}
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
					try {
						this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
					} catch (e) { }
				}

				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState) {
						case 1:
							self.onLoading();
							break;
						case 2:
							self.onLoaded();
							break;
						case 3:
							self.onInteractive();
							break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;

							if (self.execute) {
								self.runResponse();
							}

							if (self.elementObj) {
								elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input"
								|| elemNodeName == "select"
								|| elemNodeName == "option"
								|| elemNodeName == "textarea") {
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							if (self.responseStatus[0] == "200")
							{
							 self.onCompletion();
							 if (pageTracker != null)
	                          pageTracker._trackPageview(urlstring);  						 
							}
							else {
								self.onError();
							}

							self.URLString = "";
							/* These lines were added by Alf Magne Kalleland ref. info on the sack home page. It prevents memory leakage in IE */

							delete self.xmlhttp['onreadystatechange'];
							self.xmlhttp=null;
							self.responseStatus=null;
							self.response=null;
							self.responseXML=null;
														
							break;
					}
				};
				this.xmlhttp.send(this.URLString);
			}
		}
	};
	this.reset();
	this.createAJAX();
}
//*************************************************************************************************//
var dynamicContent_ajaxObjects = new Array();
function addJavascript(jsname,pos)
{
     var th = document.getElementsByTagName(pos)[0];
     var s = document.createElement('script');
     s.setAttribute('type','text/javascript');
     s.setAttribute('Src',jsname);
     th.appendChild(s);
     alert(jsname);
  } 

function StartWaiting(Target,mode)
{
 if (Target != "")
 {
   var obj = dog(Target);
   if (obj != null)
   {  
    SetOpacity(obj,35);
    if (mode==0)
      obj.innerHTML = "<div style='position:absolute; vertical-align: middle; text-align: center; width:75%;'>"
			         +"<img src='/App_Themes/Panel/loading.gif'/></div>";
    }
  }
}
 function StopWaiting(Target,mode)
 {
  if (Target != "")
  {
   var obj = dog(Target);
   if (obj != null)
   {
    SetOpacity(obj,100);
    if (mode==0) obj.innerHTML="";
   }
  }
 }
 
function ajax_parseJs(obj)
{
	var scriptTags = dog(obj).getElementsByTagName('script');
	var string = '';
	var jsCode = '';

	for(var no=0;no<scriptTags.length;no++)
	{
	if(scriptTags[no].src)
	    {
	     addJavascript(scriptTags[no].src,'head');
		}
	else
	    {
			if(navigator.userAgent.toLowerCase().indexOf('opera')>=0)
				jsCode = jsCode + scriptTags[no].text + '\n';
			else
				jsCode = jsCode + scriptTags[no].innerHTML;	
		}
		
	}
	if(jsCode)ajax_installScript(jsCode);
}

function ajax_installScript(script)
{		
  try
  {
    if (!script)
        return;
    if (window.execScript)        	
    	window.execScript(script)
    else if(window.jQuery && jQuery.browser.safari) // safari detection in jQuery
        window.setTimeout(script,0);
    else window.setTimeout(script,0);
  }
  catch(err)
  {
    alert(err);
  }  
}
//**************************************************RunAction***********************************//
function ajax_RunContent(divId,response)
{
   var str = response;
   if (str.substring(0,7) == '<script')
      if ( dog('divscript') != null ) divId = 'divscript';
   dog(divId).innerHTML = str;
   ajax_parseJs(divId);
}

function ajax_showContent(divId,response)
{
	StopWaiting(divId,0);
    ajax_RunContent(divId,response);
}

function RunAjax(url,Param,divId,ExecFunc)
{
    var ajaxIndex = dynamicContent_ajaxObjects.length;
	dynamicContent_ajaxObjects[ajaxIndex] = new sack();
 	var items = Param.split(/&/g);
    for(var no=0;no<items.length;no++)
    {
	var tokens = items[no].split('=');
	if(tokens.length==2){
	   dynamicContent_ajaxObjects[ajaxIndex].setVar(tokens[0],tokens[1]);}
	}
	dynamicContent_ajaxObjects[ajaxIndex].requestFile = url;	
	dynamicContent_ajaxObjects[ajaxIndex].onCompletion = function(){ExecFunc(divId,dynamicContent_ajaxObjects[ajaxIndex].response); dynamicContent_ajaxObjects[ajaxIndex] = false; };
	dynamicContent_ajaxObjects[ajaxIndex].onError = function(){ dynamicContent_ajaxObjects[ajaxIndex].response = showError(dynamicContent_ajaxObjects[ajaxIndex].response); ExecFunc(divId,dynamicContent_ajaxObjects[ajaxIndex].response);};
	dynamicContent_ajaxObjects[ajaxIndex].runAJAX();	
}

function LoadPage(url,Param,divId)
{
 StartWaiting(divId,0);
 RunAjax(url,Param,divId,ajax_showContent);
}
function RunAction(url,Param,divId)
{
 RunAjax(url,Param,divId,ajax_RunContent); 
}
function ExecAction(url,Param,ExecFunc)
{
 RunAjax(url,Param,'',ExecFunc); 
}
//************************************** LoadPage ******************************//
function ShowPage(Param,divId)
{ 
  if (divId == '')
    divId = 'divMain';
  LoadPage(ActionPage,'ActionType=Action&Action='+Param,divId);
}
function ShowRun(Param,divId)
{
  if (divId == '')
    divId = 'divMain';
  RunAjax(ActionPage,'ActionType=Action&Action='+Param,divId,ajax_RunContent);
}
function ShowAction(Param,ExecFunc)
{ 
  ExecAction(ActionPage,'ActionType=Action&Action='+Param,ExecFunc);
}
//*******************************************************************************//
function OpenPage(Param,divId)
{
   RunAjax(ActionPage,'ActionType=Action&Action='+Param,divId,OpenFunc);
}
function OpenFunc(divId,value)
{
   my_window = window.open("",
    "","width=600,height=400,alwaysRaised=yes,dependent=yes,resizable=no,scrollbars=yes");
   my_window.document.write("<input id='ResultId' value='"+divId+"' type='hidden'>");
   my_window.document.write(value); 
   my_window.opener = this;
   my_window.document.close();
}
//********************************************************************************//
function AdvData()
{
   this.model = "";
   var objectList = new Array();
   var objectSearch = new Array();
   this.state = 0;   //0:insert   1:update    3:delete
   this.Fields = "";
   this.FieldsCount = 0;
   this.ObjSelectField = null;
   this.divGrid="";
   this.divMsg="";
   this.divStruct="";
   this.resetData = function(model,divGrid,divMsg,divStruct)
   {
     this.model = model;
     this.divGrid = divGrid;
     this.divMsg = divMsg;
     this.divStruct = divStruct;
     this.enableFields(false);
   }
   function object()
   {
	this.fieldName = "";
	this.fieldTitle = "";
	this.objName="";
	this.Validate="";
	this.object;
   }
   this.AddObj = function(fieldName,objName,fieldTitle,validate)
   {
    var Index = objectList.length;
    objectList[Index] = new object();
    objectList[Index].fieldName = fieldName;
    objectList[Index].objName = objName;
    objectList[Index].fieldTitle = fieldTitle;
    objectList[Index].validate = validate;  
   }
   this.AddEditor = function()
   {
    var Index = objectList.length - 1;
    objectList[Index].object = new HTMLArea(objectList[Index].objName);
    objectList[Index].object.generate();
   }
   this.AddSearchObj = function(fieldName,objName,fieldTitle,validate)
   {
    var Index = objectSearch.length;
    objectSearch[Index] = new object();
    objectSearch[Index].fieldName = fieldName;
    objectSearch[Index].objName = objName;
    objectSearch[Index].fieldTitle = fieldTitle;
    objectSearch[Index].validate = validate;  
   }
  this.clearFields = function()
  {
    for (var i=0;i<objectList.length;i++)
     if (objectList[i].objName.substr(0,3) == "edt")
      objectList[i].object.setHTML('');
    else
       dog(objectList[i].objName).value = '';
   Fields="";
   FieldsCount=0;
  }
  
  this.enableFields = function(enabled)
  {
   for (var i=0;i<objectList.length;i++)
    dog(objectList[i].objName).disabled = !enabled;
 }
  this.AddField = function(FieladName, FieldValue)
  {
   if(Fields!="")
    Fields+="&";
   Fields+=FieladName+"="+FieldValue;
  }
  this.showData = function(pageCount)
  {
   page = ""; 
   if (pageCount != null)
     page = "&Page="+pageCount;
   LoadPage(ActionPage,'ActionType=Action&Action=DataShow&Model='+this.model+page,this.divGrid);
  }
  this.showDetail = function(SelectField,DetailClass,Detailmodel,DetailGrid)
  {
    if(this.ObjSelectField == null)
      this.ObjSelectField = dog(SelectField);
    if (this.ObjSelectField != null)
     {
       if((this.ObjSelectField.value != "")&&(this.ObjSelectField.value != undefined))
        LoadPage(ActionPage,'ActionType=Action&Action=DataSearch&Model='+Detailmodel+'&Class='+DetailClass+'&'+objectList[0].fieldName+'='+this.ObjSelectField.value,DetailGrid);
      else
        alert('ابتدا انتخاب کنید');
      }
     else
       alert('لطفا دوباره سعی کنید');
   }
  this.showField = function(SelectField)
  {
   if(this.ObjSelectField == null)
    this.ObjSelectField = dog(SelectField);
   if (this.ObjSelectField != null)
   {
    if((this.ObjSelectField.value != "")&&(this.ObjSelectField.value != undefined))
      ShowAction('DataShowField&Model='+this.model+'&'+objectList[0].fieldName+'='+this.ObjSelectField.value,this.viewField);
    else
      alert('ابتدا انتخاب کنید');
   }
   else
    alert('لطفا دوباره سعی کنید');
  }
 
  this.viewField = function(divId,value)
  {
   try
   {
    var Jobj;
    Jobj = eval("({Fields:"+value+"})");
    for(var i=0; i<objectList.length ;i++)
     if (objectList[i].objName.substr(0,3) == "edt")
     {
      if((Jobj.Fields[i] != "")&&(objectList[i].object!=null))
       objectList[i].object.setHTML(Jobj.Fields[i]);
     }
     else
       dog(objectList[i].objName).value = Jobj.Fields[i];
   }  
   catch(err)
   {
    if(dog(this.divMsg)!= null)
      dog(this.divMsg).innerHTML = showError(value);
    else alert(showError(value));
   }
  }
  this.insertField = function(SelectField)
  {
   this.state = 1;
   VisibleTab(this.divStruct);
   this.clearFields(SelectField);
   this.enableFields(true);
  }
  this.editField = function(SelectField)
  {
   this.state = 2
   VisibleTab(this.divStruct);
   this.showField(SelectField);
   this.enableFields(true);
  }
  this.deleteField = function(SelectField)
  {
   this.state = 3
   VisibleTab(this.divStruct);
   this.showField(SelectField);
   this.enableFields(true);
  }
  this.getName = function(ObjName)
  {
    for(var i=0;i<objectList.length;i++)
      if (objectList[i].objName == ObjName)
       return objectList[i].fieldName;
    for(var i=0;i<objectSearch.length;i++)
      if (objectSearch[i].objName == ObjName)
       return objectSearch[i].fieldName;
    return '';   
  }
  this.getEditor = function(ObjName)
  {
   for(var i=0;i<objectList.length;i++)
      if (objectList[i].objName == ObjName)
       return objectList[i].object;
  }
  this.AddValue = function(fieldName,ObjName)
  {
   if ((ObjName.substr(0,3) == "chb") || (ObjName.substr(0,3) == "rad"))
    {this.AddField(fieldName,dog(ObjName).checked);}
   else if (ObjName.substr(0,3) == "edt")
    {
      var value = this.getEditor(ObjName).getHTML()
      this.AddField(fieldName,encodeURIComponent(value));}
   else
    this.AddField(fieldName,dog(ObjName).value);
  }
  this.saveAction = function(ActionName)
  {
    Fields = '';
    Validate = '';  
    for(var i=0;i<objectList.length;i++)
    {
     if (objectList[i].Validate != "")
       {
        var AdvValid=new AdvValidate();
        ValidateItem = AdvValid.Validate("", dog(objectList[i].objName).value,objectList[i].Validate);
        if(ValidateItem != "")
         Validate = Validate + ValidateItem;
        else
         this.AddValue(objectList[i].fieldName,objectList[i].objName);
       } 
      else
       this.AddValue(objectList[i].fieldName,objectList[i].objName); 
    }
    if (Validate != "")
     {
       alert(Validate);
       return;
     } 
    var PostParams = "";
    switch(this.state)
    {
      case 1:PostParams="Insert";break;
      case 2:PostParams="Update";break;
      case 3:PostParams="Delete";break;
    }
    if (!confirmMsg())
      return;
    if (PostParams != "")
     ShowPage(ActionName+"&ActionType="+PostParams+"&Model="+this.model+"&"+Fields,this.divMsg);
    else
     alert('ابتدا عمل خود را انتخاب کنید'); 
    this.clearFields();
    this.enableFields(false);
    RefreshTab(this.divStruct);
    this.showData();
  }
  this.saveField = function()
  {
    var ActionName = "";
    switch(this.state)
    {
      case 1:ActionName="DataInsert";break;
      case 2:ActionName="DataUpdate";break;
      case 3:ActionName="DataDelete";break;
    }
    this.saveAction(ActionName);
  }
  this.search = function()
  {
    for(var i=0;i<objectSearch.length;i++)
     this.AddValue(objectSearch[i].fieldName,objectSearch[i].objName);
   ShowPage('DataSearch&Class=Master&Model='+this.model+'&'+Fields,this.divGrid);
  }
  this.report = function()
  {
    Fields = '';
    for(var i=0;i<objectSearch.length;i++)
     if (dog(objectSearch[i].objName)!= null)
     {
      this.AddValue(objectSearch[i].fieldName,objectSearch[i].objName);
      if(objectSearch[i].objName.indexOf("cboSearch") >= 0)
        this.AddField(objectSearch[i].fieldName+"Title",dog(objectSearch[i].objName).options[dog(objectSearch[i].objName).selectedIndex].text);
     }
    ShowPage('DataReport&Class=Master&ReportType='+this.divStruct+'&Model='+this.model+'&'+Fields,'divReport');
  }
  this.exportData = function()
  {
    Fields = '';
    for(var i=0;i<objectSearch.length;i++)
     if (dog(objectSearch[i].objName)!= null)
     {
      this.AddValue(objectSearch[i].fieldName,objectSearch[i].objName);
      if(objectSearch[i].objName.indexOf("cboSearch") >= 0)
        this.AddField(objectSearch[i].fieldName+"Title",dog(objectSearch[i].objName).options[dog(objectSearch[i].objName).selectedIndex].text);
     }
    window.open(ActionPage+'?ActionType=Action&Action=DataExport&Class=Master&ReportType='+this.divStruct+'&Model='+this.model+'&'+Fields,"");
  }
  this.fillField = function(SourceField,DescField)
  {
    if(SourceField.indexOf("Search") > 0)
     SearchField = '&SearchField=true';
    else
     SearchField  = '';
    if (dog(DescField) != null)
      ShowPage('DataFillField&Class=Master'+SearchField+'&SourceValue='+dog(SourceField).value+'&SourceField='+this.getName(SourceField)+'&DescField='+this.getName(DescField)+'&Model='+this.model,DescField);
  }
  this.cancelField = function()
  {
    this.clearFields();
    this.enableFields(false);
  }
  //************************* loadOption **************//
  this.LoadOption = function()
  {
    if((dog('cboUserOption') != null)&&(dog('cboUserOption').value != ""))
      ShowAction('DataLoadOption&UserOptionId='+dog('cboUserOption').value,this.viewOption);
  }
  this.viewOption = function(divId,value)
  {
   try
   {
    var Jobj;
    Jobj = eval("("+value+")");
    for(var i=0;i<Jobj[0].Count;i++)
     if((Jobj[i+1].ObjName.substr(0,3) == "chb") || (Jobj[i+1].ObjName.substr(0,3) == "rad"))
      dog(Jobj[i+1].ObjName).checked = Jobj[i+1].ObjValue;
     else dog(Jobj[i+1].ObjName).value = Jobj[i+1].ObjValue; 
   }  
   catch(err)
   {
    if(dog(this.divMsg)!= null)
      dog(this.divMsg).innerHTML = showError(value);
    else alert('Error In Json -> ' + value);
   }
  }
  this.SaveOption = function()
  {
     if((dog('txtUserOption') != null)&&(dog('txtUserOption').value != ""))
     {
      if (confirmMsg())
       return;
      var ActionName = 'DataSaveOption&UserOptionName='+dog('txtUserOption').value;
      for(var i=0;i<objectSearch.length;i++)
       if (dog(objectSearch[i].objName)!= null)
          this.AddValue(objectSearch[i].fieldName,objectSearch[i].objName);
      alert(Fields);    
      ShowRun(ActionName+'&'+Fields,this.divMsg);
    }
  }
  this.DeleteOption = function()
  {
    if((dog('cboUserOption') != null)&&(dog('cboUserOption').value != ""))
    {
     if (confirmMsg())
      return;
     ShowRun('DataDeleteOption&UserOptionId='+dog('cboUserOption').value,this.divMsg);
    }
  }
}
//*****************************************************************************
function AdvValidate()
{
  this.Validate = function(Name,Value,Validation)
  { 
    result = "";
    var command = Validation.split(",");
    for(var i=0;i<command.length;i++)
      result = result + this.ChackValidate(Name,Value,command[i]);
  }
  
  this.ChackValidate = function(Name,Value,command)
  {
   switch(command) 
    { 
        case "req": 
        case "required": 
         { 
		   ret = this.TestRequiredInput(Name,Value)
           break;             
         }//case required 
        case "maxlength": 
        case "maxlen": 
          { 
             var strMaxLen = command.split(":");
			 ret = this.TestMaxLen(Name,Value,strMaxLen[1]);
             break; 
          }//case maxlen 
        case "minlength": 
        case "minlen": 
           { 
			 var strMinLen = command.split(":");
			 ret = this.TestMinLen(Name,Value,strMinLen[1]);
             break; 
            }//case minlen 
        case "alnum": 
        case "alphanumeric": 
           { 
				ret = this.TestInputType(Name,Value,"[^A-Za-z0-9]",Name+": Only alpha-numeric characters allowed");
				break; 
           }
        case "alnum_s": 
        case "alphanumeric_space": 
           { 
				ret = this.TestInputType(Name,Value,"[^A-Za-z0-9\\s]",Name+": Only alpha-numeric characters and space allowed ");
				break; 
           }		   
        case "num": 
        case "numeric": 
           { 
                ret = this.TestInputType(Name,Value,"[^0-9]",Name+": Only digits allowed ");
                break;               
           }
        case "alphabetic": 
        case "alpha": 
           { 
                ret = this.TestInputType(Name,Value,"[^A-Za-z]",Name+": Only alphabetic characters allowed ");
                break; 
           }
        case "alphabetic_space": 
        case "alpha_s": 
           { 
                ret = this.TestInputType(Name,Value,"[^A-Za-z\\s]",Name+": Only alphabetic characters and space allowed ");
                break; 
           }
        case "email": 
          { 
			   ret = this.TestEmail(Name,Value,strError);
               break; 
          }
        case "lt": 
        case "lessthan": 
         { 
    	      ret = this.TestLessThan(Name,Value,cmdvalue,strError);
              break; 
         }
        case "gt": 
        case "greaterthan": 
         { 
			ret = this.TestGreaterThan(Name,Value,cmdvalue,strError);
            break; 
         }//case greaterthan 
        case "regexp": 
         { 
			ret = this.TestRegExp(Name,Value,cmdvalue,strError);
           break; 
         }
        case "dontselect": 
         { 
			 ret = this.TestDontSelect(Name,Value,cmdvalue,strError)
             break; 
         }
		case "dontselectchk":
		{
			ret = this.TestDontSelectChk(Name,Value,cmdvalue,strError)
			break;
		}
		case "shouldselchk":
		{
			ret = this.TestShouldSelectChk(Name,Value,cmdvalue,strError)
			break;
		}
		case "selone_radio":
		{
			ret = this.TestSelectOneRadio(Name,Value,strError);
		    break;
		}		 
     } 
	 return ret
	}
	this.TestRequiredInput = function(Name,Value)
    {
     if(eval(Value.length) == 0) 
       return Name + "باید پر شود"; 
    }
    this.TestMaxLen = function(Name,Value,strMaxLen)
    {
     if(eval(Value.length) > eval(strMaxLen)) 
       return  Name + ""+ strMaxLen +" characters maximum "; 
    }
    this.TestMinLen = function(Name,Value,strMinLen)
    {
     if(eval(Value.length) < eval(strMinLen)) 
       return Name + " : " + strMinLen + " characters minimum  "; 
    }
    this.TestInputType = function(Name,Value,strRegExp,strError)
    {
     var charpos = Value.search(strRegExp);
     if(Value.length > 0 &&  charpos >= 0) 
       return  strError;
    }
}  
