var myForm;

var sAreaName = "workingArea";

var nGridWidthOffset = -100;
var nGridHeightOffset = -100;
var nBrowserWidth = 1020;
var nBrowserHeight = 600;
var nGridWidthRatio = 0;
var bAdjustWidth = true;

var nFieldWidthTotal = 600;
var nScrollbarOffset = 26;

// browsers
var bOpera = false;
var bIE = false;
var bFirefox = false;
var bSafari = false;
var bChrome = false;

// popup window
var newWindow = null;
var newWindow2 = null;

//var bOpening = false;

//This function is used to trim String
function trimString (str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

//Check if the string is empty
function isEmpty(value)
{
	var bEmpty = false;

	if (trimString(value) == "")
		bEmpty = true;

	return bEmpty;
}

function validateQuotes(s)
{
	if (s.value.indexOf('"') != -1 || s.value.indexOf("'") != -1)
	{
		alert("Invalid entry! Double quote and single quote are not allowed.");
		s.disabled = false;

		while (s.value.indexOf("'") != -1)
		{
			s.value = s.value.replace("'", "");
		}

		while (s.value.indexOf('"') != -1)
		{
			s.value = s.value.replace('"', "");
		}

		s.focus();
	}
}

function validateDoubleQuote(s)
{
	if (s.value.indexOf('"') != -1)
	{
		alert("Invalid entry! Double quotes are not allowed.");
		s.disabled = false;

		while (s.value.indexOf('"') != -1)
		{
			s.value = s.value.replace('"', "");
		}

		s.focus();
	}
}

function textLength(s, maxlimit)
{
	if (s.value.length > maxlimit)
	{
		s.value = s.value.substring(0, maxlimit);
	}
}

// Convert string to an int
function strToInt(vStr)
{
	if (vStr == "")
		return 0;
	else
		return parseInt(vStr, 10);
}

// Convert string to a float
function strToFloat(vStr)
{
	if (vStr == "")
		return 0;
	else
		return parseFloat(vStr);
}

// Convert int to a fix length string
// Parameters:	vInt		-- The int value
//				vLen		-- The length of result string
//				vFillChar	-- The char that will be filled into string
function intToStr(vInt, vLen, vFillChar)
{
	var vRetVal = "" + vInt;

	if (vLen > 0)
	{
		while (vRetVal.length < vLen)
		{
			vRetVal = vFillChar + vRetVal;
		}
	}

	return vRetVal;
}

function isValidNumber(s)
{
	var i;
	var hasDecimalPoint = false;

	if (isEmpty(s))
	{
		return false;
	}

	for (i = 0; i < s.length; i++)
	{
	  var c = s.charAt(i);

	  if(!isDigit(c) && !(c=="." && !hasDecimalPoint) && !(i==0 && c=="-"))
	  	return false;

	  if (c==".")
	  	hasDecimalPoint = true;
	}

	return true;
}

//Validate if the given parameter is a positive integer
//Param: s		the input parameter to be evaluated
function isPositiveInteger(s)
{
	var i;

	if (strToInt(s) <= 0)
	{
		return false;
	}

	for (i = 0; i < s.length; i++)
	{
	  var c = s.charAt(i);

	  if(!isDigit(c))
	  	return false;
	}

	return true;
}

function isNetscape()
{
	if(window.navigator.appName == "Netscape")
		return true;
	else
		return false;
}

//Validate if ID is valid or not. Valid Id has A-Z, a-z, and 0-9 only.
function validateIdFormat(s)
{
	var i;
	for (i = 0; i < s.length; i++)
	{
	  var c = s.charAt(i);

	  //if(!isDigit(c)) return false;
	  if(!isLetter(c) && !isDigit(c))
	  	return false;
	}
	return true;
}

//Validate if User Id is valid or not. Valid Id has A-Z, a-z, 0-9, "-", "_" and "." only.
function validateUserIdFormat(s)
{
	var ok = true;
	var c;
	for (var i=0; i<s.value.length; i++)
	{
		c = "" + s.value.substring(i, i+1);
		if(!isLetter(c) && !isDigit(c) && (c != "-") && (c != "_") && (c != "."))
		{
			ok = false;
			break;
		}
	}

	if (!ok)
	{
		alert("Invalid entry! Only letters, digits, '-', '_' and '.' are allowed.");

		var temp = "";
		for (var i=0; i<s.value.length; i++)
		{
			c = "" + s.value.substring(i, i+1);
			if(isLetter(c) || isDigit(c) || (c == "-") || (c == "_") || (c == "."))
			{
				temp = temp + c;
			}
		}
		s.value = temp;

		s.focus();
	}
}

//Validate if input is valid or not. Valid input has 0-9 only.
function validateDigitFormat(s)
{
	if(isEmpty(s))
	{
		return false;
	}

	var i;
	for (i = 0; i < s.length; i++)
	{
	  var c = s.charAt(i);

	  //if(!isDigit(c)) return false;
	  if(!isDigit(c))
	  	return false;
	}
	return true;
}

// Returns true if character c is an English letter (A .. Z, a..z).
function isLetter (c){
	return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) );
}

