var doc = null;

var Extend_timer = new Array(); 
var Extend_status = new Array();
var Old_Bidcounter = new Array();
var Auction_ids=0;
var Product_id=0;
var Pagename='';
var Timer_color="";  	
var Flashing_timer=0;
var Lang_path="";


function ajax() {
	// Make a new XMLHttp object

    if (window.XMLHttpRequest) {
        try {
            doc = new XMLHttpRequest();
        } catch(e)  {}
    } else if (window.ActiveXObject) {
        try {
            doc = new ActiveXObject('Msxml2.XMLHTTP');
        } catch(e)  {
          try {
              doc = new ActiveXObject('Microsoft.XMLHTTP');
          } catch(e)  {}
        }
    }
}

function Update_Bid_Detail()
{	
	ajax();
	doc.open('GET', "./timer_location.php?section=update_bid&Runngin_list="+Auction_ids+"&Product_id="+Product_id, true); 	
	doc.setRequestHeader('Content-Type','application/x-www-form-urlencoded');        
  
	doc.onreadystatechange = function() { 
			
	if(doc.readyState == 4)
		{
		if(doc.status == 200)
			{ 
			if(doc.responseText!='')
				{
				var arraylist=doc.responseText.split("|@|");
				for(var l=0;l<arraylist.length;l++)
					{
						
						var arraylist1=arraylist[l].split("**");
						var pro_id =(parseInt(arraylist1[0]));
						
						
						if(arraylist1[1]=='Y')
							document.getElementById('counter_index_div_'+pro_id).innerHTML = "<font color='red'><b>END</b></font>";
						else if(Extend_status[pro_id]!=arraylist1[1])
									Update_status(pro_id);
					
					if(Old_Bidcounter[pro_id]!=parseInt(arraylist1[2]))
							{
						
							Old_Bidcounter[pro_id]=parseInt(arraylist1[2]);	
							Update_credits();	
							if(Product_id!=0)
								{
								Update_Auction_Detail_Product();	
								Update_bid_table();
								}
							else
								Update_Auction_Detail(pro_id);	
					
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 10);
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 70);
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 130);	
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 200);
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 270);
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 330);
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 400);
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 470);
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = ""', 530);
						
							} 
						} 
		
		}}}}; 
		
	 setTimeout('Update_Bid_Detail()', 3000); 
     doc.send(null);
}


function Run_timer_product()
{
	if(Extend_timer[Product_id]>0)
		{
		if(Extend_status[Product_id]=="E")
			{
			if(Extend_timer[Product_id]==4)
				Add_robot_bid(Product_id);
	
			if(Extend_timer[Product_id]<=Flashing_timer)
				{
				Show_flash_image(Product_id)	
		document.getElementById('counter_index_div_'+Product_id).innerHTML="<font color='"+Timer_color+"'>"+calc_counter_from_time_short(Extend_timer[Product_id])+"</font>";
				}
			else
				{
				document.getElementById('flashing_index_div_'+Product_id).innerHTML = '';	
				document.getElementById('counter_index_div_'+Product_id).innerHTML = "<font color='red'>" + calc_counter_from_time_short(Extend_timer[Product_id]) + "</font>";
				}
			}
		else if(Extend_status[Product_id]=="N")
			document.getElementById('counter_index_div_'+Product_id).innerHTML = '' + calc_counter_from_time(Extend_timer[Product_id]);
		else if(Extend_status[Product_id]=="P")
			{
				document.getElementById('bid_btn_'+Product_id).innerHTML = "<div style='padding-top:6px;'>PAUSED</div>";
				document.getElementById('counter_index_div_'+Product_id).innerHTML = "<b>--:--:--</b>";
			}
		}
	else
		{
		if(Extend_status[Product_id]=="N")	
			{
			Extend_status[Product_id]='E';		
			Expire_home_bid(Product_id);
			}
		else if(Extend_status[Product_id]=='E')
			{
			Extend_status[Product_id]='S';
			document.getElementById('counter_index_div_'+Product_id).innerHTML = "<b>Waiting</b>";
			setTimeout('Expire_extend_bid('+Product_id+')', 1000);
			}
		else if(Extend_status[Product_id]=="P")
			{
			document.getElementById('bid_btn_'+Product_id).innerHTML = "<div style='padding-top:8px;'>PAUSED</div>";
			document.getElementById('counter_index_div_'+Product_id).innerHTML = "<b>--:--:--</b>";
			}	
		}
			Extend_timer[Product_id]=(Extend_timer[Product_id]-1);	
			
		
		setTimeout('Run_timer_product();', 950); 
	
	}

