<!-- Use for ajax for bid -->
var GlobalVar = 0;
var GlobalStat = 0;
	function changeimage(id)
	{
		var idnew = id;
		if(idnew==1)
		{
			document.getElementById('mainimage'+idnew).style.display='block';
			document.getElementById('mainimage2').style.display='none';
			document.getElementById('mainimage3').style.display='none';
			document.getElementById('mainimage4').style.display='none';
		}
		if(idnew==2)
		{
			document.getElementById('mainimage'+idnew).style.display='block';
			document.getElementById('mainimage1').style.display='none';
			document.getElementById('mainimage3').style.display='none';
			document.getElementById('mainimage4').style.display='none';
		}
		if(idnew==3)
		{
			document.getElementById('mainimage'+idnew).style.display='block';
			document.getElementById('mainimage1').style.display='none';
			document.getElementById('mainimage2').style.display='none';
			document.getElementById('mainimage4').style.display='none';
		}
		if(idnew==4)
		{
			document.getElementById('mainimage'+idnew).style.display='block';
			document.getElementById('mainimage1').style.display='none';
			document.getElementById('mainimage2').style.display='none';
			document.getElementById('mainimage3').style.display='none';
		}
	}
<!-- end for ajax -->
	function setLogin(id)
	{
		document.getElementById(id).src='images/bid_click_login_hover.jpg';		
	}

	function setBid(id)
	{
		document.getElementById(id).src='images/bid_click_white_bid.jpg';		
	}
	
	function changeImage(image)
	{
		document.getElementById(image).src='images/bid_click_bid_hover.jpg';		
	}
	function changeImageout(image)
	{
		document.getElementById(image).src='images/bid_click_white_bid.jpg';			
	}
function changeData(responseText,stat_us)
{
	var text = responseText;
	if(text!="")
	{
		counter = text.split('#');
	    for (i = 0; i < counter.length; i++)
		{
		   counter_data1 = counter[i].split(':');
		   auction_id = counter_data1[0];
		   auction_price = counter_data1[1];
		   auction_bidder_name = counter_data1[2];
		   if(auction_bidder_name=="")
		   {
			  auction_bidder_name="---" 
		   }
			if(document.getElementById('price_index_page_' + auction_id).innerHTML != "&#0036;" + auction_price)
			{
				if(GlobalVar == 1)	
				{
					document.getElementById('price_index_page_' + auction_id).style.backgroundColor = "#f79909";
				}
		   		document.getElementById('price_index_page_' + auction_id).innerHTML = "&#0036;" + auction_price;
		   		document.getElementById('product_bidder_' + auction_id).innerHTML = auction_bidder_name;
			}
			else
			{
				document.getElementById('price_index_page_' + auction_id).style.backgroundColor = "white";	
			}
		}
	}
	GlobalVar = 1;
}
function hidedisplayzoom(div_id) {
	document.getElementById(div_id).style.display = 'block';
	if(document.getElementById('zoomimagename').innerHTML!="" && document.getElementById('zoomimagename').innerHTML!=div_id)
	{
		document.getElementById(document.getElementById('zoomimagename').innerHTML).style.display	= 'none';
	}
	document.getElementById('zoomimagename').innerHTML = div_id;
}
function closezoomimage(div_id)
{
	document.getElementById(div_id).style.display='none';
}
function calc_counter_from_time(diff) {
diff1 = diff - 0;
  if (diff1 >= 0) {
    days=Math.floor(diff1 / 86400)
    hours1=Math.floor(diff1 / 3600)
    minutes=Math.floor((diff1 / 3600 - hours1) * 60)
    seconds=Math.round((((diff1 / 3600 - hours1) * 60) - minutes) * 60)
if(hours1 >= 24)
{ 
dayhr = days * 24;
hours = hours1;
}
else
{ 
hours = hours1;
}
  } else {
    hours = 0;
    minutes = 0;
    seconds = 0;
  }

  if (seconds == 60) {
    seconds = 0;
  }

  if (minutes < 10) {
    if (minutes < 0) {
      minutes = 0;
    }
    minutes = '0' + minutes;
  }
  if (seconds < 10) {
    if (seconds < 0) {
      seconds = 0;
    }
    seconds = '0' + seconds;
  }
  if (hours < 10) {
    if (hours < 0) {
      hours = 0;
    }
    hours = '0' + hours;
  }
//if(days >=1){return days + "D " + hours + ":" + minutes + ":" + seconds;}
//if(days ==0 && hours >= 1){return hours + ":" + minutes + ":" + seconds;}
//if(days ==0 && hours == 0 && minutes >=1){return minutes + ":" + seconds;}
//if(days ==0 && hours == 0 && minutes ==0 && seconds >=1){return seconds;}
//if(days ==0 && hours == 0 && minutes ==0 && seconds <= 0){return "Wait";}
//if(diff1 < 0){return "Wait"}
return hours1 + ":" + minutes + ":" + seconds;
}
var xmlhttp = false;
try {
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
	xmlhttp = false;
	}
}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	xmlhttp = new XMLHttpRequest();
}
function CheckSaveProperty(auction_ids){
	var objId = "URL"
		var ServerPage = "update_time.php?aids=" + auction_ids;
		var objNew = document.getElementById(objId)
		xmlhttp.open("GET",ServerPage)
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				mainarray = xmlhttp.responseText.split('/');
				counters = mainarray[0].split('#')
				for (i = 0; i < counters.length; i++)
				{			
					counter_data = counters[i].split(':');
					auction_id = counter_data[0];
					pausestatus = counter_data[2];
					if(counter_data[1]=='0')
					{
					document.getElementById('counter_index_page_' + auction_id).innerHTML = 'Ended';					
					document.getElementById('image_main_' + auction_id).src = "images/but_sold2.jpg";
					document.getElementById('image_main_' + auction_id).onclick="";
					document.getElementById('image_main_' + auction_id).onmouseover="";
					document.getElementById('image_main_' + auction_id).onmouseout="";
					}
					else if(pausestatus==1)
					{
						document.getElementById('counter_index_page_' + auction_id).innerHTML = 'Pause';					
						document.getElementById('image_main_' + auction_id).src = "images/bid_click_white_bid_hover.jpg";
						document.getElementById('image_main_' + auction_id).onclick="";
						document.getElementById('image_main_' + auction_id).onmouseover="";
						document.getElementById('image_main_' + auction_id).onmouseout="";
					}
					else
					{
					auction_time = counter_data[1];
						if(auction_time<10)
						{
						document.getElementById('counter_index_page_' + auction_id).style.color = '#E80000';	
					document.getElementById('counter_index_page_' + auction_id).innerHTML = calc_counter_from_time(auction_time);
						}
						else
						{
						document.getElementById('counter_index_page_' + auction_id).style.color = '#6e6d6d';	
					document.getElementById('counter_index_page_' + auction_id).innerHTML = calc_counter_from_time(auction_time);
						}
					}
				}
			}
		}
