var formShown=0;
var forceHideSurvey=0;
//setTimeout("checkVar();",2000);


function addGoal(goal){
	if(goal=='button'){
	    if(typeof(_vis_opt_top_initialize) == "function") {
		    // Code for Custom Goal: Popup Button Pushed
		     _vis_opt_goal_conversion(230);
		    // uncomment the following line to introduce a half second pause to ensure goal always registers with the server
		    // _vis_opt_pause(500);
	    }
    }
	if(goal=='display'){
	    if(typeof(_vis_opt_top_initialize) == "function") {
		    // Code for Custom Goal: Popup Displayed
		     _vis_opt_goal_conversion(229);
		    // uncomment the following line to introduce a half second pause to ensure goal always registers with the server
		    // _vis_opt_pause(500);
	    }
	}
}

function fetchPopup(){
		var urlToGet = "http://socialsecuritydisabilitybenefits.co/popTest/exitPop2.html"
//		alert(doPopup);
		if(doPopup==1){
			urlToGet = "http://socialsecuritydisabilitybenefits.co/popTest/exitPopB.html";
//		} else {
//			urlToGet = "http://socialsecuritydisabilitybenefits.co/popTest/exitPop2.html";
		}
//		alert(urlToGet);
		at.ajax({
		  type: 'GET',
		  url: urlToGet,
		  windowname: true,
		  data: 'test=1',
		  error: function(jqXHR, textStatus, errorThrown) {
		    alert("We're sorry, an error has occured.  Please try again "+errorThrown);
	//	    console.log(errorThrown);
		  },
		  success: function(textStatus){
//		  	alert(textStatus);
		  	document.getElementById("myDiv").innerHTML = textStatus;
		  }});
		  
}

function pushButton(){
	hideSurvey();
	addGoal('button');
	var url = document.URL;
	if(url=="http://socialsecuritydisability.ws/social_security_disability_application.html"){
		removeCopy();
	} else {
		window.location = "http://socialsecuritydisability.ws/social_security_disability_application.html";
	}
}

function showSurvey(){
	if(doPopup!=0){
		if(forceHideSurvey == "0"){
			addGoal('display');
			at("#surveyDiv").show("fast")	
			at("#backgroundPopup").css({
				"opacity": "0.4"
			});
			at("#backgroundPopup").fadeIn("fast");
		}
		forceHideSurvey=1;
	}
}
function hideSurvey(){
	at("#surveyDiv").hide("fast")	
	at("#backgroundPopup").css({
		"opacity": "0.0"
	});
	at("#backgroundPopup").fadeOut("fast");
}