function Run_timer()
{
	if(Auction_ids!='0')
		{
		var arraylist=Auction_ids.split(",");
			
		for(l=0;l<arraylist.length;l++)
		{	 
			var pro_id =(parseInt(arraylist[l]));
		
			if(Extend_timer[pro_id]>0)
				{
				if(Extend_status[pro_id]=="E")
					{
					if(Extend_timer[pro_id]==4)
						Add_robot_bid(pro_id);
				
				document.getElementById('counter_index_div_'+pro_id).innerHTML = "<font color='red'>" + calc_counter_from_time_short(Extend_timer[pro_id]) + "</font>";			
					}
				else if(Extend_status[pro_id]=="N")
					document.getElementById('counter_index_div_'+pro_id).innerHTML = '' + calc_counter_from_time(Extend_timer[pro_id]);
				else if(Extend_status[pro_id]=="P")
						{
							document.getElementById('bid_btn_'+pro_id).innerHTML = "PAUSED";
							document.getElementById('counter_index_div_'+pro_id).innerHTML = "<b>PAUSE</b>";
						}
					}
				else
					{
					if(Extend_status[pro_id]=="N")	
						{
						Extend_status[pro_id]='E';		
						Expire_home_bid(pro_id);
						}
					else if(Extend_status[pro_id]=='E')
						{
							Extend_status[pro_id]='S';
							document.getElementById('counter_index_div_'+pro_id).innerHTML = "<b>Waiting</b>";
							setTimeout('Expire_extend_bid('+pro_id+')', 1000);
						}
					else if(Extend_status[pro_id]=="P")
						{
							document.getElementById('bid_btn_'+pro_id).innerHTML = "<div style='padding-top:6px;'>PAUSED</div>";
							document.getElementById('counter_index_div_'+pro_id).innerHTML = "<b>PAUSE</b>";
						}	
					}
					Extend_timer[pro_id]=(Extend_timer[pro_id]-1);	
			} 
		}
		setTimeout('Run_timer();', 950); 
	
	}

function Update_status(Pro_id)
{
		ajax();
	doc.open('GET', "./timer_location.php?section=update_status&Auction_ids="+Auction_ids+"&Pro_id="+Pro_id+"&Pagename="+Pagename+"&Product_id="+Product_id, true);
	doc.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
		
	doc.onreadystatechange = function()
	   	{ 
		if(doc.readyState == 4)
			{
			if(doc.status == 200)
				{
				if(doc.responseText!=0)
					{
						var Main_array=doc.responseText.split("**");	
						
						Extend_timer[Pro_id] = parseInt(Main_array[1]);		
						Extend_status[Pro_id]=Main_array[2];	
						if(Main_array[0]!="")
							document.getElementById('bid_btn_'+Pro_id).innerHTML = Main_array[0];	
							
					}
				}
			}
	    };
	doc.send(null);
}

