/*
onerror= handle_error;

function handle_error(HL_Message, HL_URL, HL_Line)
{
HL_ErrorText="An error has been encountered... please report this.\n\n";
HL_ErrorText+="Error: " + HL_Message + "\n";
HL_ErrorText+="URL: " + HL_URL + "\n";
HL_ErrorText+="Line: " + HL_Line + "\n\n";

alert(HL_ErrorText);

return true;
}

function check_all(CL_Area1, CL_Area2)
{
for(CL_Increment1= 0; CL_Increment1 < CL_Area2.length; CL_Increment1++)
{
if(typeof(CL_Area2[CL_Increment1].name))
{
continue;
}

if(CL_Area2[CL_Increment1].disabled != true)
{
alert(1);
CL_Area2[CL_Increment1].checked= CL_Area1.checked;
}
}
}
*/

function check_all(CL_Area1, CL_Area2)
{
/* check_all(this, this.form); */

for(CL_Increment1= 0; CL_Increment1 < CL_Area2.length; CL_Increment1++)
{
if(CL_Area2[CL_Increment1].disabled != true)
{
CL_Area2[CL_Increment1].checked= CL_Area1.checked;
}
}
}

function open_window(OW_URL, OW_Name, OW_Toolbar, OW_Width, OW_Height)
{
OW_Toolbar= OW_Toolbar.replace("Toolbar: ", "toolbar= ");
OW_Toolbar= OW_Toolbar.replace("T", "yes");
OW_Toolbar= OW_Toolbar.replace("F", "no");
OW_Width= OW_Width.replace("Width: ", "width= ");
OW_Height= OW_Height.replace("Height: ", "height= ");

OW_AlternateOptions= OW_Toolbar + ", " + OW_Width + ", " + OW_Height;

window.open(OW_URL, OW_Name, OW_AlternateOptions);
}

function window_location()
{
return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
}

function mouse_x(evt)
{
return evt.clientX ? evt.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) : evt.pageX;
}

function mouse_y(evt)
{
return evt.clientY ? evt.clientY + (document.documentElement.scrollTop || document.body.scrollTop) : evt.pageY;
}

/*
function tooltip(evt, T_TooltipID)
{
T_SmallSearch= T_TooltipID.search("Small");

T_TooltipID= T_TooltipID.replace("Small", "");

if(document.getElementById)
{
T_WindowLocation= window_location();

T_Element= document.getElementById(T_TooltipID);

T_Style= T_Element.style;

if(T_SmallSearch=="-1")
{
T_Style.width="400px";
}

else
{
T_Style.width="150px";
}

T_ShowTooltip= T_Style.visibility;

if(T_Element.offsetWidth) T_Width= T_Element.offsetWidth;

else if(T_Element.clip.width) T_Width= T_Element.clip.width;

if(T_ShowTooltip=="visible" || T_ShowTooltip=="show")
{
T_Style.width="150px";

T_Style.visibility="hidden";
}

else
{
T_Coordinates= mouse_y(evt) + 20;

T_Level= mouse_x(evt) - (T_Width / 4);

if(T_Level < 2) T_Level= 2;

else if(T_Level + T_Width > T_WindowLocation) T_Level -= T_Width / 2; T_Level +='px'; T_Coordinates +='px'; T_Style.left= T_Level; T_Style.top= T_Coordinates; T_Style.visibility= "visible";
}
}
}*/

function xml_request()
{
if(window.XMLHttpRequest)
{
XR_XMLRequest= new XMLHttpRequest();
}

else
{
try
{
XR_XMLRequest= new ActiveXObject("msxml2.XMLHTTP");
}

catch(e)
{
XR_XMLRequest= new ActiveXObject("Microsoft.XMLHTTP");
}
}

return XR_XMLRequest;
}

