var Survey = function(){
	this.survey = {
		actionURL: "http://mhe.daytondailynews.com/survey/intercept.php",
		formMethod: "POST",
		heading: "Thank you for your feedback",
		summary1: "What do you think of the new Classified/Deals section?",
		options1: [
					['like', 'I like it. It\'s easier to navigate and has more relevant content.'],
					['hate', 'I don\'t like it. Bring back the old Classified/Deals section.'], 
					['neutral', 'I don\'t have a strong opinion.']
				 ],
		summary2: "How often did you visit the old Classified/Deals section?",
		options2: [
					['daily', 'Daily'],
					['weekly', 'Weekly'], 
					['monthly', 'Monthly']
				 ],
		comments: "Is there anything else you would like to see in this section?",
		submit: "Submit survey and leave",
		cancel: "Cancel"
	},
	this.trigger = function (event) {
		// Tint live page
		var myTint = document.createElement("div");
		myTint.setAttribute('id', 'myTint');
		if(document.all) {
			myTint.style.filter = "alpha(opacity=80)";
		} else {
			myTint.style.MozOpacity = 80/100;
		}
		myTint.innerHTML = '<br />';
		document.body.appendChild(myTint);
		
		// Add intercept box
		var myIntercept = document.createElement("div");
		myIntercept.setAttribute('id', 'myIntercept');
		var myInterceptHTML = '<form action="'+this.survey.actionURL+'" method="'+this.survey.formMethod+'">';
			myInterceptHTML+= '<h3 style="font-weight:normal;font-size:1.5em;">'+this.survey.heading+'<\/h3>';
			myInterceptHTML+= '<p style="font-weight:bold;">'+this.survey.summary1+'<\/p>';
			for(var i=0;i<this.survey.options1.length;i++)
			{
				myInterceptHTML+= '<p onclick="this.getElementsByTagName(\'input\')[0].checked=true;"><input type="radio" name="question1" value="'+this.survey.options1[i][0]+'" \/> '+this.survey.options1[i][1]+'<\/p>';
			}
			myInterceptHTML+= '<p style="font-weight:bold;">'+this.survey.summary2+'<\/p>';
			myInterceptHTML+= '<p>';
			for(var i=0;i<this.survey.options2.length;i++)
			{
				myInterceptHTML+= '<input type="radio" name="question2" value="'+this.survey.options2[i][0]+'" \/>'+this.survey.options2[i][1]+' &nbsp; ';
			}
			myInterceptHTML+= '<\/p>';
			myInterceptHTML+= '<p style="padding-top:10px;font-weight:bold;">'+this.survey.comments+'<\/p>';
			myInterceptHTML+= '<p><textarea style="font-family:arial;font-size:12px;padding:3px;width:90%;height:50px;" name="comments"><\/textarea><\/p>';
			myInterceptHTML+= '<input type="hidden" name="hostname" value="www.daytondailynews.com" \/>';
			myInterceptHTML+= '<p><input type="submit" style="font-weight:bold;" value="'+this.survey.submit+'" \/> <input type="button" value="'+this.survey.cancel+'" onclick="location.href=location.referrer" \/><\/p>';
			myInterceptHTML+= '<\/form>';
		myIntercept.innerHTML = myInterceptHTML;
		document.body.appendChild(myIntercept);
		scroll(0,0);
	}
};


