var responseWin_HEIGHT = 250;
var responseWin_WIDTH  = 400;

// ================================================================= wrapperResponse

function wrapperResponse(url, title)
{
 var longURL = url;
 var shortURL = url.substring((url.lastIndexOf('/') + 1));
 
 surveyHTML = surveyHTML.replace( /%__docTitle__%/g,    title    );	
 surveyHTML = surveyHTML.replace( /%__docShortURL__%/g, shortURL );
 surveyHTML = surveyHTML.replace( /%__docLongURL__%/g,  longURL  );
  
  var y = (screen.availHeight - responseWin_HEIGHT)/2;
  var x = (screen.availWidth - responseWin_WIDTH)/2;
  
  // for big resolutions cut width in half
  if (screen.availWidth > 1800){ x = ((screen.availWidth/2) - responseWin_WIDTH)/2; };
  
  var winProperties = "scrollBars=no,toolbar=no,resizeable=yes,status=no,width=" + responseWin_WIDTH + ",height=" + responseWin_HEIGHT + ",screenX=" + x + ",screenY=" + y + ",top=" + y + ",left=" + x;
    
  // pop survery
  var responseWin = window.open("", "responseWin", winProperties);
  window.self.focus(); // hide pop up
  window.location.href = url;
  responseWin.document.open();
  responseWin.document.write(surveyHTML);
  responseWin.document.close();
};


// ================================================================= changeLinks

function changeLinks()
{
	if(window.old_onload != null){ window.old_onload(); };
 
  	for(var i=0; i < document.links.length; i++)
    	{
      	if((document.links[i].hostname.indexOf("download.intel") != -1)||(document.links[i].name == "survey"))
			{
		  	var download_href = document.links[i].href;
	  	  	document.links[i].href = "javascript:wrapperResponse('" + download_href + "', '" + document.title + "');";
			};
    	};
};

window.old_onload = window.onload; // catch existing event handlers
window.onload = changeLinks;     // onload event

 


// ================================================================= survey HTML
// preload these images first
var preloadLogo = new Image();
preloadLogo.src = "http://www.intel.com/design/shared/pix/intelLogoSm.gif"
var preloadSpacer = new Image();
preloadSpacer.src = "http://www.intel.com/design/shared/pix/spacer.gif"


var surveyHTML = new String();
surveyHTML += "<html>";
surveyHTML += "<head topmargin='0' leftmargin='0' marginwidth='0' marginheight='0'>";
surveyHTML += "<title>Intel Collateral Survey</title>";
surveyHTML += "</head>";
surveyHTML += "<body topmargin='0' leftmargin='0' marginheight='0' marginwidth='0'>";
surveyHTML += "<FORM NAME='collateralSurvey' ACTION='https://process.imdreportbuilder.com/process2.asp' METHOD='POST'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='BUSINESS_NAME' VALUE='%__docTitle__%'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='EMAIL_ADDRESS' VALUE='%__docShortURL__%'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='COMMENTS' VALUE='%__docTitle__% : %__docShortURL__% : %__docLongURL__%'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='FIRST_NAME' VALUE='Collateral'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='LAST_NAME' VALUE='Survey'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='JOB_TITLE' VALUE='red'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='ADDRESS_LINE_1' VALUE='blue'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='CITY' VALUE='orange'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='STATE' VALUE='green'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='POSTAL_CODE' VALUE='000000'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='COUNTRY' VALUE='yellow'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='BUSINESS_PHONE_NBR' VALUE='violet'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='FAX_NUMBER' VALUE='indigo'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='Promotion_ID' VALUE='L2X05'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='Form_Code' VALUE='WEB'>";
surveyHTML += "<INPUT TYPE='hidden' NAME='resultURL' VALUE='http://www.intel.com/design/shared/surveys/surveyClose.htm'>";
surveyHTML += "<table border='0' cellpadding='0' cellspacing='0' width='398'>";
surveyHTML += "<tr><td colspan='4'><img src='/design/shared/pix/spacer.gif' alt='' border='0' height='10' width='1'></td></tr>";
surveyHTML += "<tr><td>&nbsp;</td><td colspan='3'><img src='http://www.intel.com/design/shared/pix/intelLogoSm.gif' alt='' border='0' width='43' height='22'><br><img src='http://www.intel.com/design/shared/pix/spacer.gif' alt='' border='0' height='3' width='43'></td></tr>";
surveyHTML += "<tr><td colspan='4' bgcolor='#0000ff'>&nbsp;</td></tr>";
surveyHTML += "<tr><td width='10'><img src='http://www.intel.com/design/shared/pix/spacer.gif' alt='' border='0' height='3' width='1'></td><td valign='top' colspan='3'>&nbsp;<br><span style='font-family: arial, sans-serif; font-size: 14px; font-weight: bold;'>Was this information helpful to you?</span><br>&nbsp;<br></td></tr>";
surveyHTML += "<tr><td width='10'><img src='http://www.intel.com/design/shared/pix/spacer.gif' alt='' border='0' height='3' width='1'></td><td valign='top' style='font-family: arial, sans-serif; font-size: 12px;'>This is what I was looking for:</td><td width='10'>&nbsp;</td><td valign='top' style='font-family: arial, sans-serif; font-size: 12px;'><input type='radio' name='MOM_883' value='883A'> Yes &nbsp;&nbsp;<input type='radio' name='MOM_883' value='883B'> No</td></tr>";
surveyHTML += "<tr><td colspan='4'>&nbsp;</td></tr>";
surveyHTML += "<tr><td width='10'><img src='http://www.intel.com/design/shared/pix/spacer.gif' alt='' border='0' height='3' width='1'></td><td valign='top' style='font-family: arial, sans-serif; font-size: 12px;'>This information was easy to locate:</td><td width='10'><img src='http://www.intel.com/design/shared/pix/spacer.gif' alt='' border='0' height='3' width='1'></td><td valign='top' style='font-family: arial, sans-serif; font-size: 12px;'><input type='radio' name='MOM_884' value='884A'> Yes &nbsp;&nbsp;<input type='radio' name='MOM_884' value='884B'> No</td></tr>";
surveyHTML += "<tr><td colspan='4'>&nbsp;<br>&nbsp;<br></td></tr>";
surveyHTML += "<tr><td colspan='4' align='right'><input type='submit' value='Close Window'>&nbsp;</td></tr>";
surveyHTML += "</table>";
surveyHTML += "</form>";
surveyHTML += "</span>";
surveyHTML += "</body>";
surveyHTML += "<script type='text/javascript'>";
surveyHTML += "var id = window.setTimeout('window.self.focus()', 3000);";
surveyHTML += "</script>";
surveyHTML += "</html>";
