/****************
 * versasec.js
 * Javascript functions for fomatting versasec.com pages
 ****************/

/**
 * Column width helper functions
 * @param int colNum - col number
 * @param boolean handheld - optional if not provided -> false
 * @return int - column width
 */
function cw(colNum)
{
  return cw(colNum, false);
}
function cw(colNum, handheld)
{
  if (1==colNum){
    return (handheld? 0: 119);
  }else if (2==colNum){
    return (handheld? 114: 375);
  }else if (3==colNum){
    return (handheld? 72: 72);
  }else if (4==colNum){
    return (handheld? 214: 214);
  }else{
    return 0;
  }
}

/**
 * Get social networking links
 * @return String
 */
function getSocial()
{
	  rvSC = "<a href=\"http://twitter.com/versasec\" target=\"twitter\"><img src=\"/img/twitter.16.png\" alt=\"twitter\" border=\"0\" /></a>"
    + "<a href=\"http://www.linkedin.com/company/versatile-security\" target=\"linkedin\"><img src=\"/img/linkedin.16.png\" alt=\"Linked in\" border=\"0\" /></a>"
    + "<a href=\"http://slideshare.net/versasec\" target=\"slideshare\"><img src=\"/img/slideshare.16.png\" alt=\"slideshare\" border=\"0\" /></a>"
    + "<a href=\"http://www.youtube.com/versatilesecurity\" target=\"youtube\"><img src=\"/img/youtube.16.png\" alt=\"youtube\" border=\"0\" /></a>"
    + "<a href=\"http://www.facebook.com/versasec\" target=\"facebook\"><img src=\"/img/facebook.16.png\" alt=\"facebook\" border=\"0\" /></a>"
    + "<g:plusone size=\"small\" count=\"false\"></g:plusone>";
    return rvSC;
}

/**
 * Top navigation helper function
 * @param boolean handheld - if handheld or not
 * @return String - top navigation links as string
 */
function topNavS(handheld)
{
  rvSC = "<p style=\"word-spacing: 15px;\">"
    + " <a style=\"text-decoration: none\" href=\"/index.html\"><span class=\"TopNav\">Home</span></a>"
    + " <a style=\"text-decoration: none\" href=\"/products.html\"><span class=\"TopNav\">Products</span></a>"
    + " <a style=\"text-decoration: none\" href=\"/services.html\"><span class=\"TopNav\">Services</span></a>"
    + " <a style=\"text-decoration: none\" href=\"/support.html\"><span class=\"TopNav\">Support</span></a>"
    + " <a style=\"text-decoration: none\" href=\"/company.html\"><span class=\"TopNav\">Company</span></a>"
    + " <a style=\"text-decoration: none\" href=\"/search.html\"><span class=\"TopNav\">Search</span></a>"
    + "&nbsp;</p>";
  rvHH = "<p style=\"word-spacing: 15px;\">"
    + " <a style=\"text-decoration: none\" href=\"/products.html\"><span class=\"TopNav\">Products</span></a>"
    + " <a style=\"text-decoration: none\" href=\"/services.html\"><span class=\"TopNav\">Services</span></a>"
    + " <a style=\"text-decoration: none\" href=\"/support.html\"><span class=\"TopNav\">Support</span></a>"
    + " <a style=\"text-decoration: none\" href=\"/company.html\"><span class=\"TopNav\">Company</span></a>&nbsp;</p>";
  return (handheld?rvHH:rvSC);
}


/**
 * Creates a formatted navigation link for level 2 menu 
 * @param String label - link label
 * @param String link - the actual linked document
 * @param String target - target window, optional
 * @return String - link line
 */
function sidenavLink(label, link)
{
  return sidenavLink(label, link, "");
}
function sidenavLink(label, link, target)
{
  return (" <a style=\"text-decoration: none\" href=\""+link+"\"" + (null==target || 1>target.length? "" : " target=\""+target+"\"") +"><span class=\"SubTopNav\">"+label+"</span></a>");
}

/**
 * Chat button
 * @return String
 */
