// Global variables

var isupplyCaseReason = new Array("","ASN or promise or receipt","Inventory", "Kanban", "EDI messaging","Forecast", "User login or admin", "Alert", "Lean Logistics LLN","Dynamic Min/Max DMM", "Other", "Question");
var isupplyQ = new Array( new Array(""),
new Array("Buyer name","Supplier name","Part number(s)","Vendor code","Ship ID or packing slip","ASN creation date and time","ASN creation type (manual, EDI, data feed)"),
new Array("Buyer name","Supplier name","Part number(s)","Vendor code","Inventory level in ERP","Inventory level in i-Supply"),
new Array("Buyer name","Supplier name","Part number(s)","Vendor code","Date and time issue occurred"),
new Array("Buyer name","Supplier name","Part number(s)","Vendor code","DUNS number","EDI type (856/DESADV, 830/DELFOR, or 862/DELJIT)","Ship ID or packing slip (for 856/DESADV)","Last date and time you received EDI data"),
new Array("Buyer name","Supplier name","Part number(s)","Vendor code","Forecast schedule (daily or weekly)","Forecast level in ERP","Forecast level in i-Supply"),
new Array("Company name","User name"),
new Array("Buyer name","Supplier name","Part number(s)","Vendor code","Alert type","Sample of alert notification (if available)"),
new Array("Buyer name","Supplier name","Part number(s)","Vendor code","PickUp time","Snapshot or order Time"),
new Array("Buyer name","Supplier name","Vendor code","Agent name"),
new Array("Buyer name","Supplier name","Vendor code"),
new Array(""));



var gtmCaseReason = new Array("","Report","EDI messaging","User login or admin","Problem","Other","Question");
var gtmQ = new Array(new Array(""),
new Array("Report name","Report location"),
new Array("EDI type","EDI date and time"),
new Array("User name","User role"),
new Array(""),
new Array(""),
new Array(""));


function setPageOptions() {
removeEle();

var reason = document.getElementById("00N300000017L9q");
var product = document.getElementById("00N30000000rgrT");
var productIdx = product.selectedIndex;
var reasonIdx = reason.selectedIndex;

//i-Supply is selected
if(productIdx == 0)
loadisupplyReason();

//GTM product is selected
else
loadGTMReason();
//setQuestions();
}

function removeEle() {
var ni = document.getElementById("tobemodify");
var old = document.getElementById("questions");
if(old != null)
ni.removeChild(old);
}

function loadGTMReason() {
var reason = document.getElementById("00N300000017L9q");
reason.options.length = 0;

for(var i = 0; i< gtmCaseReason.length; i++)
{
reason.options[i] = new Option(gtmCaseReason[i], gtmCaseReason[i]);
}
}

function loadisupplyReason() {
var reason = document.getElementById("00N300000017L9q");
reason.options.length = 0;

for(var i = 0 ; i< isupplyCaseReason.length; i++)
{
reason.options[i] = new Option(isupplyCaseReason[i], isupplyCaseReason[i]);
}
}



function setQuestions() {
removeEle();

var reason = document.getElementById("00N300000017L9q");
var product = document.getElementById("00N30000000rgrT");

var productIdx = product.selectedIndex;
var reasonIdx = reason.selectedIndex;

var ni = document.getElementById("tobemodify");
var newLabel = document.createElement("div");

newLabel.setAttribute("id","questions");

var questions = "Please provide the following information in the description field below:<br>";

if(productIdx == 0) //isupply
{
for (var i = 0 ; i < isupplyQ[reasonIdx].length; i++)
{
questions += isupplyQ[reasonIdx][i];
questions +="<br>";
}

if(isupplyQ[reasonIdx].length == 1)
{
questions = "";
}
else
{
questions +="<br>";
}

newLabel.innerHTML = questions;
ni.appendChild(newLabel);

}
else //GTM products
{
for (var i = 0 ; i < gtmQ[reasonIdx].length; i++)
{
questions += gtmQ[reasonIdx][i];
questions +="<br>";

}
if(gtmQ[reasonIdx].length == 1)
questions = "";
else
questions +="<br>";

newLabel.innerHTML = questions;
ni.appendChild(newLabel);
}


}
