
function makeWindow(url, h, w) {
    //open Generic Window
    var dims = "height=" + h + ",width=" + w;
    var options = dims + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=100,top=5";
    HaveWin = window.open(url, "win", options);
    //Win.moveTo(100,5);
    HaveWin.focus();
}

function makeNewWindow(url, h, w) {
    //open Generic Window
    var dims = "height=" + h + ",width=" + w;
    var options = dims + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=100,top=5";
    HaveWin = window.open(url, "name", options);
    HaveWin.focus();
}

function browserName() {
        if (navigator.appName == "Microsoft Internet Explorer")
            return 1;
        if (navigator.appName == "Netscape"){
            if (document.getElementById){
                return 3;
            }else{
                return 2;
            }       
       }
   }





function makeTextindow(title,urlText,headline) {
var nameCode=browserName();

msg=window.open("","msg","height=240,width=480,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,left=100,top=5");

msg.document.write("<html><title>"+title+"</title>");
msg.document.write("<link rel=\"stylesheet\" href=\"/includes/common2.css\" type=\"text/css\">");
msg.document.write("<body bgcolor='white' onblur=window.close()>");
msg.document.write("<table width=\"100%\" border=\"0\" cellspacing=\"5\" cellpadding=\"5\">")
msg.document.write("<tr><td colspan=\"2\"><img src=\"http://cdc-img.ibsrv.net/common/navigation/images/cdc_logo.gif\" width=\"144\" height=\"29\" vspace=\"0\" hspace=\"0\" border=\"0\"></td>");
msg.document.write("<td>");
       if(nameCode == 2){
            msg.document.write("<a href='javascript:window.close();'>close window</a>");
       }else if(nameCode == 3){
            msg.document.write("<input type='button' onClick='javascript:window.close();' name='closewindow' value='close window' class='sbttn' title='Close Window'></a>"); 
       }else{
            msg.document.write("<input type='button' onClick='javascript:window.close();' name='closewindow' value='close window' class='sbttn' title='Close Window'></a>");    
       }
msg.document.write("</td>");
msg.document.write("<tr><td><span class=\"textpx11\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">");
msg.document.write("<B>"+headline+"</B>"); 
msg.document.write(urlText); 
msg.document.write("</font></td><TR></table>");
msg.document.write("</body></html>");
msg.document.close();
}


function makeNamedWindow(url, name, h, w) {
    var dims = "height=" + h + ",width=" + w;
    var options = dims + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=100,top=5";
    childWin = window.open(url, name, options);
    childWin.focus();
}

function makeNoResizeWindow(url, name, h, w) {
    var dims = "height=" + h + ",width=" + w;
    var options = dims + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,left=100,top=5";
    childWin = window.open(url, name, options);
    childWin.focus();
}

function openLLC(url, h, w) {
    var dims = "height=" + h + ",width=" + w;
    var options = dims + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=100,top=5";
    closeLLC();
    llcWin = window.open(url, "llc", options);
    if (llcWin != 'undefined' && llcWin != 'null' && !llcWin.closed) llcWin.focus();
}

function closeLLC() {
  var options = "height=10,width=10,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,left=10000,top=0";
  var isForm = 1, winObj = null, winObj1 = null;
  
  for (var i = 0; i < document.cookie.split(';').length; i++) {
    if (trim(document.cookie.split(';')[i].split('=')[0].toLowerCase()) == "isform") {
      isForm = document.cookie.split(';')[i].split('=')[1];
      break;
    }
  }
  if (isForm == 0) {
    if (parent.frames['view'] != null) {
      winObj = parent.frames['view'].llcWin;
      winObj1 = parent.frames['view'].childWin;
    }
    else {
      var llcWin = window.open("", "llc", options);
      var childWin = window.open("", "img", options);      
      llcWin.close();
      childWin.close();
    }
  }
  else {
    winObj = parent.llcWin;
    winObj1 = parent.childWin;
  }
  if ((winObj+'') != 'undefined' && (winObj+'') != 'null' && (!winObj.closed)) winObj.close();
  if ((winObj1+'') != 'undefined' && (winObj1+'') != 'null' && (!winObj1.closed)) winObj1.close();
}

function formatCurrency (number) {	
	var num = new String (number);
	if (num.indexOf (".") == -1) {
		intLen = num.length;
		toEnd = intLen;
		var strLeft = new String (num.substring (0, toEnd));
		var strRight = new String ("00");
	} else {
		pos = eval (num.indexOf ("."));
		var strLeft = new String (num.substring (0, pos));
		intToEnd = num.length;
		intThing = pos + 1;
		var strRight = new String (num.substring (intThing, intToEnd));

		if (strRight.length > 2) {
			nextInt = strRight.charAt(2);
			if (nextInt >= 5) {
				strRight = new String (strRight.substring (0, 2));
				strRight = new String (eval ((strRight * 1) + 1));
				if((strRight * 1) >= 100) {
					strRight = "00";
					strLeft = new String (eval ((strLeft * 1) + 1));
				}
				if (strRight.length <= 1) {
					strRight = new String ("0" + strRight);
				}
			} else {
				strRight = new String (strRight.substring (0, 2));
			}
		} else {
			if (strRight.length != 2)
				strRight = strRight + "0";
		}
	}
	
	var strLeftNum = parseInt(num);
	
	//Handle negative currency
	if(strLeftNum <  0)   strLeft = strLeft.substring(1,strLeft.length);


	if (strLeft.length > 3) {
		var curPos = (strLeft.length - 3);
		while (curPos > 0) {
			var remainingLeft = new String (strLeft.substring (0, curPos));
			var strLeftLeft = new String (strLeft.substring (0, curPos));
			var strLeftRight = new String (strLeft.substring (curPos, strLeft.length));
			strLeft = new String (strLeftLeft + "," + strLeftRight);
			curPos = (remainingLeft.length - 3);
		}
	}
	
	//Handle negative currency
	if(strLeftNum < 0)  strLeft = "-" + strLeft;
	
	strWhole = strLeft + "." + strRight;
	finalValue = "$" + strWhole;
	return (finalValue);
}

function stripPennies(sMoneyStr) {		
  var showPennies = false;
  var isNegative = false;
  var sTmpStr = (sMoneyStr + '');
  var i = 0;
  var sTmpStr2 = ''
  var sGoodStr = '-()$0123456789,.';
  if (!showPennies) {
    if (sTmpStr == '' || sTmpStr == 'null' || sGoodStr.indexOf(sMoneyStr.charAt(1)) == -1 || sGoodStr.indexOf(sMoneyStr.charAt(2)) == -1)
	  return sMoneyStr;
	if (sTmpStr.charAt(0) == '-')
	  sTmpStr = '(' + sTmpStr.slice(1,sTmpStr.length);
	 else   if((sTmpStr.charAt(0) == '$') && (sTmpStr.charAt(1) == '-'))
       {   //Handle negative currency 	
	   	    sTmpStr = '(' + sTmpStr.charAt(0) + sTmpStr.substring(2,sTmpStr.length);	
	  	    isNegative = true;
	   }
	for (i=0;i<sTmpStr.length;i++) {
	  if (sTmpStr.charAt(i) != ' ' && sGoodStr.indexOf(sTmpStr.charAt(i)) != -1) 
	  sTmpStr2 += sTmpStr.charAt(i);
	}
	sTmpStr = sTmpStr2;
	if (sTmpStr.indexOf('.') != -1)
	  sTmpStr = sTmpStr.substring(0,sTmpStr.indexOf('.'));
  }
   if(isNegative) sTmpStr = sTmpStr + ")";
  return (sTmpStr);
}

function ltrim(stringValue) {
  stringValue = (stringValue + '');
  var i=0;
  for (i=0; i<stringValue.length; i++) {
    if (stringValue.charAt(i) != ' ') {
      return (stringValue+'').substring(i,(stringValue.length));
    }
  }
  stringValue = '';
  return stringValue;
}
  
function rtrim(stringValue) {
  stringValue = (stringValue + '');
  var i=0;
  for (i=(stringValue.length-1); i>=0; i--) {
    if (stringValue.charAt(i) != ' ') {
      return (stringValue+'').substring(0,(i+1));
    }
  }
  stringValue = '';
  return stringValue;
}
  
function trim(stringValue) {
  var retStr = (stringValue+'');
  retStr = ltrim(retStr);
  retStr = rtrim(retStr);
  return retStr;
} 