// Returns true if character c is a digit between 0 to 9.
function isDigit (c){
	return ((c >= "0") && (c <= "9"));
}

function isValidEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported)
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function doModal(url,MyWindow,mwidth,mheight)
{
    if (window.showModelessDialog)
        {
        var newWindow = window.showModelessDialog(url,MyWindow,"help:0;resizable:1;dialogWidth:"+mwidth+"px;dialogHeight:"+mheight+"px;status:no");

        newWindow.name = "NewWindow";

        return newWindow;
        }
    else
        {
        var newWindow = window.open(url,MyWindow,"toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=1,resizable=1,width=" + mwidth +",height=" + mheight + ",left=10,top=10");

        newWindow.name = "NewWindow";

        return newWindow;
        }
}

//show/hide the search or filter area
//Param	vArea	"" if to hide all
//				"Filter" if to show filter and hide search
//				"Search" if to show search and hide filter
function showHideSearchFilter(vArea)
{
	if(vArea == "")
	{
		document.getElementById("searchFilterArea").style.display = "none";
		document.getElementById("filterArea").style.display = "none";
		document.getElementById("searchArea").style.display = "none";
	}
	else if(vArea == "Filter")
	{
		document.getElementById("searchFilterArea").style.display = "";
		document.getElementById("filterArea").style.display = "";
		document.getElementById("searchArea").style.display = "none";
	}
	else if(vArea == "Search")
	{
		document.getElementById("searchFilterArea").style.display = "";
		document.getElementById("filterArea").style.display = "none";
		document.getElementById("searchArea").style.display = "";
	}
}

//show/hide the filter area
//Param	vArea	"" if to hide filter
//				"Filter" if to show filter
function showHideFilter(vArea)
{
	if(vArea == "")
	{
		document.getElementById("filterArea").style.display = "none";
	}
	else if(vArea == "Filter")
	{
		document.getElementById("filterArea").style.display = "";
	}
}

function doPrint()
{
	alert("For a better printing result, select the Landscape Layout Orientation in the Print dialog box.");
	window.print();
}

// Adjust area's width and height
function onAdjustArea()
{
	var nWinHeight = document.body.clientHeight;
	var nTempHeight = nWinHeight-nToolHeightOffset;
	if (nTempHeight < 0)
		nTempHeight = 0;

	document.getElementById(sAreaName).style.height = nTempHeight;

	// If setting nToolWidthAdjust to 0, don't adjust the width
	if (nToolWidthAdjust > 0)
	{
		var nWinWidth  = document.body.clientWidth;
		var nTempWidth = nWinWidth*nToolWidthAdjust;
		document.getElementById(sAreaName).style.width = nTempWidth;
	}
}

function doPrintDivOverflow()
{
	document.getElementById("workingArea").style.overflow = "visible";
	doPrint();
	document.getElementById("workingArea").style.overflow = "auto";
}

// Handles key pressed event.
// Param: 	myfield 	current field
// 			e			event
function onKeyPressed(myfield,e)
{
	var keycode;

	if (window.event)
	{
		keycode = window.event.keyCode;
		editingField = window.event.srcElement;
	}
	else if (e)
	{
		keycode = e.which;
		editingField = e.srcElement;
	}
	else
		return true;

	if (keycode == 13)
	   	return moveToNextCell(myfield);
	else
	{
		//alert(myfield.value.length);
		//setCaretPosition(myfield, myfield.value.length);	
		return true;
	}
}

