// Detects whether reg or pub document and displays floating feedback with 
// according reactions to low bingo scores (1-3).
// This version is for the floating feedback on the right side of the document.

// name this window
window.name = "cco_main";
window.focus();

var f = document.feedback;
var SearchStg = '/public/';
var SearchPatt  = new RegExp(SearchStg);
var dURL = document.URL;


var droadMap = getMeta('roadMap');  // Added by Akhilesh (akmoghe) on 09/21/2005
var dPawsId   = getMeta('document.id'); // Added by Akhilesh (akmoghe) on 09/21/2005

// get the right form URL by checking the document URL: returns either cgi-bin or pcgi-bin version
if (dURL.match(SearchPatt)) {
	//formUrl = "http://www.cisco.com/pcgi-bin/fbdash/survey_submit.pl";
	//formUrl = "http://www.cisco.com/pcgi-bin/front.x/Support/FBDataCollector/survey_submit.pl" //Fields version
        formUrl = "http://www.cisco.com/pcgi-bin/front.x/feedbk/survey_submit.pl";
	updateUrl = "/public/news_training/whats_hot.shtml";
}
else {
	//formUrl = "http://www.cisco.com/cgi-bin/fbdash/survey_submit.pl";
	//formUrl = "http://www.cisco.com/cgi-bin/front.x/Support/FBDataCollector/survey_submit.pl" //Fields version
          formUrl = "http://www.cisco.com/cgi-bin/front.x/feedbk/survey_submit.pl";
	updateUrl = "/kobayashi/news_training/whats_hot.shtml";
}

// Execute on the onClick event for the button named Send so that the thanks window gets opened to the right size.
function openWindow() {

	var f = document.feedback;
	var windowUrl;
	var windowPar;
	
	if ((f.scale_711[2].checked == true) || (f.scale_711[3].checked == true) || (f.scale_711[4].checked == true)) {
	windowUrl = "/public/support/feedback/blank.html";
	windowPar = "scrollbars=yes,width=500,height=400,left=50,top=50";
	}
	else {
	windowUrl = "/public/support/feedback/thanks_stay.html";
	windowPar = "scrollbars=yes,width=300,height=170,left=200,top=200";
	}
	
	window.open(	windowUrl,
			"thanks",
			windowPar)
}

// Sets parameters for the form hidden elements, required for script execution
function setParams() {

	var SearchStg = '/public/';
	var SearchPatt = new RegExp(SearchStg);
	var dURL = document.URL;
	var f = document.feedback;

// Looks at the entitlement of the form, based on URL, and sets appropriate "Additional Resources" page URL
if ((f.scale_711[2].checked == true) || (f.scale_711[3].checked == true) || (f.scale_711[4].checked == true)) {
	if (dURL.match(SearchPatt)) { 
		f.redirect_url.value = "/public/support/feedback/need_help.html";
	}
	else {
   		f.redirect_url.value = "/kobayashi/support/feedback/need_help.html";
   	}
}
	
else { 
   f.redirect_url.value = "/public/support/feedback/thanks.html";
}
}

//Replaces quot marks in doc page title to prevent clipping

var pagetitle = document.title;
var re = /"/g;
pagetitle = pagetitle.replace(re,'(quote)');


function submitFeedback() {
// After all other processing, sends feedback and launches subsequent actions if it's the first submission
var f = document.feedback;

if (f.submitswitch.value == "false") {

openWindow();
setParams();
f.submit();
f.reset();
f.submitswitch.value="true";
}

else { 
alert('You have already submitted feedback. If you would like to make another submission, please click the Reload button.')
}
}

function lowScore() {
// Reminder window code..				

	var f = document.feedback;
	
if (((f.scale_711[3].checked == true) || (f.scale_711[4].checked == true)) && (f.text_713.value=='')) {
	windowUrl = "/public/support/feedback/reminder.html";
	windowPar = "scrollbars=yes,status=yes,width=300,height=170,left=200,top=200";
	
	window.open(	windowUrl,
			"reminder",
			windowPar)
}

else {
submitFeedback();
}
}

// Validates the form so that it won't submit without one of the first three elements filled out.
// Also launches reminder window if user rates 1 or 2 without comments