function Update_timer()
{
		ajax();
	doc.open('GET', "./timer_location.php?section=update_timer&Runngin_list="+Auction_ids, true);
	doc.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
		
	doc.onreadystatechange = function()
	   	{ 
		if(doc.readyState == 4)
			{
			if(doc.status == 200)
				{
				if(doc.responseText!=0)
					{
		  			var arraylist=doc.responseText.split("|@|");
						
					for(l=0;l<arraylist.length;l++)
						{	
						var Main_array=arraylist[l].split("**");
						var pro_id =(parseInt(Main_array[0]));
						Extend_timer[pro_id] = parseInt(Main_array[1]);	
						Extend_status[pro_id]=Main_array[2];	
						} 
					}
		}
				}
		  };
		 setTimeout('Update_timer();', 5000);  
     doc.send(null);

}	

function Update_Auction_Detail(Pro_id)
{	
	ajax();
 doc.open('GET', "./timer_location.php?section=update_auction_details&Pro_id="+Pro_id, true); 	
	doc.setRequestHeader('Content-Type','application/x-www-form-urlencoded');        
   
	doc.onreadystatechange = function() { 
			
	if(doc.readyState == 4)
		{
		if(doc.status == 200)
			{ 
			if(doc.responseText!='')
				{
				var arraylist=doc.responseText.split("**");
				document.getElementById('winner_index_div_'+Pro_id).innerHTML = arraylist[0];
				document.getElementById('price_index_div_'+Pro_id).innerHTML = arraylist[1];	
				
				Extend_timer[Pro_id] = parseInt(arraylist[2]);		
						
		}}}}; 

	 
     doc.send(null);
	
	 
}

function Update_Auction_Detail_Product()
{	
	ajax();
 doc.open('GET', "./timer_location.php?section=update_auction_details_product&product_id="+Product_id, true); 	
	doc.setRequestHeader('Content-Type','application/x-www-form-urlencoded');        
   
	doc.onreadystatechange = function() { 
			
	if(doc.readyState == 4)
		{
		if(doc.status == 200)
			{ 
			if(doc.responseText!='')
				{
				var Main_array=doc.responseText.split("=#=");
				var arraylist=Main_array[0].split("**");
				document.getElementById('winner_index_div_'+Product_id).innerHTML = arraylist[0];
				document.getElementById('price_index_div_'+Product_id).innerHTML = arraylist[1];	
				
				Extend_timer[Product_id] = parseInt(arraylist[3]);		
							
					var arraylist3=Main_array[1].split("*@*");
					
						if(arraylist3[2]=="L")
							{
							if(arraylist3[3]!="I")
								document.getElementById("bid_from").value = arraylist3[3];
									
							if(arraylist3[5]!="R")
								Update_bid_table();
							}
						else
							{
							if(arraylist3[2]!="R")
								Update_bid_table();	
							}
					
							document.getElementById('price_index1_div_'+Product_id).innerHTML = arraylist3[0];
							document.getElementById('price_save_div_'+Product_id).innerHTML = arraylist3[1];
					
						
		}}}}; 

	 
     doc.send(null);
	
	 
}


function Valid_username(login){
		ajax();
	   if (doc){
	       doc.open("GET", "./location1.php?section=username&login="+login, false); 
	       doc.send(null);
	      return  doc.responseText;
	    }
}
function CheckAvail(id_region){
		var avail=document.getElementById(id_region).value;
		ajax();
	    if (doc){
	       doc.open("GET", "location1.php?section=tutoring&avail="+avail, false);
	       doc.send(null);

			if(doc.responseText==1) 
				{
				alert(document.getElementById('username_already_exist').innerHTML+"\n");
				return false;
				}
			else if(doc.responseText==2)
			 {
				alert(document.getElementById('this_username_available').innerHTML+"\n");
				return false; 
			 }
			else if(doc.responseText==3)
			 {
				alert(document.getElementById('please_enter_username').innerHTML+"\n");
				return false; 
			 } 
			else
			return true;
			 
		}	
	
	}
