function trimAll(sString) //function to trim the left spaces and the right spaces of a string.
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
function BtnClick(txtBox,strBtn)
{
				
	var sString=trimAll(txtBox.value);
	if(sString!="")
	{
		if(self.opener.IsFolderExists(sString,strBtn))
		{
			alert("Folder name already exists");
			txtBox.focus();
			txtBox.select();
			return false;
		}
	}
	else
	{
		alert("Please enter the folder name");
		txtBox.focus();
		return false;
	}
}



 function CloseFrame()
 {
			
	if(document.all)
		{
			parent.document.body.cols= "0,*";
		}
	else
		{
			this.parent.setAttribute('rows','0,*')
		}
		
	
 }
 
 
 /* To Correctly handle PNG transparency in Win IE 5.5 and 6.  */
function correctPNG() 
{
    //IE versions less than ie 7 do not properly resolve png transparency values
    //This is an IE specific hack to make png transparency work in ie 5.5 through ie 6.x
    var versionIndex = Number(navigator.appVersion.toLowerCase().indexOf("msie ")) + 5;
    var majorVersion = Number(navigator.appVersion.charAt(versionIndex));
    var minorVersion = Number(navigator.appVersion.charAt(versionIndex + 2));

    if(navigator.appName == "Microsoft Internet Explorer"
        && (majorVersion == 6 || (majorVersion == 5 && minorVersion >= 5)))
    { 
        for(var i=0; i<document.images.length; i++)
        {
            var img = document.images[i];
            var imgName = img.src.toUpperCase();
            if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
            {
                var oldImageCount = document.images.length;

                var imgID = (img.id) ? "id='" + img.id + "' " : ""
                var imgClass = (img.className) ? "class='" + img.className + "' " : ""
                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
                var imgStyle = "display:inline-block;" + img.style.cssText 
                if (img.align == "left") imgStyle = "float:left;" + imgStyle
                if (img.align == "right") imgStyle = "float:right;" + imgStyle
                if ((img.parentElement && img.parentElement.href) || (img.parentNode && img.parentNode.getAttribute("href"))) imgStyle = "cursor:hand;" + imgStyle;

                var strNewHTML = "<span " + imgID + imgClass + imgTitle
                + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
                + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
                img.outerHTML = strNewHTML;

                i = i - 1;
            }
        }
    }
}
   
   //To get the control's client id during runtime.
 function GetClientId(controlid)
  {  
      for (var i=0;i < document.form1.elements.length;i++)
      {
          if(document.form1.elements[i].id != null)
          {         
                var index = document.form1.elements[i].id.indexOf(controlid);                
                if(document.form1.elements[i].id.substring(index) == controlid)
                {                
                   return document.form1.elements[i].id;                   
                }
          }
      }
      return controlid;
  } 
//To open the CustomError Popup Window  
function DisplayError()
{
    window.open('../Aspx/CustomError.aspx','','scrollbars=yes,status=no,width=500,height=450,left=250,top=250,resizable=yes');
}