// JavaScript Document
var objWin;
var objBack;
var SurveyURL;

function ShowSurveyWindow() {
	var outHTML;

	SurveyURL = "http://www.expertscan.autodata.com/Default.aspx?webid=16430F3F-BDF4-4228-9351-98F45E92B329"
//	SurveyURL = "/includes/survey.asp"

	outHTML = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
	outHTML += "<tr><td colspan=\"2\" style=\"height: 100px; font-size: 28pt; font-weight: bold; vertical-align: middle; text-align: left; padding: 6px;\">Complete a short survey and be entered to win an iPod Nano</td></tr>"
	outHTML += "<tr><td colspan=\"2\" style=\"height: 70px; font-size: 16pt; font-family: Arial Narrow; vertical-align: middle; text-align: left; padding: 6px;\">Community Care Physicians wants to hear from you.  Please click below to complete a short survey.  It will only take a few minutes.</td></tr>"
	outHTML += "<tr align=\"center\" ><td style=\"height: 75px; background-color: gray;\">"
	outHTML += "<a href=\".\" onclick=\"RunSurvey(1)\" style=\"text-decoration: none;\"><div style=\"color: silver; background-color: black; border: 4px solid silver; width: 150px; height: 30px; font-weight: bold; font-size: 16pt; padding-top: 8px; \">Take survey</div></a>"
	outHTML += "</td><td style=\"height: 75px; background-color: gray; \">"
	outHTML += "<a href=\".\" onclick=\"RunSurvey(0)\" style=\"text-decoration: none;\"><div style=\"color: silver; background-color: black; border: 4px solid silver; width: 150px; height: 30px; font-weight: bold; font-size: 16pt; padding-top: 8px; \">No thanks</div></a>"
	outHTML += "</td></tr>"
	outHTML += "<tr align=\"right\"><td colspan=\"2\" style=\"background-color: gray; height: 15px; \"><a href=\"OnlineCommTerms.asp\" style=\"color: white; font-size: 10pt; text-decoration: none; padding-right: 5px;\" target=\"_blank \">Click here for online communication terms and conditions</a></td></tr>"
	outHTML += "</table>"

	if (document.getElementById) {
		objWin = document.getElementById("ShowSurvey");
		objBack = document.getElementById("SurveyBack");
	}
	else if (document.all) {
		objWin = document.all("ShowSurvey");
		objBack = document.all("SurveyBack");
	}
	else if (document.layers) {
		objWin = document.layers("ShowSurvey");
		objBack = document.layers("SurveyBack");
	}

	with (objWin.style) {
		fontSize = "14pt";
		fontFamily = "Arial";
		color = "#a21f4b";
		fontWeight = "bold";
		height = "250px";
		width = "600px";
		backgroundColor = "white";
		verticalAlign = "top";
	}

		objBack.align = "center";
		with (objBack.style) {
			position = "absolute";
			left = "0px";
			top = "0px";
			backgroundColor = "silver";
		}
	
	if (GetBrowserVer.indexOf("MSIE 6") == -1) {
		setOpacity(objBack, 90);
		with (objBack.style) {
			height = "100%";
			width = "100%";
		}

//	setOpacity(objWin, 95);
		with (objWin.style) {
			position = "relative";
			top = "225px";
		}
	}
	else {
		document.getElementById("JumpTo").style.display = "none";
		with (objBack.style) {
			paddingTop = "250px";
			height = screen.availHeight;
			width = screen.availWidth;
		}
		
		setOpacity(objBack, 95);

//		setOpacity(objWin, 95);
		with (objWin.style) {
			top = "250px";
		}
	}

	objWin.innerHTML = outHTML
}

function RunSurvey(flag) {
	var xmlhttp;
	var btnClicked;
	var TodayIs;
	
	TodayIs = new Date();

	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else {// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}

	if (flag==1) {
		window.open(SurveyURL, "CCPSurvey", "menubar=no, resizable=yes, scrollbars=yes, status=no, toolbar=no");
		btnClicked = "btn=Y&recdate" + TodayIs;
	}
	else {
		btnClicked = "btn=N&recdate=" + TodayIs;
	}
	
//alert("1: " + btnClicked);
//xmlhttp.onreadystatechange = function() {
//alert("Now: " + xmlhttp.status + " " + xmlhttp.readyState);
//alert(xmlhttp.responseText);
//}
	xmlhttp.open("POST","SurveyResult.asp",true);
	xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xmlhttp.send(btnClicked);
//alert("Wait: " + xmlhttp.readyState);

	objBack.style.visibility = "hidden";
}