function CheckEmail(id_region){

		var emailadd=document.getElementById(id_region).value;
		ajax();
	    if (doc){
	       doc.open("GET", "location1.php?section=availmail&emailadd="+emailadd, false);
	       doc.send(null);
			
			if(doc.responseText==1) 
				{
				alert(document.getElementById('email_already_exist').innerHTML+"\n");
				return false;
				}
		else if(doc.responseText==2)
			 {
				alert(document.getElementById('this_email_available').innerHTML+"\n");
				return false; 
			 }
			else if(doc.responseText==3)
			 {
				alert(document.getElementById('please_enter_email').innerHTML+"\n");
				return false; 
			 } 
			else
			return true;
	    }	
	
	}	


function Valid_mobile(tel){
		ajax();
	   if (doc){
	       doc.open("GET", "./location1.php?section=mobile&tel="+tel, false); 
	       doc.send(null);
	      return  doc.responseText;
	    }
}

function Edit_Valid_mobile(tel){
		ajax();
	   if (doc){
	       doc.open("GET", "./location1.php?section=edit_mobile&tel="+tel, false); 
	       doc.send(null);
		  
	      return  doc.responseText;
	    }
}

function Edit_Valid_username(login){
		ajax();
	   if (doc){
	       doc.open("GET", "./location1.php?section=edit_username&login="+login, false); 
	       doc.send(null);
		  
	      return  doc.responseText;
	    }
}



function Valid_email(email){
		ajax();
	   if (doc){
	       doc.open("GET", "./location1.php?section=email&email="+email, false);   
	       doc.send(null);
	      return  doc.responseText;
	    }
}

function Edit_Valid_email(email){
		ajax();
	   if (doc){
	       doc.open("GET", "./location1.php?section=edit_email&email="+email, false);   
	       doc.send(null);
	      return  doc.responseText;
	    }
}

function bid_list(item_id,table_type)
{
		ajax();
	   if (doc){
	       doc.open("GET", "./location.php?section=bid_list_table&item_id="+item_id+"&table_type="+table_type, false);   
	       doc.send(null);
 			 var mainarraylist=doc.responseText.split("|**|");
			if(mainarraylist[1]=="bidlist")
			document.getElementById('bidlist_table_div').innerHTML = mainarraylist[0];
			
			if(table_type=='B')
				Update_bid_table();
	    }
}

function bidbutler_list(item_id,table_type)
{
		ajax();
	   if (doc){
	       doc.open("GET", "./location.php?section=book_bidbutler_table&item_id="+item_id+"&table_type="+table_type, false);   
	       doc.send(null);
 			 var mainarraylist=doc.responseText.split("|**|");
			if(mainarraylist[1]=="book_bidbulter")
			document.getElementById('book_bidbutler_table_div').innerHTML =  mainarraylist[0];

	    }
}

function get_info_drop_dowm(promotion_id){
	  ajax();
	  if (doc){
	       doc.open("GET", "./location1.php?section=promotion&promotion_id=" + promotion_id, false);
	       doc.send(null);
	    	// Write the response to the div	    	
	       document.getElementById('info_div').innerHTML = doc.responseText;
	    }	
	}

function Update_bid_table(){
	    	ajax();
		if (doc){
	       doc.open("GET", "./location.php?section=update_bid_table&product_id="+Product_id, false);
		   doc.send(null);
    	// Write the response to the div
	       var mainarraylist=doc.responseText.split("|**|");
		   if(mainarraylist[1]=="BidHistory")
		   {
             document.getElementById('bid_table_div1').innerHTML = mainarraylist[0];
			if(mainarraylist[3]=='I')
 			 document.getElementById("bid_from").value = mainarraylist[2];
		   }
		   
		}
	}

function Show_flash_image(item_id)
	{
			ajax();
	   if (doc){
		    doc.open('GET', "./timer_location.php?section=show_flash_image&item_id="+item_id, false); 
	        doc.send(null);
			 var mainarraylist=doc.responseText.split("|**|");
			if(mainarraylist[1]=="Flash_text")
			document.getElementById('flashing_index_div_'+item_id).innerHTML = mainarraylist[0];
		
			}
	}


