<?php session_start();  //Developed by ITechScripts
error_reporting(0);
require 'include/announcements.php'; // ITECHBIDS Configuration File
require 'include/itechbids.php'; // Server compatibility Patch
if(empty($_SESSION[userid]))
{
 echo '<meta http-equiv="refresh" content="0;url=signin.php?url=watchlist.php&productid='.$productid.'">';
 echo "<font size=+1 color=#003366>$lang_676....</font>"; 
 exit();
}
?>
<script language="javascript">
function selectall()
 {
	len=document.watch_form.len.value;
	if(len==1)
	 {
	if(document.watch_form.chkMain.checked==true) 
				document.watch_form.chkbox.checked=true;
		if(document.watch_form.chkMain.checked==false)
			document.watch_form.chkbox.checked=false;
	}
		else
	 {
		for(i=0;i<len;i++)
		 {
	if(document.watch_form.chkMain.checked==true)
			document.watch_form.chkbox[i].checked=true;
		if(document.watch_form.chkMain.checked==false)
			document.watch_form.chkbox[i].checked=false;     
			  				}
	}
	
}
function del()
{
var where_to= confirm("Are You Sure You Want to delete the item[s]?");
if (where_to== true)
 {
document.watch_form.delete1.value="del";
document.watch_form.submit();
  }
else
 {
  window.location="watchlist.php";
  document.watch_form.submit();
  }

}
function com()
{
document.watch_form.action="compare.php";
document.watch_form.submit();
}
function delete_all()
{
var where_to= confirm("Are U Sure U Want to delete all the items?");
if(where_to==true)
 {
document.watch_form.delete1.value="all";
document.watch_form.action="watchlist.php";
document.watch_form.submit();
   }
else
 {
  window.location="watchlist.php";
  document.watch_form.submit();
  }
}
function watch_all()
{
//document.watch_form.delete1.value="all";
document.watch_form.action="watchall.php";
document.watch_form.submit();
}
</script>
<body >
<? 
$type=$_GET[type];

$user_id=$_SESSION[user_id];
$mode=$_GET[delete1];
if($mode=="all")
{
 $del="delete from watch_list ";
 mysql_query($del);

 $dis_all=$err_2;
}
if($mode=="del")
{
  $items=$_GET[chkbox];
  $count=count($items);
  if($count!=0)
   {
   foreach($items as $item)
    {
$del="delete from watch_list where productid=".$item;
mysql_query($del);
$conf=$err_32;
    }
	echo '<meta http-equiv="refresh" content"=0; url=watchlist.php">';
    //exit();
   }
  else // if($count!=0)
  {
  $war=$err_33;

  }
// }  
}
$datecheck=date("Y-m-d H:i:s");
if($type=="watched"){
$watch_sql22="select * from watch_list a, auction_details b where a.productid=b.productid and a.user_id=$user_id and (expire_date > '$datecheck') group by b.productid";
}
if($type=="bid"){
$watch_sql22="select * from auction_details b, site_bids a where a.productid=b.productid and status='Active' and (expire_date > '$datecheck') and a.user_id=$user_id group by a.productid";
}
if($type=="won"){
$watch_sql22="select * from site_bids a,auction_details b where b.selling_method!='want_it_now' and a.user_id=$user_id and a.productid=b.productid and a.user_pos='Yes'";
}
$auctype="$type";
$watch_res1=mysql_query($watch_sql22);
$watch_total_records1=mysql_num_rows($watch_res1);
require 'themes/auctionlist.tpl';
?>
