	function move_res(fbox, tbox, dis_fsort, dis_tsort) 
	{
		var arrFbox = new Array();
		var arrTbox = new Array();
		var arrLookup = new Array();
		var i;
		for (i = 0; i < tbox.options.length; i++) {
			arrLookup[tbox.options[i].text] = tbox.options[i].value;
			arrTbox[i] = tbox.options[i].text;
		}
		var fLength = 0;
		var tLength = arrTbox.length;
		for(i = 0; i < fbox.options.length; i++) {
			arrLookup[fbox.options[i].text] = fbox.options[i].value;
			if (fbox.options[i].selected && fbox.options[i].value != "") {
				arrTbox[tLength] = fbox.options[i].text;
				tLength++;
			}else {
				arrFbox[fLength] = fbox.options[i].text;
				fLength++;
			}
		}
		if (!dis_fsort){
			arrFbox.sort();
		}
		if (!dis_tsort){
			arrTbox.sort();
		}
		fbox.length = 0;
		tbox.length = 0;
		var c;
		for(c = 0; c < arrFbox.length; c++) {
			var no = new Option();
			no.value = arrLookup[arrFbox[c]];
			no.text = arrFbox[c];
			fbox[c] = no;
		}

		if ( typeof( window[ 'countrycode' ] ) != "undefined" ) {
		if (articleform.countrycode.length > 10 || articleform.countrycode.length + arrTbox.length > 100){
			alert('You can only select up to ten countries');
			// put the first ten values on the "t box"
			for (c = 0; c < 10; c++){
				var no = new Option();
				no.value = arrLookup[arrTbox[c]];
				no.text = arrTbox[c];
				tbox[c] = no;
			}
			// keep the rest on the "from box"
			//alert (arrTbox.length);
			var a =0;
			for (c = 10; c < arrTbox.length; c++){
				var no = new Option();
				no.value = arrLookup[arrTbox[c]];
				no.text = arrTbox[c];
				//alert(no.text + no.value);
				fbox[a] = no;
				a++;

			}}
		}else{
			for(c = 0; c < arrTbox.length; c++) {
				var no = new Option();
				no.value = arrLookup[arrTbox[c]];
				no.text = arrTbox[c];
				tbox[c] = no;
			}
		}
	}

	function get_radio_value()
	{
	for (var i=0; i < document.articleform.rt.length; i++)
	   {
	   if (document.articleform.rt[i].checked)
		  {
		  var rad_val = document.articleform.rt[i].value;
		  alert("rt3 " + rad_val);
		  }
	   }
	}

	function build_xml_request(form){

		var i;
		var arrTbox = new Array();
		var arrLookup = new Array();
		// get the radio button
		for (var i=0; i < form.rt.length; i++)
		{
		   if (form.rt[i].checked)
			  {
				  var rad_val = form.rt[i].value;
			  }
		}

		var xml_request = "format=/thefacts/chart/format.xml?" + "rt_" + rad_val + ",period_" +
		/*var xml_request = "/format.htm?" + "rt_" + rad_val + ",period_" + */form.elements['period'].value + ",startdate_" + form.elements['startdate'].value + ",enddate_" + form.elements['enddate'].value + ",category_" + form.elements['category'].value;
		// get the  countries
		for (i = 0; i < form.elements.countrycode.options.length; i++) {
			arrLookup[form.elements.countrycode.options[i].text] = form.elements.countrycode.options[i].value;
			arrTbox[i] = form.elements.countrycode.options[i].text;
		}
		for(c = 0; c < arrTbox.length; c++) {
				var no = new Option();
				no.value = arrLookup[arrTbox[c]];
				no.text = arrTbox[c];
				xml_request = xml_request + ",countrycode_" + no.value ; 

		}
		//alert(xml_request);
		//var fo = new FlashObject("/bin/flash/graph/chart4.swf", "chart", "100%", "280px", 7, "#FFFFFF");
		//fo.addParam("menu", "false");
		//fo.addParam("allowScriptAccess", "sameDomain");
		//fo.addVariable("loadedVars", "format="+encode(xml_request) );
		//fo.addVariable("loadedVars", xml_request );
		//alert(encode(location.search.substring(1)));
		//fo.write("flashcontent");
	}

	var FLAG = 0;
	function process_get_params (FLAG){

		 if (FLAG == 0){
			var R_URL = document.URL;
			if (document.URL.indexOf('?') == -1 ){
				FLAG ++;
				return FLAG;
			}else{
				// parse the findings onto a string we can pass to the flash object
				var URLindex = document.URL.indexOf('?');
				var GET_p = R_URL.slice( URLindex+1 , R_URL.length);
				GET_p = GET_p.replace(/\=/g, "_");
				GET_p = GET_p.replace(/\&/g, ",");
				var xml_request = "format=/thefacts/chart/format.xml?";
				xml_request =  xml_request + GET_p; 
				var fo = new FlashObject("/bin/flash/graph/chart4.swf", "chart", "100%", "280px", 7, "#FFFFFF");
				fo.addParam("menu", "false");
				fo.addParam("allowScriptAccess", "sameDomain");
				fo.addVariable("loadedVars", xml_request );
				fo.write("flashcontent");

				FLAG ++;
				return FLAG;
			}	

			}else{
				FLAG ++;
				return FLAG;
		 }
	}
	function load(url){
		var load;
		window.open(url,'','scrollbars=yes,menubar=yes,height=300,width=700,resizable=yes,toolbar=yes,location=no,status=no');
	}

	// hides or shows a div
	// use the flag yes to show else dont show
	// pass the div_id of the div 
	function show_div(show, div_id) {
	  if (show =='yes') {
		document.getElementById(div_id).style.display = "";
	  } else {
		document.getElementById(div_id).style.display = "none";
	  }
	  return false;
	}

	function build_url(type,form,fields){
		//alert("BLOGS"+document.articleform.elements.uid.value +"TYPE" + type);
		var arrTbox = new Array();
		var arrLookup = new Array();
		var url;
		if (type =="blogs"){
			url = "/thenews/rss/bloggers.xml?nv=0";
		}else{
			url = "/thenews/rss/index.xml?nv=0";
		}
		if (document.articleform.elements.uid.value== "all" && type =="blogs" ){
			//alert(document.articleform.elements.uid.value);
			url = "/thenews/rss/blogs.xml?nv=0";
		}
		var arrTbox = new Array();
		var arrLookup = new Array();
		var current_field = fields[0]; 
		for (var b = 0; b < articleform.elements.fb_countrycodes.options.length; b++) {				arrLookup[document.articleform.elements.fb_countrycodes.options[b].text] = articleform.elements.fb_countrycodes.options[b].value;
			arrTbox[b] = articleform.elements.fb_countrycodes.options[b].text;
		}
		for(c = 0; c < arrTbox.length; c++) {
				var no = new Option();
				no.value = arrLookup[arrTbox[c]];
				no.text = arrTbox[c];
				url = url + "&amp;fb_countrycodes=" + no.value ; 
		}
		var arrTbox = new Array();
		var arrLookup = new Array();

		for (var b = 0; b < articleform.elements.fb_topiccodes.options.length; b++) {				arrLookup[document.articleform.elements.fb_topiccodes.options[b].text] = articleform.elements.fb_topiccodes.options[b].value;
			arrTbox[b] = articleform.elements.fb_topiccodes.options[b].text;
		}
		for(c = 0; c < arrTbox.length; c++) {
				var no = new Option();
				no.value = arrLookup[arrTbox[c]];
				no.text = arrTbox[c];
				url = url + "&amp;fb_topiccodes=" + no.value ; 
		}
		arrTbox = new Array();
		arrLookup = new Array();
		if (document.articleform.elements.uid != "undefined"){
			if (document.articleform.elements.uid.value !="all"){
				url = url + "&amp;uid=" + document.articleform.uid.value;
			}
		}
		arrTbox = new Array();
		arrLookup = new Array();
		for (var b = 0; b < articleform.elements.fb_emergencycodes.options.length; b++) {				arrLookup[document.articleform.elements.fb_emergencycodes.options[b].text] = articleform.elements.fb_emergencycodes.options[b].value;
			arrTbox[b] = articleform.elements.fb_emergencycodes.options[b].text;
		}
		for(c = 0; c < arrTbox.length; c++) {
				var no = new Option();
				no.value = arrLookup[arrTbox[c]];
				no.text = arrTbox[c];
				url = url + "&amp;fb_emergencycodes=" + no.value ; 
		}
		// add the low graphics
		if ( document.getElementById("low_band").checked){
				url = url + "&amp;lite=1";
		}
		return url;
	}

	function setStyle(objId, style, value){
	   document.getElementById(objId).style[style]= value;
	}
	/* USAGE:
	 * objId    = element id.
	 * style    = the style to be changed.
	 * value    = the value assigned to the style.
	*/ 

	function showTab (tabId, pre, pagination, pagDiv, botpagDiv){
		//document.write("<pre>DEBUG</pre>");
		// hide all content and tab highlights
		var item;
		var item_id = ""+ pre + "" + tabId;
		for (var i = 0 ; i <  TABS.length; i++ ){
			item = i;
			show_div('no',TABS[item]);
			document.getElementById(""+ pre + "" + TABS[item]).className='';
		}
		
		// show tab contents and highlight tab
		show_div('yes',tabId); // DD 18/03/2008 tabId 
		document.getElementById(""+ pre + "" + tabId).className='current';

		// decode pagination so HTML renders
		pagination  = pagination .replace(/~/g, '"');
   
		// do pagination innerHTML
		document.getElementById(pagDiv).innerHTML = pagination;

		// do bottom pagination	innerHTML
		document.getElementById(botpagDiv).innerHTML = pagination;

		// update currentTab hidden element
		document.getElementById('currentTab').value = tabId;
		
		// using cookies due to issue with pagination a href; the later uses the pages user to create its links the currentTab value is static and cannot be changes by js.
		SetCookie('currentTab', tabId);
		//
	}
/* 
	you are given the value of a select option and you want to automatically
	highlight the dropdown option.
*/
function selectDropdownOptionByValue(id,_value){
	for (i = 0; i < id.options.length; i++) {
		if (id.options[i].value == _value ){
			id.selectedIndex = i;
		}
	}
}

/*
	trims any leading zeros of a given number
*/
function trimNumber(s) {
  while (s.substr(0,1) == '0' && s.length>1) { s = s.substr(1,9999); }
  return s;
}