// Move to focus the next column
// Param: 	myfield	current field
//			offset		the row offset
function moveToNextCell(myfield)
{
	//alert(myfield.id);
	var nRow = strToInt(myfield.id.substr(3));
	var sCol = myfield.id.substr(0, 3);
//alert(nRow + "; "+ sCol);	
	var sNextCellId = sCol + intToStr((nRow+1), 3, "0");
	var oNextCell = document.getElementById(sNextCellId);

	if (oNextCell != null)
	{
		oNextCell.focus();
	}
	else
	{
		myfield.blur();
	}

	return false;
}

function printPartOfPage(elementId, sHeader, sFooter) 
{  
	 var printContent = document.getElementById(elementId);  
	
	 var windowUrl = 'about:blank';  
	 
	 var printWindow = window.open(windowUrl, '_blank', 'resizable=1,scrollbars=1,left=10,top=10,width=800,height=600');  
	 printWindow.document.write(sHeader);
	 printWindow.document.write(printContent.innerHTML);  
	 printWindow.document.write(sFooter);
	
	 printWindow.document.close();  
	
	 printWindow.focus();  
	
	 //printWindow.print();  
	
	// printWindow.close(); 
}  

function getPrintHeader()
{	
	var sRet = '<link rel="stylesheet" href="css/print.css" type="text/css"> ';	
	sRet += '<div class="noprint"><table class=fullcontainer><tr class=toolbar>';
	sRet += '<td colspan=5 width=35%>';
	sRet += '<input type=button class=toolbarButton onClick="window.close();" value="Close">';
	sRet += '&nbsp;&nbsp;&nbsp;<input type=button class=toolbarButton onClick="window.print();" value="Print">';
	sRet += '</td></tr></table></div>';
	
	return sRet;
}	

function setCaretPosition(elem, caretPos) {  
    if(elem != null) {
        if(elem.createTextRange) {
            var range = elem.createTextRange();
            range.move('character', caretPos);
            range.select();
        }
        else {
            if(elem.selectionStart) {
                elem.focus();
                elem.setSelectionRange(caretPos, caretPos);
            }
            else
                elem.focus();
        }
    }
}

function onAdjustGridArea(oArea)
{	   	  
	getBrowserInfo();
   var nScreenHeight = window.screen.availHeight;        
 	var nDiffH = nScreenHeight - nBrowserHeight; 	
 	 	
 	var nDiffOffset = 1.1;
 	   
   var nTempHeight = nScreenHeight - (150 + (nDiffH * nDiffOffset)) + nGridHeightOffset;
  
   if(nTempHeight < 100)
   	nTempHeight = 100;
          	   
   oArea.style.height=Math.round(nTempHeight);
   
   if(bAdjustWidth)
   {
   	/*
   		var nScreenWidth = window.screen.availWidth; 
   		var nDiffW = nScreenWidth - nBrowserWidth;
	   //nGridWidthOffset -= 6;
	   var nTempWidth = nScreenWidth + nGridWidthOffset; 
	   if(nDiffW > 0)
	   	nTempWidth -= nDiffW;
	   	
	   if(nGridWidthRatio > 0)
	   		nTempWidth = nTempWidth * nGridWidthRatio;
	   		
	   if(nToolWidthAdjust > 0)
	   	   	nTempWidth = nTempWidth * nToolWidthAdjust;	
	   		
	   oArea.style.width=Math.round(nTempWidth); 
	   		// alert(oArea.style.Width);  
	   */
	   
	   oArea.style.width=Math.round(nFieldWidthTotal+nScrollbarOffset); 
	  // var oRecBarArea = document.getElementById("recBarArea");	
	 //  oRecBarArea.style.width=Math.round(nFieldWidthTotal); 	
   }
             
//alert("Grid: oArea.style.height="+oArea.style.height+"; nDiffH="+nDiffH+"; nBrowserHeight="+nBrowserHeight+"; nTempHeight="+nTempHeight);   
     
}

