function toggleNav(which,what)
{
	if(what=='show')
	{
		document.getElementById(which).style.display = 'block';
	}
	else
	{
		document.getElementById(which).style.display = 'none';
	}
}

function toggleCalendar(which)
{

	if(document.getElementById(which).style.display == 'block')
	{
		document.getElementById(which).style.display = 'none';
	}
	else
	{
		document.getElementById(which).style.display = 'block';
	}

}

function launchPrintEdition(url)
{
	window.open(url, 'printedition', 'resizable=no,toolbar=no,resizable=yes,scrollbars=auto,menubar=no,status=no,directories=no');
}

function changeMonth(whichMonth, changeMonth)
{

	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			// Get the data from the server's response
			// State	Description
			// 0	The request is not initialized
			// 1	The request has been set up
			// 2	The request has been sent
			// 3	The request is in process
			// 4	The request is complete
			document.getElementById("printedition_calendar").innerHTML = xmlHttp.responseText;
		//	document.myForm.time.value = xmlHttp.responseText;
		}
	}

	var runCommand = templateURL + "/v04_includes/calendar.php?date=" + whichMonth + "&change=" + changeMonth;

	xmlHttp.open("GET",runCommand,true);
	xmlHttp.send(null);

} // end function changeMonth


function changeMonth2(whichMonth, changeTo)
{

	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			// Get the data from the server's response
			// State	Description
			// 0	The request is not initialized
			// 1	The request has been set up
			// 2	The request has been sent
			// 3	The request is in process
			// 4	The request is complete
			document.getElementById("printedition_calendar").innerHTML = xmlHttp.responseText;
		//	document.myForm.time.value = xmlHttp.responseText;
		//	ISSUU.smartlook.clickCapture.hijackLinks();
		}
	}

	var runCommand = templateURL + "/v04_includes/calendarNew.php?date=" + whichMonth + "&change=" + changeTo;

	xmlHttp.open("GET",runCommand,true);
	xmlHttp.send(null);


} // end function changeMonth2

function swapBestOf(what) {
	document.getElementById('bestof_editorspicks').style.display = 'none';
	document.getElementById('bestof_foodanddrink').style.display = 'none';
	document.getElementById('bestof_nightlife').style.display = 'none';
	document.getElementById('bestof_sportsandfitness').style.display = 'none';
	document.getElementById('bestof_shopsandstyle').style.display = 'none';
	document.getElementById('bestof_dclife').style.display = 'none';	
	if(what=='bestof_showall'){
		document.getElementById('bestof_editorspicks').style.display = 'block';
		document.getElementById('bestof_foodanddrink').style.display = 'block';
		document.getElementById('bestof_nightlife').style.display = 'block';
		document.getElementById('bestof_sportsandfitness').style.display = 'block';
		document.getElementById('bestof_shopsandstyle').style.display = 'block';
		document.getElementById('bestof_dclife').style.display = 'block';
	}
	else {
		document.getElementById(what).style.display = 'block';
	}

	document.getElementById('bestof_editorspicks_nav').className = 'unselected';
	document.getElementById('bestof_showall_nav').className = 'unselected';
	document.getElementById('bestof_foodanddrink_nav').className = 'unselected';
	document.getElementById('bestof_nightlife_nav').className = 'unselected';
	document.getElementById('bestof_sportsandfitness_nav').className = 'unselected';
	document.getElementById('bestof_shopsandstyle_nav').className = 'unselected';
	document.getElementById('bestof_dclife_nav').className = 'unselected';

	document.getElementById(what + '_nav').className = 'selected';	
//	document.getElementById('txtSelectedSection').value = which;


}

function clearWriteIn(what)
{

	if (document.getElementById(what).value == 'write-in')
	{
		document.getElementById(what).value = '';
	}
	//setCheckedValue(radioObj, newValue);	// need to give radio buttons values in order to auto-set the OTHER radio button on voting
}

function setRadioValue(hdnTextBox, val)
{
	var txtbox = document.getElementById(hdnTextBox);
	txtbox.value = val;
}

function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}


function anchorSlideDown()
{

	var query = location.href.split('#');
	if (query != "")
	{
		currentScrollPosition = document.documentElement.scrollTop;
	   	window.scroll(0,currentScrollPosition-50); // horizontal and vertical scroll targets
	}

}



function toggleReader(whichReader)
{
	switch (whichReader)
	{
		case "ISSUU":
			$("a#pdflink").css('display','none');
			$("a#issuulink").css('display','block');
			break;
		case "PDF":
			$("a#issuulink").css('display','none');
			$("a#pdflink").css('display','block');
			break;
	}
}
