function publishArticle(args,action)
{
	var pub;
	var ok;
if (action=='P')
	 ok=confirm('You are about to publish this article.\nThis will make it available to related viewers.\nDo you wish to continue?');
else
	 ok=confirm('You are about to unpublish this article.\nThis will make it unavailable to related viewers.\nDo you wish to continue?');

	if (ok==true)
	{
		document.location.href=args;
		return;
	} else {
		//alert('Canceled');
		return;
	}
	

}

function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}


function toggleDiv(div)
{

if (document.getElementById(div).style.display=='block')
	document.getElementById(div).style.display ='none';
else
	document.getElementById(div).style.display = 'block';

}



function toggleNode(div,image,idx,key)
{
var style;
var head='headdiv'+idx;


if (document.getElementById(div,image))
	style=document.getElementById(div).style.display;
else
	return;


var path=document.getElementById('vpath').value;
if (document.getElementById(div).style.display == 'none')
	{
		document[image].src=path+'box_collapse.png';
		document.getElementById(div).style.display = 'block';
		removeFromCookie('UCDExpCollapse',key+'.C:',1)
		//document.getElementById(head).className = 'article_header';
		return;
	} 
	document[image].src=path+'box_expand.png';
	document.getElementById(div).style.display = 'none';
	createCookie('UCDExpCollapse',key+'.C:',1);
	///////document.getElementById(head).className = 'article_header_collapse';
}


function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    //var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
	var strQueryString = strHref.substr(strHref.indexOf("?"));
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (
		aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
}

/*
function getPage(value)
{
var args='?m=' + getURLParam('m') + '&topicid=' + getURLParam('topicid') + '&cid=' + getURLParam('cid') + '&action='+ getURLParam('action');
var aid = document.getElementById('aid').value;

	document.location.href='index.php'+args+'&page='+value+'&aid='+aid;

}
*/

function goIndexPage(){

var m         = document.artlist.marg.value;
var topic     = document.artlist.artselect.options[document.artlist.artselect.selectedIndex].value;

var tvalue = new Array();       // topic string
tvalue = topic.split(',');				
var topicid=tvalue[0];
var cid=tvalue[1];
var uaid=tvalue[2];
var aid=tvalue[3];  // Topic

	//document.location.href='index.php?action=viewarticle&m='+m+'&topicid='+topicid+'&cid='+cid+'&uaid='+uaid+'&aid='+aid+'#article_'+aid;
	document.location.href=parent.window.location.pathname+'?action=viewarticle&m='+m+'&topicid='+topicid+'&cid='+cid+'&uaid='+uaid+'&aid='+aid+'#article_'+aid;

	
}

