the easiest way would be something like:
Code:
if(pageindex % 2 == 0)
// then it's even
else
// then it's odd the modulus operator (%) returns the remainder of any division operation. Here's a python example (since it's easier to read/understand)
Code:
>>> 3 % 2
1
>>> 14 % 7
0
because 14 divides evenly by 7, there's no remainder, but 3 doesn't divide evenly by 2, so there's a remainder of 1, etc.
hth