//********************************************************
//BNAYNI SOFTWARE
//Copyright 2001 Chris Daniel, I guess
//********************************************************

function OpenPage(url)			//Currently not used, but probably should be...
{
  window.open(url);
}

function GetLevel(PageLevel)		//This is used for URLs (mainly images). Think relativity :-)
{
  if (PageLevel == 3)
    {level = "http://hosted.planetquake.gamespy.com/";}
  if (PageLevel == 2)
    {level = "http://hosted.planetquake.gamespy.com/";}
  if (PageLevel == 1)
    {level = "http://hosted.planetquake.gamespy.com/";}
  if (PageLevel == 0)
    {level = "";}

}

function ItemStart(BoldCaption, Caption)			//This should be used for displaying just about all content
{

  document.write("<table width='100%' bgcolor='#666666' cellpadding='1' cellspacing='1'>")
  document.write(" <tr>")
  document.write("  <td class='ItemTitleBar'>")
  document.write("<b>" + BoldCaption + "</b>" + Caption + "</a></td>")
  document.write(" </tr>")
  document.write("</table>")
  document.write("<table width='100%' cellpadding='0' cellspacing='0'>")
  document.write(" <tr>")
  document.write("  <td bgcolor='#666666' width='1'></td>")
  document.write("  <td width='2'></td>")
  document.write("  <td><font color='#FFFFFF' size='2'>")

}

function NewsItemStart(caption, date, poster)			//The only difference is a NewItem has a date and poster...
{

  document.write("<a name='" + caption + "'>")
  document.write("<table width='100%' bgcolor='#666666' cellpadding='1' cellspacing='1'>")
  document.write(" <tr>")
  document.write("  <td class='ItemTitleBar'>")
  document.write("<b>" + caption + "</b> - " + date + " - <a href='team/" + poster + ".html'>" + poster + "</a></td>")
  document.write(" </tr>")
  document.write("</table>")
  document.write("<table width='100%' cellpadding='0' cellspacing='0'>")
  document.write(" <tr>")
  document.write("  <td bgcolor='#666666' width='1'></td>")
  document.write("  <td width='2'></td>")
  document.write("  <td><font color='#FFFFFF' size='2'>")

}

function ItemEnd()
{
  document.write("  </td>")
  document.write("  <td bgcolor='#666666' width='1'></td>")
  document.write(" </tr>")
  document.write(" <tr>")
  document.write("  <td bgcolor='#666666' colspan='4' height='1'></td>")
  document.write(" </tr>")
  document.write(" <tr>")
  document.write("  <td colspan='4' height='10'></td>")
  document.write(" </tr>")
  document.write("</table>")
}



//************************IMAGES*****************************

function OpenImg(image, ImgTitle)
{

  NewWindow=open("", "displayWindow", 				//This is a big ol' hack so that whenever a thumbnail
    "width=512,height=384,status=no,toolbar=no,menubar=no");	//is clicked, even if there was already an image window
  NewWindow.close();						//open it will always gain focus and be on top

  NewWindow=open("", "displayWindow", 
    "width=512,height=384,status=no,toolbar=no,menubar=no");

  // open document for further output
  NewWindow.document.open();
  
  // create document
  NewWindow.document.write("<html><head><title>" + ImgTitle + "</title></head>\n");
  NewWindow.document.write("<body background='#333333' leftmargin='0' topmargin='0'>");
  NewWindow.document.write("<center><img src='" + image + "' WIDTH=512></CENTER>\n");
  NewWindow.document.write("</body></html>");

  // close the document - (not the window!)
  NewWindow.document.close();
}

function Thumbnail(width, thumbnail, image, ImgTitle)
{
  if (ImgTitle == "No Image")			//If there's no image (it's showing the static image)
  {						//then don't let them click on it!
    document.write("<img src='" + thumbnail + "' width='" + width + "' border='0'>");
  }
  else
  {
    document.write("<A onClick='OpenImg(" + '"' + image + '", "' + ImgTitle + '"' + ");'><img src='" + thumbnail + "' width='" + width + "' border='0'></a>");
  }
}



//**********************************************************
//PAGE LAYOUT STUFF
//These are functions that are used to "draw" all of
//the common page elements (everything other than the
//content of each page - the Header, Footer, NavBar, anything else)
//**********************************************************

//********************Stupid Ad Banner**********************

function AdBanner()
{
now = new Date(); 
random = now.getTime();
clickurl = "/accipiter/adclick.html/CID=00004429b354751a00000000/SITE=PQ/AAMSZ=IAB_FULL_BANNER/AREA=HOSTED";
imageurl = "http://ad.doubleclick.net/ad/N763.mplayer.com/B47184.3;sz=468x60;ord=";

  document.write("<table width='640' cellpadding='0' cellspacing='0'>")
  document.write(" <tr>")
  document.write("  <td colspan='5' bgcolor='#666666' height='1'></td>")
  document.write(" </tr>")
  document.write(" <tr>")
  document.write("  <td bgcolor='#666666' width='1'></td>")
  document.write("  <td bgcolor='#000000' width='85'></td>")
  document.write('<td><a href="'+ clickurl +'?'+ random +'" target="_top"><img src="'+ imageurl +'?'+ random +'" width=468 height=60 border=0></a></td>');
  document.write("  <td bgcolor='#333333' width='85'></td>")
  document.write("  <td bgcolor='#666666' width='1'></td>")
  document.write(" </tr>")
  document.write(" <tr>")
  document.write("  <td colspan='5' bgcolor='#666666' height='1'></td>")
  document.write(" </tr>")
  document.write("</table>")
  document.write("<table><tr><td height='6'></td></tr></table>")	//A bit of space before the site
}

