
$(document).ready(function()
{
    
	/*if($(".butonerror").size()>=1)
	    $(".butonerror").corner();
	if($(".bidbutlererror").size()>=1)
	    $(".bidbutlererror").corner();*/	
	
	
});
function init(ids, pageval)
{
	//alert(ids+""+pageval);
	setAuctionsvalues(ids, pageval);	
	refreshID=setInterval("setAuctionsvalues('"+ids+"','"+pageval+"')",1000);
}


	  function setAuctionsvalues(index_auctions,page_name)
	  {
		  
		
		   var auctions=index_auctions;
		  $.post("ajax_auction_data.php", { all_auctions: index_auctions } , function(data)
	      {
			  
			 //alert(data);
             //splitting the values
			 auctions=data.split('|');
			//alert(auctions)
			 for(i=0;i<=auctions.length;i++)
			 {
				 if(auctions[i] != undefined)
				 {
				  auc_det=auctions[i].split("#");
				  if(auc_det != undefined)	
				 
				  $('#product_time_'+$.trim(auc_det[0])).html(auc_det[2]);										
					  $('#product_time_'+$.trim(auc_det[0])).css({color:"#0000CC"});
				if(auc_det[4]<=10)
					{$('#product_time_'+$.trim(auc_det[0])).css({color:"#CC0000"});}
					
					// auction price animated
					price_value=auc_det[1];
					price_value=price_value.replace(/&pound;/,"£");
					//alert(price_value);
				   if( $.trim($('#product_price_'+auc_det[0]).html())!= $.trim(price_value))
				   {					   
					  var bg_color=$('#product_price_'+$.trim(auc_det[0])).parents('tr').attr('bgcolor');
					  $('#product_price_'+auc_det[0]).animate({backgroundColor:"#CC0000"},200).animate({backgroundColor:bg_color},500);					 
				   }
				   //change the price of auction from ajax
				    $('#product_price_'+$.trim(auc_det[0])).html(auc_det[1]);
					$('#bidder_name_'+$.trim(auc_det[0])).html(auc_det[3]);					
				
				 	
					if(auc_det[2]=="Ended")
					{
						if(page_name=="product_detail")	
						$('#buttn_'+$.trim(auc_det[0])).html('<img src="images/sold_small.gif" border="0" title="sold" />');
						else
						$('#buttn_'+$.trim(auc_det[0])).html('<img src="images/sold.gif" border="0" title="sold" />');			
					}
					
					$('#bid_error_'+auc_det[0]).hide();	
					$('#bid1_error_'+auc_det[0]).hide();
					$('#bid_butler_erro').hide();
				 }
			 }  
          });
	  }	 

function place_bid(auc_id,user_id,page_name)
{
	
	if(user_id == undefined || user_id == null || user_id == '')
	{document.location.href='index.php?f=relogin';}
	else
	{
			$.post("ajax_bidding_process.php", { auction_id: auc_id } , function(data)
	      	{
             //splitting the values
			//alert(data);
			 auctions=data.split('#');
			
			
			
				 if(auctions!= undefined && auctions[1]!='recharge' && auctions[1]!='you_cannot_bid' && auctions[1]!='pause_alert')
				 {					 	
					//alert("price value");
					// auction price animated
					price_value=auctions[1];
					price_value=price_value.replace(/&pound;/,"£");
					
					//alert(price_value);
				   if($.trim($('#product_price_'+auctions[0]).html())!= $.trim(price_value))
				   {
					  var bg_color=$('#product_price_'+$.trim(auc_det[0])).parents('tr').attr('bgcolor');					 
					  $('#product_price_'+$.trim(auctions[0])).animate({backgroundColor:"#CC0000"},200).animate({backgroundColor:bg_color},500);					 
				   }
				  
				   $('#product_price_'+$.trim(auc_det[0])).html(auctions[1]);					
					$('#bidder_name_'+$.trim(auc_det[0])).html(auctions[2]);
					$('#user_bid_balance').html(auctions[3]);
					
				 }
				 else if(auctions[1]=='recharge')
				 {
					 
					 // alert('Please Recharge Your Account.'+auc_id);	
					  $('#bid_error_'+auc_id).show();						  
				 }	
				else if(auctions[1]=='you_cannot_bid')
				 {
					 					
					  $('#bid1_error_'+auc_id).show();						  
				 }	
				 else if(auctions[1]=='pause_alert')
				 {
					 				
					  $('#pause_error_'+auc_id).show();						  
				 }	
				 
			 
          });
	}
		
		
}
function hide_fade(aid)
{
	$('#bid_error_'+aid).hide();	
}

function hide_fade1(aid)
{
	$('#bid1_error_'+aid).hide();	
}

function hide_fade2(aid)
{
	$('#pause_error_'+aid).hide();	
}

function hide_bidbutler_error(aid)
{
	$('#bid_butler_erro').hide();	
}

