var retUrl = "";
function gup( name ){
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results != null ) {
		if (results[1].indexOf("www") > -1){
			myresult = results[1].substring(results[1].indexOf("www"));
			document.write ('<a href="http://'+myresult+'" target="_blank">'+myresult+'</a>');
			retUrl = "http://"+myresult;
		} else {
			var res = results[1];
			res = res.replace("%253A", ":");
			res = res.replace("%253D", "=");
			res = res.replace("%253F", "?");
			res = res.replace("%2526", "&");
			document.write ('<a href="'+res+'" target="_blank">'+res+'</a>'); 
			retUrl = res;
		}
	}
}
gup('url');
 
function createCookie(name, value, days){
	if (days) {
	    var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
    }else{
		var expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/ ;domain=.kontera.com;";
}
 
var optMeOut = function(){
	var txt;
	if (document.cookie.match(/KONA_USER_GUID=no_links/) === null){
		createCookie("KONA_USER_GUID", "no_track", 1825);
		txt = "You have opted out of audience analysis and remarketing.";
	} else {
		txt = "You have already opted out of audience analysis and remarketing."
	}
	
	document.getElementById("confirmationBox").innerHTML = "<strong>"+txt;
	if(retUrl.length>0){
		document.getElementById("confirmationBox").innerHTML += "<br><a class='green_link' href='"+retUrl+"'>Click here</a> to return to the site you were viewing.";
	}
	document.getElementById("confirmationBox").innerHTML += "</strong>";
	document.getElementById("confirmationBox").style.display = "block";
}
 
var disableKonteraLinks = function() {
	createCookie("KONA_USER_GUID", "no_links", 1825);
	document.getElementById("confirmationBox").innerHTML = "Kontera links were successfully disabled.";
	if(retUrl.length>0){
		document.getElementById("confirmationBox").innerHTML += "<br><a class='green_link' href='"+retUrl+"'>Click here</a> to return to the site you were viewing.";
	}
}
 
