

function setRemember(p_createCookie){
	now = new Date();
	now.setDate(now.getDate()+90);
	document.cookie = cookieName+"=true;expires="+(p_createCookie ? now.toGMTString() : "Thu, 01-Jan-1970 00:00:01 GMT");
}

function checkRemember(){
	if(document.cookie.indexOf(cookieName+"=true")!=-1){
		goMain();
	}
}

function checkValid(){
	if(document.cookie.indexOf(cookieName+"_valid=true")==-1){
		document.location.href = gatewayUrl;
	}
}

function goMain(p_country){
	var t_popParam;
	document.cookie = cookieName+"_valid=true";
	if (p_country == "Colombia") {
	    var p_country = "col";
	} 
	if (p_country == "Mexico") {
	    var p_country = "mex";
	}
	if (p_country == "Argentina") {
	    var p_country = "arg";
	}
	if (p_country == "Chile") {
	    var p_country = "chi";
	} 
	if (p_country == "Panama") {
	    var p_country = "pan";
	}
	if (p_country == "Uruguay") {
	    var p_country = "ury";
	}
	if (p_country == "Peru") {
	    var p_country = "per";
	}
	if (p_country == "Porto Rico") {
	    var p_country = "pri";
	}
	if (p_country == "Costa Rica") {
	    var p_country = "cri";
	}
	if (p_country == "Trinindad e Tobago") {
	    var p_country = "tto";
	}
	
	if(mainPop){
		t_popParam = "height="+mainPopHeight+", width="+mainPopWidth+", top="+((screen.height-mainPopHeight)/2)+", left="+((screen.width-mainPopWidth)/2);
		//window.open(mainUrl, cookieName, t_popParam);
		if(landingUrl){
			var p = landingUrl.split('?');
			var prefixo = '?';
			if (p.length > 1) {
				prefixo = '&';
			}
			document.location.href = landingUrl +prefixo+"country=" + p_country;
		}
	}else{
		document.location.href = mainUrl + "?country=" + p_country;
	}
}

function sendForm(p_remember, p_country){
	setRemember(p_remember);
	goMain(p_country);
}