xmlhttp.send(null);
}
function CheckSaveProperty1(auction_ids,auc_his_id,butlerbuttonid){
	var objId = "URL"
		var ServerPage = "update_time.php?aids=" + auction_ids + "&auc_his_id=" + auc_his_id;
		var objNew = document.getElementById(objId)
		xmlhttp.open("GET",ServerPage)
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				mainarray = xmlhttp.responseText.split('/');
				counters = mainarray[0].split('#')
				for (i = 0; i < counters.length; i++)
				{			
					counter_data = counters[i].split(':');
					auction_id = counter_data[0];
					pausestatus = counter_data[2];
					if(counter_data[1]=='0')
					{
					document.getElementById('counter_index_page_' + auction_id).innerHTML = 'Ended';					
					document.getElementById('image_main_' + auction_id).src = "images/but_sold2.jpg";
					document.getElementById('image_main_' + auction_id).onclick="";
					document.getElementById('image_main_' + auction_id).onmouseover="";
					document.getElementById('image_main_' + auction_id).onmouseout="";
					if(butlerbuttonid==auction_id)
					{
						document.getElementById('bookbidbutlerbutton').disabled = true;
					}
					}
					else if(pausestatus==1)
					{
						document.getElementById('counter_index_page_' + auction_id).innerHTML = 'Pause';					
						document.getElementById('image_main_' + auction_id).src = "images/bid_click_white_bid_hover.jpg";
						document.getElementById('image_main_' + auction_id).onclick="";
						document.getElementById('image_main_' + auction_id).onmouseover="";
						document.getElementById('image_main_' + auction_id).onmouseout="";
					}
					else
					{
					auction_time = counter_data[1];
						if(auction_time<10)
						{
						document.getElementById('counter_index_page_' + auction_id).style.color = '#E80000';	
					document.getElementById('counter_index_page_' + auction_id).innerHTML = calc_counter_from_time(auction_time);
						}
						else
						{
						document.getElementById('counter_index_page_' + auction_id).style.color = '#6e6d6d';	
					document.getElementById('counter_index_page_' + auction_id).innerHTML = calc_counter_from_time(auction_time);
						}
					}
				}
			CheckProHistory(mainarray[1]);	
			}
		}
