var selectedMailID = 0;


function getInfoBox()
{
	var dummy = $time() + $random(0, 100);
	var url = "ajax/infoBox.asp?dummy=" + dummy;
	$('msgContainer').load(url);
	//new Ajax(url, {method: 'get',update: $('msgContainer')}).request();
	var t=setTimeout("getInfoBox()",30000)
}



function getLastLoots()
{
	var dummy = $time() + $random(0, 100);
	var url = "ajax/lastLoots.asp?dummy=" + dummy;
	$('indexloot').load(url);

	//new Ajax(url, {method: 'get',update: $('indexloot')}).request();
	var t=setTimeout("getLastLoots()",15000)
}



function getLastLootsAdvanced(e)
{
	var dummy = $time() + $random(0, 100);
	var url = "ajax/lastLootsAdvanced.asp?LI="+ e +"&dummy=" + dummy;
	$('indexloot').load(url);
	//new Ajax(url, {method: 'get',update: $('indexloot')}).request();
	//var t=setTimeout("getLastLootsAdvanced("+e+")",15000)
	var t = setTimeout(function() { getLastLootsAdvanced( e ) }, 15000) ;
}


function getLastMiningAdvanced(e)
{
	var dummy = $time() + $random(0, 100);
	var url = "ajax/lastMiningAdvanced.asp?LI="+ e +"&dummy=" + dummy;
	$('indexloot').load(url);
	//new Ajax(url, {method: 'get',update: $('indexloot')}).request();
	var t = setTimeout(function() { getLastMiningAdvanced( e ) }, 15000) ;
}


function getLastCraftingAdvanced(e)
{
	var dummy = $time() + $random(0, 100);
	var url = "ajax/lastCraftingAdvanced.asp?LI="+ e +"&dummy=" + dummy;
	$('indexloot').load(url);
	//new Ajax(url, {method: 'get',update: $('indexloot')}).request();
	var t = setTimeout(function() { getLastCraftingAdvanced( e ) }, 15000) ;
}

function popUpAdminChat(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=850,height=800');");
}


function popUpUserChat(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=600');");
}

function getLastMining()
{
	var dummy = $time() + $random(0, 100);
	var url = "ajax/lastMining.asp?dummy=" + dummy;
	$('indexloot').load(url);
	//new Ajax(url, {method: 'get',update: $('indexloot')}).request();
	var t=setTimeout("getLastMining()",15000)
}

function getLastCrafting()
{
	var dummy = $time() + $random(0, 100);
	var url = "ajax/lastCrafting.asp?dummy=" + dummy;
	$('indexloot').load(url);
	//new Ajax(url, {method: 'get',update: $('indexloot')}).request();
	var t=setTimeout("getLastCrafting()",15000)
}


function getChat(chatID)
{
	var dummy = $time() + $random(0, 100);
	var url = "ajax/getChatLines.asp?dummy=" + dummy + "&chatID=" + chatID;
	$('chatArea').load(url);
	//new Ajax(url, {method: 'get',update: $('chatArea')}).request();
	var t=setTimeout("getChat('"+ chatID +"')",2500)
}


function checkSupport()
{
	var dummy = $time() + $random(0, 100);
	var url = "ajax/getNewChats.asp?dummy=" + dummy ;
	$('dynLoader').load(url);
	//new Ajax(url, {method: 'get',update: $('dynLoader')}).request();
	var t=setTimeout("checkSupport()",7000)
}


function startAdminChat(chatID)
{
	var dummy = $time() + $random(0, 100);
	var url = "ajax/getAdminChat.asp?dummy=" + dummy + "&chatID=" + chatID;
	$('chatArea').load(url);
	//new Ajax(url, {method: 'get',update: $('chatArea')}).request();
	var t=setTimeout("startAdminChat('"+ chatID +"')",2500)
}

function say(element, chatID)
{
	var txt = document.getElementById(element).value;
	var url = "ajax/speak.asp?txt=" + txt + "&chatID=" + chatID;
	$('NOTAVALIBLE').load(url);
	//new Ajax(url, {method: 'get',update: $('NOTAVALIBLE')}).request();
	document.getElementById(element).value = '';
}

