﻿// JScript File contains the functions for String Validations
// creator : MFS_SKS
 
		//function to check the first character for white spaces or any special characters
		function checkFirstChar(value){
			var leftChar;
			var bag = new Array();
			bag = ["*","%","#","@","!","$","^","(",")","<",">"]
			leftChar = value.charAt(0);
			// checks for blank spaces
			if ((leftChar == " ") || (leftChar == "\n") || (leftChar == "\t") || (leftChar == "\r")){
				alert("First character cannot be a space");
				return true;
			} 
			
			//checks for special characters
			for(var i=0; i < bag.length ;i++){
				if(leftChar == bag[i]){
					alert("First character cannnot be a special character " + leftChar);
					return true;
				}
			}
			return false;
		}
		
		// function that checks for invalid characters such as < > in the entire string
		function checkInvalidCharacter(s){
			var i;
			for (i = 0; i < s.length; i++)
			{   
				// Check that current character for < >.
				var c = s.charAt(i);
				if((c == "<") || (c == ">") || (c == "!")){
					alert("You have entered invalid characters !, <, Or >");
					return true;
				} 
			}
			return false;
		}
		
		// function trims the Null string
        function trim(strText){ 
            return strText.replace(/^\s*|\s*$/g,"");
        } 
        
        // function that checks for invalid characters such as < > in the entire string
		function checkInvalidCharacters(inputText)
		{		    
		    if (inputText.match(/[<>!]/))  
            {
				alert("You have entered invalid characters !, <, or >");
				return true;				
			}
			return false;
		}
		
		//created by MFS_RK, Feb 29 2008 to center popup window
		function centeredWindow(url, popW, popH, features, returnWindowHandle) {
	
	        if(!features)
	        {
		        features = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1";
	        }	
	        var w = 800, h = 600;
        		
	        if (document.all || document.layers) {
  		        w = screen.availWidth;
  		        h = screen.availHeight;
	        }

	        var leftPos = (w-popW)/2;
	        var topPos = (h-popH)/2;
	        features += ",width=" + popW + ",height=" + popH + ",top=" + topPos + ",left=" + leftPos;	
	        var link = window.open(url, "link", features);
	        try
	        {
	        link.focus();
	        }
	        catch(ex)
	        {
	        }
        	
	        if(returnWindowHandle)
	        {
		        return link;
	        }
        }