xmlhttp.send(null);
}
function setbidding(prid,aid,uid)
{
	var url="getbid.php?prid="+prid+"&aid="+aid+"&uid="+uid;

	new Ajax.Request(url,
		{   
		method: 'get',   
		onSuccess: function(transport) 
		{     
			if(transport.status==200)
			{	
				var temp=transport.responseText;
				if(temp=="unsuccess")
				{
					if(confirm("Please recharge your bid account"))
					{
						window.location.href='buybids.html';
					}
				}	
				if(temp=="highbidder")
				{
					if(confirm("You Are Already The High Bidder"))
					{
						window.location.href='index.php';
					}
				}	
				if(temp=="success")
				{
					obj = document.getElementById('bids_count');
					objvalue = document.getElementById('bids_count').innerHTML;
					if(obj.innerHTML!='0')
					{
						obj.innerHTML = Number(objvalue) - 1;
					}
				}
			}
		}
		});		
}
function CheckProHistory(aucid_new){
		var history__data = "";
		var history____data;
		history__data = aucid_new;
		if(history__data!="" && history__data!="|")
		{
			history____data = history__data.split('|');
			counter_history = history____data[0].split('#');
			counter_history_mybid = history____data[1].split('#');
			if(counter_history!="")
			{
				for (i = 0; i < counter_history.length; i++)
				{
				   history_data = counter_history[i].split(':');
				   bidding_price = history_data[0];
				   bidding_username = history_data[1];
				   if(bidding_username=="" && bidding_price!="")
				   {
					   bidding_username="user removed";
				   }
				   bidding_type = history_data[2];
					document.getElementById('bid_price_' + i).innerHTML = "&#0036;" + bidding_price;
					document.getElementById('bid_user_name_' + i).innerHTML = bidding_username;
					if(bidding_type=='s')
					{
						document.getElementById('bid_type_' + i).innerHTML = "Einzelgebot";
					}
					else if(bidding_type=='b')
					{
						document.getElementById('bid_type_' + i).innerHTML = "BietBuddy";
					}
				}
			}
			if(counter_history_mybid!="")
			{
				for (i = 0; i < counter_history_mybid.length; i++)
				{
				   history_data1 = counter_history_mybid[i].split('!');
				   bidding_price1 = history_data1[0];
				   bidding_time1 = history_data1[1];
				   bidding_type1 = history_data1[2];
					document.getElementById('my_bid_price_' + i).innerHTML = "&#0036;" + bidding_price1;
					document.getElementById('my_bid_time_' + i).innerHTML = bidding_time1;
					if(bidding_type1=='s')
					{
						document.getElementById('my_bid_type_' + i).innerHTML = "Single Bid";
					}
					else if(bidding_type1=='b')
					{
						document.getElementById('my_bid_type_' + i).innerHTML = "AutoBidder";
					}
				}
			}
		 }
}
function PressImageDownBid(id)
{
	document.getElementById(id).src = 'images/bid_click_press.jpg';
}
function PressImageUpBid(id)
{
	document.getElementById(id).src = 'images/bid_click_bid_hover.jpg';
}
function PressImageDownLogin(id)
{
	document.getElementById(id).src = 'images/login_click_press.jpg';
}
function PressImageUpLogin(id)
{
	document.getElementById(id).src = 'images/bid_click_login_hover.jpg';
}
function changedatabutler(data,page,butlerpbids)
{
	data1 = eval('(' + data.responseText + ')');
	k = 1;
	for (j=0;j<data.butlerslength.length;j++)
	{	
			if(data.butlerslength[j].bidbutler.startprice!="")
			{	
				if(Number(j)<Number(data.butlerslength.length))
				{
					butlerstartprice = "$"+data.butlerslength[j].bidbutler.startprice;
					butlerendprice = "$"+data.butlerslength[j].bidbutler.endprice;
					butlerbid = data.butlerslength[j].bidbutler.bids;
					but_id = data.butlerslength[j].bidbutler.id;
					var blockst = 1;
				}
				else
				{
					butlerstartprice = "&nbsp;";
					butlerendprice = "&nbsp;";
					butlerbid ="&nbsp;";
					but_id = "";
					var blockst = 0;
				}
			}	
			else
			{
				butlerstartprice = "&nbsp;";
				butlerendprice = "&nbsp;";
				butlerbid ="&nbsp;";
				but_id = "";
				var blockst = 0;
			}
			if(j==0)
			{
				document.getElementById('mainbutlerbody_' + k).style.display = 'block';
				document.getElementById('butlerstartprice_1').innerHTML = butlerstartprice;
				document.getElementById('butlerendprice_1').innerHTML = butlerendprice;
				document.getElementById('butlerbids_1').innerHTML = butlerbid;
				if(blockst==1)
				{
				document.getElementById('deletebidbutler_1').style.display = 'block';
				document.getElementById('deletebidbutler_1').innerHTML = "<img src='images/btn_closezoom.png' style='cursor: pointer;' onclick='DeleteBidButler(\""+but_id+"\",\"1\");' id='butler_image_1' />";
				//document.getElementById('butler_image_1').onclick = "DeleteBidButler('"+but_id+"','1')";
				}
				else
				{
				document.getElementById('deletebidbutler_1').style.display = 'none';
				}
			}
			else if(j==1)
			{
				document.getElementById('mainbutlerbody_' + k).style.display = 'block';
				document.getElementById('butlerstartprice_2').innerHTML = butlerstartprice;
				document.getElementById('butlerendprice_2').innerHTML = butlerendprice;
				document.getElementById('butlerbids_2').innerHTML = butlerbid;
				if(blockst==1)
				{
				document.getElementById('deletebidbutler_2').style.display = 'block';
				document.getElementById('deletebidbutler_2').innerHTML = "<img src='images/btn_closezoom.png' style='cursor: pointer;' onclick='DeleteBidButler(\""+but_id+"\",\"2\");' id='butler_image_2' />";
				}
				else
				{
				document.getElementById('deletebidbutler_2').style.display = 'none';
				}
			}
			else if(j==2)
			{
				document.getElementById('mainbutlerbody_' + k).style.display = 'block';
				document.getElementById('butlerstartprice_3').innerHTML = butlerstartprice;
				document.getElementById('butlerendprice_3').innerHTML = butlerendprice;
				document.getElementById('butlerbids_3').innerHTML = butlerbid;
				if(blockst==1)
				{
				document.getElementById('deletebidbutler_3').style.display = 'block';
				document.getElementById('deletebidbutler_3').innerHTML = "<img src='images/btn_closezoom.png' style='cursor: pointer;' onclick='DeleteBidButler(\""+but_id+"\",\"3\");' id='butler_image_3' />";
				}
				else
				{
				document.getElementById('deletebidbutler_3').style.display = 'none';
				}
			}
			else if(j>2)
			{
				document.getElementById('mainbutlerbody_' + k).style.display = 'block';
				document.getElementById('butlerstartprice_' + k).innerHTML = butlerstartprice;
				document.getElementById('butlerendprice_' + k).innerHTML = butlerendprice;
				document.getElementById('butlerbids_' + k).innerHTML = butlerbid;
				if(blockst==1)
				{
				document.getElementById('deletebidbutler_' + k).style.display = 'block';
				document.getElementById('deletebidbutler_' + k).innerHTML = "<img src='images/btn_closezoom.png' style='cursor: pointer;' onclick='DeleteBidButler(\""+but_id+"\",\"" + k + "\");' id='butler_image_" + k +"' />";
				}
				else
				{
				document.getElementById('deletebidbutler_' + k).style.display = 'none';
				}
			}
		k++;
	}
	for(p=data.butlerslength.length+1;p<=20;p++)
	{
		document.getElementById('mainbutlerbody_' + p).style.display = 'none';
	}
	if(page=="abut")
	{
		document.getElementById('live_no_bidbutler').style.display = 'none';
		if(butlerpbids!="&nbsp;")
		{
			objbids = document.getElementById('bids_count');
			objbidsvalue = document.getElementById('bids_count').innerHTML;
			if(objbids.innerHTML!='0')
			{
				objbids.innerHTML = Number(objbidsvalue) - Number(butlerpbids);
			}
		}	
	}
}
function ChangeButlerImageSecond() 
{
	document.getElementById('butlermessage').style.display='none';
	clearInterval(changeMessageTimer);
}
	function onBeforeUnloadAction()
	{
		url1="updatelogin.php";
		xmlhttp.open("GET",url1)
		xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				datatemp = xmlhttp.responseText;
		}
		}
	xmlhttp.send(null);
	}
			window.onbeforeunload = function(e){
			if(!e) e = window.event;
			if(typeof e.pageX == "number")
			{
				X = e.pageX;
				Y = e.pageY;
			}
			else
			{
				X = e.clientX;
				Y = e.clientY;
			}
			if((X<0) || (Y<0))
			{
				 return onBeforeUnloadAction();
		    }
		 }
	function UpdateLoginLogout()
	{
		url1="updatelogin.php";
		xmlhttp.open("GET",url1);
		xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				datatemp = xmlhttp.responseText;
		}
		}
xmlhttp.send(null);
}
