/*  JavaScript source file for specific functions for the =1FS= Website.  */
/*  Author: Azzkikr=1FS= aka Michael U. Schmidmeister  */
/*  Website: http://www.firewalkers.net  */
/*  Last update: 18 April 2003  */

/*  ------------------------------------------------------------------------------------------------------  */

/*  DATE         -  HISTORY  */
/*  20 Apr 2003  -  Function ShowScreenshot(ImageName,ImageExt) added (used for BHD battle screenshots)  */
/*  20 Apr 2003  -  Beginning to write down changes to this file, called history.  */
/*                  Should have done very much earlier, would have been useful sometimes, damn! ;-)  */

/*  ------------------------------------------------------------------------------------------------------  */



/*  Function for writing UTC time into pages  */
/*  Used for Main / News page f.e. - currently not in use  */

function TimeUTC()
 {
  nowUTC = new Date();
  nowUTCmodified = nowUTC.toGMTString();
  Time = nowUTCmodified.substr(0,25);
  document.write(Time + "&nbsp;UTC");
 }



/*  Function for opening specific in-squad applications and windows  */
/*  Used for Time Conversion Chart, Services or calling Regulations page in Enlist section f.e.  */

var BackgroundMusicInfo = 'home_musicinfo.html';
var Contact = 'main_contact.html';
var Duties ='members-uoc_duties.html';
var HotTopics ='main_hottopics.html';
var Schedule = 'http://www.calsnet.net/1fs';
var SiteInfo = 'home_siteinfo.html';
var Stats = 'stats/index.php';
var TimeConversionChart = 'information_timezones_tcc2.html';


var BkgrdMusicPopup = 'swf';
var BkgrdMusicWin = 'BkgrdMusicWin';
var ContactWin = 'ContactWin';
var HotTopicsWin = 'HotTopicsWin';
var InfoWin = 'InfoWin';
var StatsWin = 'ServerStatsWin';
var TCCWin = 'TCCWin';


var BkgrdMusicPopupDetails = 'status=yes,location=yes,menubar=yes,width=500,height=160,top=0,left=0';
var BkgrdMusicDetails = 'titlebar=no,toolbar=no,status=no,scrollbars=no,width=330,height=315,top=0,left=0,resizable=no';
var ContactDetails = 'titlebar=no,toolbar=no,status=yes,scrollbars=yes,width=610,height=500,top=15,left=15';
var DutiesDetails = 'titlebar=no,toolbar=no,status=yes,scrollbars=yes,width=350,height=500,top=0,left=0,resizable=yes';
var HotTopicsDetails = 'titlebar=no,toolbar=no,status=yes,scrollbars=yes,width=600,height=250,top=0,left=0';
var InfoWinDetails = 'titlebar=no,toolbar=no,status=yes,scrollbars=yes,width=750,height=500,top=0,left=0,resizable=yes';
var StatsDetails = 'titlebar=no,toolbar=yes,status=yes,scrollbars=yes,width=750,height=460,top=0,left=0,resizable=yes';
var TCCDetails = 'titlebar=no,toolbar=no,status=yes,scrollbars=yes,width=750,height=500,top=0,left=0,resizable=yes';

function OpenWindow(URL,WindowName,Details)
 {
  appl = window.open(URL,WindowName,Details);
  appl.focus();
 }



/*  Function for calling pages from Site Map pop-up window  */
/*  currently not in use  */

function ShowPage(URL)
 {
  page = window.open(URL,'MainFrame');
  page.focus();
  self.close();
 }



/*  Function for writing and linking back to section from subordinated pages  */
/*  Used for Battles, Information / Resources f.e.  */

/* Area variables */
var MainNews = 'main.html>Main / News';
var ArchivedNews = 'news_archives.html>Archived News';
var Battles = 'battles.html>Battles';
var BHDRecords = 'battles.html>Battles';
var TFDRecords = 'battles_tfd-lw.html>TFD/LW Records';
var LWRecords = 'battles_tfd-lw.html>TFD/LW Records';
var DFRecords = 'battles_df.html>DF Records';
var InfoRes = 'information.html>Information / Resources';
var Operatives = 'members.html>Operatives';
var Decorations = 'decorations.html>Decorations';

function WriteBackto(Section)
 {
  document.write("<a href=" + Section + "</a>");
 }