function getBrowserInfo() 
{  
  if( typeof( window.top.innerWidth ) == 'number' ) {
    //Non-IE
    nBrowserWidth = window.top.innerWidth;
    nBrowserHeight = window.top.innerHeight;
  } else if( window.top.document.documentElement &&
      ( window.top.document.documentElement.clientWidth || window.top.document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    nBrowserWidth = window.top.document.documentElement.clientWidth;
    nBrowserHeight = window.top.document.documentElement.clientHeight;
  } else if( window.top.document.body && ( window.top.document.body.clientWidth || window.top.document.body.clientHeight ) ) {
    //IE 4 compatible
    nBrowserWidth = window.top.document.body.clientWidth;
    nBrowserHeight = window.top.document.body.clientHeight;
  }
  //window.alert( 'Width = ' + nBrowserWidth );
 // window.alert( 'Height = ' + nBrowserHeight );
}

function validateDate(vTime)
{
	var dtTime = new Date(vTime);
	if((vTime.indexOf(', ') == -1) || (vTime.indexOf(' ') != 3) || (dtTime == "NaN"))
	{
		return false;
	}

	return true;
}

//Check if the string is empty for rich text editor
function isEmptyRTE(s)
{
	return isEmpty(replaceString(s, "<p>&nbsp;</p>", ""));
}

function replaceString(str, oldStr, newStr)
{
	var sRetVal = "";
	var index = str.indexOf(oldStr);

	while(index != -1)
	{
		sRetVal = sRetVal + str.substring(0, index) + newStr;
		str = str.substring(index + oldStr.length);
		index = str.indexOf(oldStr);
	}

	sRetVal = sRetVal + str;

	return sRetVal;
}

function openWin(url,mwidth,mheight, mLeft, mTop)
{					
	if(newWindow == null || newWindow.closed)
	{			
		if(mLeft == null)
			mLeft = 60;
		
		if(mTop == null)
			mTop = 20;
	
		newWindow = window.open(url,"","width="+mwidth+"px,height="+mheight+"px,resizable=1,scrollbars=1,statusbar=0,menubar=0,left="+mLeft+"px,top="+mTop+"px");
				
		newWindow.name = "NewWindow";	
	//	window.setTimeout("bOpening = false;", 1000, "JAVASCRIPT");		
		return newWindow;		
	}	
	else
	{	
		openWin2(url,mwidth,mheight, mLeft, mTop);
		//alert(MSG_POPUP_WINDOW_OPENED);	
	}	
}

function openWin2(url,mwidth,mheight, mLeft, mTop)
{					
	if(newWindow2 == null || newWindow2.closed)
	{			
		if(mLeft == null)
			mLeft = 60;
		
		if(mTop == null)
			mTop = 20;
	
		newWindow2 = window.open(url,"","width="+mwidth+"px,height="+mheight+"px,resizable=1,scrollbars=1,statusbar=0,menubar=0,left="+mLeft+"px,top="+mTop+"px");
				
		newWindow2.name = "NewWindow2";	
	//	window.setTimeout("bOpening = false;", 1000, "JAVASCRIPT");		
		return newWindow2;		
	}	
	else
	{			
		alert(MSG_POPUP_WINDOW_OPENED);	
	}	
}

function checkBrowser()
{
	var agt = navigator.userAgent.toLowerCase(); 
//alert(agt);
	bOpera = (agt.indexOf("opera") != -1);
	bIE = !bOpera && (agt.indexOf("msie") > -1); 
	bFirefox = !bIE && (agt.indexOf("firefox") > -1); 
	bSafari = !bFirefox && (agt.indexOf("safari") > -1);	
	bChrome = !bSafari && (agt.indexOf("chrome") > -1);
}

// for htmlxgrid 2.6
// Case insensitive sorting
function str_custom(a,b,order){    // the name of the function must be > than 5 chars
        if (order=="asc")
            return (a.toLowerCase()>b.toLowerCase()?1:-1);
        else
            return (a.toLowerCase()>b.toLowerCase()?-1:1);
    }
    
// grid sorting
function sortGrid(vGrid, vInd, vSortOrder)
{			
		vGrid.sortRows(vInd, vGrid.fldSort[vInd], vSortOrder);
		vGrid.setSortImgState(true,vInd,vSortOrder); 
}		
/*
function setSort(vPageIndex,index,vsortorder)
{
	var oHeader = window.top.Header; 		
	var sSortStr = oHeader.getSortStr();
	
	var nIndex = sSortStr.indexOf(vPageIndex);
	if(nIndex > -1)
	{		
		var nEnd = sSortStr.indexOf(";", nIndex);
	//	sTemp = sTemp.substring(0, nEnd+1);	
	//alert("aaa:"+sTemp+"ccc");	
	//	replaceString(sSortStr, trimString(sTemp), "");
		
		sSortStr = sSortStr.substring(0, nIndex) + sSortStr.substring(nEnd+1);
		
		//sSortStr.replaceAll(sTemp, "");
	//alert("bbb:"+sSortStr);
	}	
	
	sSortStr += vPageIndex+index+","+vsortorder+";";
	
	oHeader.setSortStr(sSortStr);		
}

function getSort(vPageIndex, vGrid)
{
	if(vGrid.getRowsNum() < 1)
		return;
	
	var oHeader = window.top.Header; 
	var sSortStr = oHeader.getSortStr();
	
	var nIndex = sSortStr.lastIndexOf(vPageIndex);
	var nPageIndexLen = vPageIndex.length;
	//alert(sSortStr);
	if(nIndex > -1)
	{
		var sTemp = sSortStr.substring(nIndex+nPageIndexLen);
		var nEnd = sTemp.indexOf(";");
		sTemp = sTemp.substring(0, nEnd);
	//alert(sTemp);	
		var aSort = strToArray(sTemp, ",");
		
		var nInd = strToInt(aSort[0]);
		var sSortOrder = aSort[1];
	//alert(nInd+"; "+ sSortOrder);	
		sortGrid(vGrid, nInd, sSortOrder);		
	}	
}	*/

function attachAfterSorting(vGrid)
{
	vGrid.attachEvent("onAfterSorting", function(index,type,vSortOrder){             
             setSort(index,vSortOrder);
        });	
}	   

function setSort(index,vsortorder)
{
	myForm.sSortBy.value = index;	
	myForm.sSortOrder.value = vsortorder;		
}

function getSort(vGrid)
{
	var nSort = myForm.sSortBy.value;
	
	if(isEmpty(nSort))
		return;
	
	var sSortOrder = myForm.sSortOrder.value;
	
	sortGrid(vGrid, nSort, sSortOrder);			
}	

function onChangeDate(vObjName)
{	
	var oTime = document.getElementsByName(vObjName)[0];		
	myCalendar.select(oTime, vObjName, DATE_FORMAT_STR, "");
}

function showElemById(vName)
{
	document.getElementById(vName).style.display = "";		
}	

function hideElemById(vName)
{
	document.getElementById(vName).style.display = "none";		
}

function showElemByName(vName)
{
	var oObj = document.getElementsByName(vName);
	var nObjNum = oObj.length;
	var sObjStr = "";
	
	for(var i=0;i<nObjNum;i++)
	{		
		oObj[i].style.display = sObjStr;	
	}			
}	

function hideElemByName(vName)
{
	var oObj = document.getElementsByName(vName);
	var nObjNum = oObj.length;
	var sObjStr = "none";
	
	for(var i=0;i<nObjNum;i++)
	{		
		oObj[i].style.display = sObjStr;	
	}			
}

function isHomeLib(vLibTypeId)
{
	var bRet = (vLibTypeId >= LIB_TYPE_HOME_EVENT && vLibTypeId <= LIB_TYPE_HOME_IMAGE_B);
		
	return bRet;
}	

function getTextInHtml(vObj)
{
	checkBrowser();
	var sRet = "";
	if(bIE)
		sRet= vObj.innerText;
	else	
		sRet= vObj.textContent;	
		
	return sRet;	
}	

function showTextInHtml(vObj, vStr)
{
	checkBrowser();
	if(bIE)
		vObj.innerText = vStr;
	else
		vObj.textContent = vStr;	
}

function initMyRTE()
{
	initRTE("rte/images/", "rte/", "css/RichText.css");	
}	

function onMyProfile()
{
	openWin('UserEdit.jsp',985,800);	
}	

function setIPM(vLink)
{
	document.getElementById("ipm").href = vLink;	
}	

function printPageWithWorkingArea()
{	
	var oArea = document.getElementById("workingArea");
	if(oArea != null)
	{
		oArea.style.overflow = "visible";
		oArea.style.border = "none";
		oArea.style.width = "80%";
	}	

    window.print();

	if(oArea != null)
	{
	    oArea.style.overflow = "auto";
	    oArea.style.border = "1px solid black";
	    oArea.style.width = "100%";
	}    
}	

function isOnList(vList, vText)
{
	var bRet = false;
			
	if((","+vList+",").indexOf(","+vText+",") > -1)
	{			
		bRet = true;												
	}		
	//alert("vList="+vList+"; vText="+vText+";; bRet="+bRet);		
	return bRet;
}

function addToList(vList, vText)
{			
	//alert("add vList1="+vList);	
	if(!isOnList(vList, vText)) // don't add duplicate text
	{
		if(!isEmpty(vList))
		{			
			vList += ",";												
		}	
		
		vList += vText;		
	}

	//alert("add vList2="+vList);	
	return vList;	
}

function removeFromList(vList, vText)
{			
	//alert("vList1="+vList);	
	if(!isEmpty(vList))
	{			
		if(vList.indexOf(","+vText) > -1)
			vList = vList.replace(","+vText, "");
		else if(vList.indexOf(vText+",") > -1)
			vList = vList.replace(vText+",", "");
		else			
			vList = vList.replace(vText, "");													
	}	
	//alert("vList2="+vList);	
	return vList;	
}

function onCheckKeyword(vField)
{
	var sField = vField.value;
	
	if(sField.indexOf(DEFAULT_KEYWORD_SEARCH) > -1)
		vField.value = replaceString(sField, DEFAULT_KEYWORD_SEARCH, "");	
}	

// Handles key pressed event.
// Param: 	myfield 	current field
// 			e			event
function onKeyword(myfield,e)
{
	var keycode;

	if (window.event)
	{
		keycode = window.event.keyCode;
		editingField = window.event.srcElement;
	}
	else if (e)
	{
		keycode = e.which;
		editingField = e.srcElement;
	}
	else
		return true;

	if (keycode == 13)
	{		
	   	onSearch();
	   	return false;
	}   	
	else
	{			
		return true;
	}
}

function isImageFile(vFileName)
{
	var bRet = false;
	
	if(!isEmpty(vFileName))
	{
		var sExt = vFileName.substring(vFileName.lastIndexOf(".")+1).toUpperCase();
		
		if(sExt == "JPG" || sExt == "GIF" || sExt == "PNG" || sExt == "BMP")
			bRet = true;
	}

	return bRet;	
}

function onLogout(vLoc)
{
	if (confirm('Do you really want to log out?')) 
	{
		closeChildWindows();
		window.location.href=vLoc;	
	}	
}	

// Changes the cursor to an hourglass
function cursor_wait() {
document.body.style.cursor = 'wait';
}

// Returns the cursor to the default pointer
function cursor_clear() {
document.body.style.cursor = 'default';
}

function closeChildWindows()
{		
	if (newWindow != null && !newWindow.closed)
		newWindow.close();

	if (newWindow2 != null && !newWindow2.closed)
		newWindow2.close();
}

function openIPM(vLink)
{
	window.open(vLink, '_blank');
	logActivity(LOG_TYPE_NAVIGATE, LOG_SOURCE_IPATHMAKER_CLICKS);		
}	

function logActivity(vLogTypeId, vLogSourceId)
{		
	var sUrl = "LogActivity.jsp?LogTypeId="+vLogTypeId+"&LogSourceId="+vLogSourceId;			
	var MyIFrame = document.getElementById("hidFrame");
	MyIFrame.src = sUrl;	
}

function removeHTMLTags(vStr){
	var sRet = "";
 	if(!isEmpty(vStr)){
 		
 		/* 
  			This line is optional, it replaces escaped brackets with real ones, 
  			i.e. < is replaced with < and > is replaced with >
 		*/	
 	/* 	vStr = vStr.replace(/&(lt|gt);/g, function (strMatch, p1){
 		 	return (p1 == "lt")? "<" : ">";
 		}); */
 		
 		sRet = vStr.replace(/<\/?[^>]+(>|$)/g, ""); 		
 	}	
 	
 	return sRet;
}