//**********************************************************

function Header(level)
{
  AdBanner();

  document.write("<table width='640' cellpadding='0' cellspacing='0'>")
  document.write(" <tr>")
  document.write("  <td colspan='3' bgcolor='#666666' height='1'></td>")
  document.write(" </tr>")
  document.write(" <tr>")
  document.write("  <td bgcolor='#666666' width='1'></td>")
  document.write("  <td bgcolor='#333333'><img src='" + level + "siteimages/title.jpg'></td>")
  document.write("  <td bgcolor='#666666' width='1'></td>")
  document.write(" </tr>")
  document.write(" <tr>")
  document.write("  <td colspan='3' bgcolor='#666666' height='1'></td>")
  document.write(" </tr>")
  document.write("</table>")
}

function NavTitle(text)
{
  document.write("<table width='100%' cellpadding='0' cellspacing='0'><tr><td height='20' valign='middle'>")
  document.write("&nbsp" + text + "</td></tr></table>")
}

function NavButton(level, text, link)
{
  GetLevel(level);

  document.write("<table width='100%' background='" + level + "siteimages/buttonbg1.gif' cellpadding='0' cellspacing='0'>")
  document.write("<tr><td height='20' valign='middle'>&nbsp")


  if (text == "Forum")					//This is needed because the Forum link is an outside
  {							//link - the url is NOT relative to the current page's location
    document.write("<a href='" + link + "'>" + text + "</a></td></tr></table>")
  }
  else
  {
    document.write("<a href='" + level + link + "'>" + text + "</a></td></tr></table>")
  }
}

function NavBar(level)
{
 NavTitle("Site")
//  NavButton(level, "Main Page", "index.html")
  NavButton(level, "Recent News", "index-2.html")
  NavButton(level, "News Archive", "NewsArchive.html")
  NavButton(level, "Forum", "http://network54.com/Hide/Forum/101334")
  NavButton(level, "Links", "Links.html")
 NavTitle("Quake: Bnayni")
  NavButton(level, "About", "bnayni/About.html")
  NavButton(level, "Story", "bnayni/Story.html")
  NavButton(level, "Features", "bnayni/Features.html")
  NavButton(level, "Screenshots", "bnayni/Screenshots.html")
  NavButton(level, "Files", "bnayni/Files.html")
 NavTitle("The Bnayni Team")
  NavButton(level, "DaZ", "team/DaZ.html")
  NavButton(level, "Hawkeye", "team/Hawkeye.html")
  NavButton(level, "Jester", "team/Jester.html")
  NavButton(level, "Necros", "team/Necros.html")
  NavButton(level, "Sacred", "team/Sacred.html")
  NavButton(level, "Open Positions", "team/OpenPositions.html")
 NavTitle("")
}

function ContentStart()
{
  document.write("<table width='100%' cellpadding='0' cellspacing='0'>")
  document.write(" <tr>")						//
  document.write("  <td colspan='3' height='10'></td>")			//Adds some space between the header and Contents
  document.write(" </tr>")						//
  document.write(" <tr>")
  document.write("  <td width='8'></td>")				//Adds some space between the NavBar and Contents
  document.write("  <td>")
}

function ContentEnd()
{
  document.write("  </td>")
  document.write(" </tr>")
  document.write("</table>")
}

function Footer(level)
{

  document.write("<table width='640' cellpadding='0' cellspacing='0'>")
  document.write(" <tr>")
  document.write("  <td colspan='4' bgcolor='#666666' height='1'></td>")
  document.write(" </tr>")
  document.write(" <tr>")
  document.write("  <td bgcolor='#666666' width='1'></td>")
  document.write("  <td bgcolor='#303030' background='" + level + "siteimages/footer.jpg' height='20' width='394'>")
  document.write("   &nbspCopyright © 2001 Bnayni Software</td><td bgcolor='#333333'></TD>")
  document.write("  <td bgcolor='#666666' width='1'></td>")
  document.write(" </tr>")
  document.write(" <tr>")
  document.write("  <td colspan='4' bgcolor='#666666' height='1'></td>")
  document.write(" </tr>")
  document.write("</table>")

}

//*****************(This is a semibreak hehe)**************************

function PageLayoutStart(PageLevel)
{
  GetLevel(PageLevel);	

  Header(level);							//The Header is a whole table by itself

  document.write("<table width='640' cellpadding='0' cellspacing='0'>")	//The NavBar and Content are all in one table
  document.write(" <tr><td bgcolor='#666666' width='1'></td>")		//The thin (width=1) line left of the NavBar
  document.write("  <td bgcolor='#666666' width='120' valign='top'>")	//This starts the NavBar cell

  NavBar(level);							//The NavBar has it's own table inside the cell

  document.write("<center><img src='http://counter.gamespy.com/countisapi.dll?trgb=000000&amp;ft=0&amp;df=pqstaticsoftwaremain.dat&amp;dd=E'><br><br></center>")

  document.write("  </td>")						//This ends the NavBar cell
  document.write("  <td bgcolor='#2A2A2A' width='1'></td>")		//The thin line right of the NavBar
  document.write("  <td valign='top'>")					//The Content table will go in this cell

  ContentStart();							//The Content has it's own table in the cell
}

function PageLayoutEnd(PageLevel)
{
  GetLevel(PageLevel);

  ContentEnd();								//End the Content's table

//  document.write("</td>")						//...I think this is not needed anymore...
//
  document.write("  </td>")						//This bit simply ends the table
  document.write(" </tr>")						//that the NavBar and Contents
  document.write("</table>")						//tables are in

  Footer(level);							//The footer has it's own table by itself
}


