// Author: $Author: Tony Perrie $
// Date: $Date$
// Id: $Id$

function Trim(string) {  
  return string.replace(/[ \t]+/g,'')
}

function removeHtmlTags(string) {
  return string.replace(/<[^>]+>/g, '');
}

function getLongestLine(strInfoBlock) {
  maxlinecount=30;
  linecount=0;
  test="";
  notags = removeHtmlTags(Trim(strInfoBlock));
  for(i=0; i<notags.length; i++) {
    test+=linecount + ":" + notags.charAt(i) + " ";
    if ((notags.charAt(i) == '\n') || (notags.charAt(i) == '\r')) {
	  if (linecount > maxlinecount) {
	    maxlinecount=linecount;	
	  }
	  linecount=0;
    }
    linecount++;
  }
  return maxlinecount;
}

function show_popup(type, day) {
  ptype="popup_"+type+String(day);
  document.getElementById(ptype).style.zIndex="100";
  document.getElementById(ptype).style.position="absolute";
  document.getElementById(ptype).style.background="#fff";
//  document.getElementById(ptype).style.background="#fdfde5";
//  document.getElementById(ptype).style.padding="10px";
//  document.getElementById(ptype).style.opacity="0.93";
//  document.getElementById(ptype).style.border="1px dotted";
  strCalID = String(type)+String("_event_address")+String(day);

  if (navigator.appName == "Microsoft Internet Explorer") { 
    strCalEventInfo = document.getElementById(strCalID).innerText;
    intMaxLineLength = getLongestLine(strCalEventInfo);
    intCalInfoWidth = intMaxLineLength*6.25+50;
    strCalInfoWidthValue = String(intCalInfoWidth) + String("px");
    document.getElementById(ptype).style.width=strCalInfoWidthValue;
    document.getElementById(ptype).style.display="block";
  } else {
    strCalEventInfo = document.getElementById(strCalID).innerHTML;
    intMaxLineLength = getLongestLine(strCalEventInfo);
    intCalInfoWidth = intMaxLineLength*6.25+50;
    strCalInfoWidthValue = String(intCalInfoWidth) + String("px !important");
    document.getElementById(ptype).style.width=strCalInfoWidthValue;
    document.getElementById(ptype).style.margin="0px";
    document.getElementById(ptype).style.float="right";
    document.getElementById(ptype).style.display="block";
  }
}