function validate() {

// Code only works on IE. This is a browser detect so Netscape ignores.

	var f = document.feedback;
	
if (document.all) {
					
rate=false;

if (f.text_713.value!='') rate=true;
					
for (i=0;i<5;i++) {
if (f.scale_711[i].checked) rate=true;
}
					
for (i=0;i<3;i++) {
if (f.choice_965[i].checked) rate=true;
}
														
if (!rate) {
alert('Please fill out at least one item before submitting.');
event.returnValue=false;
}

else {
lowScore();
}

}   
					
// For netscape...
else {
lowScore();
}

}


//Right-hand side format
document.writeln('<FORM ACTION=\"' + formUrl + '\" NAME=\"feedback\" METHOD=\"POST\" target=\"thanks\" onSubmit=\"return submitForm()\">');
document.writeln('  <TABLE WIDTH=\"130\" BORDER=\"0\" ALIGN=\"RIGHT\" CELLPADDING=\"8\" CELLSPACING=\"0\">');
document.writeln('    <tr>');
document.writeln('      <td> <a href=\"' + updateUrl + '\"><font face=\"Arial, Helvetica, sans-serif\" size=\"-1\"><b>TAC ');
document.writeln('        Notice:</b> What\'s Changing on TAC Web</font></a></td>');
document.writeln('    </tr>');
document.writeln('    <tr>');
document.writeln('      <td>&nbsp;</td>');
document.writeln('    </tr>');
document.writeln('    <TR>');
document.writeln('      <TD>');
document.writeln('        <TABLE BORDER=\"0\" BGCOLOR=\"#CCCCFF\" CELLSPACING=\"1\" CELLPADDING=\"0\">');
document.writeln('          <TR ALIGN=\"CENTER\">');
document.writeln('            <TD>');
document.writeln('              <TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"2\" BGCOLOR=\"#FFFFFF\">');
document.writeln('                <TR>');
document.writeln('                  <TD>');
document.writeln('                    <TABLE BORDER=\"0\" CELLSPACING=\"2\" CELLPADDING=\"0\" WIDTH=\"100%\">');
document.writeln('                      <TR ALIGN=\"CENTER\">');
document.writeln('                        <TD NOWRAP><FONT FACE=\"Arial, Helvetica, sans-serif\" COLOR=\"#333399\"><B><FONT SIZE=\"-1\">Help');
document.writeln('                          us help you.</FONT></B></FONT> </TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD ><IMG SRC=\"/images/blank.gif\" WIDTH=\"6\" HEIGHT=\"6\"></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD BGCOLOR=\"#CCCCFF\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><IMG SRC=\"/images/spacer-ltblue.gif\" WIDTH=\"4\" HEIGHT=\"1\"></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR BGCOLOR=\"#CCCCFF\">');
document.writeln('                        <TD ><FONT FACE=\"Verdana, Arial, Helvetica, sans-serif\" SIZE=\"-2\"><B>Please rate');
document.writeln('                          this document.</B></FONT></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD BGCOLOR=\"#CCCCFF\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><IMG SRC=\"/images/spacer-ltblue.gif\" WIDTH=\"4\" HEIGHT=\"1\"></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD ALIGN=\"LEFT\" VALIGN=\"TOP\">');
document.writeln('                          <TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">');
document.writeln('                            <TR>');
document.writeln('                              <TD>');
document.writeln('                                <INPUT TYPE=\"radio\" NAME=\"scale_711\" VALUE=\"5\">');
document.writeln('                              </TD>');
document.writeln('                              <TD><FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"-2\">Excellent</FONT></TD>');
document.writeln('                            </TR>');
document.writeln('                            <TR>');
document.writeln('                              <TD>');
document.writeln('                                <INPUT TYPE=\"radio\" NAME=\"scale_711\" VALUE=\"4\">');
document.writeln('                              </TD>');
document.writeln('                              <TD><FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"-2\">Good</FONT></TD>');
document.writeln('                            </TR>');
document.writeln('                            <TR>');
document.writeln('                              <TD>');
document.writeln('                                <INPUT TYPE=\"radio\" NAME=\"scale_711\" VALUE=\"3\">');
document.writeln('                              </TD>');
document.writeln('                              <TD><FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"-2\">Average</FONT></TD>');
document.writeln('                            </TR>');
document.writeln('                            <TR>');
document.writeln('                              <TD>');
document.writeln('                                <INPUT TYPE=\"radio\" NAME=\"scale_711\" VALUE=\"2\">');
document.writeln('                              </TD>');
document.writeln('                              <TD><FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"-2\">Fair</FONT></TD>');
document.writeln('                            </TR>');
document.writeln('                            <TR>');
document.writeln('                              <TD>');
document.writeln('                                <INPUT TYPE=\"radio\" NAME=\"scale_711\" VALUE=\"1\">');
document.writeln('                              </TD>');
document.writeln('                              <TD><FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"-2\">Poor</FONT></TD>');
document.writeln('                            </TR>');
document.writeln('                          </TABLE>');
document.writeln('                        </TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD ><IMG SRC=\"/images/blank.gif\" WIDTH=\"6\" HEIGHT=\"6\"></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD BGCOLOR=\"#CCCCFF\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><IMG SRC=\"/images/spacer-ltblue.gif\" WIDTH=\"4\" HEIGHT=\"1\"></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR BGCOLOR=\"#CCCCFF\">');
document.writeln('                        <TD ><FONT FACE=\"Verdana, Arial, Helvetica, sans-serif\" SIZE=\"-2\"><B>This document');
document.writeln('                          solved my problem.</B></FONT></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD BGCOLOR=\"#CCCCFF\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><IMG SRC=\"/images/spacer-ltblue.gif\" WIDTH=\"4\" HEIGHT=\"1\"></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD ALIGN=\"LEFT\" VALIGN=\"TOP\">');
document.writeln('                          <TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">');
document.writeln('                            <TR>');
document.writeln('                              <TD>');
document.writeln('                                <INPUT TYPE=\"hidden\" NAME=\"choice_965_description\" VALUE=\"This doc solved my problem(2015=yes,2016=no,2017=browsing)\">');
document.writeln('                                <INPUT TYPE=\"radio\" NAME=\"choice_965\" VALUE=\"2015\">');
document.writeln('                              </TD>');
document.writeln('                              <TD><FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"-2\">Yes</FONT></TD>');
document.writeln('                            </TR>');
document.writeln('                            <TR>');
document.writeln('                              <TD>');
document.writeln('                                <INPUT TYPE=\"radio\" NAME=\"choice_965\" VALUE=\"2016\">');
document.writeln('                              </TD>');
document.writeln('                              <TD><FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"-2\">No</FONT></TD>');
document.writeln('                            </TR>');
document.writeln('                            <TR>');
document.writeln('                              <TD>');
document.writeln('                                <INPUT TYPE=\"radio\" NAME=\"choice_965\" VALUE=\"2017\">');
document.writeln('                              </TD>');
document.writeln('                              <TD><FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"-2\">Just browsing</FONT></TD>');
document.writeln('                            </TR>');
document.writeln('                          </TABLE>');
document.writeln('                        </TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD ALIGN=\"LEFT\" VALIGN=\"TOP\"><IMG SRC=\"/images/blank.gif\" WIDTH=\"6\" HEIGHT=\"6\"></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD BGCOLOR=\"#CCCCFF\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><IMG SRC=\"/images/spacer-ltblue.gif\" WIDTH=\"4\" HEIGHT=\"1\"></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR BGCOLOR=\"#CCCCFF\">');
document.writeln('                        <TD ALIGN=\"LEFT\" VALIGN=\"TOP\"><FONT FACE=\"Verdana, Arial, Helvetica, sans-serif\" SIZE=\"-2\"><B>Suggestions');
document.writeln('                          for improvement:</B></FONT></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD BGCOLOR=\"#CCCCFF\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><IMG SRC=\"/images/spacer-ltblue.gif\" WIDTH=\"4\" HEIGHT=\"1\"></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD ALIGN=\"LEFT\" VALIGN=\"TOP\"><FONT SIZE=\"-2\" FACE=\"Arial, Helvetica, sans-serif\">');
document.writeln('                          <TEXTAREA NAME=\"text_713\" ROWS=\"5\" COLS=\"14\" WRAP=\"virtual\" MAXLENGTH=\"256\"></TEXTAREA><BR>');
document.writeln('                          &nbsp;(256 character limit)</FONT><INPUT TYPE=\"hidden\" NAME=\"syzygy\" VALUE=\"108\"></TD>');
document.writeln('                      </TR>');

