(function(){
if(typeof jQuery!='undefined'){
return startScript();
}
function getScript(url,success){
var script=document.createElement('script');
script.src=url;
var head=document.getElementsByTagName('head')[0],done=false;
script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')){done=true;success();}};
head.appendChild(script);
}
getScript('http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js',function(){return startScript();});
function startScript(){
(function ($) {
var time = setTimeout(function () {setTimeout("startTrack()",1050);}, 0),
lastelm = null;
$.readyOrDone = function (fn) {
var s = document.readyState,
getLast = function () {
var elms = document.getElementsByTagName('*');
return elms[elms.length - 1];
};
if (s === 'complete') {
$.ready(function () {setTimeout("startTrack()",1050);});
} else if (typeof s === 'undefined') {
lastelm = getLast();
clearTimeout(time);
time = setTimeout(function () {
if (getLast() === lastelm && typeof document.readyState === 'undefined') {
$.ready(function () {setTimeout("startTrack()",1050);});
}
}, 1000);
}
$(fn);
};
})($);
}
})();
var popBox = {
width : 720,
height : 500,
featuredImage : "http://surveytool61.3s.se/popup/images/prototype1.png"
};
var w3c=(document.getElementById)? true: false;
var ns4=(document.layers)?true:false;
var ie5=(w3c && document.all && !window.opera)? true : false;
var ie6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
var ie7 = (typeof document.body.style.maxHeight != "undefined" && document.all);
var strictMode = ((document.documentElement.clientWidth || document.documentElement.clientHeight) && (ie6 || ie7) && !window.opera) ? true : false;
var ns6=(w3c && !document.all)? true: false;
var windowWidth = ns6 ? window.innerWidth : document.body.clientWidth;
var windowHeight = ns6 ? window.innerHeight : document.body.clientHeight;
if (windowWidth == 0 || strictMode) windowWidth = document.documentElement.clientWidth;
if (windowHeight == 0 || strictMode) windowHeight = document.documentElement.clientHeight;
var maximum_duration_in_days = 90;
var minimum_number_of_visits = 0;
var delay_in_seconds = 1;
var interval_in_hours = 1;
var maximum_number_of_responses = 2000;
var visitorInterval = 100;
var sUrl = "http://surveytool70.3s.se/?s=182webb";
var micp = 11430;
var sid = 0;
var trackerName = "3stracker";
var rightNow = new Date();
/* cookie function */
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 nameCookie = name + "=";
var cookieArray = document.cookie.split(';');
for(var i=0;i < cookieArray.length;i++) {
var cookie = cookieArray[i];
while (cookie.charAt(0)==' ') cookie = cookie.substring(1,cookie.length);
if (cookie.indexOf(nameCookie) == 0) return cookie.substring(nameCookie.length,cookie.length);
}
return null;
}
function makeKey (id,visit,view,time,flag,status) {
var key = [id.toString(16),visit.toString(16),view.toString(16),time.toString(16),flag,status];
return key.join(".");
}
function drawPopContainer() { //show the popup
if ($("#absolutLda").css("display") == "none") {
$("#aspnetForm").css("display","none");
} else {
setTimeout("drawPopContainer()",3000);
return;
}
var isMSIE = /*@cc_on!@*/false;
$("html").css("overflow","hidden").css("position","fixed");
$("body").css("overflow","hidden");
$("body").prepend('
');
$("#cover").height($(window).height()).width($(window).width()+20);
$(window).resize(function(){
$("#cover").height($(window).height()).width($(window).width()+20);
$("#3spop").css("top",($(window).height()-$("#3spop").height())/2+"px").css("left",($(window).width()-$("#3spop").width())/2+"px");
});
}
function popClose(hasAccepted) { //restore orginal page layout and remove popup
var cookieStr = readCookie(trackerName);
var value = cookieStr.split(".");
sid = parseInt(value[0],16);
var returns = parseInt(value[1],16);
var pageviews = parseInt(value[2],16);
var lastTimeStamp = parseInt(value[3],16);
var newKey = makeKey(sid,returns,pageviews,lastTimeStamp,1,(hasAccepted) ? 1:0);
createCookie(trackerName,newKey,maximum_duration_in_days);
if (hasAccepted) {
$.getJSON("http://surveytool61.3s.se/popup/setResponseCount.php?micp="+micp+"&sid="+sid+"&domain="+location.hostname+"&status=Y&jsoncallback=?",function (data) {
//save response
});
window.open(sUrl+"&pop="+sid,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, width=800, height=600");
} else {
$.getJSON("http://surveytool61.3s.se/popup/setResponseCount.php?micp="+micp+"&sid="+sid+"&domain="+location.hostname+"&status=N&jsoncallback=?",function (data) {
//save response
});
}
$("#3spop").remove();
$("#cover").remove();
$("html").css("overflow","auto").css("position","relative");
$("body").css("overflow","auto");
$("#aspnetForm").css("display","");}
function startTrack() {
if (readCookie(trackerName) == null) { //new visitor
$.getJSON("http://surveytool61.3s.se/popup/getNewSID.php?micp="+micp+"&domain="+location.hostname+"&now="+rightNow.getTime()+"&jsoncallback=?",function(data){
sid = parseInt(data.sid); //getting a ungiue ID from surveytool
if (sid > 0) { //if ID is valid i.e
var newKey = makeKey(sid,1,1,parseInt(rightNow.getTime()),0,0); //create a key for the cookie string
createCookie(trackerName,newKey,maximum_duration_in_days); //create cookie
if (minimum_number_of_visits==0) {//check for criteria to serve survey, in this case no minimum requirement of previous visit
$.getJSON("http://surveytool61.3s.se/popup/getPopCount.php?micp="+micp+"&sid="+sid+"&view=0&visit=0&domain="+location.hostname+"&now="+rightNow.getTime()+"&jsoncallback=?",function (data) {
var popCount = parseInt(data.response); //get the total number of response so far
var visitorCount = parseInt(data.count); //get the total number of visitor so far
var toShow = (visitorCount > 0 && ((visitorCount % visitorInterval) == 0)) ? true : false
if (popCount >= 0 && popCount <= maximum_number_of_responses && toShow) { //show Popup
setTimeout(function () {drawPopContainer(); var newKey = makeKey(sid,returns,pageviews,lastTimeStamp,1,0); createCookie(trackerName,newKey,maximum_duration_in_days);},delay_in_seconds*1000);
}
});
}
}
});
} else { // returning visitor
var cookieStr = readCookie(trackerName);
var value = cookieStr.split(".");
sid = parseInt(value[0],16);
var returns = parseInt(value[1],16);
var pageviews = parseInt(value[2],16);
var lastTimeStamp = parseInt(value[3],16);
var hasShown = (parseInt(value[4],16)) ? true : false;
var interval = interval_in_hours * 60 * 60 * 1000;
if (lastTimeStamp + interval < rightNow.getTime()) { // if visitor return within a determined interval do not count as new visit
returns++;
lastTimeStamp = parseInt(rightNow.getTime());
}
pageviews++;
var newKey = makeKey(sid,returns,pageviews,lastTimeStamp,parseInt(value[4]),parseInt(value[5])); //update Key
createCookie(trackerName,newKey,maximum_duration_in_days);//update cookie
if (!hasShown && returns > minimum_number_of_visits) {//check for criteria to serve survey
$.getJSON("http://surveytool61.3s.se/popup/getPopCount.php?micp="+micp+"&sid="+sid+"&view="+pageviews+"&visit="+returns+"&domain="+location.hostname+"&now="+rightNow.getTime()+"&jsoncallback=?",function (data) {
var popCount = parseInt(data.response); //get total number of responses so far
var visitorCount = parseInt(data.count); //get total number of visitor
var toShow = (visitorCount > 0 && ((visitorCount % visitorInterval) == 0)) ? true : false
if (popCount > 0 && popCount <= maximum_number_of_responses && toShow) { //show popup
setTimeout(function () {drawPopContainer(); var newKey = makeKey(sid,returns,pageviews,lastTimeStamp,1,0); createCookie(trackerName,newKey,maximum_duration_in_days);},delay_in_seconds*1000);
}
});
}
}
}