/*
cannot use the set cookie function across different domains, 
(i.e remember what site the user picked on last visit,) because each domain sets its own cookie.
Therefore each cookie could well end up with different value which potentially could result in 
the user being bounced around like a squash ball, and the user not being able to reset their choice of country on sites
*/

// redirect on userEvent of select
function redirectCountry(){

$('#country').change(function () {
	
	
var userLocation = $('#country option:selected').val();
	 
if(userLocation == 'us')
{
	location.href = 'http://www.whichfranchise.com/us/';
} 
else if(userLocation == 'uk')
{
	location.href = 'http://www.whichfranchise.com/';
}
else if(userLocation == 'au')
{
	location.href = 'http://www.whichfranchise.net.au/';
}
else if(userLocation == 'ie')
{
   location.href = 'http://www.whichfranchise.ie/';
}
else if(userLocation == 'sa')
{
  location.href = 'http://www.whichfranchise.co.za/';
}
else if(userLocation == 'fl')
{
  location.href = 'http://www.whichfranchise.com/florida/';
}
})
} 

//first checks if cookie already set, if so will then redirect
//if no cookie pointing to an other site this then allows cookie to be set by user on this site
$(document).ready(function()
{
	redirectCountry();
		
});