var ccCommunity;
//function errorHandle() {return true;} //window.onerror=errorHandle;

var ccCollapsedImg = "/ico/collapsed.gif";
var ccExpandedImg = "/ico/expanded.gif";
function ccAreaExpanded(id) {return ccObjExpanded(document.getElementById(id));}
function ccObjExpanded(o) {var s=o.style;if(s.display){return!(s.display=="none"||s.display=="");}else{return(o.className!="ccHidden");}}

// fooDiv:block Id, fooImg:image Id, 
// arguments[2] : use self-defined expanding icon, arguments[3] : use self-defined collapsing icon
function ccToggleArea(id, imgId) { 
  var o = document.getElementById(id);
  var style = o.style, onIcon, offIcon, s;
  if (arguments[3]) {offIcon = arguments[3];} if (arguments[2]) {onIcon = arguments[2];}
  if (document.all) {s = o.style.display;}
  else { s = window.getComputedStyle(o, null).getPropertyValue("display");}
  if (s=="none"||s ==""){ccExpandObj(o, imgId, onIcon);}else{ ccCollapseObj(o, imgId, offIcon);}
  return false;
}

function ccExpandArea(id, imgId) { ccExpandObj(document.getElementById(id), imgId); }
function ccExpandObj(o) { //obj, image ID
  if (o==null) {return false;}
  var t = o.tagName;
  if (t=="DIV") { o.style.display="block";} 
  else if(t=="SPAN"||t=="INPUT"||t=="A"||t=="BUTTON"||t=="NOBR"||t=="IMG") {o.style.display="inline";} 
  else {
    if (document.all) {o.style.display="block";} 
    else {
      if (t=="TABLE") {o.style.display="table";}
      else if (t=="TR") {o.style.display="table-row";}
      else if (t=="THEAD" || t=="TBODY") {o.style.display="table-row-group";}
      else if (t=="TD" || t=="TH") {o.style.display="table-cell";}
      else if (t=="LI") {o.style.display="list-item";}
      else {o.style.display="block";}
    }
  }
  o.style.visibility="visible";
  if (arguments[2] && arguments[2]!="") {ccSwitchImg( arguments[1], arguments[2]);}
  else if (arguments[1] && arguments[1]!="") {ccSwitchImg( arguments[1], ccExpandedImg);}
  return false;
}

function ccCollapseArea(id,imgId){return ccCollapseObj(document.getElementById(id), imgId);}
function ccCollapseObj(o) { //obj, image name
  if (o==null) {return false;}
  o.style.display="none"; o.style.visibility="hidden";
  if (arguments[2] && arguments[2]!="") {ccSwitchImg(arguments[1],arguments[2]);}
  else if (arguments[1] && arguments[1]!="") {ccSwitchImg(arguments[1],ccCollapsedImg);}
  return false;
}
function ccSwitchImg(imgName, img) {document.images[ imgName ].src = img;} //obj or string
function strtrim() {return this.replace(/^\s+/,'').replace(/\s+$/,'');}
String.prototype.trim=strtrim;

function ccGetCookie(k) {
  if(document.cookie.length > 0) {
    var i=document.cookie.indexOf(k+"=");
    if (
      i!=-1) {i+=k.length+1;var j=document.cookie.indexOf(";", i);if (j == -1){ j = document.cookie.length;}
      return decodeURIComponent(document.cookie.substring(i, j));
    }
  }
  return null;
}

function ccSetCookie( k, v, e, path) { //key, value, expired, path
  var s=k+"="+encodeURIComponent(v);
  if (e){var d = new Date();d.setTime(d.getTime()+(e*24*3600*1000));s=s+"; expires="+d.toGMTString();}
  if(path){s=s+"; path="+path;}
  document.cookie = s;
}
function ccDelCookie(k){if(ccGetCookie(k)){document.cookie=k+"=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";}}

function ccLoadScript(scriptName) {
  var o=document.createElement('script');o.type='text/javascript';o.src = scriptName;
  document.getElementsByTagName('head')[0].appendChild(o);
}

function ccSetHiddenStyle(id){document.writeln("<STYLE type='text/css'>#"+id+" {display:none;visibility:hidden;}</STYLE>");}
function ccUseAccessibleProfile(){var s= ccGetCookie("CC_accessible");return(s!=null&&s=="true");}
function ccDelayLoadScript(){ccLoadScript("/js/ccOpenWin.js");if(ccUseAccessibleProfile()){ccLoadScript("/js/ccTableAsPresentation.js");}}
if (window.attachEvent) {window.attachEvent('onload', ccDelayLoadScript);} 
else if (window.addEventListener) {window.addEventListener("load", ccDelayLoadScript, true);}else{ccDeplayLoadScript();}