﻿<!--

//This javascript displays a hidden div and will not
//ask the same user more than once to take a survey

var cookieName = "zetabidsurvey";
var surveyLocation ="http://vovici.com/wsb.dll/s/ce85g3742d";

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
   var nameEQ = name + "=";
   var ca = document.cookie.split(';');

     for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function doSurveyCheck() {
    var ranNum= Math.floor(Math.random()*100);
    //alert(ranNum);

    surveyQuestion = "1";

    //100% chance of being asked to take survey
    if (ranNum >= "0") {

		//see if user was already asked to take survey
		var x = readCookie(cookieName)
		if (x) {
			var y = readCookie(cookieName);
			if (y == "visit") {
			 surveyQuestion = "2";
			} else {
			 surveyQuestion = "3";
			}
		}

		  //if less than 2 times then survey
		  if ( (surveyQuestion < "3") ) {

				if (readCookie(cookieName) == "visit") {
				  createCookie(cookieName,'visit2',30);
				} else {
				  createCookie(cookieName,'visit',30);
				}
				writeDiv();
				showLayer('hidden');
			}
		 }
     }

function usrTookSurvey() {
  createCookie(cookieName,'visit2',30);
}

function focusOpener() {
	windowHandle = window.open(surveyLocation,'survey',  'toolbar=0, scrollbars=1, height=700, width=840');
 }

var isDHTML = 0;
var isLayers = 0;
var isAll = 0;
var isID = 0;

if (document.getElementById) {
	isID = 1;
	isDHTML = 1;
}
else {
	if (document.all) {
		isAll = 1;
		isDHTML = 1;
	}
	else {
		browserVersion = parseInt(navigator.appVersion);
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
			isLayers = 1;
			isDHTML = 1;
		}
	}
}

function findDOM(objectID,withStyle) {
	if (withStyle == 1) {
		if (isID) {
			return (document.getElementById(objectID).style);
		}
		else if (isAll) {
				return (document.all[objectID].style);
		}
		else {
			if (isLayers) {
				return (document.layers[objectID]);
			}
		}
	}
	else {
		if (isID) {
			return (document.getElementById(objectID));
		}
		else if (isAll) {
				return (document.all[objectID]);
		}
		else {
			if (isLayers) {
				return (document.layers[objectID]);
			}
		}
	}
}

function setClass(objectID, newClass) {
	var dom = findDOM(objectID, 0);
	dom.className = newClass;
}

// layer management
var layerRef = null;
if (isID) {
	layerRef = "document.getElementById";
}
if (isAll) {
	layerRef = "document.all";
}
if (isLayers) {
	layerRef = "document.layers";
}

var styleSwitch = ".style" //isNS4 ? "" : ".style";

// showLayer
function showLayer( layerName ) {
	if (isID) {
		eval(layerRef+'("'+layerName+'")'+styleSwitch+'.visibility="visible"');
	}
	else {
		eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
	}
}

// hideLayer
function hideLayer( layerName ) {
	if (isID) {
		eval(layerRef+'("'+layerName+'")'+styleSwitch+'.visibility="hidden"');
	}
	else {
		eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
	}
}

// changeStyle
function changeStyle( layerName, newStyle ) {
  eval(layerRef+'["'+layerName+'"].className="'+newStyle+'"');
}

function takeSurvey() {
	focusOpener();
	hideLayer('hidden');
 }

function doNotTakeSurvey() {
	javascript:void(hideLayer('hidden'));
 }

function writeDiv(){
  document.write('<div id="hidden" name="hidden" style="visibility:hidden;border:2px #007AAA solid; width:400px;height:175px; top:225px;left:500px;position:absolute;padding:10px;index:10;background-color:#FFFEEE;z-index:999;">');
  document.write('<div align="right"><a href="#" onClick="doNotTakeSurvey();">Close this window&nbsp;X</a></div>');
  document.write('<div align="right">&nbsp;<br></div>');
  document.write('<center><font color="black">');
  document.write("Zetabid would value your participation in a brief & confidential survey.");
  document.write("</font><br><br>");
  document.write('<a href="#" onClick="javascript:takeSurvey();usrTookSurvey();"><font color="#007AAA"> (I accept)</font></a>');
  document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
  document.write('<a href="#" onClick="doNotTakeSurvey();"><font color="#007AAA">(I decline)</font></a>');
  document.write("<br>");
  document.write('</center>');
  document.write('</div>');
}

//-->

