/***********************************************
* Drop Down/ Overlapping Content- ?Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function getposOffset(overlay, offsettype){
  var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
  var parentEl=overlay.offsetParent;
  while (parentEl!=null){
    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
    parentEl=parentEl.offsetParent;
  }
  return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
  if (document.getElementById){
    var subobj=document.getElementById(subobjstr)
    subobj.style.display=(subobj.style.display!="block")? "block" : "none"
    var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
    var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
    
    // hack by JJC
    ypos = ypos - 200
    
    subobj.style.left=xpos+"px"
    subobj.style.top=ypos+"px"
    
    showContents();
    
    return false
  }
  else
    return true
}

function overlayclose(subobj){
  document.getElementById(subobj).style.display="none"
}

function showContents()
{
  var txtObj = document.getElementById("blogbox");
  var pageBody = document.getElementById("PageBody").innerHTML;  
  var pageTxt = document.getElementById("PageTitle").innerHTML;
  pageBody  = filterHTMLComment(pageBody);
  txtObj.setAttribute("readOnly", "true")
  
  if (pageTxt=="") pageTxt = "View This Article!"  
  
  txtObj.value = '<center>\n\
  <A href="' + document.location.href + '" target="_blank">\n\
    <img src="http://' + window.location.host +'/images/cep_banner.gif" BORDER="0" alt="Singapore United Article"/>\n\
  </A><br/>\n\
  <a href="' + document.location.href + '" target="_blank">' + pageTxt + '</a>\n\
</center><br/>\n\
'+pageBody;
  txtObj.select();

}

function filterHTMLComment(inputString){
var rebuildString = "";
if (inputString)
{
	var pos = 0;
	var wordLength = inputString.length;
	while (true) {
			var x = inputString.indexOf("<!--", pos);
			var y = inputString.indexOf("-->", x + 3);
			var strB4Process = "";
			var tempString = "";
			if ((x == -1) || (y == -1)) {
				tempString = inputString.substring(pos, inputString.length);												
				rebuildString = rebuildString + tempString;
				break;
			}
			else {
				tempString = inputString.substring(pos,x);				
				
				rebuildString = rebuildString + tempString;				
				pos = y + 3;
				
			}
		}
}

return rebuildString;
}