<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>      
    <title>Cookie Redirect</title>
    <meta http-equiv="x-ua-compatible" content="IE=edge">
    <!-- <script type="text/javascript" src="https://tags.tiqcdn.com/utag/ups/maestro/qa/utag.js"></script> -->
    <script language="JavaScript" type="text/javascript" src="/assets/resources/scripts/VisitorAPI.js"></script>
	<script language="JavaScript" type="text/javascript" src="/assets/resources/scripts/DIL.js"></script>
		
	<script>
    var xDil = DIL.create({
			partner: "ups",
			uuidCookie:{
				name:'aam_uuid',
				days:120
				},
			visitorService:{
				namespace:"036784BD57A8BB277F000101@AdobeOrg"  // REPLACE ORG ID WITH UPS ORG ID
			}
			});
    
	</script>


    <script type="text/javascript">
    	function GetQueryStringParams(sParam) {
        //var plugin = this;
	    var sPageURL = window.location.search.substring(1);
	    //console.log(sPageURL);
	    var sURLVariables = sPageURL.split('&');
	    //console.log(sURLVariables);
	    for (var i = 0; i < sURLVariables.length; i++) {
	        var sParameterName = sURLVariables[i].split('=');
	        if (sParameterName[0] == sParam) {
	            return sParameterName[1];            
	        }
	      }
	      return;
	    };

    	function getCookie(aam_uuid) {
    		//alert("getCookie Fired");
		    var cookieName = aam_uuid + "=";
		    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(cookieName) == 0) {
		            return c.substring(cookieName.length, c.length);
		        }
		    }
		    return "";
		};

		(function checkCookie() {
			//var utag_data = "";
		    setTimeout(function(){ 
    		var aamuuidCookie=getCookie("aam_uuid");
		    //var refUrl  = document.referrer;
		    var refUrl;
		    var referrer = window.location.href.split("?r=");
		    console.log(referrer);
		    refUrl = referrer[1];
		    //alert(refUrl + " Line 80")
		    console.log(refUrl);
		    refUrl = decodeURIComponent(refUrl);
		    console.log(refUrl);
		    //alert(refUrl + "Line 83");
            refUrl = refUrl.replace(/\&/,'?');
		    var meta = document.createElement('meta');
			meta.httpEquiv = "refresh";
		    if (aamuuidCookie != "") {
		    	//alert("Yes cookie");
		    	//alert(refUrl);
		        meta.content = '0' + ';' + 'URL' + '='+ "'" + refUrl + "'";				
		    } else if(aamuuidCookie == "") {
		    	//alert("no cookie");
		    	if (refUrl.indexOf("?") > -1){
		    		refUrl = refUrl + "&" + 'cookie=false';

		    		console.log(refUrl);
		    		//alert(refUrl);
			    } else {
			    	refUrl = refUrl + "?" + 'cookie=false';
			    	console.log(refUrl);
			    	//alert(refUrl);
			    };
			    
			   //refUrl = refUrl.replace(/\?\&/g,'?');
			   console.log(refUrl + " Line 94");
		       //meta.content = '0' + ';' + 'URL' + '='+ "'" + refUrl + "'";
		       meta.content = '0;' + 'URL' + '='+ refUrl;		    
			}
			console.log(refUrl + " Before Firefox");	
			/*if (navigator.userAgent.indexOf("Firefox") > -1) {
              	console.log(refUrl + " Inside Firefox");
    			window.location.href = refUrl;
			  } else if ((navigator.appName == 'Microsoft Internet Explorer') || (navigator.userAgent.indexOf('MSIE') > -1)) {
			  	console.log(refUrl + "IN IE Block");
			  	window.location.href =  "'" + refUrl + '"';
			  	//window.location.href = refUrl;
			  }	       */
		    document.getElementsByTagName('head')[0].appendChild(meta); 
		    //alert("meta insersion");
              if (navigator.userAgent.indexOf("Firefox") > -1) {
              	console.log(refUrl);
    			window.location.href = refUrl;
			  } else if (navigator.userAgent.indexOf('MSIE') > -1 || (!!navigator.userAgent.match(/Trident\/7\./))) {
			  	console.log(refUrl + "Line 104");
			  	window.location.href = refUrl;
			  }
			  console.log("Document Loaded");
    	}, 300);
		}());

    </script>
    <!-- <meta http-equiv="refresh" content="50;URL=''" /> -->

 </head>
  <body> 

  </body>  
</html> 






