

window.onerror = null;

// BEGIN: SETTINGS      
var surveyURL        = "https://digiumenterprise.com/answer/?sid=227253&chk=2J3QXKVS";
var surveyName       = "supportsurvey2008lta"; // no special characters!!!
var cookieName 		 = "supportsurvey_2008_lta"; //Set a cookie Name
var lotteryMaxValue  = 3; // p_survey_openned = 1/2*(lotteryMaxValue-1) 
                          // 1=always, 2=~50%, 3=25%, 11=5%, 51=1%, 101=0,5%, 201=0,25%
						  // (Values corrected by apl 19.5.2005)
var multiLevelDisabled = new Array('/Get+Support+And+Software');

/* Survey Cookies */
function openSurveyPopup() {
	
	//window.open(surveyURL)
	var namePop =  'pop_' + surveyName;
	//alert(namePop)
	window.open(surveyURL,namePop, "scrollbars=yes,status=no,width=630,height=648")
}

function createSurveyCookie(name, value, days) {
 if(days) {
    var date = new Date();
    var expirationTime = 24*60*60*1000*180;  
    date.setTime(date.getTime() + expirationTime) //(days*60*60*1000)); *24*60*60*1000
    var expires = "; expires="+date.toGMTString();
 } else {
    expires = "";
 }
 document.cookie = name+"="+value+expires+"; path=/";
}

function readSurveyCookie(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;
}
/* End Survey Cookies */


/* Lottery Function */
function surveyOpenerLottery() {
  // check if this survey has already been shown
  if(readSurveyCookie(cookieName) ){
       // Return without doing anything
      return;
  }
	
  var randNum = Math.round(Math.random()*(lotteryMaxValue-1));
 
  if(randNum == 0) {
      // hit by lottery
      createSurveyCookie(cookieName, "yes", 180); //expires in 180 days
      openSurveyPopup();
  }
}

/* Onload of Pages */
$(document).ready(function(){
	//get MLC
	var mlc = hbx.mlc;
	var j=0;
	
	//Cookie Name
	var cookieDisabled = 'isDisabled';
	mlc = mlc.toLowerCase();
	
	//Compare Array with HBX MultiLevelContent
	for (var i = 0; i < multiLevelDisabled.length; i++) {
		if(mlc.indexOf(multiLevelDisabled[i].toLowerCase())==0)j++;
	}
	
	//If is Disabled Area
	if(j!=0){
		createSurveyCookie(cookieDisabled, "yes", 1);
	}
	else{
		//alert(readSurveyCookie(cookieDisabled))
		if(readSurveyCookie(cookieDisabled)=='yes' ){
		    surveyOpenerLottery();
			createSurveyCookie(cookieDisabled,'no');
		}
	}
});

