First, all statements inside IF ELSEIF and ELSE
should be between {} brackets
if ($this==$that)
{
do stuff
}
else
{
if ($that==$this)
{
#do other stuff
}
else
{
do more stuff
}
};
Second:
Use a SWITCH instead of the confusing IF's
switch($document)
{
case "reliability":
fo things
break;
case "something else":
do other things
break;
default:
do things if none of the above matched
};