﻿ 
 function hide(id) {
    var obj = getDocumentObject(id);
    if(obj != null)
	    obj.style.display = "none";
}
function show(id) {	
    var obj = getDocumentObject(id);
   
    if(obj != null)
    {
        obj.style.display = "";
	 
		         
    }
	    
}
function selectAll(tag)
    {
       var tempval=document.getElementById(tag);
       tempval.focus();
       tempval.select();
       
    }  
function getDocumentObject( id ){
    return document.getElementById( id );
}

 function trim(str) 
     {  
        if(!str || typeof str != 'string')   return '';    
              return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' '); 
     }
     
     function Own_PostBack(eventTarget, eventArgument) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
    
    function PreventScriptInputSpecTitle(element)
{
      var valueElement = document.getElementById(element);
            if(valueElement.value.toLowerCase().indexOf('<script') > -1 || valueElement.value.toLowerCase().indexOf('</script>') > -1)                                                   
            {
               
                    valueElement.focus();
                    alert('Please do not include script tag in your input');
                    return false;
              
            }
            else if(valueElement.value.toLowerCase().indexOf('<') > -1 || valueElement.value.toLowerCase().indexOf('>') > -1)
            {
                //'Please do not include "<" or ">" in your comment!'
                valueElement.focus();
                alert('Please do not include "<" or ">" in here!');
                return false;
            } 
//            else if(checkHavingBadWord(valueElement.value))
//            {
//               
//                    valueElement.focus();
//                    alert("The input data contains words or phrases which are not allowed. \nPlease try again.");
//                    return false;
//           
//            }  
            
            return true;  
}

function PreventScriptInputSpec(element)
{
      var valueElement = document.getElementById(element);
            if(valueElement.value.toLowerCase().indexOf('<script') > -1 || valueElement.value.toLowerCase().indexOf('</script>') > -1)                                                   
            {
               
                    valueElement.focus();
                    alert('Please do not include script tag in your input');
                    return false;
              
            }
            
            
            return true;  
}
function validateNotEmpty( strValue ) {
/************************************************
DESCRIPTION: Validates that a string is not all
  blank (whitespace) characters.

PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid, otherwise false.
*************************************************/
   var strTemp = strValue;
   strTemp = trimAll(strTemp);
   if(strTemp.length > 0){
     return true;
   }
   return false;
}
function trimAll( strValue ) {
/************************************************
DESCRIPTION: Removes leading and trailing spaces.

PARAMETERS: Source string from which spaces will
  be removed;

RETURNS: Source string with whitespaces removed.
*************************************************/
 var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }

   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}
function replacespace( text)
    {
        var result =text;
        while(result.indexOf(' ')!=-1)
        {
            result = result.replace(" ", "");
       }
        return result;
    }
function js_EmailValidate(emailAdress)
{
    var regInvalid = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; 
    var regValid = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;    
    if (regValid.test(emailAdress)&& !regInvalid.test(emailAdress) ) return true;
    return false;
}