function Expire_home_bid(pro_id) {
		ajax();
	    if (doc){
	       doc.open("GET", "./location.php?section=expire_bid&pro_id="+pro_id, false);
 			doc.send(null);
			var mainarraylist=doc.responseText.split("|**|");
			if(mainarraylist[1]=="expire_bid_time")
			Extend_timer[pro_id] = parseInt(mainarraylist[0]);	
			
			}
}	

function Expire_extend_bid(pro_id) {
		ajax();
	   doc.open('GET', "./location.php?section=expire_extend&pro_id="+pro_id, true);
        doc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');        
       doc.onreadystatechange = function()
	   	{ 
	
	 	  if (doc.readyState == 4)
		  	{
				
	           if (doc.status == 200)
				{  
				
				var arraylist=doc.responseText.split("**");
				var pro_id =(parseInt(arraylist[1]));
				var Status=trim(arraylist[0]);
				if(Status=="S")
					{
					Extend_status[pro_id]='Y';
					document.getElementById('counter_index_div_'+pro_id).innerHTML = "<font color='red'><b>END</b></font>" ;
		
				if(pro_id==Product_id)				
					document.getElementById('bid_btn_'+pro_id).innerHTML = "<div style='padding-top:6px;'><font color='white'><b>SOLD</b></font></div>";
				else
					document.getElementById('bid_btn_'+pro_id).innerHTML = "<div style='padding-top:6px;'><font color='white'><b>SOLD</b></font></div>";
				
					if(pro_id==Product_id)		
						Congratulation_auction(pro_id); 
						Show_buy_auction(pro_id);
					}
				else
					{
					Extend_status[pro_id]='E';		
					Extend_timer[pro_id] = (parseInt(arraylist[2]));	
					}
				}
			}
		}
			doc.send(null);
}	

function trim(str, chars) {
return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function Add_robot_bid(pro_id) {
			ajax();
	    if (doc){
	       doc.open("GET", "./location.php?section=add_robot_bid&pro_id="+pro_id, false);
 			doc.send(null);
			//alert(doc.resonseText);
			}
		}


function add_to_watchlist(item_id){
			ajax();
	    if (doc){
	       doc.open("GET", "./location1.php?section=add_to_watchlist&item_id=" + item_id, false);
		   	doc.send(null);
			
			if(doc.responseText==1)
				alert("This product to be add in your watchlist successfully.");
			else if(doc.responseText==2)
				alert("This product has been watched.");
			}
}
	
	

	
	function calc_counter_from_time(diff) 
{

  if (diff > 0) {
	days=Math.floor(diff / (3600*24));
		  
    hours1=Math.floor((diff / 3600)-(days*24));
	  hours=Math.floor((diff / 3600));			
    minutes=Math.floor((diff / 3600 - hours1 -(days*24)) * 60);
	
    seconds=Math.round((((diff / 3600 - hours1-(days*24)) * 60) - minutes) * 60);
  } else {
	days=0;
    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;
  }
  

  return hours + " : " + minutes + " : " + seconds;
}


function calc_counter_from_time_short(diff) {

  if (diff > 0) {
    hours=Math.floor(diff / 3600)

    minutes=Math.floor((diff / 3600 - hours) * 60)

    seconds=Math.round((((diff / 3600 - hours) * 60) - minutes) * 60)
  } 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;
  }

  return minutes + " : " + seconds;
}