function chatButtonS()
{
  rvSC = "<link href=\"http://chatserver.comm100.com/css/comm100_livechatbutton.css\" rel=\"stylesheet\" type=\"text/css\"/>"
+ "<div id=\"comm100_ChatButton\">"
+ " <div id=\"comm100_warp\">"
+ "  <div id=\"comm100_dvhelp\"><p style=\"word-spacing: 15px;\">"
+ "   <a class=\"comm100_ahelp_css\" href=\"http://www.comm100.com/livechat/\" onclick=\"comm100_Chat();return false;\" target=\"_blank\" title=\"Live Chat Software for Website\">"
+ "    <img id=\"comm100_ButtonImage\" src=\"http://chatserver.comm100.com/BBS.aspx?siteId=45481&amp;planId=623&amp;partnerId=-1\" style=\"border:0px\" alt=\"Live Chat Software for Website\" />"
+ "   </a>&nbsp;</p>"
+ "   <script src=\"http://chatserver.comm100.com/js/LiveChat.js?siteId=45481&amp;planId=623&amp;partnerId=-1\" type=\"text/javascript\"></script>"
+ "  </div>"
+ " </div>"
+ "</div>";
  return rvSC;
}

/**
 * Writes the header of the document. Inlude side navigation links as needed.
 * Example 1, two links: mainHead(1, sidenavLink("Test1", "test1.html") + sidenavLink("Test2","test2.html"))
 * Example 2, no links: mainHead(2, "")
 * @param int contentCols - number of columns that content should be displayed in (1 or 2) 
 * @param String sidenavLinks - all links as a string - see sidenavLink() 
 */