function quitchat(chatID)
{
	var url = "ajax/speak.asp?txt=Has left the chat.&chatID=" + chatID;
	$('NOTAVALIBLE').load(url);
	//new Ajax(url, {method: 'get',update: $('NOTAVALIBLE')}).request();
}


function loadMail(mailID)
{
	document.getElementById('mailMain').innerHTML = "Fetching mail. Please wait.";
	var url = "ajax/loadMail.asp?ID=" + mailID;
	$('mailMain').load(url);
	//new Ajax(url, {method: 'get',update: $('mailMain')}).request();
	selectedMailID = mailID;
}





function getFileDownload(PT)
{
	
	var sel = document.getElementById("fileFormat");
    var FT = sel.options[sel.selectedIndex].value;
    
    var sel1 = document.getElementById("dateRange");
    var DR = sel1.options[sel1.selectedIndex].value;
    
    var sel2 = document.getElementById("who");
    var who = sel2.options[sel2.selectedIndex].value;
    
    var sel3 = document.getElementById("targetItem");
    var selItem = sel3.options[sel3.selectedIndex].value;
    
    var sel4 = document.getElementById("timeFormat");
    var TF = sel4.options[sel4.selectedIndex].value;
    
    
	document.getElementById('globalDL').innerHTML = "Generating file. Please wait.";
	$('globalDL').load("ajax/generateGlobals.asp?FT=" + FT + "&PT=" + PT + "&TS=" + DR + "&WHO=" + who + "&SI=" + selItem + "&TF=" + TF);
}



function getPDFDownload(PT)
{
        var sel1 = document.getElementById("targetItem");
        var DR = sel1.options[sel1.selectedIndex].value;
        if(DR != '0')
        {
	        document.getElementById('PDFDL').innerHTML = "Generating PDF file. Please wait.";
	        $('PDFDL').load("ajax/report-ajax.asp?mobID=" + DR);
	    }
	    else
	    {
	    alert('Please select which mob you want the report for');
	    }
	    
    
}




function deleteMail()
{
	if (selectedMailID > 0)
	{
	window.location = 'mail.asp?mode=deleteMail&M='+ selectedMailID + '';	
	}
	else
	{
	alert('Please select which mail you would like to delete!');	
	}
}

function replyMail()
{
	if (selectedMailID > 0)
	{
	window.location = 'mail.asp?mode=replyMail&M='+ selectedMailID + '';	
	}
	else
	{
	alert('Please select which mail you would like to reply to!');	
	}
}
















function getHuntingGlobals(index, playerId)
{
	var dummy = $time() + $random(0, 100);
	document.getElementById('HGL_LIST').innerHTML = "";
	var url = "ajax/huntingGlobals.asp?PID=" + playerId + "&IX=" + index + "&dum=" + dummy;
	$('HGL_LIST').load(url);
	//new Ajax(url, {method: 'get',update: $('HGL_LIST')}).request();
}


function getHuntingGlobalsLA(index, LAID)
{
	var dummy = $time() + $random(0, 100);
	document.getElementById('landareaglobals').innerHTML = "";
	var url = "ajax/huntingLA.asp?LAID=" + LAID + "&IX=" + index + "&dum=" + dummy;
	$('landareaglobals').load(url);
	//new Ajax(url, {method: 'get',update: $('HGL_LIST')}).request();
}



function getMiningGlobalsLA(index, LAID)
{
	var dummy = $time() + $random(0, 100);
	document.getElementById('landareaglobals').innerHTML = "";
	var url = "ajax/miningLA.asp?LAID=" + LAID + "&IX=" + index + "&dum=" + dummy;
	$('landareaglobals').load(url);
	//new Ajax(url, {method: 'get',update: $('HGL_LIST')}).request();
}


function getMiningGlobals(index, playerId)
{
	var dummy = $time() + $random(0, 100);
	document.getElementById('MGL_LIST').innerHTML = "";
	var url = "ajax/miningGlobals.asp?PID=" + playerId + "&IX=" + index + "&dum=" + dummy;
	$('MGL_LIST').load(url);
	//new Ajax(url, {method: 'get',update: $('MGL_LIST')}).request();
}