/*  Function for loading images into a specific file  */
/*  Used for BHD Battles  */

function ShowScreenshot(ImageName,ImageExt)
 {
  ImageFileURL = 'loadimage.html?file='+ImageName+'='+ImageExt;
  ImageWindow = open(ImageFileURL,'ImageWindow','titlebar=no,toolbar=no,status=yes,scrollbars=no,width=730,height=500,top=0,left=0');
 }



/*  Function for loading images into a specific file  */
/*  Used for Battles, 100 Killz Klub f.e.  */

function openImageWindow(ImageName,ImageExt)
 {
  ImageFileURL = 'loadimage.html?file='+ImageName+'='+ImageExt;
  ImageWindow = open(ImageFileURL,'ImageWindow','titlebar=no,toolbar=no,status=yes,scrollbars=no,width=680,height=540,top=0,left=0');
 }



/*  Function for checking field entries  */
/*  Used for application form (Enlist section)  */

function chkApplForm()
 {
  if(document.Application.callsign.value == "")
   {
    alert("Form incomplete. Enter your callsign.");
    document.Application.callsign.focus();
    return false;
   }
  if(document.Application.firstname.value == "")
   {
    alert("Form incomplete. Enter your first name.");
    document.Application.firstname.focus();
    return false;
   }
  if(document.Application.lastname.value == "")
   {
    alert("Form incomplete. Enter your last name.");
    document.Application.lastname.focus();
    return false;
   }
  if(document.Application.age.value == "")
   {
    alert("Form incomplete. Enter your age.");
    document.Application.age.focus();
    return false;
   }
  var chkZ = 1;
  for(i=0;i<document.Application.age.value.length;++i)
   if(document.Application.age.value.charAt(i) < "0"
   || document.Application.age.value.charAt(i) > "9")
    chkZ = -1;
  if(chkZ == -1)
   {
    alert("Wrong input for 'Age'. Age contains numbers only.");
    document.Application.age.focus();
    return false;
   }
  if(document.Application.hometown.value == "")
   {
    alert("Form incomplete. Enter your hometown (including state and country).");
    document.Application.hometown.focus();
    return false;
   }
  if(document.Application.mail.value == "")
   {
    alert("Form incomplete. Enter your e-mail address.");
    document.Application.mail.focus();
    return false;
   }
  if(document.Application.mail.value.indexOf('@') == -1)
   {
    alert("Invalid e-mail address entered. Enter your valid e-mail address.");
    document.Application.mail.focus();
    return false;
   }
  if(document.Application.icq.value == "")
   {
    alert("Form incomplete. Enter your ICQ number.");
    document.Application.icq.focus();
    return false;
   }
  var chkZ = 1;
  for(i=0;i<document.Application.icq.value.length;++i)
   if(document.Application.icq.value.charAt(i) < "0"
   || document.Application.icq.value.charAt(i) > "9")
    chkZ = -1;
  if(chkZ == -1)
   {
    alert("Wrong input. ICQ contains numbers only.");
    document.Application.icq.focus();
    return false;
   }
  if(document.Application.timezone.value == "invalid_choice")
   {
    alert("Wrong input for 'Time Zone'. Choose the time zone you live in.");
    document.Application.timezone.focus();
    return false;
   }
  if(document.Application.password.value == "")
   {
    alert("Form incomplete. Enter a password.");
    document.Application.password.focus();
    return false;
   }
  if(document.Application.primary_weapon.value == "invalid_choice")
   {
    alert("Wrong input for 'Primary Weapon'. Choose your primary weapon.");
    document.Application.primary_weapon.focus();
    return false;
   }
  if(document.Application.other_squad.value == "invalid_choice")
   {
    alert("Wrong input for 'Are you already in a Delta Force squad?'. Choose your answer.");
    document.Application.other_squad.focus();
    return false;
   }
  if(document.Application.cpu.value == "")
   {
    alert("Form incomplete. Enter CPU type and speed.");
    document.Application.cpu.focus();
    return false;
   }
  if(document.Application.ram.value == "")
   {
    alert("Form incomplete. Enter amount of RAM.");
    document.Application.ram.focus();
    return false;
   }
  if(document.Application.internet_conn.value == "")
   {
    alert("Form incomplete. Enter your internet connection type and speed.");
    document.Application.internet_conn.focus();
    return false;
   }
  if(document.Application.terms_and_conditions.value == "")
   {
    alert("Form incomplete. Accept the Terms and Conditions in order to apply for membership in =1FS=. Read regulations first.");
    document.Application.termsandconditions.focus();
    return false;
   }
 }



