<!--
    /************************************************************************
    *   Limit textbox
    ************************************************************************/   
    function textCounter(field, fieldbyname, countfield, maxlimit) {
        var p_Element;
        if ( document.getElementById(fieldbyname) != undefined)
        {
            p_Element = document.getElementById(fieldbyname);
        }
        else
        {
            p_Element = document.getElementById(field);
        }
        if (p_Element.value.length > maxlimit) // if too long...trim it!
            p_Element.value = p_Element.value.substring(0, maxlimit);
        // otherwise, update 'characters left' counter
        else 
            document.getElementById(countfield).value = maxlimit - p_Element.value.length;
    }
    
    /************************************************************************
    *Test Password Strength
    ************************************************************************/
    function passwordChanged(passwordField, field, fieldbyname, field2, field2byname, strengthField) {
        var p_Element;
        var p_Password = document.getElementById(passwordField)
        if ( document.getElementById(fieldbyname) != undefined)
        {
            p_Element = document.getElementById(fieldbyname);
        }
        else if ( document.getElementById(field) != undefined)
        {
            p_Element = document.getElementById(field);
        }
        else if ( document.getElementById(field2) != undefined)
        {
            p_Element = document.getElementById(field2);
        }
        else if ( document.getElementById(field2byname) != undefined)
        {
            p_Element = document.getElementById(field2byname);
        }
        p_Element.value = p_Password.value;
        var strength = document.getElementById(strengthField);
        var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
        var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
        var enoughRegex = new RegExp("(?=.{6,}).*", "g");
        if (p_Password.value.length==0) {
        strength.innerHTML = 'Type Password';
        } else if (false == enoughRegex.test(p_Password.value)) {
        strength.innerHTML = 'More Characters';
        } else if (strongRegex.test(p_Password.value)) {
        strength.innerHTML = '<span style="color:green">Strong!</span>';
        } else if (mediumRegex.test(p_Password.value)) {
        strength.innerHTML = '<span style="color:orange">Medium!</span>';
        } else { 
        strength.innerHTML = '<span style="color:red">Weak!</span>';
        }
    }

    /************************************************************************
    *   Pre-load Image
    ************************************************************************/
    img1Clear = new Image();
    img1Clear.src = "/App_System/Lib/Image/1clear.gif";


    /************************************************************************
    *   Standard Functions
    *       Standard functions from editors / templates
    *
    ************************************************************************/
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }

    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }

    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }

    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }

    /************************************************************************
    *   Function CopyToClipboard()
    *       Copies a value to the clipboard
    *
    ************************************************************************/
    function CopyToClipboard(p_strText)
    {
        if (window.clipboardData) 
        {
            window.clipboardData.setData('Text', p_strText);
        }
    }
    
    /************************************************************************
    *   Function SetNavItemClass()
    *       Set the default class of an HTML item
    *
    ************************************************************************/ 
    function SetNavItemClass(p_objElement, p_strClass)
    {
        document.getElementById(p_objElement).className = p_strClass;
    } 

    /************************************************************************
    *   Function PopUp()
    *       Creates a new popup window
    *
    ************************************************************************/
    function PopUp(pstrURL, pstrName, pintWidth, pintHeight, pblnScroll, pblnResize, pblnMenus, pblnStatus)
    {
        intLeftPosition = (screen.width) ? (screen.width/3) : 0;
        intTopPosition = (screen.height) ? (screen.height/3) : 0;        
        
        strSettings = 'width='+pintWidth+',height='+pintHeight+',top='+intTopPosition+',left='+intLeftPosition+'toolbar='+pblnMenus+',location='+pblnMenus+',directories='+pblnMenus+',status='+pblnStatus+',menubar='+pblnMenus+',scrollbars='+pblnScroll+',resizable='+pblnResize;
        objNewWindow = window.open(pstrURL, pstrName, strSettings);
        if(objNewWindow.window.focus)
        {
            objNewWindow.window.focus();
        }
    }

    /************************************************************************
    *   Function MakeNewWindow()
    *       Creates a new popup window
    *
    ************************************************************************/
    function MakeNewWindow(strURL, intWidth, intHeight, blnResizeable, blnScrollbars) 
    {
        var strOptions
            strOptions = "width=" + intWidth + ",height=" + intHeight + ",resizable=" + blnResizeable + ",scrollbars=" + blnScrollbars
        
        this.name = "frmMainWindow"
        SourceWindow=window.open(strURL, "" ,strOptions);
        SourceWindow.focus();
     }

    /************************************************************************
    *   Function mouseOver()
    *       changes graphics on a page during mouse events
    *
    ************************************************************************/ 
    function mouseOver(strCurrentImage, strNewImage)
    {
        if (parseFloat(navigator.appVersion) >= 3.0)
        {
            document.images[strCurrentImage].src = strNewImage;
        }
    }


    /************************************************************************
    *   Function toggleView()
    *       toggles the Hide / Show style of an element on the page
    *
    ************************************************************************/ 
    function toggleView(p_objElement)
    {
        if (document.getElementById(p_objElement).className == "SHOW")
        {
            document.getElementById(p_objElement).className = "HIDE";
        }
        else
        {
            document.getElementById(p_objElement).className = "SHOW"
        }
    } 


    /************************************************************************
    *   Variables: Validation
    *       Validation Masks for use throught the site
    *
    ************************************************************************/
    var MASK_ALPHA               = /^([a-z]|[A-Z]|[0-9])+$/;
    var MASK_ALPHA_WITH_SPACES   = /^(\w|\s)+$/;
    var MASK_NUMERIC             = /^(\d)+$/;
    var MASK_NUMERIC_WITH_SPACES = /^(\d|\s)+$/;
    var MASK_EMAILADDRESS        = /^([a-z]|[A-Z]|[0-9]|-|\.|_)+(@)+([a-z]|[A-Z]|[0-9]|-|\.|_)+$/;
    var MASK_DOMAINNAME          = /^([a-z]|[A-Z]|[0-9]|-|\.)+$/;
    var MASK_IPADDRESS           = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;

    /************************************************************************
    *   Function isRequired()
    *       checks to make sure a value exists
    *
    ************************************************************************/
    function isRequired(p_strValue)
    {
        if (p_strValue.length > 0 )
            return true;
        else
            return false;
    }

    /************************************************************************
    *   Function isIPAddress()
    *       checks for proper IP Address with regular expressions
    *
    ************************************************************************/
    function isIPAddress(p_strIPValue, p_blnRequired)
    {
        var intCount;
        var blnContinue = true;
        
        //Check to see if required
        if (p_blnRequired == true)
        {
            blnContinue = isRequired(p_strIPValue);
        }
        
        //Check for proper format
        if (blnContinue == true) 
        {
            var astrIP = p_strIPValue.match(MASK_IPADDRESS);
            if (astrIP == null)
            {
                return false;
            } 
            else 
            {
                for (intCount = 0; intCount < 4; intCount++) 
                {
                    if (astrIP[intCount+1] > 255) 
                    {
                        return false;
                    }
                }
            }
        } 
        else 
        {
            return false;
        }
        return true;
    }

    /************************************************************************
    *   Function ValidateCheck()
    *       General Validate check using regular expressions
    *
    ************************************************************************/
    function ValidateCheck(p_strValue, p_objMask, p_blnRequired)
    {
        var blnContinue = true;
        
        //Check to see if required
        if (p_blnRequired == true)
        {
            blnContinue = isRequired(p_strValue);
        }
        
        //Check for proper format
        if (blnContinue == true) 
        {
            var astrValue = p_strValue.match(p_objMask);
            if (astrValue == null)
            {
                return false;
            } 
        } 
        else 
        {
            return false;
        }
        return true;
    }
    
    
    /************************************************************************
    *   Function GetServerData()
    *       Client side call to return content from a server request
    *
    ************************************************************************/
    function GetServerData(p_LocalObject, p_strAddress) 
    {

        var xmlhttp=false;
        /*@cc_on @*/
        /*@if (@_jscript_version >= 5)
        // Conditional compilation for old browsers and security blocked creation of the objects.
         try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } 
         catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");} catch (E) { xmlhttp = false; } }
        @end @*/
        
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
        {
            try { xmlhttp = new XMLHttpRequest(); } 
            catch (e) { xmlhttp = false; }
        }
        if (!xmlhttp && window.createRequest) 
        {
            try { xmlhttp = window.createRequest(); } 
            catch (e) { xmlhttp = false; }
        }

        xmlhttp.open("GET", p_strAddress, true);
        xmlhttp.onreadystatechange = function() 
        {
            if (xmlhttp.readyState == 4) 
            {
                document.all.item(p_LocalObject).innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.send(null)
    }
    
    
    /************************************************************************
    *Content Manager Tutorial Pop Up Window
    ************************************************************************/
    function popup(ContentEditor, windowname) {
            if (!window.focus) return true;
            var href;
            if (typeof (ContentEditor) == 'string')
                href = ContentEditor;
            else
                href = ContentEditor.href;
            window.open(href, windowname, 'width=350, height=400, resizable=yes, scrollbars=yes');
            return false;
    }
    
//-->

