// Survey Popunder, Cookie Verification and Modal Display

//Removes red "x" in IE on missing images
function ImageLoadFailed() {
window.event.srcElement.style.display = "none";
}

//specify page to pop-under
var popunder="http://i-way.org/Surveys/site_feedback_c"

//specify popunder window features
//set 1 to enable a particular feature, 0 to disable
var winfeatures="width=850,height=710,scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0"

function loadpopunder(){
win2=window.open(popunder,"",winfeatures)
win2.blur()
window.focus()
}

function SetCookie() {
if(arguments.length < 2) { return; }
var n = arguments[0];
var v = arguments[1];
var d = 0;
if(arguments.length > 2) { d = parseInt(arguments[2]); }
var exp = '';
if(d > 0) {
	var now = new Date();
	then = now.getTime() + (d * 24 * 60 * 60 * 1000);
	now.setTime(then);
	exp = '; expires=' + now.toGMTString();
	}
document.cookie = n + "=" + escape(String(v)) + '; path=/' + exp;
} // function SetCookie()

function ReadCookie(n) {
var cookiecontent = new String();
if(document.cookie.length > 0) {
	var cookiename = n+ '=';
	var cookiebegin = document.cookie.indexOf(cookiename);
	var cookieend = 0;
	if(cookiebegin > -1) {
		cookiebegin += cookiename.length;
		cookieend = document.cookie.indexOf(";",cookiebegin);
		if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
		cookiecontent = document.cookie.substring(cookiebegin,cookieend);
		}
	}
return unescape(cookiecontent);
} // function ReadCookie()
// &mdash;>


function CheckCookie() {
var surveyCookie = ReadCookie("I-way Consumer Survey Date");

if(surveyCookie !="") {
}
else {
	SetCookie("I-way Consumer Survey Date", "Asked", 30);
    $(function() {
		$("#survey_box").overlay({

			expose: 'black',
			top: 60,
			closeOnClick: false,
			load: true
	
	});
	});
}
}
//function CHeckCookie ().  If cookie exists, does nothing.  If cookie !exist, prompts user for survey options
window.onload = CheckCookie;
