$(document).ready(function() { checklang(); invalidpin(); }); //Shows pin error is missing or wrong function invalidpin(){ var pinerror = 0; try{ var pinvalid = getUrlParameter('invalid'); if(pinvalid=='True'||pinvalid=='False'){ $('.pinerror').show(); try { getCookie(pinerror); } catch(err) { //do nothing } } else { //Remove comment to test //$('.pinerror').show(); }; } catch(err) { //do nothing } } function checklang(){ var navlang = navigator.language.substring(0,2).toUpperCase(); var pagelang = $('html')[0].lang.toUpperCase(); var cookielang; try { getCookie(cname); } catch(err) { //do nothing } } //Sets start language //Most text can be placed in DIVs with either english or spanish at the class //Input values though need to be set directly using .val() function togglelang(lang,page){ try{ if(lang=='es'){ //$('.english').attr("style", "display: none !important"); //$('.spanish').attr("style", "display: inline !important"); //$('#toggletoen').removeAttr("style"); //$('#toggletoes').attr("style", "display: none !important"); //$('#lang').val("es"); //$("#RD_PIN").attr("placeholder", "Ingrese el código de acceso"); //$("#buttonsubmit").attr("value", "Iniciar encuesta"); createcookie('es'); window.open(page,"_self"); } else { //$('.spanish').attr("style", "display: none !important"); //$('.english').attr("style", "display: inline !important"); //$('#toggletoes').removeAttr("style"); //$('#toggletoen').attr("style", "display: none !important"); //$('#lang').val("en"); //$("#RD_PIN").attr("placeholder", "Enter Access Code"); //$("#buttonsubmit").attr("value", "Start Survey"); //$('#submitText').val(" Submit "); createcookie('en'); window.open(page,"_self"); } } catch(err){ //do nothing } } function updatelink(){ try{ var pin = getUrlParameter('pin'); var st = getUrlParameter('st'); //manually overriding the st temporarily st=""; var lang = getUrlParameter('lang'); var domain = document.domain; var urlen = "https://"+domain+"/SE/?st=="+pin+"&lang="+lang; var urles = "https://"+domain+"/SE/?st="+st+"&p="+pin+"&lang="+lang; $("#gobacklinken").attr("href", urlen); $("#gobacklinkes").attr("href", urles); $("#pinen").html(pin); } catch(err) { //do nothing } } //Gets URL parameters function getUrlParameter(sParam) { var sPageURL = decodeURIComponent(window.location.search.substring(1)), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : sParameterName[1]; } } }; //Splits pin and last digit into two hidden fields on page. function movepin(){ var fullpin = $('#pinInput').val(); if(fullpin.length==5){ var pinonly = fullpin.substring(0,4) var lastdigit = fullpin.substring(4,5) $('#pin').val(pinonly); $('#LASTDIGIT_LAST').val(lastdigit); } else { $('#pin').val(''); $('#LASTDIGIT_LAST').val(''); } }; //Using a cookie so that the language will display the same language as the last time the page was accessed. function createcookie(cname, lang){ if(lang.length==0){ lang = 'en'; } exdays = 90; var d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); var expires = "expires="+d.toUTCString(); document.cookie = cname + "=" + lang + "; " + expires +"; path=/;"; } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); if(ca.length>0){ for(var i=0; i