I have this code to redirect someone to another page. The php line must remain there as it is.

PHP Code:
<?php $id=2; include('/home/xxx/public_html/bbb/rr_rrr.php');?>
<script language="JavaScript">
<!--
   window.location.replace('http://mylink.com/xys?sub=xx');
//-->
</script>
But now I need to redirect the person to a page that depends on some variables. The following script works:

PHP Code:
<?php $id=2; include('/home/xxx/public_html/bbb/rr_rrr.php');?>
<?php
$sub
=$_GET['sub'];
$offer=$_GET['offer'];

if (
$offer == "111") {$product "http://mylink.com/xcv?sub=yy";}
if (
$offer == "222") {$product "http://mylink.com/xys?sub=xx";} 
header("Location: $product");
exit();
?>
However, I need the redirect section as javascript. How can I achieve this?

Thanks,

Jon