function Add_bid(pro_id) {
			ajax();
	    if (doc){
			
			Extend_timer[pro_id]=(Extend_timer[pro_id]+1);
	       doc.open("GET", "./location.php?section=add_bid&pro_id="+pro_id+"&extend_timer="+Extend_timer[pro_id], false);
 			doc.send(null);
			if(parseInt(doc.responseText)==99999)
				document.location="login.html";
			else
				{
				var mainarraylist=doc.responseText.split("**");
				if(mainarraylist.length>3)
					{
					Old_Bidcounter[pro_id]=mainarraylist[3];	
						
					if(Product_id!=0)
						{
						Update_Auction_Detail_Product();	
						Update_bid_table();
						}
					else
						Update_Auction_Detail(pro_id);
					
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 10);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 70);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 130);	
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 200);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 270);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 330);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 400);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#88c136"', 470);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = ""', 530);	
					if(Product_id=='')
					document.getElementById('div_blance').innerHTML = mainarraylist[1];
					}
				else
					{
					if(mainarraylist[1]=="ADDBID")	
						alert(trim(mainarraylist[0]));
					}
				}
			}
		}

function showdisplay(item_id){
			ajax();
	    if (doc){
	       doc.open("GET", "./location1.php?section=show_detail&item_id=" + item_id, false);
		   	doc.send(null);
			//alert(doc.responseText);
			document.getElementById('auction_detail_'+parseInt(item_id)).innerHTML = doc.responseText;
					
			}
}

function hidedisplay(item_id){

document.getElementById('auction_detail_'+parseInt(item_id)).innerHTML = '';

}


function hidedisplay_auctiontype(div_id){
  el = document.getElementById(div_id);

  if (div_id == 'help_AUCTIONS_FLAG_1_CENT')
  {
    if (document.getElementById('help_AUCTIONS_FLAG_CLICK_ONLY'))
  {
    document.getElementById('help_AUCTIONS_FLAG_CLICK_ONLY').style.display = "none";
  }
  if (document.getElementById('help_AUCTIONS_FLAG_INTERNATIONAL'))
  {
    document.getElementById('help_AUCTIONS_FLAG_INTERNATIONAL').style.display = "none";
  }
  }
  if (div_id == 'help_AUCTIONS_FLAG_CLICK_ONLY')
  {
    if (document.getElementById('help_AUCTIONS_FLAG_1_CENT'))
  {
    document.getElementById('help_AUCTIONS_FLAG_1_CENT').style.display = "none";
  }
  if (document.getElementById('help_AUCTIONS_FLAG_INTERNATIONAL'))
  {
    document.getElementById('help_AUCTIONS_FLAG_INTERNATIONAL').style.display = "none";
  }
  }
  if (div_id == 'help_AUCTIONS_FLAG_INTERNATIONAL')
  {
    if (document.getElementById('help_AUCTIONS_FLAG_CLICK_ONLY'))
  {
    document.getElementById('help_AUCTIONS_FLAG_CLICK_ONLY').style.display = "none";
  }
  if (document.getElementById('help_AUCTIONS_FLAG_1_CENT'))
  {
    document.getElementById('help_AUCTIONS_FLAG_1_CENT').style.display = "none";
  }
  }

  if (el) {
    if (el.style.display == "none") {
      el.style.display = "";

    } else {
      el.style.display = "none";
    }
  }
}

function Congratulation_auction(item_id)
{			ajax();
	    if (doc){
	       doc.open("GET", "./location.php?section=congratulation_auction&item_id="+item_id, false);
 			doc.send(null);
            var mainarraylist=doc.responseText.split("|**|");
			
			if(mainarraylist[1]=="congraulation")

			document.getElementById('congratulation_auction_div_'+parseInt(item_id)).innerHTML = mainarraylist[0];

		}
	
}

function Show_buy_auction(item_id)
{			ajax();
	    if (doc){
	       doc.open("GET", "./location.php?section=show_buy_auction&item_id="+item_id, false);
 			doc.send(null);
            var mainarraylist=doc.responseText.split("|**|");
			
			if(mainarraylist[1]=="buy_auction")
			document.getElementById('show_buy_auction_'+parseInt(item_id)).innerHTML = mainarraylist[0];
		}
		
		Update_Buy_Detail(item_id);
	
}

