﻿/*
** Written by Andrew Dunn
**
** Goal is to intect new buttons into the Standard Toolbar
** These buttons will link to customized forms that display
** Less information that the standard editform, hopefully 
** Processing will be faster on the slimmed down forms
**
*/

/* 
** Variable Setup
** Links are hard coded here
** if something is broken, look here first
*/
// Grab the records ID from the html parameters of the page
var iD = this.getUrlParameter("ID");

// Grab the records Source from html parameters of the page (this will allow the form, on submission, to track back to the users original state)
var source = this.getUrlParameter("Source");

// The Toolbar ID is specific to the page, it is hardcoded here
var tableID = "ctl00_m_g_a216b286_3eee_4c05_9b6e_08f9ce8b5ecb_ctl00_ctl01_ctl00_toolBarTbl";

// Due to the size of the new 'buttons' and the need for more in the future I am now pushing them into their own row.
var table = document.getElementById(tableID);

// Create a new row to bump down the existing buttons, OUR buttons will take precedence!
table.insertRow(0);

// Get the new row ready to be piped.
var toolbarRow = table.rows[0];

// The row is fresh so the node numbering starts at zero
var nodeNumber = 0;

// Variables for each button
var informationFlowLogo = "http://prod.servername.intranet.local/resources/img/sharepoint/icons/informationFlow_edit.png";
var informationFlowLink = "http://prod.servername.intranet.local/sites/arch/lists/Customized%20List/EditFormInformationFlow.aspx?ID=";
var informationFlowText = "Edit Information Flow";

var businessLogo = "http://prod.servername.intranet.local/resources/img/sharepoint/icons/coins.png";
var businessLink = "http://prod.servername.intranet.local/sites/arch/lists/Customized%20List/EditFormBusiness.aspx?ID=";
var businessText = "Edit Business";

var contactLogo = "http://prod.servername.intranet.local/resources/img/sharepoint/icons/group.png";
var contactLink = "http://prod.servername.intranet.local/sites/arch/lists/Customized%20List/EditFormContacts.aspx?ID=";
var contactText = "Edit Contacts";

var developerLogo = "http://prod.servername.intranet.local/resources/img/sharepoint/icons/script.png";
var developerLink = "http://prod.servername.intranet.local/sites/arch/lists/Customized%20List/EditFormDeveloper.aspx?ID=";
var developerText = "Edit Developer";

var techLogo = "http://prod.servername.intranet.local/resources/img/sharepoint/icons/server.png";
var techLink = "http://prod.servername.intranet.local/sites/arch/lists/Customized%20List/EditFormTechnology.aspx?ID=";
var techText = "Edit Technology";

var documentLogo = "http://prod.servername.intranet.local/resources/img/sharepoint/icons/report.png";
var documentLink = "http://prod.servername.intranet.local/sites/arch/lists/Customized%20List/EditFormDocuments.aspx?ID=";
var documentText = "Edit Documents";

var planningLogo = "http://prod.servername.intranet.local/resources/img/sharepoint/icons/chart_curve.png";
var planningLink = "http://prod.servername.intranet.local/sites/arch/lists/Customized%20List/EditFormPlanning.aspx?ID=";
var planningText = "Edit Planning";


//Push the buttons into the toolbar ( tableRow, logoUrl, linkUrl, linkText, nodeNumber )
addButton ( toolbarRow, informationFlowLogo, informationFlowLink, informationFlowText, nodeNumber++ );
addSeperator ( toolbarRow, nodeNumber++ );
addButton ( toolbarRow, businessLogo, businessLink, businessText, nodeNumber++ );
addSeperator ( toolbarRow, nodeNumber++ );
addButton ( toolbarRow, contactLogo, contactLink, contactText, nodeNumber++ );
addSeperator ( toolbarRow, nodeNumber++ );
addButton ( toolbarRow, developerLogo, developerLink, developerText, nodeNumber++ );
addSeperator ( toolbarRow, nodeNumber++ );
addButton ( toolbarRow, techLogo, techLink, techText, nodeNumber++ );
addSeperator ( toolbarRow, nodeNumber++ );
addButton ( toolbarRow, documentLogo, documentLink, documentText, nodeNumber++ );
addSeperator ( toolbarRow, nodeNumber++ );
addButton ( toolbarRow, planningLogo, planningLink, planningText, nodeNumber++ );


//Now we have to do some hacking to the toolbar because we have one too many buttons,  FIRST Remove  the New Item button
table.rows[1].deleteCell(0);

//Remove the Verticle Bar
table.rows[1].deleteCell(0);

//Remove the Edit Button
table.rows[1].deleteCell(0);

//Remove the Verticle Bar
table.rows[1].deleteCell(0);

//Now the bottom row is all screwed up, so rip out the last cell
table.rows[1].deleteCell(7);


//Now add some empty cells to balance top to bottom
table.rows[1].insertCell(7);
table.rows[1].insertCell(8);
table.rows[1].insertCell(9);
table.rows[1].insertCell(10);
table.rows[1].insertCell(11);
table.rows[1].insertCell(12);

//Now we should add far right cells that will expand to push the buttons left. to both rows
this.bufferCell = table.rows[0].insertCell(nodeNumber++);
this.bufferCell.setAttribute("class", "ms-toolbar");
this.bufferCell.setAttribute("width", "99%");

this.bufferCell = table.rows[1].insertCell(13);
this.bufferCell.setAttribute("class", "ms-toolbar");
this.bufferCell.setAttribute("width", "99%");

//Hack over, breath.
