function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function checkState() {
// get data from gf storage
var ss = JSON.parse(sessionStorage.getItem('formData')),
state = '';
if (ss) {
state = ss.state;
}
// get data from mc cookie
var mcCookieData = getCookie('prev');
// check if mcCookieData exists and decode the URI
if (mcCookieData) {
var cookieObj = JSON.parse('{"' + decodeURI(mcCookieData).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,
'":"') + '"}');
state = cookieObj.state;
};
if (state) {
var arr = ['CA', 'TX', 'WA', 'CO', 'MI', 'IL', 'PA', 'VA', 'FL', 'GA', 'OR', 'AZ'],
stResult = arr.indexOf(state) > -1;
if (stResult === true) {
console.log("Located in Area");
$('#lendaEl').removeClass('lendaEl-hidden');
}
}
}
checkState();