﻿// Java Script Library 


	String.prototype.trim = function() {
			a = this.replace(/^\s+/, '');
			return a.replace(/\s+$/, '');
	};		

	String.prototype.removeSpecialChars = function() {
		pattern=/[^A-Za-z0-9-_' ']/g;
		return this.replace(pattern,'');
};		

function TrimAndRemoveSpecialChar(fInput)
	{
		s1=fInput.removeSpecialChars();
		s2=s1.trim();
		return s2.split(" ").join("_");
  }
	
	// To focus to input control, as the calling 'focus' onload, so this is a work around.
	function SetFocus(controlID)
	{
 		setTimeout('$("#'+controlID+'").focus();',250);
	}

	function ResizeThickBox()
		{
			var oldHeight,oldWidth,newHeight,newWidth,leftMargin,topMargin;
			oldHeight=$("#TB_iframeContent").height();
			oldWidth=$("#TB_iframeContent").width();
			newHeight=document.getElementById('TB_iframeContent').contentWindow.document.body.scrollHeight;
			newWidth=document.getElementById('TB_iframeContent').contentWindow.document.body.scrollWidth;
      if ((oldHeight!=newHeight) || (oldWidth!=newwidth))
      {
     		newHeight=newHeight +65;
	    	newWidth=newWidth+15;
				leftMargin=parseInt((newWidth / 2),10);
				topMargin=parseInt((newHeight / 2),10);
	     	$("#TB_window").css({marginLeft:"-"+leftMargin+'px',marginTop:"-"+topMargin+'px',
						 width:newWidth+'px',height:newHeight+'px'});
				$("#TB_iframeContent").css({width:newWidth+'px',height:newHeight+'px'});
			}	
	
		}