function state_changed()
{
if(X_XMLRequest.readyState== 4 || X_XMLRequest.readyState=="complete")
{
SC_ResponseText= X_XMLRequest.responseText;

SC_DeleteErrorSearch1= SC_ResponseText.search("DEL_ERR001");
SC_DeleteErrorSearch2= SC_ResponseText.search("DEL_ERR002");

SC_ErrorSearch1= SC_ResponseText.search("ERR001");
SC_ErrorSearch2= SC_ResponseText.search("ERR002");

SC_ResponseText= SC_ResponseText.replace("DEL_ERR001", "");
SC_ResponseText= SC_ResponseText.replace("DEL_ERR002", "");
SC_ResponseText= SC_ResponseText.replace("ERR001", "");
SC_ResponseText= SC_ResponseText.replace("ERR002", "");

SC_SpanValue= document.getElementById(window.X_SpanName);

SC_SpanValue.innerHTML= SC_ResponseText;

if(window.X_Page=="Signup")
{
if(SC_ErrorSearch1 !="-1")
{
SC_NotificationValue1_1= document.getElementById("Notification1_Username");

SC_NotificationValue1_1.innerHTML="<br /><font color='red'>Username only consists of numbers.</font>";
}

if(SC_ErrorSearch2 !="-1")
{
SC_NotificationValue2_1= document.getElementById("Notification2_Username");

SC_NotificationValue2_1.innerHTML="<br /><font color='red'>Username already taken.</font>";
}

if(SC_DeleteErrorSearch1 !="-1")
{
SC_NotificationValue1_2= document.getElementById("Notification1_Username");

SC_NotificationValue1_2.innerHTML="";
}

if(SC_DeleteErrorSearch2 !="-1")
{
SC_NotificationValue2_2= document.getElementById("Notification2_Username");

SC_NotificationValue2_2.innerHTML="";
}
}

if(window.X_Page=="Login")
{
if(window.VF_FieldName=="user_id")
{
SC_SpanValue2= document.getElementById("Span2");

SC_SpanValue2.innerHTML= SC_ResponseText;
}

else if(window.VF_FieldName=="password")
{
SC_SpanValue2= document.getElementById("Span1");

SC_SpanValue2.innerHTML= SC_ResponseText;
}

if(SC_ErrorSearch1 !="-1")
{
SC_NotificationValue1_1= document.getElementById("Notification1_Password");

SC_NotificationValue1_1.innerHTML="<br /><font color='red'>Incorrect password.</font>";
}

if(SC_ErrorSearch2 !="-1")
{
SC_NotificationValue2_1= document.getElementById("Notification1_UserID");

SC_NotificationValue2_1.innerHTML="<br /><font color='red'>Unexistant user.</font>";
}

if(SC_DeleteErrorSearch1 !="-1")
{
SC_NotificationValue1_2= document.getElementById("Notification1_Password");

SC_NotificationValue1_2.innerHTML="";
}

if(SC_DeleteErrorSearch2 !="-1")
{
SC_NotificationValue2_2= document.getElementById("Notification1_UserID");

SC_NotificationValue2_2.innerHTML="";
}
}

if(window.X_Page=="Battle A Trainer")
{
if(SC_ErrorSearch1 !="-1")
{
if(window.MethodText=="Username")
{
SC_NotificationValue1_1= document.getElementById("Notification1_Choice");

SC_NotificationValue1_1.innerHTML="<br /><font color='red'>" + window.MethodText + " only consists of numbers.</font>";
}
}

if(SC_ErrorSearch2 !="-1")
{
SC_NotificationValue2_1= document.getElementById("Notification2_Choice");

SC_NotificationValue2_1.innerHTML="<br /><font color='red'>" + window.MethodText + " unexistant.</font>";
}

if(SC_DeleteErrorSearch1 !="-1")
{
SC_NotificationValue1_2= document.getElementById("Notification1_Choice");

SC_NotificationValue1_2.innerHTML="";
}

if(SC_DeleteErrorSearch2 !="-1")
{
SC_NotificationValue2_2= document.getElementById("Notification2_Choice");

SC_NotificationValue2_2.innerHTML="";
}
}

if(window.X_Page=="Find A Trainer")
{
if(SC_ErrorSearch1 !="-1")
{
if(window.MethodText=="Username")
{
SC_NotificationValue1_1= document.getElementById("Notification1_Choice");

SC_NotificationValue1_1.innerHTML="<br /><font color='red'>" + window.MethodText + " only consists of numbers.</font>";
}
}

if(SC_ErrorSearch2 !="-1")
{
SC_NotificationValue2_1= document.getElementById("Notification2_Choice");

SC_NotificationValue2_1.innerHTML="<br /><font color='red'>" + window.MethodText + " unexistant.</font>";
}

if(SC_DeleteErrorSearch1 !="-1")
{
SC_NotificationValue1_2= document.getElementById("Notification1_Choice");

SC_NotificationValue1_2.innerHTML="";
}

if(SC_DeleteErrorSearch2 !="-1")
{
SC_NotificationValue2_2= document.getElementById("Notification2_Choice");

SC_NotificationValue2_2.innerHTML="";
}
}

if(window.X_Page=="Send Money" || window.X_Page=="Sell Pokémon" || window.X_Page=="Create A Trade")
{
if(SC_ErrorSearch1 !="-1")
{
if(window.MethodText=="Username")
{
SC_NotificationValue1_1= document.getElementById("Notification1_Choice");

SC_NotificationValue1_1.innerHTML="<br /><font color='red'>" + window.MethodText + " only consists of numbers.</font>";
}
}

if(SC_ErrorSearch2 !="-1")
{
SC_NotificationValue2_1= document.getElementById("Notification2_Choice");

SC_NotificationValue2_1.innerHTML="<br /><font color='red'>" + window.MethodText + " unexistant.</font>";
}

if(SC_DeleteErrorSearch1 !="-1")
{
SC_NotificationValue1_2= document.getElementById("Notification1_Choice");

SC_NotificationValue1_2.innerHTML="";
}

if(SC_DeleteErrorSearch2 !="-1")
{
SC_NotificationValue2_2= document.getElementById("Notification2_Choice");

SC_NotificationValue2_2.innerHTML="";
}
}
}
}

