function areaByCode_page(areaCode)
{
	if(!WSD_AJAX)
	{
		return true;
	}

	var xmlHttp = createXMLHttpRequest();

	xmlHttp.onreadystatechange = function(){updateMenuRequest(xmlHttp);};

	xmlHttp.open("GET", WSD_WEBROOT+"dn-area_page.php?area="+areaCode, true);

	xmlHttp.send(null);

	return false;
}

function imageByLink(imageLink)
{
	if(!WSD_AJAX)
	{
		return true;
	}

	var xmlHttp = createXMLHttpRequest();

	xmlHttp.onreadystatechange = function(){updateMenuRequest(xmlHttp);};

	xmlHttp.open("GET", WSD_WEBROOT+"dn-image.php?image="+imageLink, true);

	xmlHttp.send(null);

	return false;
}

function imgCatByCode(imgCatCode)
{
	if(!WSD_AJAX)
	{
		return true;
	}

	var xmlHttp = createXMLHttpRequest();

	xmlHttp.onreadystatechange = function(){updateMenuRequest(xmlHttp);};

	xmlHttp.open("GET", WSD_WEBROOT+"dn-imgcat.php?imgCat="+imgCatCode, true);

	xmlHttp.send(null);

	return false;
}

function areaByCode(newsCode)
{
	if(!WSD_AJAX)
	{
		return true;
	}

	var xmlHttp = createXMLHttpRequest();

	xmlHttp.onreadystatechange = function(){updateAreaRequest(xmlHttp);};

	xmlHttp.open("GET", WSD_WEBROOT+"dn-lineup.php?area="+newsCode, true);

	xmlHttp.send(null);

	return false;
}

function newsByCode(newsCode)
{
	if(!WSD_AJAX)
	{
		return true;
	}

	var xmlHttp = createXMLHttpRequest();

	xmlHttp.onreadystatechange = function(){updateNewsRequest(xmlHttp);};

	xmlHttp.open("GET", WSD_WEBROOT+"dn-news.php?news="+newsCode, true);

	xmlHttp.send(null);

	return false;
}

function getDJByCode(itemCode)
{
	if(!WSD_AJAX)
	{
		return true;
	}

	var nCode = itemCode;

	var xmlHttp = createXMLHttpRequest();

	xmlHttp.onreadystatechange = function(){updateMenuRequest(xmlHttp, nCode);};

	xmlHttp.open("GET", WSD_WEBROOT+"dn-dj.php?dj="+itemCode, true);

	xmlHttp.send(null);

	return false;
}

function getMenuItemByType(itemCode)
{
	if(!WSD_AJAX)
	{
		return true;
	}

	var nCode = itemCode;

	var xmlHttp = createXMLHttpRequest();

	xmlHttp.onreadystatechange = function(){updateMenuRequest(xmlHttp, nCode);};

	xmlHttp.open("GET", WSD_WEBROOT+"dn-menu.php?type="+itemCode, true);

	xmlHttp.send(null);

	return false;
}

function getMenuItemByCode(menuItemMain, itemCode)
{
	if(!WSD_AJAX)
	{
		return true;
	}

	var nCode = itemCode;

	var xmlHttp = createXMLHttpRequest();

	xmlHttp.onreadystatechange = function(){updateMenuRequest(xmlHttp, nCode);};

	var urlRequest = "page="+menuItemMain;

	if(itemCode){urlRequest += "&pageSub="+itemCode;}

	xmlHttp.open("GET", WSD_WEBROOT+"dn-menu.php?"+urlRequest, true);

	xmlHttp.send(null);

	return false;
}

function updateAreaRequest(xmlHttp)
{
    if(xmlHttp.readyState == 4)
	{
        if(xmlHttp.status == 200)
		{
			var responseStatus = xmlHttp.responseText;

			//var menuData = responseStatus.split('|');

			var menuContent = responseStatus;

			var dnMain = E('lineupContent');

			dnMain.innerHTML = menuContent;
		}
	}
}

function updateNewsRequest(xmlHttp)
{
    if(xmlHttp.readyState == 4)
	{
        if(xmlHttp.status == 200)
		{
			var responseStatus = xmlHttp.responseText;

			//var menuData = responseStatus.split('|');

			var menuContent = responseStatus;

			var dnMain = E('newsContent');

			dnMain.innerHTML = menuContent;

			fleXenv.fleXcrollInit();
		}
	}
}

function updateMenuRequest(xmlHttp, itemCode)
{
    if(xmlHttp.readyState == 4)
	{
        if(xmlHttp.status == 200)
		{
			//set_page();

			var responseStatus = xmlHttp.responseText;

			var menuData = responseStatus.split('|');

			var menuType = menuData[0];	// Template
			var tplType = menuData[1];	// Template
			var tplBackground = menuData[2];	// Template
			var tplPaddingLeft = menuData[3];	// Template
			var tplPaddingTop = menuData[4];	// Template
			var tplPageWidth = menuData[5];	// Template
			var tplPageHeight = menuData[6];	// Template
			var menuContent = menuData[7];	// Content

			var dnMain = E('dnMain');
			var dnContent = E('dnContent');

			// support for scalable templates:
			if(tplType == "multiple")
			{
				dnMain.style.backgroundImage = "";

				dnMain.style.backgroundImage = "";
				dnMain.style.backgroundPosition = "";
				dnMain.style.backgroundRepeat = "";
				dnMain.height = "";
			}

			// default non-scalable template:
			else
			{
				var neutralBackground = (imageBuffer[tplBackground]) ? imageBuffer[tplBackground].src : WSD_WEBROOT+"images/"+tplBackground;

				dnMain.style.backgroundImage = "url('"+neutralBackground+"')";
				dnMain.style.backgroundPosition = "top center";
				dnMain.style.backgroundRepeat = "no-repeat";
				dnMain.height =  619;

				dnContent.style.marginLeft = tplPaddingLeft+"px";
				dnContent.style.marginTop = tplPaddingTop+"px";
				dnContent.style.width = tplPageWidth+'px';
				
				if(tplPageHeight > 0)
				{
					dnContent.style.height = tplPageHeight+'px';
					dnContent.style.overflowX = 'hidden';
					dnContent.style.overflowY = 'auto';
				}
				else
				{
					dnContent.style.height = 'auto';
					dnContent.style.overflowX = 'auto';
					dnContent.style.overflowY = 'auto';
				}
			}

			dnMain.innerHTML = menuContent;
			
			//alert(menuType);
			if(menuType == "gallery_videos")
			{
				$('a.media').media();
			}

			//CKEDITOR.remove('FCKeditor1');
			//loadFCK('none');
		}
	}
}

