﻿/// <reference path="jquery-1.3.intellisense.js" />
//Adds info from the submit data box.
function AddDatajs() {
    if (document.getElementById("tbAddInfo").value.length > 10) {
        if (document.getElementById("divGuids") != null)
            MainMaster.AddItem(document.getElementById("tbAddInfo").value, '', document.getElementById("divGuids").innerHTML, OnWSAddDataComplete);
        else
            MainMaster.AddItem(document.getElementById("tbAddInfo").value, '', '', OnWSAddDataComplete);
    }
    else
        document.getElementById("divWarning").innerHTML = "Nothing Submitted";
}
//clears the submit info box.
function ClearBox() {
    document.getElementById("tbAddInfo").value = '';
    document.getElementById("tbAddInfo").focus();
}
//Shows the results.
function OnWSAddDataComplete(results) {
    var sub = results.substring(0, 2);
    if (sub == "0,") { //it Failed
        document.getElementById("divWarning").innerHTML = results.substring(2);
    }
    else { //it didn't fail.
        document.getElementById("divWarning").innerHTML = results;
        if (location.href.indexOf("kd.aspx", 0) > 1 | location.href.indexOf("ProvinceDetail.aspx", 0) > 1)
            window.location = location.href;
    }
    ClearBox();
}


function showLegendAddData() {
    $("#divAddDataLegend").toggleClass("popUp");
}
//Retires a Kingdom...
function RetireKingdom(ownerKDID, kdID) {
    MainMaster.RetireKd(ownerKDID, kdID, OnWSRetireKingdomComplete);
}
function OnWSRetireKingdomComplete(results) {
    window.location = location.href;
}
function getTopAd(signedIn) {
    document.getElementById("divAddTop").innerHTML = "<map name='admap37989' id='admap37989'><area href='http://www.projectwonderful.com/out_nojs.php?r=0&amp;c=0&amp;id=37989&amp;type=5' shape='rect' coords='0,0,728,90' title='' alt='' target='_blank' /></map><table cellpadding='0' border='0' cellspacing='0' width='728' bgcolor=''><tr><td><img src='http://www.projectwonderful.com/nojs.php?id=37989&amp;type=5' width='728' height='93' usemap='#admap37989' border='0' alt='' /></td></tr><tr><td bgcolor='' colspan='1'><center><a style='font-size:10px;color:#fff;text-decoration:none;line-height:1.2;font-weight:bold;font-family:Tahoma, verdana,arial,helvetica,sans-serif;text-transform: none;letter-spacing:normal;text-shadow:none;white-space:normal;word-spacing:normal;' href='http://www.projectwonderful.com/advertisehere.php?id=37989&amp;type=5' target='_blank'>Your ad could be here, right now.</a></center></td></tr></table>";
    if (signedIn === "true")
        setTimeout('getTopAd("true")', 10000);

    //    MainMaster.RefreshAd(OnWSRefreshAdd);
}
function getSideAd() {
    document.getElementById("divAdRight").innerHTML = '<map name="admap38158" id="admap38158"><area href="http://www.projectwonderful.com/out_nojs.php?r=0&amp;c=0&amp;id=38158&amp;type=3" shape="rect" coords="0,0,128,480" title="" alt="" target="_blank" /></map><table cellpadding="0" border="0" cellspacing="0" width="128" bgcolor=""><tr><td><img src="http://www.projectwonderful.com/nojs.php?id=38158&amp;type=3" width="128" height="480" usemap="#admap38158" border="0" alt="" /></td></tr><tr><td bgcolor="" colspan="1"><center><a style="font-size:10px;color:#FFF;text-decoration:none;line-height:1.2;font-weight:bold;font-family:Tahoma, verdana,arial,helvetica,sans-serif;text-transform: none;letter-spacing:normal;text-shadow:none;white-space:normal;word-spacing:normal;" href="http://www.projectwonderful.com/advertisehere.php?id=38158&amp;type=3" target="_blank">Your ad could be here, right now.</a></center></td></tr></table><map name="admap38154" id="admap38154"><area href="http://www.projectwonderful.com/out_nojs.php?r=0&amp;c=0&amp;id=38154&amp;type=2" shape="rect" coords="0,0,117,30" title="" alt="" target="_blank" /></map><table cellpadding="0" border="0" cellspacing="0" width="117" bgcolor="#333"><tr><td><img src="http://www.projectwonderful.com/nojs.php?id=38154&amp;type=2" width="117" height="30" usemap="#admap38154" border="0" alt="" /></td></tr></table>';
    setTimeout('getSideAd()', 7000);
}
function OnWSRefreshAdd(results) {
    document.getElementById("divAddTop").innerHTML = results;
    var pw_d = document;
    pw_d.projectwonderful_adbox_id = "37989";
    pw_d.projectwonderful_adbox_type = "5";
    pw_d.projectwonderful_foreground_color = "";
    pw_d.projectwonderful_background_color = "";

    setTimeout('getAdd()', 10000);

}

function GetTimeLeftInTick_Start(start) {
    window.start = parseFloat(start);
    setTimeout('GetTimeLeftInTick()', 1000)
}

function GetTimeLeftInTick() {
    var minutes = Math.floor(window.start / 60);
    var secs = Math.floor(window.start - (minutes * 60));
    document.getElementById('timeLeft').innerHTML = minutes + "m " + secs + "s";
    window.start -= 1;
    if (window.start != 0)
        GetTimeLeftInTick_Start(window.start);
    else
        MainMaster.RefreshUtopianTime(OnWSRefreshUtopianTimeComplete);
}
function OnWSRefreshUtopianTimeComplete(results) {
    document.getElementById('liUtopianDateTime').innerHTML = results[0];
    GetTimeLeftInTick_Start(results[1]);
}