function display_navigation(DN_SpanName)
{
DN_SpanValue= document.getElementById(DN_SpanName);

DN_SpanValue.style.display="inline";
}

function hide_navigation(HN_SpanName)
{
HN_SpanValue= document.getElementById(HN_SpanName);

HN_SpanValue.style.display="none";
}

function verify_login()
{
X_XMLRequest= xml_request();

if(X_XMLRequest== null)
{
alert("Unfortunately, your current browser does not appear to accept AJAX requests. Please download a newer internet browser, such as Mozilla Firefox.");

return 0;
}

VL_URL="/javascript_ajax2_verifylogin.php?protection=" + Math.random();

if(X_XMLRequest.readyState== 4 || X_XMLRequest.readyState=="complete")
{
X_XMLRequest.open("GET", VL_URL, false);

X_XMLRequest.send(null);

VL_ResponseText= X_XMLRequest.responseText;

if(VL_ResponseText !="T")
{
VL_ResponseText="F";
}
}

else
{
VL_ResponseText="T";
}

return VL_ResponseText;
}

function random_number(RN_MinimumNumber, RN_MaximumNumber)
{
if(RN_MinimumNumber== null || RN_MaximumNumber== null)
{
RN_MinimumNumber= 0;
RN_MaximumNumber= 1;
}

if(RN_MinimumNumber > RN_MaximumNumber)
{
RN_MinimumNumber= RN_MaximumNumber;
}

return Math.floor(Math.random() * (RN_MaximumNumber - RN_MinimumNumber + 1)) + RN_MinimumNumber;
}

function hash_data(HD_String)
{
HD_String= sha1(sha1(md5(md5(HD_String))));

return HD_String;
}

function checkbox_hover(CH_SpanName1, CH_HoverType)
{
CH_SpanValue1= document.getElementById(CH_SpanName1);
CH_SpanValue2= document.getElementById(CH_SpanName1 + "Background");

CH_Background1= CH_SpanValue2.innerHTML;

if(CH_HoverType=="Over")
{
CH_Background1= CH_Background1.replace(".png", "_hover.png");

CH_SpanValue1.style.background= CH_Background1;

CH_SpanValue2.innerHTML= CH_Background1;
}

else
{
CH_Background1= CH_Background1.replace("_hover.png", ".png");

CH_SpanValue1.style.background= CH_Background1;

CH_SpanValue2.innerHTML= CH_Background1;
}
}

window.CheckboxDisabled1="F";
window.CheckboxDisabled2="F";

function fill_checkbox(FC_SpanName1, FC_FieldName1)
{
if(window.CheckboxDisabled1 !="T" && window.CheckboxDisabled2 !="T")
{
FC_AmpersandSearch1= FC_SpanName1.search("&F");
FC_AmpersandSearch2= FC_SpanName1.search("&T");

FC_SpanName1= FC_SpanName1.replace("&F", "");
FC_SpanName1= FC_SpanName1.replace("&T", "");

FC_SpanValue1= document.getElementById(FC_SpanName1);
FC_SpanValue2= document.getElementById(FC_SpanName1 + "Information");
FC_SpanValue3= document.getElementById(FC_SpanName1 + "Background");

if(FC_FieldName1 !="None")
{
FC_FieldValue1= document.getElementById(FC_FieldName1);
}

FC_Background1= FC_SpanValue3.innerHTML;

FC_InnerHTML= FC_SpanValue2.innerHTML;

if(FC_AmpersandSearch1 !="-1")
{
FC_InnerHTML="T";
}

else if(FC_AmpersandSearch2 !="-1")
{
FC_InnerHTML="F";
}

if(FC_InnerHTML=="F")
{
FC_Background1= FC_Background1.replace("empty", "true");

FC_SpanValue1.style.background= FC_Background1;

FC_SpanValue2.innerHTML="T";
FC_SpanValue3.innerHTML= FC_Background1;

if(FC_FieldName1 !="None")
{
FC_FieldValue1.checked= true;
}
}

else
{
FC_Background1= FC_Background1.replace("true", "empty");

FC_SpanValue1.style.background= FC_Background1;

FC_SpanValue2.innerHTML="F";
FC_SpanValue3.innerHTML= FC_Background1;

if(FC_FieldName1 !="None")
{
FC_FieldValue1.checked= false;
}
}
}
}

