function Diary(w)
{
	var re = /(([&\?]week=)(-?\d+))/gim;
	var str = location.href;
	var ar = str.match(re);
	if(ar && ar.length > 0)
	{
		str = str.replace(RegExp.$1, RegExp.$2 + (parseInt(RegExp.$3) + parseInt(w)));
	}
	else if(str.indexOf("?") > 0)
	{
		str += "&week=" + w;
	}
	else
	{
		str += "?week=" + w;
	}
	
	location.href = str;
}




function writeDate()
{
	document.write((new Date()).toString().substr(0,20));
}


function showPlayer(url)
{
	var win = window.open(url, "rteplayer", "height=560,width=860,status=yes,toolbar=no,menubar=no,location=no");
	win.focus();
}
function showRadioPlayer(url)
{
	var win = window.open(url, "rteradioplayer", "height=645,width=752,status=yes,toolbar=no,menubar=no,location=no");
	win.focus();
}

function showlisting(a,b)
{
	var el1 = document.getElementById("listing" + a);
	var el2 = document.getElementById("listing" + b);
	
	if(el1 != null && el2 != null)
	{
		el1.style.display = "none";
		el2.style.display = "block";
		el2.style.width = "100%";
	}
}


function changeStoryImage (img)
{
	var el = document.getElementById("storyImage" + img);

	for (i=1; document.getElementById("storyImage" + i) != null; i++)
	{
		document.getElementById("storyImageListItem" + i).className = "unselected";
		document.getElementById("storyImage" + i).style.display = "none";
	}
	if(el != null)
	{
		document.getElementById("storyImageListItem" + img).className = "selected";
		el.style.display = "block";
	}

}

function gotoDate(dt)
{
	var new_date = new Date(dt);
	
	if(new_date > today || new_date.getDay() == 6 || new_date.getDay() == 0)
		return;
	
	var month = new_date.getMonth()+1;
	if(month < 10) month = "0" + month;

	var date = new_date.getDate();
	if(date < 10) date = "0" + date;

	window.location = "/business/" + new_date.getFullYear() + "/" +  month + date + "/" + "index.html";
}

function gotoDateProg(dt)
{
	var new_date = new Date(dt);
	
	if(new_date > today)
		return;
	
	var month = new_date.getMonth()+1;
	if(month < 10) month = "0" + month;
	var date = new_date.getDate();
	if(date < 10) date = "0" + date;

	var new_loc = String(window.location);
	new_loc = "/business/" + new_date.getFullYear() + "/" +  month + date + "/" + PROG_FILENAME + ".html";
	
	window.location = new_loc;
}


var CALENDAR_DATE = new Date();
var PROG_FILENAME="index";
function getCalendarDatesAsync(url, dt)
{
	if(Sarissa)
	{
		CALENDAR_DATE = dt;
		var xmlhttp = new XMLHttpRequest();
		xmlhttp.open("GET", url, true);
		
		xmlhttp.onreadystatechange = function() {
		    if (xmlhttp.readyState == 4) {
		        renderCalendar(CALENDAR_DATE, "gotoDateProg", xmlhttp.responseText)
		    }
		}
		xmlhttp.send(null);
	}
}

function changeMonth(dt)
{
	dt = new Date(dt);
	getCalendarDatesAsync("/business/" + PROG_FILENAME + "/inc/archive.inc", dt.valueOf());
}



function PrintPreview() {
	var pageEl = document.getElementById("primaryContent");
    var Ad = document.getElementById("SpecialAd");
    if (Ad) {
		Ad.innerHTML = "";
    }
    var pageString = "<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"/business/style/print.css\" /></head>" + 
					"<body><img src=\"/business/images/logo_printable_business.gif\">\n<hr>" + pageEl.innerHTML + 
					"<p><strong>Story from RT&Eacute; Business:<br />" + document.location + "</strong></p></body></html>";
	var win = window.open();
    win.document.write(pageString);
    win.document.close();
}


function cConvert(){
	window.open("/business/currencyconvertor.html","frmCurrencyConverter","menubar=no,width=860,height=412")
}


function fadeUpNews(element, red, green, blue) {
    if (element.fade) {
        clearTimeout(element.fade);
    }
    element.style.backgroundColor = "rgb(" + red + "," + green + "," + blue + ")";
    if (red == 255 && green == 255 && blue == 255) {
        return;
    }
    var newred = red + Math.ceil((255 - red) / 20);
    var newgreen = green + Math.ceil((255 - green) / 20);
    var newblue = blue + Math.ceil((255 - blue) / 20);
    var repeat = function () {fadeUpNews(element, newred, newgreen, newblue);};
    element.fade = setTimeout(repeat, 50);
}

function liveModuleFade(oNode, oTargetElement, update) {
    if (update) {
        fadeUpNews(oTargetElement.ownerDocument.getElementById("liveModuleNews_xmlHolder"), 212, 89, 21);
    }
}

