﻿
       // Validates empty strings
       function ClientValidate(source, arguments)
       {
          if (arguments.Value == '')
            arguments.IsValid = false;
          else
            arguments.IsValid = true;
       }
       
       // Validates contact us drop down
       function CheckDropDown(source,arguments)
       {
           if (arguments.Value == '-')
             arguments.IsValid = false;
           else
             arguments.IsValid = true;
       }
       
       // Validates text box length
       function CheckLength(source,arguments)
       {
           if (arguments.Value.length > source.MaximumLength)
           {
            arguments.IsValid = false;
           }else{
            arguments.IsValid = true;
           }
       }
              
       function CheckContent(source,arguments)
       {
           var reg = new RegExp("[^\\w\\s.\"@',&/?-]");
           
           if (reg.test(arguments.Value) == true)
           {
            arguments.IsValid = false;
           }else{
            arguments.IsValid = true;
           }
       }
       
       function CheckString(source,arguments)
       {
           var reg = new RegExp("[^\\w\\s.\",'-]");
           
           if (reg.test(arguments.Value) == true)
           {
            arguments.IsValid = false;
           }else{
            arguments.IsValid = true;
           }
       }
       //Generate Pop-up Div
        function leavingWebsite(url, target){
        if(!document.getElementById("popupDiv")){
	        window.scrollTo(0,0);
        	
	        var strInnerHTML = "<table summary=\"popupHolder\">";
	        strInnerHTML += "<tr>";
	        strInnerHTML += "<td colspan=\"2\"><strong>NOTICE: You are currently leaving the Secure Government website for a 3rd Party one.</strong></td>";
	        strInnerHTML += "</tr>";
	        strInnerHTML += "<tr>";
	        strInnerHTML += "<td><input type=\"button\" value=\"Continue\" onclick=\"leavingWebsite_Continue('"+url+"','"+ target+"')\"/></td>";
	        strInnerHTML += "<td><input type=\"button\" value=\"Cancel\" onclick=\"leavingWebsite_Cancel()\"/></td>";
	        strInnerHTML += "</tr>";
	        strInnerHTML += "</table>";
        	
	        var objPopupDiv = document.createElement("div");
            objPopupDiv.setAttribute("id","popupDiv");
            objPopupDiv.style.width = "350px";
            objPopupDiv.style.height = "130px";
            objPopupDiv.innerHTML = strInnerHTML;
            document.body.appendChild(objPopupDiv);
	        centerPopup();
	        window.onresize = function (){
		        centerPopup();
	        }
        }
        }

        //Cancel Functionality
        function leavingWebsite_Cancel(){
	        objPopupDiv = document.getElementById("popupDiv");
	        document.body.removeChild(objPopupDiv);
	        window.onresize = function (){
		        return false;
	        }
        }

        //Continue Functionality
        function leavingWebsite_Continue(url, target){
	        target = target.toLowerCase();
	        if (target=="blank"){
		        window.open(url);
	        }else{
		        eval(target+".location='"+url+"'");
	        }
	        leavingWebsite_Cancel();
        }

        //Center Pop-up Div
        function centerPopup(){
	        objPopupDiv = document.getElementById("popupDiv");
	        intWidth = parseInt(document.documentElement.clientWidth) - parseInt(objPopupDiv.style.width);
	        intWidth = intWidth / 2;
	        objPopupDiv.style.left = intWidth + "px";
        	
	        intHeight = parseInt(document.documentElement.clientHeight) - parseInt(objPopupDiv.style.height);
	        intHeight = intHeight / 2;
	        objPopupDiv.style.top = intHeight + "px";
         }
         
         function inputOnFocus(element){
	        if(element.value == 'Search...'){
		        element.value = '';
		        element.style.color = '#000000';
	        }
        }
        function inputOnBlur(element){
	        if(element.value == ''){
		        element.style.color = '#999999';
		        element.value = 'Search...';
	        }
        }
        
    
       // Validates e-mail addresses
       function CheckEmail(source,arguments)
       {
           var reg = new RegExp("\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
           
           if (reg.test(arguments.Value) == true)
           {
            arguments.IsValid = true;
           }else{
            arguments.IsValid = false;
           }
       }
       
       // Validates contact us drop down
       function CheckDropDown(source,arguments)
       {
           if (arguments.Value === '-')
             arguments.IsValid = false;
           else
             arguments.IsValid = true;
       }
       
       // Validates text box length
       function CheckLength(source,arguments)
       {
           if (arguments.Value.length > source.MaximumLength)
           {
            arguments.IsValid = false;
           }else{
            arguments.IsValid = true;
           }
       }
              
       function CheckContent(source,arguments)
       {
           var reg = new RegExp("[^\\w\\s.\"@',&/?-]");
           
           if (reg.test(arguments.Value) == true)
           {
            arguments.IsValid = false;
           }else{
            arguments.IsValid = true;
           }
       }
       
       function CheckString(source,arguments)
       {
           var reg = new RegExp("[^\\w\\s.\",'-]");
           
           if (reg.test(arguments.Value) == true)
           {
            arguments.IsValid = false;
           }else{
            arguments.IsValid = true;
           }
       }
       
       function CheckTelephone(source,arguments)
       {
       var reg = new RegExp ("^[0-9]+$");
       
       if (reg.test(arguments.Value) == true)
           {
            arguments.IsValid = true;
           }else{
            arguments.IsValid = false;
           }
       }
       //Replaces the image search with white background
        function doClear(element){
            if(element.value == ''){
            element.style.background = '#FFFFFF';
            }
        }
      
      function doClearMsg(strObjId)
        {
         if (strObjId.value === "type your e-mail address here")
            {
                strObjId.value = "";
            }       
        }