function Update_Buy_Detail(pro_id) {
	 ajax();
	 if (doc){
	       doc.open("GET", "./location.php?section=buy_detail&pro_id=" + pro_id, false);
 			doc.send(null);
			var mainarraylist=doc.responseText.split("|**|");
			//alert(doc.responseText);
			if(mainarraylist[1]=="show_buy_bid")
		     document.getElementById('bid_rebate_price_div_'+pro_id).innerHTML = mainarraylist[0];
		  }
		setTimeout('Update_Buy_Detail('+pro_id+');',15000); 
	}
	
function showzoomdisplay(item_id){
		ajax();
	    if (doc){
	       doc.open("GET", "./location1.php?section=showzoomdisplay&item_id=" + item_id, false);
		   	doc.send(null);
			document.getElementById('zoom_img_'+parseInt(item_id)).innerHTML = doc.responseText;
					
			}
}


function Update_credits() {
		ajax();	
	  if (doc){
	       doc.open("GET", "./timer_location.php?section=update_credits", false);
 			doc.send(null);
			var mainarraylist=doc.responseText.split("|**|");
		   if(mainarraylist[1]=="update_balance")
		     document.getElementById('div_blance').innerHTML = mainarraylist[0];
			  
		  }
		setTimeout('Update_credits();',15000); 
	}



function hidezoomdisplay(item_id){

document.getElementById('zoom_img_'+parseInt(item_id)).innerHTML = '';

}

function Show_product_details(URL)
	{
	document.location=URL;
	}
	
 function do_empty(sel_id){ document.getElementById(sel_id).value="";  }
	function do_default(sel_id,text_val){
		if(document.getElementById(sel_id).value=="")
			document.getElementById(sel_id).value =text_val;
	}
	
function search_validation(frm)
 {
 var error=0;
 var message="";
 if(frm.search.value=="" || frm.search.value=="Search Product")
    {		
       if(error==0)
	     frm.search.focus();
       message=message+document.getElementById('search_alert').innerHTML+"\\n";
	   error=1;
	}
 	if(message)
 	  {	  
	    alert(message);
		return false;
	   }
	   else
	   {	
	   		document.loginform.submit();
			return true;
	   }
	 }	
function validation(frm)
{
	var error=0;
	var message="";
if(frm.login.value=="" || frm.login.value=="Username")
    {		
       if(error==0)
	     frm.login.focus();
       message=message+document.getElementById('login_alert').innerHTML+"\n";
	   error=1;
	}
  if(frm.pass.value=="" || frm.pass.value=="Password")
    {		
       if(error==0)
	     frm.pass.focus();
       message=message+document.getElementById('pass_exists').innerHTML+"\n";
	   error=1;
	}
	if(message)
 	  {	  
	    alert(message);
		return false;
	   }
	   else
	   {	
	   		document.loginform.submit();
			return true;
	   }
	}

 function validation_friend(frm)
	{
	var error=0;
	var message="";
	
	if(frm.friend_email.value=="" || frm.friend_email.value=="FRIEND EMAIL")
		{		
		   if(error==0)
			 frm.friend_email.focus();
		   message=message+document.getElementById('friend_email_alert').innerHTML+"\n";
		   error=1;
		}
	else
		{
			var frmEmail1 =frm.friend_email.value.toLowerCase();	
			var frmEmailformat = /^[^@\s]+@([-a-z0-9]+\.)+([a-z]{2}|com|net|edu|org|gov|mil|int|biz|pro|info|arpa|aero|coop|name|museum)$/;
			if (!frmEmailformat.test(frmEmail1)) 
			{
				if(error!=1)
					frm.friend_email.focus();
				message=message+document.getElementById('friend_email_check').innerHTML+"\n";		
				error=1;
			}
		}
	   if(message)
 	  {	  
	    alert(message);
		return false;
	   }
	   else
	   {	
	   		document.tellfriend.submit();
			return true;
	   }
	}

