//************ 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("&");

            for (var i=0;i< vars.length;i++)

            {

//                        var pair = vars[i].split("=");

//                        if (pair[0] == "VT")

//                        {

//                                    var VT=pair[1];

//                        }

 

                        var pair = vars[i].split("=");

                        if (pair[0] == "VP")

                        {

                                    var VP=pair[1];

                        }

                                    //Setting Variables Used in SiteRedirector

                                    if (pair[0] == "sourcesite" || pair[0] == "s")

                                    {

                                                var strSource=pair[1];
												
                                    }

                                    if (pair[0] == "MU")

                                    {

                                                var SiteRedirectorTag=pair[1]; //xp

                                    }

                                                

									if (pair[0] == "sourcesite" || pair[0] == "s")

									         {

									                     var strSource=pair[1];

									         }

									if (pair[0] == "trd")

									{

									            var SiteRedirectorTag1=pair[1]; //

									}
									if (pair[0] == "cuba")

									{

									            var cuba=pair[1]; //

									}
 

									//Exclusion from Existing Exit

									if (pair[0] == "sourcesite" || pair[0] == "s")
									  {
									          var strSource=pair[1];
									  }

									  if (pair[0] == "mode")

									  {
									              var modeTag=pair[1]; //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 amt()

{

            var count = GetCookie('mycount')

            if(count == null)

            {

                        SetCookie('mycount','1')

                        return 1

            }

            else 

            {

                        var newcount = parseInt(count) + 1;

                        DeleteCookie('mycount')

                        SetCookie('mycount',newcount,exp)

                        return count

            }

}

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 count = GetCookie('mycount');

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

            

            //------------------------ExitTraffic Executes Starts Here---------------------------------------------

            

            if (count == null) 

            {

                        count=1;

                        SetCookie('mycount', count, exp);

                        getExitTraffic();              

            }

            else

            {

                        count++;

                        SetCookie('mycount', count, exp);

            }

            

            //------------------------ExitTraffic Executes Ends Here---------------------------------------------

                                                                        

}

 

//Sart of the main function

function getExitTraffic()

{

            BotsExclusion();

            SiteRedirectorExclusion();

 

            if (noXpop=="false")

            {
				if(cuba=="true")
				{
					var exitWindow = window.open('http://www.cubalaya.com/?inId=1');
					//exitWindow.focus();
					RegionalExitExecution(); 
				}
				
				else
				
				{						
					//this section is for split 50%/50% but business reason both go to the same Url 100%
					if (vt%2==0)	//even 
					{
						//var PIMS1 = window.open('http://www.riverbelle.co.uk/casino/pimms/entry.asp?VT='+vt+'&mode=e&MU=xp','PIMS1','width=600,height=590');
						//PIMS1.focus();
						var TURBO1 = window.open('http://www.riverbelle.com/casino-games2/?VT='+vt+'&mode=e&MU=xp','TURBO1');
						TURBO1.focus();
						RegionalExitExecution();                        
					}
					else	
					{
			 		
						//var PIMS2 = window.open('http://www.riverbelle.co.uk/casino/pimms/entry.asp?VT='+vt+'&mode=e&MU=xp','PIMS2','width=600,height=590');
					    //PIMS2.focus();
					    var TURBO2 = window.open('http://www.riverbelle.com/casino-games2/?VT='+vt+'&mode=e&MU=xp','TURBO2');
						TURBO2.focus();
						RegionalExitExecution();                        
					}
				}
			}                                   

}

/************** Execution of the exit strategy Starts here *****************************************************************

----------------------------------------------------------------------------------------------------------------------------*/

 

function getDomain(url) {

 var domain = url.match(/:\/\/(www\.)?([^\/:]+)/);

 

 if(domain) { 

            return domain[2];

            }

 else { 

            return '';

            }

}

	 