For those who wish to create sites with different style sheets (based on the users resolution), and have two sites (like ours, one in English, one in Spanish):
Index page
(checks to see if they have a cookie from a previous visit, if not, it forwards them to forward.php):
<?php
if ($_COOKIE[Language] == "English")
{
echo "<meta http-equiv=\"refresh\" content=\"1; URL=http://cielovista.org/English/main.php?page=mainpage\"\>";
}elseif ($_COOKIE[Language] == "Spanish")
{
echo "<meta http-equiv=\"refresh\" content=\"1; URL=http://cielovista.org/Spanish/main.php?page=mainpage\"\>";
}elseif ($_COOKIE[Language] == "")
{
echo "<meta http-equiv=\"refresh\" content=\"1; URL=http://cielovista.org/forward.php\"\>";
}
?>
forward.php
(to see if they have javascript on, if so they are fowarded to index2.php, if not they see the "noscript" mesage):
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
window.location="http://cielovista.org/index2.php";
</script>
<noscript>It appears that your browser does not support JavaScript, or you have it disabled. Cielo Vista's site is best viewed with JavaScript enabled.<p>If JavaScript is disabled in your browser, please turn it back on then reload this page.<br />Thanks!
</noscript>
index2.php
(this page autodetects their screen width, and based on that determines the appropriate CSS, then writes that value to a hidden text field. You can do as many CSS's as you please, I'm only doing four. The user is prompted to select their language prefence (in this case English or Spanish) and that button posts the values to cookie.php):
<body onload="screenRes()">
<script language="JavaScript" type="text/javascript">
function screenRes()
{
sr = screen.width
if(sr <= "800")
{
document.forms[0].elements[0].value="800x600"
}
else if((sr > "800") && (sr <= "1024"))
{
document.forms[0].elements[0].value="1024x768"
}
else if((sr > "1024") && (sr <= "1280"))
{
document.forms[0].elements[0].value="1280x1024"
}
else(sr >= "1280")
{
document.forms[0].elements[0].value="1600x1200"
}
}
</script>
<div id="index"><center><img src="cvclogo.jpg" id="cvclogo" />
<br /><br />
Welcome to the Cielo Vista Church website!<br />¡Bienvenida a el sitio web de la Iglesia de Cielo Vista!
<br /><br />Would you prefer to see the site in English or Spanish?<br />¿Que prefieras mirar en Inglés o Español?</center>
<form method="post" action="cookie.php">
<input type="hidden" size="60" name="ScreenRes" /><br />
<center><input type="submit" name="Language" value="English" /> <input type="submit" name="Language" value="Español" /></center>
</form>
</div>
</body>
cookie.php
(this page determines the values and sets the cookies, then forwards them to the appropriate website for their lanuguage preference, which is shown in the appropraite size for their resolution):
<?php
if ($ScreenRes == "800x600")
$SR = "800x600";
elseif ($ScreenRes == "1024x768")
$SR = "1024x768";
elseif ($ScreenRes == "1280x1024")
$SR = "1280x1024";
elseif ($ScreenRes == "1600x1200")
$SR = "1600x1200";
if ($Language == "English")
$Lang = "English";
elseif ($Language == "Spanish")
$Lang = "Spanish";
if ($ScreenRes == "800x600")
$IM = "800x600";
elseif ($ScreenRes == "1024x768")
$IM = "1024x768";
elseif ($ScreenRes == "1280x1024")
$IM = "1280x1024";
elseif ($ScreenRes == "1600x1200")
$IM = "1600x1200";
if ($Lang == "English")
{header ("Location: http://cielovista.org/English/main.php?page=mainpage");}
elseif ($Lang == "Spanish")
{header ("Location: http://cielovista.org/Spanish/main.php?page=mainpage");}
elseif ($Lang == "")
{header ("Location: http://cielovista.org/error.php");}
setcookie("Language", "$Lang", time()+(60602490));
setcookie("Resolution", "$SR", time()+(60602490));
setcookie("Map", "$IM", time()+(606024*90));
?>
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>cookie.php</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
</body>
</html>
If anyone sees any improvements or shortcuts in this setup, post code here please! It took me three days to figure all this mess out (I'm new to programming PHP & Javascript).