// display name and email fields if public
if (dURL.match(SearchPatt)) {

document.writeln('                      <TR>');
document.writeln('                        <TD ALIGN=\"LEFT\" VALIGN=\"TOP\"><IMG SRC=\"/images/blank.gif\" WIDTH=\"6\" HEIGHT=\"6\"></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD BGCOLOR=\"#CCCCFF\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><IMG SRC=\"/images/spacer-ltblue.gif\" WIDTH=\"4\" HEIGHT=\"1\"></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR BGCOLOR=\"#CCCCFF\">');
document.writeln('                        <TD ALIGN=\"LEFT\" VALIGN=\"TOP\"><FONT FACE=\"Verdana, Arial, Helvetica, sans-serif\" SIZE=\"-2\"><B>Optional');
document.writeln('                          contact information:</B></FONT></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD BGCOLOR=\"#CCCCFF\" ALIGN=\"LEFT\" VALIGN=\"TOP\"><IMG SRC=\"/images/spacer-ltblue.gif\" WIDTH=\"4\" HEIGHT=\"1\"></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD ALIGN=\"LEFT\" VALIGN=\"TOP\"> <FONT SIZE=\"-2\" FACE=\"Arial, Helvetica, sans-serif\">');
document.writeln('                          Name: <INPUT TYPE=\"text\" NAME=\"name\" SIZE=\"14\" MAXLENGTH=\"80\"><BR>');
document.writeln('				<IMG SRC=\"/images/blank.gif\" WIDTH=\"6\" HEIGHT=\"4\"><BR>');
document.writeln('                          Email: <INPUT TYPE=\"text\" NAME=\"email\" SIZE=\"14\" MAXLENGTH=\"80\"></FONT></TD>');
document.writeln('                      </TR>');
}

