//************ Check for Odd and even VT Starts Here ***************************
		 
            var noXpop = "false";

            var RegionalPop = "false";

            var Cont="Default";

            var query = window.location.search.substring(1);  

            var vars = query.split("&");
			
			var Affiliatecheck;

          for (var i=0;i< vars.length;i++)
			{
				var pair = vars[i].split("=");
				if (pair[0] == "VT")
				{
					var VT=pair[1];
				}
					if (pair[0] == "sourcesite" || pair[0] == "s")
					{
						var strSource=pair[1];
						strSource = strSource.toLowerCase()
						Affiliatecheck = strSource.indexOf("aff");
					}
						if (pair[0] == "MU")
						{
							var SiteRedirectorTag=pair[1];
						}
			}
//************ Check for Odd and even VT Ends Here ***************************

 

//------------------------Cookie State Management Starts Here---------------------------------------------

 

var expDays = -1; // number of days the cookie should last

 

function GetCookie(name) 

{  

            var arg = name + "=";  

            var alen = arg.length;  

            var clen = document.cookie.length;  

            var i = 0;  

            while (i < clen) 

            {    

                        var j = i + alen;    

                        if (document.cookie.substring(i, j) == arg)      

                                    return getCookieVal (j);    

                                    i = document.cookie.indexOf(" ", i) + 1;    

                        if (i == 0) break;   

            }  

            return null;
}

 

 

 

function SetCookie(name, value) 

{  

            var argv = SetCookie.arguments;  

            var argc = SetCookie.arguments.length;  

            var expires = (argc > 2) ? argv[2] : null;  

            var path = (argc > 3) ? argv[3] : null;  

            var domain = (argc > 4) ? argv[4] : null;  

            var secure = (argc > 5) ? argv[5] : false;  

            document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) +  ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}

 

 

function DeleteCookie(name) 

{  

            var exp = new Date();  

            exp.setTime (exp.getTime() - 1);  

            var cval = GetCookie (name);  

            document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();

}

 

 

var exp = new Date(); 

exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

 

function getCookieVal(offset) 

{

            var endstr = document.cookie.indexOf (";", offset);

            if (endstr == -1)

                        endstr = document.cookie.length;

            return unescape(document.cookie.substring(offset, endstr));

}

 

//------------------------Cookie State Management Ends Here---------------------------------------------

    

//************* SourceSites Checks Starts Here *******************************

function BotsExclusion()

{           

            var noPop_array = new Array(6);

            noPop_array[0]="AFF81035"

            noPop_array[1]="AFF57222"

            noPop_array[2]="AFF25486"

    noPop_array[3]="AFF16205"

    noPop_array[4]="AFF75501"

    noPop_array[5]="AFF72573"

                        

            var x=0;

            if (strSource != null)

            {

                        for (x=0; x<6; x++) 

                        {

                                    if (strSource.toUpperCase() == noPop_array[x])

                                    {

                                                noXpop = "true";

                                    }

                        } 

            }

}

//************* SourceSites Checks Ends Here *******************************

 

//------------ Site redirector exlcusions Starts Here ----------------------

function SiteRedirectorExclusion()

{

            if (SiteRedirectorTag != null)

            {           

                        if (SiteRedirectorTag.toUpperCase() == "XP")

                        {

                         noXpop = "true";

                        }

            }

}

//------------ Site redirector exlcusions Ends Here ------------------------

 

/*---------------------------------------------------------------------------

!!!!!! Collection of geopraphical location info Starts Here !!!!!!!!!!!!!!!!*/

function GetCountry()

{  

            if (document.cookie.length > 0) 

  { 

     var AllCookies=document.cookie;

     var IndividualCookie=AllCookies.split(";");

 

     if (AllCookies.indexOf("&cont=")!=-1)

             var AllCookiesIndex=AllCookies.indexOf("cont=")

             var AllCookiesLastIndex=AllCookies.lastIndexOf("&start")

             var FullCont=AllCookies.substring(AllCookiesIndex,AllCookiesLastIndex)

     Cont=FullCont.replace("cont=","")

     //alert(AllCookiesIndex); 

             //alert(AllCookiesLastIndex);

             //alert(Cont);

  } 

} 

/*!!!! Collection of geopraphical location info Ends Here !!!!!!!!!!!!!!!!

-----------------------------------------------------------------------------*/

 

function RegionalExitExecution()

{

            GetCountry();

            var ContValue = Cont.toLowerCase();

            var result = null;

 

            /*switch (ContValue)

             {

               case "de": window.open('/popups/german/index.asp?a=71590&VT='+VT+'&nopop=true','GermanExit',''); break;

               case "jp": window.open('/popups/gamingclub-japanese.asp?VT='+VT+'&nopop=true','JapeneseExit','width=352,height=351'); break;

               //case "us": window.open('http://www.universalnutrition.com','EnglishExit',''); break;

               default: result = 'unknown';

             }*/ 

}

 

/*----------------------------------------------------------------------------------------------------------------------------

**************** Execution of the exit strategy Starts here ******************************************************************/

window.onunload = function() 
{
    var mydomain=getDomain(window.location.href);
    var elem=document.activeElement;

    if(elem) 
    {
        if(elem.tagName == 'A') 
        {
            if(elem.href) 
            {
                var yourdomain=getDomain(elem.href);

                if(yourdomain != mydomain)
                    getExitTraffic();
            }
        }
    }
    else 
            getExitTraffic();              
//        }
    }

 

//Sart of the main function

function getExitTraffic()
{
       BotsExclusion();

       SiteRedirectorExclusion();
       
	   if(!(Affiliatecheck==0))
	      {
            if (noXpop=="false")
            {
//                var ct = GetCookie('ct');               
//                
//                if (!ct)
//                {
//                    ct = 1;
//                    document.cookie = 'ct=' + escape(ct) + ';expires=Sun, 7 Mar 2010 23:59:59 GMT;'; // my birthday ;-) lol
                    //var exitWindow = window.open('http://www.mygoldticket.com/?VP=LNC' + vt);
                //}
//				if (!ct) 
//				{
//					ct = 1;
//					document.cookie = 'ct=' + escape(ct) + ';expires=Sun, 7 Mar 2010 23:59:59 GMT;'; // my birthday ;-) lol
//					var exitWindow = window.open('http://www.riverbelle.com/casino/pimms/entry.asp?VP=LNC'+VT+'&mode=o&cc=LNC','PIMS','width=600,height=590');
//				}
//				else
//				var answer = confirm("Start playing Casino games now! \n No download required.")
//				  if (answer){
//				   //window.navigate("/download_helper/download.asp?EventId=24824");
//				   var exitWindow = window.open('http://www.luckynugget.co.uk/tracking.asp?Link=MICROGAMING&EventId=30290');
//				  }					
//					

				//RegionalExitExecution(); 
		    }
		}                                   
}

/************** Execution of the exit strategy Starts here *****************************************************************

----------------------------------------------------------------------------------------------------------------------------*/

 

function getDomain(url) {

 var domain = url.match(/:\/\/(www\.)?([^\/:]+)/);

 

 if(domain) { 

            return domain[2];

            }

 else { 

            return '';

            }

}

	 