<?php
session_start();
$con = mysql_connect("ormaf.db.12382748.hostedresource.com","ormaf","Khawar@ormaf21") OR DIE ("Unable to 
            connect to database! Please try again later.");

if($con)
{
	mysql_select_db("ormaf",$con) or die(mysql_error());
	define('softFuzon',$con);
}
$array = explode('/',$_SERVER['REQUEST_URI']); 

/*echo '<pre>';
print_r($array);
echo '</pre>';*/

if(isset($_SESSION['security']['email'])&&$_SESSION['security']['email']!="")
{
	if(isset($array[1])&&$array[1]=='signin')
	{
		if(isset($array[2])&&$array[2]=='rm'||$array[2]=='pms')
		{
			
			include("../../classes/classUser.php");
			include("../../classes/classUserSubscription.php");
			include("../../classes/classQueryGlobal.php");
			include("../../classes/classFilter.php");
			include("../../classes/classMyException.php");
			
			include("../signinclasses/classDocument.php");
			include("../signinclasses/classRetrievePAA.php"); 	
			include("../signinclasses/classCalender.php"); 	
			include("../signinclasses/classShareData.php"); 
		}
		else
		{
		
			include("../classes/classUser.php");
			include("../classes/classUserSubscription.php");
			include("../classes/classQueryGlobal.php");
			include("../classes/classFilter.php");
			include("../classes/classMyException.php");
			
			include("signinclasses/classDocument.php");
			include("signinclasses/classRetrievePAA.php"); 	
			include("signinclasses/classCalender.php"); 
			include("signinclasses/classShareData.php");
		}
		
	}
	else
	{
		header("Location:signin/summary.php");
	}
	
	
	
}
elseif(!isset($_SESSION['security']['email'])&&isset($array[1])&&$array[1]=='signin')
{
	if(isset($array[1])&&$array[1]!='')
	{
		header("Location:../../index.php");
	}
	else
	{
		header("Location:../index.php");
	}
}

if(isset($_POST['country_name'])&&$_POST['country_name']!="")
{	
	if($_POST['country_name']=='canada')
	{
		$country_url = 'ca/index.php';
	}
	else
	{
		if(isset($array[2])&&$array[2]=='ca')
		{
			$country_url = '../index.php';
		}
		else
		{
			$country_url = 'index.php';
		}
	}
	
	
	header("Location:".$country_url);
	$_SESSION['country_name'] = $_POST['country_name'];	
}


/*if(isset($_SESSION['security']['email'])&&$_SESSION['security']['email']!="")
{
	
	switch($array[2])
	{
		
		case "index.php":
		case "register.php":
		case "get_started.php":
		case "why_ormaf.php":
		case "tips.php":
		case "help.php":
		case "login.php":
		
		
		header("location:signin/step1.php");
	}
}*/

?>