function getCraftingGlobals(index, playerId)
{
	var dummy = $time() + $random(0, 100);
	document.getElementById('CGL_LIST').innerHTML = "";
	var url = "ajax/craftingGlobals.asp?PID=" + playerId + "&IX=" + index + "&dum=" + dummy;
	$('CGL_LIST').load(url);
    //new Ajax(url, {method: 'get',update: $('CGL_LIST')}).request();
}


function suggestNameMail()
{
	var dummy = $time() + $random(0, 100);
	myTyped = document.getElementById('mailToName').value;
	if (myTyped.length > 3)
	{
	document.getElementById('NEWmailToSuggestions').innerHTML = "finding suggestions. Please wait.";
	var url = "ajax/findNames.asp?PLName=" + myTyped + "&dum=" + dummy;
	$('NEWmailToSuggestions').load(url);
	//new	Ajax(url, {method: 'get',update: $('NEWmailToSuggestions')}).request();
	}
}


function setMailToName(e)
{
	document.getElementById('mailToName').value = e;	
}


function getOnlineLiveList()
{
	var dummy = $time() + $random(0, 100);
	var url = "ajax/onlineUsers.asp?dummy=" + dummy ;
	$('indexUsers').load(url);
	//new Ajax(url, {method: 'get',update: $('indexUsers')}).request();
	var t=setTimeout("getOnlineLiveList()",15000)	
}




function getLootChart(index, mobID)
{
	var dummy = $time() + $random(0, 100);
	document.getElementById('GLC_LIST').innerHTML = "Fetching data. Please wait.";
	var url = "ajax/lootChart.asp?MID=" + mobID + "&IX=" + index + "&dum=" + dummy;
	$('GLC_LIST').load(url);
	//new Ajax(url, {method: 'get',update: $('GLC_LIST')}).request();
}



function getMiningChart(index, mineralID)
{
	var dummy = $time() + $random(0, 100);
	document.getElementById('GLC_LIST').innerHTML = "Fetching data. Please wait.";
	var url = "ajax/miningChart.asp?MID=" + mineralID + "&IX=" + index + "&dum=" + dummy;
	$('GLC_LIST').load(url);
	//new Ajax(url, {method: 'get',update: $('GLC_LIST')}).request();
}


function getCraftingChart(index, itemID)
{
	var dummy = $time() + $random(0, 100);
	document.getElementById('GLC_LIST').innerHTML = "Fetching data. Please wait.";
	var url = "ajax/craftingChart.asp?MID=" + itemID + "&IX=" + index + "&dum=" + dummy;
	$('GLC_LIST').load(url);
	//new Ajax(url, {method: 'get',update: $('GLC_LIST')}).request();
}


function showList(e)
{
	document.getElementById(e).style.display = 'block';
	document.getElementById('hide_' + e).style.display = 'block';
	document.getElementById('show_' + e).style.display = 'none';
}

function hideList(e)
{
	document.getElementById(e).style.display = 'none';
	document.getElementById('hide_' + e).style.display = 'none';	
	document.getElementById('show_' + e).style.display = 'block';	
}



function toggleShowAuctionMenuElement(e)
{
    var element = document.getElementById(e + "_subs");
    if(element.style.display == 'block')
    {
        element.style.display = 'none';
        //Vis plus
        document.getElementById(e + "_minus").style.display = "none";
        document.getElementById(e + "_plus").style.display = "block";
    }
    else
    {
        element.style.display = 'block';
        //Vis minus
        document.getElementById(e + "_minus").style.display = "block";
        document.getElementById(e + "_plus").style.display = "none";
    
    }
}


function loadAuctionItemList(ID,stack)
{
	var dummy = $time() + $random(0, 100);
	var url = "ajax/loadAuctionItemList.asp?ID="+ ID +"&stack=" + stack + "&dummy=" + dummy ;
	$('auctionContent').load(url);
}



function loadAuctionItemDetails(ID,stack)
{
	var dummy = $time() + $random(0, 100);
	var url = "ajax/loadAuctionItemdetails.asp?ID="+ ID +"&stack=" + stack + "&dummy=" + dummy ;
	$('auctionContent').load(url);
}