function update_party(UP_Page)
{
X_XMLRequestParty= xml_request();

if(X_XMLRequestParty== null)
{
alert("Unfortunately, your current browser does not appear to accept AJAX requests. Please download a newer internet browser, such as Mozilla Firefox.");

return 0;
}

UP_URL="/javascript_ajax3_updateparty.php?banner_width=" + window.BannerWidth + "&protection=" + Math.random();

X_XMLRequestParty.open("GET", UP_URL, false);

X_XMLRequestParty.send(null);

UP_ResponseText= X_XMLRequestParty.responseText;

UP_ResponseText= UP_ResponseText.replace(/accent_e/g, "é");

if(UP_ResponseText=="Not Logged In")
{
alert("You are currently not logged in.");

UP_ElementValue1= document.getElementById("PP_ObtainPromo");

if(UM_Page=="Promotional Pokémon")
{
UP_ElementValue1.value="Not Logged In";
}
}

else
{
UP_SpanValue1= document.getElementById("H_Party");

UP_SpanValue1.innerHTML= UP_ResponseText;

if(UP_Page=="Promotional Pokémon")
{
UP_ElementValue1= document.getElementById("PP_ObtainPromo");

UP_ElementValue1.value="Successfully Obtained";
}
}
}

function update_money(UM_Page)
{
X_XMLRequestMoney= xml_request();

if(X_XMLRequestMoney== null)
{
alert("Unfortunately, your current browser does not appear to accept AJAX requests. Please download a newer internet browser, such as Mozilla Firefox.");

return 0;
}

UM_URL="/javascript_ajax4_updatemoney.php?protection=" + Math.random();

X_XMLRequestMoney.open("GET", UM_URL, false);

X_XMLRequestMoney.send(null);

if(X_XMLRequestMoney.responseText=="Not Logged In")
{
alert("You are currently not logged in.");
}

else
{
UM_SpanValue1= document.getElementById("H_Money");

UM_SpanValue1.innerHTML= X_XMLRequestMoney.responseText;
}
}

function add_bb_code(AB_FieldName1, AB_BBCode, AB_Other)
{
AB_FieldValue1= document.getElementById(AB_FieldName1);

AB_AlterValue="T";

if(AB_Other=="URL")
{
AB_SiteURL= prompt("Please specify the site URL.", "http://tpmrpg.net");

if(AB_SiteURL != null)
{
AB_SiteName= prompt("Please specify the site/URL name.", "Example");

if(AB_SiteName != null)
{
AB_BBCode= AB_BBCode.replace("replace1", AB_SiteURL);
AB_BBCode= AB_BBCode.replace("replace2", AB_SiteName);
}

else
{
AB_AlterValue="F";
}
}

else
{
AB_AlterValue="F";
}
}

if(AB_AlterValue !="F")
{
AB_FieldValue1.value= AB_FieldValue1.value + AB_BBCode;
}
}

function hide_alert(HA_Alerts, HA_AlertsEnabled, HA_SpanName1)
{
if(HA_AlertsEnabled=="T")
{
HA_SpanValue1= document.getElementById(HA_SpanName1);
HA_SpanValue2= document.getElementById("H_Alerts");

if(HA_SpanValue1 != null)
{
HA_SpanValue1.style.display="none";

HA_Alerts= Math.round(HA_Alerts - 1);

if(HA_Alerts <= 0)
{
HA_SpanValue2.style.display="none";
}
}
}
}

function empty(E_Value)
{
var E_Key;

if(E_Value==="" || E_Value=== 0 || E_Value==="0" || E_Value=== null || E_Value=== false || E_Value=== undefined)
{
return true;
}

if(typeof E_Value=="object")
{
for(E_Key in E_Value)
{
if(typeof E_Value[E_Key] !=="function")
{
return false;
}
}

return true;
}

return false;
}

function is_integer(II_Value)
{
if(parseFloat(II_Value) != parseInt(II_Value) || typeof II_Value !=="number")
{
II_Result= false;
}

else
{
II_Result= true;
}

return II_Result;
}

function decode_html_entity(DHE_String)
{
DHE_FieldValue1= document.createElement("textarea");

DHE_FieldValue1.innerHTML= DHE_String;

return DHE_FieldValue1.value;
}

function convert_to_money(CTM_Amount)
{
CTM_DisplayAmount= number_format(CTM_Amount);

CTM_DisplayAmount="$" + CTM_DisplayAmount + ".00";

return CTM_DisplayAmount;
}

function convert_to_credits(CTC_Amount)
{
CTC_DisplayAmount= number_format(CTC_Amount);

CTC_DisplayAmount="&pound;" + CTC_DisplayAmount;

return CTC_DisplayAmount;
}

function grammar_s(GS_Number, GS_Return)
{
if(GS_Number != 1)
{
GS_Result="s";
}

if(GS_Return=="T")
{
return GS_Result;
}

else
{
return GS_Result;
}
}

function disable_arrow_keys()
{
DAK_Holder= document.createElement("P");

DAK_Holder.appendChild(document.createTextNode(""));

for(DAK_Increment1= 0; DAK_Increment1 < 100; DAK_Increment1++)
{
document.body.appendChild(DAK_Holder.cloneNode(true));
}

add_event(document.body, "keydown", key_down);
add_event(window, "keydown", key_down);
}

