
if (typeof OTS_showingSurvey == 'undefined') {
	OTS_showingSurvey = 0;
}
var OTSSMGSurvey = {
	screener : null
};
OTSSMGSurvey.load = function() {
	if (!OTSSMGSurvey.isAllowed()) return;
	var n = parseInt(OTSSMGSurvey.getCookie('survey_visited_ext'));
	if (isNaN(n)) n = 0;
	if (n > 1) {
		OTSSMGSurvey.show();
	} else {
		n++;
	}
	//OTSSMGSurvey.setCookie('survey_visited_ext', n, 30);
	OTSSMGSurvey.setCookie('survey_visited_ext', n, 7);
}
OTSSMGSurvey.show = function() {
	if (OTS_showingSurvey == 1) return;
	OTSSMGSurvey.screener = document.createElement('div');
	OTSSMGSurvey.screener.style.background = '#ccc url(http://images.onthesnow.com/ots/images/survey_hdr_de.gif) no-repeat 0 0';
	OTSSMGSurvey.screener.style.border = '1px solid #999';
	OTSSMGSurvey.screener.style.margin = '0';
	OTSSMGSurvey.screener.style.padding = '55px 15px 15px 15px';
	OTSSMGSurvey.screener.style.display = 'block';
	OTSSMGSurvey.screener.style.float = 'none';
	OTSSMGSurvey.screener.style.position = 'absolute';
	OTSSMGSurvey.screener.style.top = '150px';
	OTSSMGSurvey.screener.style.left = '100px';
	OTSSMGSurvey.screener.style.zIndex = '1000';
	
	var x = document.createElement('a');
	x.href = '#';
	x.title = 'Close';
	x.style.background = '#fff';
	x.style.padding = '5px';
	x.style.position = 'absolute';
	x.style.top = '10px';
	x.style.right = '10px';
	x.innerHTML = '<img src="http://images.onthesnow.com/ots/images/icon_close.gif" alt="" border="0" />';
	x.onclick = function() {
		OTSSMGSurvey.hide();
	}
	OTSSMGSurvey.screener.appendChild(x);
	
	var o = document.createElement('iframe');
	o.src = 'http://www.zoomerang.com/Survey/WEB22BDEJCJDJY';
	o.style.width = '660px';
	o.style.height = '350px';
	o.style.background = '#fff';
	o.style.border = '1px solid #ccc';
	o.style.margin = '0';
	o.style.padding = '0 0 20px 0';
	o.style.display = 'block';
	o.style.float = 'none';
	o.setAttribute('frameBorder', '0');
	o.setAttribute('allowTransparency', 'false');
	o.setAttribute('scrolling', 'auto');
	OTSSMGSurvey.screener.appendChild(o);
	
	document.body.appendChild(OTSSMGSurvey.screener);
	
	OTSSMGSurvey.setCookie('survey_seen_ext', 'yes', 7);
	OTS_showingSurvey = 1;
}
OTSSMGSurvey.hide = function() {
	document.body.removeChild(OTSSMGSurvey.screener);
	OTSSMGSurvey.setCookie('survey_seen_ext', 'yes', 30);
}
OTSSMGSurvey.setCookie = function(n, v, l) {
	var d = new Date();
	var x = new Date(d.getTime() + (l * 24) * 3600 * 1000);
	document.cookie = n + '=' + v + ';expires=' + x.toGMTString() + ';path=/;';
}
OTSSMGSurvey.getCookie = function(n) {
	var c = document.cookie.match('(^|;) ?' + n + '=([^;]*)(;|$)');
	return (c) ? (unescape(c[2])) : null;
}
OTSSMGSurvey.isSeen = function() {
	return (OTSSMGSurvey.getCookie('survey_seen_ext') == 'yes');
}
OTSSMGSurvey.isRandom = function() { 
	var w = Math.floor(Math.random() * 1);
	return (w == 0);
}
OTSSMGSurvey.isAllowed = function() {
	//return (OTSSMGSurvey.isRandom() && !OTSSMGSurvey.isSeen());
	return (!OTSSMGSurvey.isSeen());
}
OTSSMGSurvey.addEvent = function(o, e, m) {
	if (o.addEventListener) {
		o.addEventListener(e, m, false);
	} else {
		o.attachEvent('on' + e, m);
	}
}
OTSSMGSurvey.addEvent(window, 'load', function() { 
	OTSSMGSurvey.load();
});

