<?php
require_once ("includes/mysql.inc.php");
require_once ("classes/settings.class.php");
$objST	= new settings($objDB);

$siteSettings=$objST->select();

$PG_TITLE=$objST->ClientFilePathName($_SERVER['PHP_SELF']);

define('CURRENCY_CODE',$siteSettings['currency']);
define('PAYMENT_CURRENCY_CODE',$siteSettings['currencycode']);

//fetch corresponding value for each page
$pagName=$objST->ClientFilePathName($_SERVER['PHP_SELF']);

$condition="where vPageName='".$pagName."'";
$pkey=$objST->fetchSingleValue($objST->select_rows(TABLEPREFIX.'MetaTags','vKeywords',$condition),'vKeywords');
$pDes=$objST->fetchSingleValue($objST->select_rows(TABLEPREFIX.'MetaTags','vDescription',$condition),'vDescription');
//page title
$condition="where vPageName='".$pagName."'";
$metaTitle=$objST->fetchSingleValue($objST->select_rows(TABLEPREFIX.'MetaTags','vTitle',$condition),'vTitle');


if(trim($pkey)!='')
{
	$keyword=$pkey;
}//end if
else
{
	//meta keywords for common
	$keyword=$siteSettings['metatagKey'];
}//end else

if(trim($pDes)!='')
{
	$description=$pDes;
}//end if
else
{
	//meta description for common
	$description=$siteSettings['metatagDes'];
}//end else

if(trim($metaTitle)!='')
{
	$siteTitle=$metaTitle;
}//end if
else
{
	$siteTitle=$siteSettings['sitename'];
}//end else

//checking user login status
if (isset($_SESSION['userlogged']) && $_SESSION['userlogged']=="YES") 
{
	$shwLink='myprofile.php';
}//end if
else
{
	$shwLink='index.php';
}//end else

if($PG_TITLE=='search.php')
{
 	$onBodyLoad='onLoad="getCountyList_First(\'ALABAMA\');"';
}//end if
if($PG_TITLE=='register.php')
{
 	$onBodyLoad='onLoad="getCountyList_First(\'ALABAMA\');"';
}//end if
if($PG_TITLE=='chatbox.php')
{
 	$onBodyLoad='onLoad="timers();timersOne();" onUnload="closeAllchildren();"';
}//end if
if($PG_TITLE=='chatboxsession.php')
{
 	$onBodyLoad='onLoad="" onUnload="closechatbox();"';
}//end if

//if logo empty shows site title in the logo place
if(trim($siteSettings['sitelogo'])!='')
{
	//checking logo default or not
	switch($siteSettings['sitelogo'])
	{
		case "logo_default.gif":
			$showLogoTop='24';
		break;

		default:
			$showLogoTop='3';
		break;
	}//end swich

	$showLogoImgTtl='<img src="images/'.$siteSettings['sitelogo'].'"alt="'.$siteTitle.'" title="'.$siteTitle.'" border="0">';
}//end if
else
{
	$showLogoTop='24';
	$showLogoImgTtl=$siteTitle;
}//end else
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><?php echo $siteTitle;?></title>
<meta name="keywords" content="<?php echo $keyword;?>">
<meta name="description" content="<?php echo $description;?>">
<meta name="copyright" content="Copyright (C) www.iScripts.com, 2007. All rights reserved.">
<meta name="author" content="www.armia.com">
<!--<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="PRAGMA" content="no-cache">-->
<meta http-equiv="Expires" content="Mon, 04 Dec 1999 21:29:02 GMT">
<link rel="shortcut icon" href="favicon.ico" >
<script src="js/jquery-1.11.0.min.js"></script>
<link href="styles/<?php echo $siteSettings['styles'];?>" rel="stylesheet" type="text/css">

        <link href="styles/responsive.css" rel="stylesheet" type="text/css">
        <link href="styles/CommonStyle.css" rel="stylesheet" type="text/css">