function add_event(AE_Object, AE_EventType, AE_Function)
{
if(AE_Object.addEventListener)
{
AE_Object.addEventListener(AE_EventType, AE_Function, false);

return true;
}

else if(AE_Object.attachEvent)
{
AE_EventParameter="on" + AE_EventType;

AE_Result= AE_Object.attachEvent(AE_EventParameter, AE_Function);

return AE_Result;
}
}

function key_down(e)
{
AE_Event= (window.event) ? event : e;

AE_KeyCode= (window.event) ? event.keyCode : e.keyCode;

AE_Escape1= 0;
AE_Escape2= true;

if(AE_KeyCode== 37 || AE_KeyCode== 38 || AE_KeyCode== 39 || AE_KeyCode== 40)
{
AE_Escape1= 1;
AE_Escape2= false;
}

if(navigator.appName=="Microsoft Internet Explorer")
{
AE_Escape= AE_Escape2;
}

else
{
AE_Escape= AE_Escape1;
}

if(AE_Escape && AE_Event.preventDefault)
{
AE_Event.preventDefault();
}

return AE_Escape;
}

function link(L_SpanName1, L_EventType)
{
L_SpanValue1= document.getElementById(L_SpanName1);

L_LinkValue= L_SpanValue1.innerHTML;

if(L_EventType=="On")
{
L_LinkValue= L_LinkValue.replace("[ ", "[");
L_LinkValue= L_LinkValue.replace(" ]", "]");

L_SpanValue1.innerHTML= L_LinkValue;
}

else
{
L_LinkValue= L_LinkValue.replace("[", "[ ");
L_LinkValue= L_LinkValue.replace("]", " ]");

L_SpanValue1.innerHTML= L_LinkValue;
}
}

function tooltip(evt, T_DivName1)
{
T_SmallSearch= T_DivName1.search("Small");

T_DivName1= T_DivName1.replace("Small", "");

T_WindowLocation= window_location();

T_DivValue1= document.getElementById(T_DivName1);

if(T_SmallSearch=="-1")
{
T_DivValue1.style.width="400px";
}

else
{
T_DivValue1.style.width="150px";
}

if(evt.type=="mousemove")
{
if(T_DivValue1.style.display !="inline")
{
T_DivValue1.style.display="inline";
}

T_MouseX= Math.round(mouse_x(evt) + 20) + "px";

T_MouseY= Math.round(mouse_y(evt) + 20) + "px";

T_DivValue1.style.left= T_MouseX;
T_DivValue1.style.top= T_MouseY;
}

else
{
if(T_DivValue1.style.display !="none")
{
T_DivValue1.style.display="none";
}
}
}

function hide_banner()
{
X_XMLRequest= xml_request();

if(X_XMLRequest== null)
{
alert("Unfortunately, your current browser does not appear to accept AJAX requests. Please download a newer internet browser, such as Mozilla Firefox.");

return 0;
}

HB_URL="/javascript_ajax1_functions.php?change_type=hide_banner&protection=" + Math.random();

X_XMLRequest.open("GET", HB_URL, false);

X_XMLRequest.send(null);

if(X_XMLRequest.responseText=="Not Logged In")
{
alert("You are currently not logged in.");
}

else if(X_XMLRequest.responseText=="Invalid")
{
alert("Invalid response... please refresh the page and try again.");
}

else
{
HB_SpanValue1= document.getElementById("H_NormalBanner");
HB_SpanValue2= document.getElementById("H_HiddenBanner");

if(X_XMLRequest.responseText=="Hidden")
{
HB_SpanValue1.style.display="none";
HB_SpanValue2.style.display="inline";

document.body.style.background="#FFFFFF";
}

else
{
HB_SpanValue1.style.display="inline";
HB_SpanValue2.style.display="none";

document.body.style.background="#FFF url(\"/images/layout/background.png\") repeat-x";
}
}
}