function mainHead(contentCols, sideNavLinks)
{		 	
 document.writeln("<body leftmargin=\"0\" topmargin=\"0\" bottommargin=\"0\" rightmargin=\"0\" marginheight=\"0\" marginwidth=\"0\" bgcolor=\"#efefef\" link=\"#AC0000\" vlink=\"#AC0000\" alink=\"#FF0000\">");
 document.writeln(" <center>");
 document.writeln("  <table id=\"TMIDDLE\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\" height=\"100%\"><tr valign=\"top\"><td align=\"center\">");
 document.writeln("   <center>"); 
 document.writeln("    <table id=\"TMAIN\" width=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#ffffff\">");
 document.writeln("     <tr>");
 document.writeln("      <td id=\"screen\"><img src=\"/img/spacer.gif\" width=\""+cw(1)+"\" height=\"0\" alt=\"\"></td>");
 document.writeln("      <td id=\"screen\"><img src=\"/img/spacer.gif\" width=\""+cw(2, false)+"\" height=\"0\" alt=\"\"></td>");
 document.writeln("      <td id=\"handheld\"><img src=\"/img/spacer.gif\" width=\""+cw(2, true)+"\" height=\"0\" alt=\"\"></td>");
 document.writeln("      <td><img src=\"/img/spacer.gif\" width=\""+cw(3)+"\" height=\"0\" alt=\"\"></td>");
 document.writeln("      <td><img src=\"/img/spacer.gif\" width=\""+cw(4)+"\" height=\"0\" alt=\"\"></td>");
 document.writeln("     </tr>");
 // -- LOGO AND SPACING --
 document.writeln("     <tr id=\"screen\">");
 document.writeln("      <td rowspan=\"3\"><a href=\"/index.html\"><img border=\"0\" src=\"/img/vs.logo.gif\" width=\"119\" height=\"104\" alt=\"Versatile Security\"></a></td>");
 document.writeln("      <td colspan=\"3\"><img src=\"/img/spacer.gif\" width=\""+(cw(2, false)+cw(3)+cw(4))+"\" height=\"25\" alt=\"\"></td>");
 document.writeln("     </tr>");
 // -- TOP NAVIGATION (L1)  + CHAT (64x50) --
 document.writeln("     <tr id=\"screen\" valign=\"bottom\">");
 document.writeln("      <td colspan=\"2\" align=\"left\">"+topNavS()+"</td>");
 document.writeln("      <td colspan=\"1\" align=\"right\">"+chatButtonS()+"</td>");
 document.writeln("     </tr>");
 // -- "SIDE" NAVIGATION (L2) + SOCIAL (16) --
 document.writeln("     <tr id=\"screen\" valign=\"top\">");
 document.writeln("      <td colspan=\"2\" align=\"left\"><p style=\"word-spacing: 12px;\">"+sideNavLinks+"&nbsp;</p></td>");
 document.writeln("      <td colspan=\"1\" align=\"right\"><p style=\"word-spacing: 15px;\">"+getSocial()+"&nbsp;</p></td>");
 document.writeln("     </tr>"); 
 // -- HANDHELD VERSION --
 document.writeln("     <tr id=\"handheld\" valign=\"middle\">");
 document.writeln("      <td colspan=\"3\" align=\"right\">");
 document.writeln("       <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
 document.writeln("        <tr valign=\"bottom\">");
 document.writeln("         <td><a href=\"/index.html\"><img border=\"0\" src=\"/img/vs.logo.gif\" width=\"119\" height=\"104\" alt=\"Versatile Security\"></a></td>");
 document.writeln("         <td align=\"right\">"+topNavS(true)+"</td>");
 document.writeln("        </tr>");
 document.writeln("        <tr><td colspan=\"2\" align=\"right\"><p style=\"word-spacing: 15px;\">"+sideNavLinks+"&nbsp;</p></td></tr>");
 document.writeln("     </table></td></tr>");

 // -- GRAPHIC SECTION --
 document.writeln("     <tr id=\"screen\">");
 // -- SIDE NAVIGATION --
 document.writeln("      <td>");
 document.writeln("       <table id=\"TSIDENAV\" width=\""+cw(1)+"\" height=\"234\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\" background=\"/img/nav.bg.gif\">");
 document.writeln("        <tr valign=\"top\">");
 document.writeln("         <td align=\"left\">");
 //document.writeln(sideNavLinks);
 document.writeln("");           
 document.writeln("         </td>");
 document.writeln("        </tr>");
 document.writeln("       </table>");
 
 document.writeln("      </td>");
// -- MAIN IMAGE --
 document.writeln("      <td>");
 document.writeln("       <img src=\"/img/main.tbg.jpg\" width=\""+cw(2, false)+"\" height=\"234\" alt=\"\">");
 document.writeln("      </td>");
 document.writeln("      <td colspan=\"2\">");
 document.writeln("       <img src=\"/img/main.right.jpg\" width=\""+(cw(3)+cw(4))+"\" height=\"234\" alt=\"\">");
 document.writeln("      </td>");
 document.writeln("     </tr>");
 // -- SPACING --
 document.writeln("     <tr id=\"screen\">");
 document.writeln("      <td colspan=\"4\"><img src=\"/img/spacer.gif\" width=\""+(cw(1, false)+cw(2, false)+cw(3)+cw(4))+"\" height=\"20\" alt=\"\"></td>");
 document.writeln("     </tr>");
 document.writeln("     <tr valign=\"top\">");
 document.writeln("      <td id=\"screen\"><img src=\"/img/spacer.gif\" width=\"119\" height=\"302\" alt=\"\"></td>");
 document.writeln("      <td colspan=\"3\">");
 document.writeln("       <table id=\"TCONTENTPH\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#ffffff\">"); 
 // -- SIZE UP THE TABLE --
 document.writeln("        <tr>");
 document.writeln("         <td id=\"handheld\"><img src=\"/img/spacer.gif\" width=\"10\" height=\"0\" alt=\"\"></td>");
 if (2==contentCols)
 {
  
  document.writeln("        <td id=\"screen\"><img src=\"/img/spacer.gif\" width=\""+(cw(2, false)+cw(3)-10)+"\" height=\"0\" alt=\"\"></td>");
  document.writeln("        <td id=\"handheld\"><img src=\"/img/spacer.gif\" width=\""+(cw(2, true)+cw(3)-10)+"\" height=\"0\" alt=\"\"></td>");
  document.writeln("        <td><img src=\"/img/spacer.gif\" width=\"10\" height=\"0\" alt=\"\"></td>");
  document.writeln("        <td><img src=\"/img/spacer.gif\" width=\""+(cw(4)-10)+"\" height=\"0\" alt=\"\"></td>");
 }
 else
 {
  document.writeln("        <td id=\"screen\" colspan=\"3\"><img src=\"/img/spacer.gif\" width=\""+(cw(2, false)+cw(3)+cw(4)-10)+"\" height=\"0\" alt=\"\"></td>");
  document.writeln("        <td id=\"handheld\" colspan=\"3\"><img src=\"/img/spacer.gif\" width=\""+(cw(2, true)+cw(3)+cw(4)-10)+"\" height=\"0\" alt=\"\"></td>"); 
 }
 document.writeln("         <td><img src=\"/img/spacer.gif\" width=\"10\" height=\"0\" alt=\"\"></td>");
 document.writeln("        </tr>");
 document.writeln("        <tr valign=\"top\">"); 
 document.writeln("         <td id=\"handheld\"><img src=\"/img/spacer.gif\" width=\"10\" height=\"300\" alt=\"\"></td>");
 if (2==contentCols)
 {       
  document.writeln("        <td>"); 
 }
 else
 {
  document.writeln("        <td colspan=\"3\">");
 }
}

/**
 * Seperates the two columns in the content area.
 */
function contentColSeperator()
{
 document.writeln("</td><td></td><td>");
}

/**
 * Writes the footer of the document
 */
function mainFoot()
{
 document.writeln("          <br id=\"handheld\" />");	
 document.writeln("         </td>");
 document.writeln("         <td></td>");
 document.writeln("        </tr>");
 document.writeln("       </table>");   	
 document.writeln("      </td>");
 document.writeln("     </tr>");
 document.writeln("     <tr id=\"screen\">");
 document.writeln("      <td colspan=\"4\"><img src=\"/img/foot.shade.gif\" width=\""+(cw(1)+cw(2, false)+cw(3)+cw(4))+"\" height=\"24\" alt=\"\"></td>");
 document.writeln("     </tr>");
 document.writeln("     <tr>");
 document.writeln("      <td colspan=\"4\">");
 document.writeln("       <table id=\"TFOOT\" width=\"100%\" height=\"58\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\" background=\"/img/foot.bg.gif\">");
 document.writeln("        <tr valign=\"middle\">");
 document.writeln("         <td align=\"left\">");
   // -- FOOTER LINKS SCREEN --
 document.writeln("          <p id=\"screen\" style=\"margin-top: 0px; margin-bottom: 0px; word-spacing: 5px;\">");
 document.writeln("           <a style=\"text-decoration: none\" href=\"/contact.html\"><span class=\"FootLink\" alt=\"\">Contact Us</span></a>&nbsp;<span class=\"FootLink\">|</span>");
 document.writeln("           <a style=\"text-decoration: none\" href=\"/legal.html\"><span class=\"FootLink\" alt=\"\">Terms of Use &amp; Legal Information</span></a>&nbsp;<span class=\"FootLink\">|</span>");
 document.writeln("           <a style=\"text-decoration: none\" href=\"/privacy.html\"><span class=\"FootLink\" alt=\"\">Privacy Statement</span></a>&nbsp;<span class=\"FootLink\">|</span>");
 document.writeln("           <a style=\"text-decoration: none\" href=\"http://www.versasec.com/corporate/corporate_pki/Versatile_Security_Corporate_CA.der\" alt=\"\"><span class=\"FootLink\">Corporate Root Certificate</span></a></p>");
    // -- FOOTER LINKS HANDHELD --
 document.writeln("          <p id=\"handheld\" style=\"margin-top: 0px; margin-bottom: 0px; word-spacing: 5px;\">");
 document.writeln("           <a style=\"text-decoration: none\" href=\"/search.html\"><span class=\"FootLink\" alt=\"\">Search</span></a>&nbsp;<span class=\"FootLink\">|</span>");
 document.writeln("           <a style=\"text-decoration: none\" href=\"/legal.html\"><span class=\"FootLink\" alt=\"\">Legal</span></a>&nbsp;<span class=\"FootLink\">|</span>");
 document.writeln("           <a style=\"text-decoration: none\" href=\"/privacy.html\"><span class=\"FootLink\" alt=\"\">Privacy</span></a>&nbsp;<span class=\"FootLink\">|</span>");
 document.writeln("           <a style=\"text-decoration: none\" href=\"http://www.versasec.com/corporate/corporate_pki/Versatile_Security_Corporate_CA.der\" alt=\"\"><span class=\"FootLink\">Corporate Root Cert</span></a></p>");
 document.writeln("          <p style=\"margin-top: 0px; margin-bottom: 0px; \"> ");
 document.writeln("           <span class=\"Foot\">&#169;2007-2011 Versatile Security Sweden AB. All rights reserved.</span>");
 document.writeln("          </p>");
 document.writeln("         </td>");
 document.writeln("        </tr>");
 document.writeln("       </table>"); // END TFOOT
 document.writeln("      </td>");
 document.writeln("     </tr>");
 document.writeln("    </table>"); // END TMAIN 
 document.writeln("   </center>");
 document.writeln("  </td></tr></table>"); // END TMIDDLE 
 document.writeln(" </center>");
   // GOOGLE +1
 document.writeln(" <script type=\"text/javascript\" src=\"http://apis.google.com/js/plusone.js\"></script>");
   // GOOGLE ANALYTICS
 document.writeln(" <script type=\"text/javascript\">");
 document.writeln(" var _gaq = _gaq || [];");
 document.writeln(" _gaq.push(['_setAccount', 'UA-20104436-1']);");
 document.writeln(" _gaq.push(['_trackPageview']);");
 document.writeln(" (function() {");
 document.writeln("   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;");
 document.writeln("   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';");
 document.writeln("   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);");
 document.writeln(" })();");
 document.writeln(" </script>");
 document.writeln("</body>");
} 
 