function  get_category_page(cat_id,jobs_id,limit)
{		
	
	$.post("ajax_auction_category_data.php", { category_id: cat_id, job_id: jobs_id, lt: limit} , function(data)
	      	{						
             if(data != undefined && data!="")
				 {  										
					var data_parts=data.split("<--second_part-->");
					$('#cat_auction_'+cat_id+'_'+jobs_id).html(data_parts[0]);
					init(data_parts[1],"all_category_page");
				 }				
          });
}
function browse_category_page(cat_id,jobs_id,limit,page_no)
{
	
	$.post("ajax_auction_category_data.php", {category_id: cat_id, job_id: jobs_id, page: page_no, lt: limit} , function(data)
	      	{						
             if(data != undefined && data!="")
				 {   
					
					var data_parts=data.split("<--second_part-->");
					$('#cat_auction_'+cat_id+'_'+jobs_id).html(data_parts[0]);
					init(data_parts[1],"all_category_page");
					
				 }				
          });
}


<!-- for product details page-->

function init_product_details(ids)
{
	setAuctionsvalues_product_details(ids);	
	refreshID=setInterval("setAuctionsvalues_product_details('"+ids+"')",1000);
}


	  function setAuctionsvalues_product_details(index_auctions){
		 
		  var auctions=index_auctions;
		  $.post("ajax_auction_details_data.php", { all_auctions: index_auctions } , function(data)
	      {
             //splitting the values
			// alert(data);
			 auc_det=data.split('#');	
			// alert(auc_det[2]);
			//alert('a'+$.trim(auc_det[11])+'.b');
				  if(auc_det != undefined)	
				  if(auc_det[12]<=10)
					{$('#product_time_'+$.trim(auc_det[0])).css({color:"#CC0000"});}
				   $('#product_time_'+$.trim(auc_det[0])).html(auc_det[2]);		  
				  	$('#product_price_'+$.trim(auc_det[0])).html(auc_det[1]);
					$('#bidder_name_'+$.trim(auc_det[0])).html(auc_det[3]);											
					$('#countdownimg').attr('src','images/uhr'+$.trim(auc_det[11])+'.png');
					$('#counterAt').html(auc_det[10]);																
					$('#no_bid_placed').html(auc_det[4]);
					$('#bid_placed_amt').html(auc_det[5]);
					$('#auc_price').html(auc_det[9]);
					$('#saving').html(auc_det[6]);
					$('#bidhistory').html(auc_det[7]);
				 
					if(auc_det[8] != undefined)
					{
						$('#last_actions').html(auc_det[8]);
					}
					
					
					if(auc_det[2]=="Ended")
					{						
						$('#buttn_'+auc_det[0]).html('<img src="images/sold.gif" border="0" title="sold" />');			
						document.location.reload();
					}
					
					$('#bid_error_'+auc_det[0]).hide();	
				
		  
          });
	  }	 
	  
function book_bidbutler(form)
{
	
	var uid=form.uid.value;
	var aid=form.aid.value;
	var b_from=form.bid_from.value;
	var b_to=form.bid_to.value;
	var no_bid=form.no_bids.value;
	
	 if (uid == '' || uid == undefined || uid == null) 
	 {return false;} 
	 else if(aid == '' || aid == undefined || aid == null)
	 {return false;}
	
	
	$.post("book_bidbutlerd.php", { user_id: uid, auc_id: aid, bid_from: b_from, bid_to: b_to, no_bids: no_bid } , function(data)
	      {
			 			 
			  butler_msg=data.split('#');	
				if(butler_msg[1]=="error")
				{
					$('#bidbutller_msg').html(butler_msg[2]);
					$('#bid_butler_erro').show();
				}
				if(butler_msg[1]=="success")
				{
					
					$('#bibutlerAccpt').html(butler_msg[2]);
					$('#user_bid_balance').html(butler_msg[3]);

				}
          });
			
		form.bid_from.value="";
		form.bid_to.value="";
		form.no_bids.value="";
	return false;	
}

function bidbutlerHistory(aid,uid)
{
		$.post("ajax_bidbutler_overview.php", {user_id: uid, auc_id: aid} , function(data)
		{			
			   if (data != '' || data != undefined || data != null) 
			   {
				  $('#bidbutlerov').html(data); 	
			   }
          });							
	
}
function my_offers(frm_o)
{	
	$('#offer_code').html('<div style="padding-left:40px; padding-top:20px; padding-bottom:20px; width:500px;" align="center"><img src="images/wheel.gif" width="16" height="16" /><div>');
	var code=frm_o.code.value;
	$.post("ajax_promotion_offer_process.php", {offer: code} , function(data)
		{			
			   if (data != '' || data != undefined || data != null) 
			   {
				  $('#offer_code').html(data);	
			   }
          });	
	
}
function hideall(divid)
{
	$('#'+divid).hide();	
}
function showall(divid)
{
	$('#'+divid).show();	
}
<!--             help page  -->
function hidedisplay_helpheaders(div_id) {
  for (var i = 0; i < 15; i++) {
    el = document.getElementById('help_header_' + i);
    if (el) {
      el.style.display = 'none';
    }
  }
  $('#'+div_id).show();
} 
$(document).ready(function(){
     
	   $("#help_body").show("slow");
    });
function display_help(hqaid)
{
	$('#help_disp').html('<div style="padding-left:40px; padding-top:20px; padding-bottom:20px; width:500px;" align="center"><img src="images/wheel.gif" width="16" height="16" /><div>');
	$.post("ajax_help_data.php", {question_id: hqaid} , function(data)
		{			
			   if (data != '' || data != undefined || data != null) 
			   {				   
				  $('#help_disp').html(data);	
			   }
          });		
}