function evolve_pokemon(EP_PokemonID, EP_SpanName1, EP_Special)
{
/* If no special, set it to "F" */

EP_SpanValue1= document.getElementById(EP_SpanName1);

X_XMLRequest= xml_request();

if(X_XMLRequest== null)
{
alert("Unfortunately, your current browser does not appear to accept AJAX requests. Please download a newer internet browser, such as Mozilla Firefox.");

return 0;
}

EP_URL="/javascript_ajax9_evolvepokemon.php?pokemon_id=" + EP_PokemonID + "&special=" + EP_Special + "&protection=" + Math.random();

X_XMLRequest.open("GET", EP_URL, false);

X_XMLRequest.send(null);

if(X_XMLRequest.responseText=="Not Logged In")
{
alert("You are currently not logged in.");
}

else if(X_XMLRequest.responseText=="Invalid Pokemon ID")
{
alert("Invalid Pokémon... please refresh the page and try again.");
}

else if(X_XMLRequest.responseText=="Invalid None")
{
alert("This Pokémon does not evolve.");
}

else if(X_XMLRequest.responseText=="Invalid Level")
{
alert("This Pokémon is not ready to evolve yet.");
}

else if(X_XMLRequest.responseText=="Invalid Special")
{
alert("This Pokémon cannot be evolved here: it must be done by going to the Evolve Pokémon page (right menu).");
}

else if(X_XMLRequest.responseText=="Invalid Special")
{
alert("This Pokémon cannot be evolved here: it must be done by going to the Evolve Pokémon page (right menu).");
}

else if(X_XMLRequest.responseText=="Invalid Special Choice")
{
alert("Invalid choice... please refresh the page and try again.");
}

else if(X_XMLRequest.responseText=="Invalid Gender Pokemon")
{
alert("Invalid gender... please report this.");
}

else if(X_XMLRequest.responseText=="Invalid Pokemon Data")
{
alert("Invalid Pokémon data -- please report this.");
}

else
{
EP_Notice= X_XMLRequest.responseText;

update_party("Evolve Pokemon");

if(EP_SpanValue1 != null)
{
EP_SpanValue1.innerHTML= EP_Notice;
}

else
{
alert(EP_Notice);
}
}
}

function show_window(SW_Content)
{
SW_SpanValue1= document.getElementById("SW_Window");
SW_SpanValue2= document.getElementById("SW_WindowContent");

SW_SpanValue2.innerHTML="<center>" + SW_Content + "</center>";

$(SW_SpanValue1).show("slow");
}

function close_window()
{
CW_SpanValue1= document.getElementById("SW_Window");
CW_SpanValue2= document.getElementById("SW_WindowContent");

$(CW_SpanValue1).hide("slow", function()
{
CW_SpanValue2.innerHTML="";
});
}

function update_happiness(UH_SpanName1)
{
UH_SpanValue1= document.getElementById(UH_SpanName1);

X_XMLRequest= xml_request();

if(X_XMLRequest== null)
{
alert("Unfortunately, your current browser does not appear to accept AJAX requests. Please download a newer internet browser, such as Mozilla Firefox.");

return 0;
}

UH_URL="/javascript_ajax5_updatehappiness.php?protection=" + Math.random();

X_XMLRequest.open("GET", UH_URL, false);

X_XMLRequest.send(null);

if(X_XMLRequest.responseText=="Not Logged In")
{
alert("You are currently not logged in.");
}

else if(X_XMLRequest.responseText=="Invalid")
{
alert("Invalid response... please refresh the page and try again.");
}

else
{
if(UH_SpanValue1 != null)
{
UH_SpanValue1.innerHTML= X_XMLRequest.responseText;
}

else
{
alert("Fatal error: the specified span name is incorrect; javascript.js.");
}
}
}

function change_right_information()
{
window.RightMenuInformationDone="F";

CRI_SpanValue1= document.getElementById("F_RightMenuInformation");
CRI_SpanValue2= document.getElementById("F_RightMenuInformation2");

if(window.RightMenuInformation=="block")
{
$(CRI_SpanValue1).hide("slow", function()
{
window.RightMenuInformation="none";

$(CRI_SpanValue2).show("slow", function()
{
window.RightMenuInformationDone="T";
});
});
}

else
{
$(CRI_SpanValue2).hide("slow", function()
{
window.RightMenuInformation="block";

$(CRI_SpanValue1).show("slow", function()
{
window.RightMenuInformationDone="T";
});
});
}
}

window.RightMenuInformationDone="T";

function your_application_options(YAO_Switch, YAO_Type, YAO_OnPage)
{
if(YAO_Switch=="yad_rightmenuinformation")
{
YAO_Check="F";

if(window.RightMenuInformationDone=="T")
{
YAO_Check="T";
}
}

else
{
YAO_Check="T";
}

if(YAO_Check=="T")
{
X_XMLRequest= xml_request();

if(X_XMLRequest== null)
{
alert("Unfortunately, your current browser does not appear to accept AJAX requests. Please download a newer internet browser, such as Mozilla Firefox.");

return 0;
}

YAO_URL="/javascript_ajax6_yourappoptions.php?switch=" + YAO_Switch + "&type=" + YAO_Type + "&protection=" + Math.random();

X_XMLRequest.open("GET", YAO_URL, false);

X_XMLRequest.send(null);

if(X_XMLRequest.responseText=="Not Logged In")
{
alert("You are currently not logged in.");
}

if(X_XMLRequest.responseText=="Invalid")
{
alert("Invalid request -- please refresh the page and try again. If you have not gone to the Your Applications page (left menu), please do so: this error was probably caused because of that.");
}

else
{
if(YAO_OnPage=="T")
{
if(YAO_Type=="enable")
{
YAO_SpanValue1= document.getElementById("YA_EnabledText" + YAO_Switch);
YAO_SpanValue2= document.getElementById("YA_EnabledOption" + YAO_Switch);

YAO_SpanValue1.innerHTML="<font color='green'>Enabled</font>";
YAO_SpanValue2.innerHTML="<a href='javascript: your_application_options(\"" + YAO_Switch + "\", \"disable\", \"T\");'>[ Disable ]</a>";
}

else
{
YAO_SpanValue1= document.getElementById("YA_EnabledText" + YAO_Switch);
YAO_SpanValue2= document.getElementById("YA_EnabledOption" + YAO_Switch);

YAO_SpanValue1.innerHTML="<font color='red'>Disabled</font>";
YAO_SpanValue2.innerHTML="<a href='javascript: your_application_options(\"" + YAO_Switch + "\", \"enable\", \"T\");'>[ Enable ]</a>";
}
}

if(X_XMLRequest.responseText=="Refresh")
{
alert("Operation successful, however, you may have to refresh for this application to work.");
}

if(YAO_Switch=="yad_rightmenuinformation")
{
change_right_information();
}
}
}
}