document.writeln('                      <TR>');
document.writeln('                        <TD><IMG SRC=\"/images/blank.gif\" WIDTH=\"10\" HEIGHT=\"10\"></TD>');
document.writeln('                      </TR>');
document.writeln('                      <TR>');
document.writeln('                        <TD ALIGN=\"CENTER\">');
document.writeln('                          <input type=\"hidden\" NAME=\"doc_title\" VALUE=\" ' + pagetitle + '\">');
document.writeln('                          <input type=\"hidden\" NAME=\"doc_url\" VALUE=\" ' + document.URL + '\">');
document.writeln('                          <input type=\"hidden\" NAME=\"referrer_url\" VALUE=\" ' + document.referrer + '\">');
document.writeln('                          <input type=\"hidden\" name=\"feedback_type\" value=\"1\">');
//document.writeln('                          <input type=\"hidden\" name=\"survey_id\" value=\"' + sid + '\">');
document.writeln('                          <input type=\"hidden\" name=\"iocontext\" value=\"PAWS\">'); //Added this value for cco document
document.writeln('                          <input type=\"hidden\" NAME=\"roadMap\" VALUE=\" ' + droadMap + '\">');
document.writeln('                          <input type=\"hidden\" NAME=\"PawsId\" VALUE=\" ' + dPawsId + '\">');

// If Output Interpreter flag is on, this adds an extra email address and Templates field.
	var email2;
	var oiFlag;

	if (email2 == null) {
		email2 = '';
	}
	
	else {
document.writeln('			    <input type=\"hidden\" name=\"Templates\" value=\"' + oiFlag + '\">');
	}
	
//document.writeln('                          <input type=\"hidden\" name=\"email_notification\" value=\"' + email + ',' + email2 + ',feedback2tacweb\">');
//document.writeln('                          <input type=\"hidden\" name=\"email_notification\" value=\"' + email + ',feedback2tacweb\">');
document.writeln('                          <input type=\"hidden\" name=\"redirect_url\" value=\"\">');
document.writeln('			    <input type=\"hidden\" name=\"format\" value=\"right\">');
document.writeln('			    <input type=\"hidden\" name=\"submitswitch\" value=\"false\">');
document.writeln('                          <font size="\-1\" face=\"Arial, Helvetica, sans-serif\"><input type=\"button\" NAME=\"send\" VALUE=\"Send\" onClick=\"validate();\"></font>');
document.writeln('                        </TD>');
document.writeln('                      </TR>');
document.writeln('                    </TABLE>');
document.writeln('                  </TD>');
document.writeln('                </TR>');
document.writeln('              </TABLE>');
document.writeln('            </TD>');
document.writeln('          </TR>');
document.writeln('        </TABLE>');
document.writeln('      </TD>');
document.writeln('    </TR>');
document.writeln('  </TABLE>');
document.writeln('  </FORM>');

// Added by Akhilesh (akmoghe) on 09/21/2005
function getMeta (k) {
	try
   {
   var metaArray = document.getElementsByName(k);
	var v=metaArray[0].content;
	
   var dTyp= getMeta('docType');
   }
   catch(Exception)
   {
      return 'UNKNOWN';
   }
	return v;	
}
