function SetCookie(cookieName,cookieValue,nDays) {
  var today = new Date();
  var expire = new Date();

  if (nDays==null || nDays==0) nDays=1;
  expire.setTime(today.getTime() + 3600000*24*nDays);
  document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}

function GPonLoad() {
  var i = document.getElementById('ssiframe');
  if(i!=null) {
    loadss(i);
  }
}

function createSilverlight(source, parent, id) {
  Silverlight.createObjectEx({
    source: source,
    parentElement: 
    document.getElementById(parent),
    id: id,
    properties: {
      width: "100%",
      height: "100%",
      version: "2.0",
      enableHtmlAccess: "true"
    },
    events: {}
  });
}

var suggestactive=false;

function rolo(action, addr, type) {
  var rolo=document.getElementById('rolo');
  var box=document.getElementById('suggestbox');
  var iframe=document.getElementById('suggestiframe');
  var source = (type == 'sms' ? '/smspopup.php' : '/pagesuggest.php?addr=' + addr);

  if(action=='show') {
    rolo.style.top=document.body.scrollTop;
    rolo.style.display='block';
    iframe.src=source;
    box.style.top=document.body.scrollTop;
    box.style.display='block';
    suggestactive=true;
  } else {
    rolo.style.display='none';
    box.style.display='none';
    suggestactive=false;
  }
}

function onScroll() {
  if(!suggestactive) return true;
  document.body.scrollTop=0;
  return false;
 }

function getIFrameDoc(iframe) {
	var doc = null;
	if (iframe.contentDocument) doc = iframe.contentDocument; // Firefox, Opera
	else if (iframe.contentWindow) doc = iframe.contentWindow.document; // Internet Explorer
	else if (iframe.document) doc = iframe.document; // other?
	return doc;
}

function trim(str,chars) {
  return ltrim(rtrim(str,chars),chars);
}
function ltrim(str,chars) {
  chars=chars||"\\s";
  return str.replace(new RegExp("^["+chars+"]+","g"),"");
}
function rtrim(str,chars) {
  chars=chars||"\\s";
  return str.replace(new RegExp("["+chars+"]+$","g"),"");
}

function openclose_module(pmid) {
  var module = document.getElementById('module_body_' + pmid);
  var ocimg = document.getElementById('module_ocimg_' + pmid);
  var tds = module.childNodes;
  var blockstring = (navigator.userAgent.toLowerCase().indexOf('msie') == -1 ? "table-cell" : "block");

  if (module.getAttribute('opened') == "true") {
    for (var i = 0; i < tds.length; i++) {
      tds[i].style.display = "none";
    }
    module.setAttribute('opened', 'false');
    ocimg.setAttribute('src', '/image/plus.gif');
  } else {
    for (var i = 0; i < tds.length; i++) {
      tds[i].style.display = blockstring;
    }
    module.setAttribute('opened', 'true');
    ocimg.setAttribute('src', '/image/minus.gif');
  }
}

function showhideocimg(pmid, action) {
  var ocimg = document.getElementById('module_ocimg_' + pmid);
  if (ocimg) ocimg.style.display = (action=="show"?"block":"none");
}

function save_openclosestate() {
}

function get_openclosestate() {
  
}