function random_colours()
{
RC_Colour= random_number(1, 5);

if(window.OldColour== RC_Colour)
{
RC_Colour= Math.round(RC_Colour + 1);

if(RC_Colour > 5)
{
RC_Colour= Math.round(RC_Colour - 2);
}
}

window.OldColour= RC_Colour;

if(RC_Colour== 1)
{
RC_Colour="blue";
}

else if(RC_Colour== 2)
{
RC_Colour="red";
}

else if(RC_Colour== 3)
{
RC_Colour="orange";
}

else if(RC_Colour== 4)
{
RC_Colour="darkgreen";
}

else
{
RC_Colour="steelblue";
}

return RC_Colour;
}

function dynamic_logout(DL_Callback)
{
/* For no callback, put "F" */

X_XMLRequest= xml_request();

if(X_XMLRequest== null)
{
alert("Unfortunately, your current browser does not appear to accept AJAX requests. Please download a newer internet browser, such as Mozilla Firefox.");

return 0;
}

DL_URL="/javascript_ajax7_dynamiclogout.php?protection=" + Math.random();

X_XMLRequest.open("GET", DL_URL, false);

X_XMLRequest.send(null);

if(X_XMLRequest.responseText=="Not Logged In")
{
alert("You are currently not logged in.");
}

else
{
if(DL_Callback !="F")
{
eval(DL_Callback);
}
}
}

window.AllowFriendChange="T";

function change_friend_type(CFT_UserID, CFT_Type, CFT_Profile)
{
if(window.AllowFriendChange=="T")
{
window.AllowFriendChange="F";

CFT_LowercaseType= CFT_Type.toLowerCase();

X_XMLRequest= xml_request();

if(X_XMLRequest== null)
{
alert("Unfortunately, your current browser does not appear to accept AJAX requests. Please download a newer internet browser, such as Mozilla Firefox.");

return 0;
}

CFT_URL="/javascript_ajax8_changefriend.php?user_id=" + CFT_UserID + "&type=" + CFT_LowercaseType + "&protection=" + Math.random();

X_XMLRequest.open("GET", CFT_URL, false);

X_XMLRequest.send(null);

if(X_XMLRequest.responseText=="Not Logged In")
{
alert("You are currently not logged in.");
}

else if(X_XMLRequest.responseText=="Invalid User ID")
{
alert("Invalid user ID... please refresh the page and try again.");
}

else if(X_XMLRequest.responseText=="Invalid Type")
{
alert("Invalid type... please refresh the page and try again.");
}

else
{
window.AllowFriendChange="T";

CFT_ResponseText= X_XMLRequest.responseText;

if(CFT_Type=="Block") { CFT_Text1="Unblock"; CFT_Text2="Block User"; CFT_Text3="Befriend"; CFT_SpanValue1= document.getElementById("FriendOption"); CFT_SpanValue2= document.getElementById("FriendOption2"); }
else { CFT_Text1="Terminate Friendship"; CFT_Text2="Befriend"; CFT_Text3="Block User"; CFT_SpanValue1= document.getElementById("FriendOption2"); CFT_SpanValue2= document.getElementById("FriendOption"); }

if(CFT_ResponseText=="T") { CFT_SpanValue1.innerHTML="[ " + CFT_Text1 + " ]"; CFT_SpanValue2.innerHTML="[ " + CFT_Text3 + " ]"; }
else { CFT_SpanValue1.innerHTML="[ " + CFT_Text2 + " ]"; CFT_SpanValue2.innerHTML="[ " + CFT_Text3 + " ]"; }
{
}
}
}
}

function in_array(IS_Needle, IS_Haystack)
{
for(IS_CurrentElement in IS_Haystack)
{
if(IS_Haystack[IS_CurrentElement]== IS_Needle)
{
return true;
}
}

return false;
}