/*  Function for checking field entries  */
/*  Used for declare war form (Declare War section)  */

function chkDeclareWarForm()
 {
  if(document.DeclareWar.contactperson.value == "")
   {
    alert("Form incomplete. Enter the contact person's callsign.");
    document.DeclareWar.contactperson.focus();
    return false;
   }
  if(document.DeclareWar.contactperson_mail.value == "")
   {
    alert("Form incomplete. Enter the contact person's e-mail address.");
    document.DeclareWar.contactperson_mail.focus();
    return false;
   }
  if(document.DeclareWar.contactperson_mail.value.indexOf('@') == -1)
   {
    alert("Invalid e-mail address entered. Type in the contact person's valid e-mail address.");
    document.DeclareWar.contactperson_mail.focus();
    return false;
   }
  if(document.DeclareWar.contactperson_icq.value == "")
   {
    alert("Form incomplete. Enter the contact person's ICQ number.");
    document.DeclareWar.contactperson_icq.focus();
    return false;
   }
  var chkNumber = 1;
  for(i=0;i<document.DeclareWar.contactperson_icq.value.length;++i)
   if(document.DeclareWar.contactperson_icq.value.charAt(i) < "0"
   || document.DeclareWar.contactperson_icq.value.charAt(i) > "9")
    chkNumber = -1;
  if(chkNumber == -1)
   {
    alert("Wrong input. ICQ contains numbers only.");
    document.DeclareWar.contactperson_icq.focus();
    return false;
   }
  if(document.DeclareWar.squadleader.value == "")
   {
    alert("Form incomplete. Enter the squad leader's callsign.");
    document.DeclareWar.squadleader.focus();
    return false;
   }
  if(document.DeclareWar.squadname.value == "")
   {
    alert("Form incomplete. Type in your squad name.");
    document.DeclareWar.squadname.focus();
    return false;
   }
  if(document.DeclareWar.squad_website.value == "")
   {
    alert("Form incomplete. Type in the URL of your squad web site.");
    document.DeclareWar.squad_website.focus();
    return false;
   }
  if(document.DeclareWar.detachment.value == "invalid_choice")
   {
    alert("Wrong input. Choose the =1FS= team you want to challenge.");
    document.DeclareWar.detachment.focus();
    return false;
   }
  if(document.DeclareWar.game.value == "invalid_choice")
   {
    alert("Wrong input. Choose the game.");
    document.DeclareWar.game.focus();
    return false;
   }
  if(document.DeclareWar.squadsize.value == "invalid_choice")
   {
    alert("Wrong input. Choose the squad size for the battle.");
    document.DeclareWar.squadsize.focus();
    return false;
   }
  if(document.DeclareWar.number_of_games.value == "invalid_choice")
   {
    alert("Wrong input. Choose number of games to be played.");
    document.DeclareWar.number_of_games.focus();
    return false;
   }
  if(document.DeclareWar.kill_limit.value == "invalid_choice")
   {
    alert("Wrong input. Choose the kill limit for the game.");
    document.DeclareWar.kill_limit.focus();
    return false;
   }
  if(document.DeclareWar.time_limit.value == "invalid_choice")
   {
    alert("Wrong input. Choose the time limit for the game.");
    document.DeclareWar.time_limit.focus();
    return false;
   }
  if(document.DeclareWar.gamehost.value == "invalid_choice")
   {
    alert("Wrong input. Choose the host for the battle.");
    document.DeclareWar.gamehost.focus();
    return false;
   }
 }



/*  Function for checking field entries  */
/*  Used for contact form (Contact page)  */

function chkContact()
 {
  if(document.Contact.name_callsign.value == "")
   {
    alert("Form incomplete. Enter your name and/or callsign.");
    document.Contact.name_callsign.focus();
    return false;
   }
  if(document.Contact.topic.value == "invalid_choice")
   {
    alert("Wrong input. Choose a topic for contact.");
    document.Contact.topic.focus();
    return false;
   }
  if(document.Contact.comments.value == "")
   {
    alert("Form incomplete. Enter details/comments for your topic.");
    document.Contact.comments.focus();
    return false;
   }
 }