<script language="javascript" type="text/javascript">
var imagewindow ;
var children = Array();
function closechatboxsession(imagewindow) {
  if (imagewindow && imagewindow.open && !imagewindow.closed)
	imagewindow.close(); 
}
 

  window.onbeforeunload = function() { //alert('sadas');
   // window.opener.MyActiveWindows[<?php echo $fid?>] = ''; 
} 
function launchchatboxsession(id)
{ 
	var winVarName = "chatwindow_"+id;
	if (!window[winVarName] || window[winVarName].closed) {
		imagewindow = window.open ('chatboxsession.php?fid='+id+'&window=new',
		"chatwindow_"+id,"menubar=0,statusbar=0,resizable=0,scrollbars=1,width=360,height=510");
		imagewindow.moveTo(180,150);
		children[children.length]=imagewindow;
		window[winVarName] = imagewindow;
	} else {
	 window[winVarName].focus();
	}
}
</script>
<script language="javascript" type="text/javascript">
var imagewindows ;
function closechatbox() 
{
	window.opener.MyActiveWindows[<?php echo $fid?>] = ''
   //window.open("javascript:window.close()", "chatbox<?php echo $_SESSION['user_id']?>", "");
/*  if (imagewindows && imagewindows.open && !imagewindows.closed) {
	imagewindows.close(); 
  } else {
    window.open("javascript:window.close()", "chatbox<?php echo $_SESSION['user_id']?>", "");
  }*/
}
function signout() 
{
	var con=confirm("Do You want to Signout");
	if(con)
	{
	return true;
	}
	else
	{
	return false;
	}
}
function launchchatbox()
{
//imagewindows = window.open ('chatbox.php',
//"chatbox<?php echo $_SESSION['user_id']?>","menubar=0,statusbar=0,resizable=0,scrollbars=1,width=360,height=474");
//imagewindows.moveTo(180,150);
}
</script>
<?php if (isset($_SESSION['userlogged']) AND $_SESSION['userlogged'] <> "") {?>
<script type="text/javascript" language="javascript">
    $(window).load(function() {
     var wtf    = $('#chatbox');
  var height = wtf[0].scrollHeight;
  wtf.scrollTop(height);
  
  setInterval ( "getMore()", 10000 );
setInterval ( "setwindowon()", 1000 );
});
     
var req = null;
function processReqChangeAjax() { 
  if (req.readyState == 4 && req.status == 200 ) { // alert( window.opener.MyActiveWindows[<?php echo $fid?>]);
      $('#chatmaintxt').append(req.responseText)
   var wtf    = $('#chatbox');
  var height = wtf[0].scrollHeight;
  wtf.scrollTop(height);
	//moveToBottom();
  }
}

function loadUrlAjax( url ) {
  if(window.XMLHttpRequest) {
    try { req = new XMLHttpRequest();
    } catch(e) { req = false; }
  } else if(window.ActiveXObject) {
    try { req = new ActiveXObject('Msxml2.XMLHTTP');
    } catch(e) {
    try { req = new ActiveXObject('Microsoft.XMLHTTP');
    } catch(e) { req = false; }
  } }
  if(req) {
    req.onreadystatechange = processReqChangeAjax;
    req.open('GET', url, true);
    req.send(null);
  }
}

function getMore()
{ 
  var url = "getchatmessage.php?fid=<?php echo $fid?>&uid=<?php echo $_SESSION['user_id']?>&timeof=<?php echo $_SESSION['timeof']?>";
  loadUrlAjax( url );
  
  
  
}

function setwindowon()
{
    window.opener.MyActiveWindows[<?php echo $fid?>] = '1';
}

function timers() { alert("sdfsd");
//setInterval ( "getMore()", 10000 );
//setInterval ( "setwindowon()", 2000 );
}
</script>
<script language="javascript" type="text/javascript" >
	//window.onLoad=setInterval ( "getMore()", 2000 );
</script>
<?php } ?>
<script>
window.history.forward();
</script>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head>
<body <?php echo $onBodyLoad;?>>

    <!--<div class="row">
      <div class="row logoo"><a href="<?php echo $shwLink;?>"><?php echo $showLogoImgTtl;?></a></div>
    </div>-->
	