// FEEDBACK FORM
// 23rd November 2006 - Updated with apostrophe stripper. MG 
// 04th September 2007 - Stripper added for double quotes and for email section. MG
// 09th April 2008 - Spelling correction of 'use' to 'us'.  

// Line Writer Function
function Line(string) {
feedbackWindow.document.write(string);
}

// Page Feedback Control.
function Feedback() {

// Get values from page launching feedback
var Project = top.window.document.title;
var PageTitle = document.title;
var PageFile = document.location.href; 
var PageDate = document.lastModified;
var Browser =  navigator.appName;
var Version = navigator.appVersion;

//Strip Apostrophes
Project = Project.split("'").join("");
Project = Project.split('"').join('');
PageTitle=PageTitle.split("'").join("");
PageTitle = PageTitle.split('"').join('');

// Open Feedback Form Window
feedbackWindow = window.open('','feedbackWin','toolbar=no,location=no,scrollbars=yes,resizable=yes,width=500,height=500');

// Write Feedback Form into Window
Line('<html><head><style>');
Line('BODY {font-family: Verdana, Arial, sans-serif; background-color: #ffffff;}');
Line('H1 {font-weight: bold;font-size: 12pt;color: #cc0000;}');
Line('P,INPUT,TEXTAREA,PRE {font-size: 8pt; margin-top: 5pt; margin-bottom: 5pt;}');
Line('</style><title>Knowledge Base Feedback Form</title></head><body>');
Line('<h1>Knowledge Base Feedback</h1>');
Line('<p>We welcome your feedback and comments to improve and correct our documentation. Use the <b>Email Form</b> button to contact us. Alternatively print this form and use the contact information below to fax or post it to us. </p>');

Line('<center><form name="theForm">');
Line('<p><textarea cols="60" rows="10" name="Comment">Enter your comments here.</textarea><br>');
// Transfer Form to Email Button
Line('<input type="button" value="Email Form" onClick="mailMessage();">');

// Print Form Button
Line('<input type="button" value="Print Form" onClick="javascript:window.print();">');
Line('</p></form></center>');

// Construct Email in Form
Line('<script language="JavaScript" type="text/javascript">');
Line('var Mail = \'wgctechpubs@avaya.com\';');
Line('var eBrowser = navigator.appName;');
Line('var eVersion = navigator.appVersion;');
Line('var eProject = \'' + Project + '\';');
Line('var ePageTitle = \'' + PageTitle + '\';');
Line('var ePageFile = \'' + PageFile + '\';');
Line('var ePageDate = \'' + PageDate + '\';');
Line('var EmailAlert = \'This button should open an email into which you can add your feedback. However this is not supported on all PCs. If you receive a warning message or the email does not appear, please print the form and fax or post it to us.\';');

// Convert Current Form to Mail URL
Line('function mailMessage() {');
// Andy.A's stripper
Line('var eNote = document.theForm.Comment.value;');
Line('eNote = eNote.split("\'").join("");');
Line("eNote = eNote.split('\"').join('');");
Line('var Subject = \'?Subject=Knowledge Base\';');
Line('var Body = \'&Body=\';');
Line('var Body = Body + \'%0A%0D Comment = \' + eNote;');
Line('var Body = Body + \'%0A%0D Project = \' + eProject;');
Line('var Body = Body + \'%0A%0D Page = \' + ePageTitle;');
Line('var Body = Body + \'%0A%0D File = \' + ePageFile; ');
Line('var Body = Body + \'%0A%0D File Date = \' + ePageDate;');
Line('var Body = Body + \'%0A%0D Browser =  \' + eBrowser;');
Line('var Body = Body + \'%0A%0D Version = \' + eVersion;');
// Line('alert(EmailAlert);');
Line('location.href = "mailto:" + Mail + Subject + Body;');
Line('}');
Line('</script>');

// Contact Info
Line('<p><b>Contact</b></p>');
Line('<table><tr>');
Line('<td valign="top"><ul><li><p>Fax: +44 1707 364442</p></li>');
Line('<li><p>Email: wgctechpubs@avaya.com</p></li>');
Line('</ul></td><td valign="top"><ul><li><p>Avaya<br>');
Line('Avaya Technical Publications<br>');
Line('Unit 1, Sterling Court<br>');
Line('15-21 Mundells<br>');
Line('Welwyn Garden City<br>');
Line('Hertfordshire<br>');
Line('AL7 1LZ<br>');
Line('United Kingdom</p></li></ul>');
Line('</td></tr></table><p>&nbsp;</p>');

// Page Info
Line('<p><b>Details:</b><br>');
Line('These details will help us identify and resolve problems. If you select <b>Email Form</b>, these details and your comments are automatically copied to the email. </p><ul>'); 
Line('<li><p>Project = ' + Project + '<br>');
Line('PageTitle = ' + PageTitle + '<br>');
Line('File = ' + PageFile + '<br>');
Line('File Date = ' + PageDate + '<br>');
Line('Browser = ' + navigator.appName + '<br>');
Line('Browser Version = ' + navigator.appVersion + '</p></li>');
Line('</ul></p>');

//Finish Writing Feedback Form
Line('</body></html>');
feedbackWindow.document.theForm.Comment.focus();
feedbackWindow.document.close();
}