function find_element(FE_Needle, FE_Haystack, FE_FindNext, FE_ReturnKey)
{
/* Utilize FE_FindNext if you want to increment Current Element upon find */

FE_Result="";

for(FE_CurrentElement in FE_Haystack)
{
if(FE_Haystack[FE_CurrentElement]== FE_Needle)
{
if(FE_FindNext=="T") { FE_CurrentElement= Math.round(parseFloat(FE_CurrentElement) + 1); }

if(FE_ReturnKey=="T")
{
FE_Result= FE_CurrentElement;
}

else
{
FE_Result= FE_Haystack[FE_CurrentElement];
}
}
}

if(FE_Result== undefined) { FE_Result=""; }

return FE_Result;
}

window.EnterAndSpace= 0;

function prevent_enter(e)
{
e= e ? e : window.event;

PE_KeyCode= e.keyCode;

if(empty(PE_KeyCode)) { PE_KeyCode= e.which; }

if(PE_KeyCode== 13 || PE_KeyCode== 32)
{
window.EnterAndSpace= Math.round(window.EnterAndSpace + 1);

alert("Do not press enter or space.");

if(window.EnterAndSpace== 3)
{
document.location="index.php";
}

if(e.preventDefault)
{
e.preventDefault();

return false;
}

else
{
return false;
}
}
}

window.AllowTravelMines="T";

function travel_mines(TM_MineID, TM_OnPage)
{
if(window.AllowTravelMines=="T")
{
window.AllowTravelMines="F";

X_XMLRequest= xml_request();

if(X_XMLRequest== null)
{
alert("Unfortunately, your current browser does not appear to accept AJAX requests. Please download a newer internet browser, such as Mozilla Firefox.");

return 0;
}

TM_URL="/javascript_ajax10_travelmines.php?mine_id=" + TM_MineID + "&on_page=" + TM_OnPage + "&protection=" + Math.random();

X_XMLRequest.open("GET", TM_URL, false);

X_XMLRequest.send(null);

if(X_XMLRequest.responseText=="Not Logged In")
{
alert("You are currently not logged in.");
}

else if(X_XMLRequest.responseText=="Invalid Mine ID")
{
alert("Invalid mining area... please refresh the page and try again.");
}

else if(X_XMLRequest.responseText=="Invalid Requirement")
{
alert("Not enough clicks on the current area yet.");
}

else
{
if(TM_OnPage=="T")
{
TM_ResponseText= X_XMLRequest.responseText;

TM_ResponseText= TM_ResponseText.replace(/accent_e/g, "é");

TM_ResponseTextArray= TM_ResponseText.split("-join-");

TM_TimesArea= TM_ResponseTextArray[0];
TM_RequiredTimes= TM_ResponseTextArray[1];
TM_Location= TM_ResponseTextArray[2];
TM_PostCode= TM_ResponseTextArray[3];
TM_ResponseText= TM_ResponseTextArray[4];

TM_SpanValue1= document.getElementById("M_TimesMinedArea");
TM_SpanValue2= document.getElementById("M_TimesMinedAreaPure");
TM_SpanValue3= document.getElementById("M_Location");
TM_SpanValue4= document.getElementById("M_Result");
TM_SpanValue5= document.getElementById("M_Statistics");

if(TM_TimesArea >= TM_RequiredTimes) { TM_Colour="green"; }
else { TM_Colour="red"; }

TM_TimesArea= parseFloat(TM_TimesArea);
TM_RequiredTimes= parseFloat(TM_RequiredTimes);

TM_DisplayTimesArea= number_format(TM_TimesArea);
TM_DisplayRequiredTimes= number_format(TM_RequiredTimes);

TM_SpanValue1.innerHTML="<font color='" + TM_Colour + "'>" + TM_DisplayTimesArea + "/" + TM_DisplayRequiredTimes + "</font>";
TM_SpanValue2.innerHTML= TM_TimesArea;
TM_SpanValue3.innerHTML= TM_Location;
TM_SpanValue4.innerHTML= TM_ResponseText;

$(TM_SpanValue5).hide("slow");

window.AllowTravelMines="T";

return TM_RequiredTimes + "-" + TM_PostCode;
}

document.location="mines.php#mine";
}
}
}

function find_coordinates(e)
{
FC_CurrentX= 0;
FC_CurrentY= 0;

if(!e)
{
e= window.event;
}

if(e.pageX || e.pageY)
{
FC_CurrentX= e.pageX;
FC_CurrentY= e.pageY;
}

else if(e.clientX || e.clientY)
{
FC_CurrentX= e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
FC_CurrentY= e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}

window.ReturnX= parseFloat(FC_CurrentX);
window.ReturnY= parseFloat(FC_CurrentY);

aaas= document.getElementById("aaa");
bbbs= document.getElementById("bbb");

if(aaas != null)
{
aaas.innerHTML= window.ReturnX;
bbbs.innerHTML= window.ReturnY;
}
}

function calculate_percentages(CP_Number1, CP_Number2)
{
CP_Result= Math.round(CP_Number1 / CP_Number2 * 100);

return CP_Result;
}