var Extend_timer = new Array(); 
var Extend_status = new Array();
var Old_Bidcounter = new Array();
var Auction_ids=0;
var Product_id=0;
var SESS_ID='';
var doc = null;

function ajax()
{
    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()
{		
	var doc=null;
	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)  {}
	        }
  		}
	doc.open('GET', "./timer_penny.php?section=update_bid&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 arraylist1=arraylist[l].split("**");
						var pro_id =(parseInt(arraylist1[0]));
						
					  if(Product_id!=0  && SESS_ID!=''){	
						document.getElementById('autobid_count_div_'+pro_id).innerHTML = arraylist1[4];
						//document.getElementById('autobid_struct_div_'+pro_id).innerHTML = arraylist1[5];
					  }
						
						if(Extend_status[pro_id]!=arraylist1[2])
						{
							Update_status(pro_id);
							if(arraylist1[2]=='E' || arraylist1[2]=='N')
							  document.getElementById('bid_btn_'+pro_id).innerHTML = arraylist1[3];	
						}
						if(Old_Bidcounter[pro_id]!=parseInt(arraylist1[1]))
							{
							if(Product_id==0 && SESS_ID!='')
								Update_credits();	
							Old_Bidcounter[pro_id]=parseInt(arraylist1[1]);	
							
							Update_Auction_Detail(pro_id);
							if(Product_id!=0)
								{
								if(SESS_ID!='')	
									Update_Auto_Bid();
								    Update_bid_table();
									
								if(SESS_ID!='' && arraylist1[2]=='E' && arraylist1[4]==0)		
									document.getElementById('autobid_struct_div_'+pro_id).innerHTML = arraylist1[5];
								}
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#ff0000"', 10);
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#fd1313"', 70);
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#fb2222"', 130);
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#fb3434"', 200);
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#fb4848"', 270);
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#fc5a5a"', 330);
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#fc7e7e"', 400);
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#fcacac"', 470);
							setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = ""', 530);	
							}
						}
					}
				}  
			}
	  };
	setTimeout('Update_Bid_Detail()', 3000); 
	doc.send(null);
}

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]<10)
							{
							if(Extend_timer[pro_id]==8)
				    				Add_autobid(pro_id);		
							if(Extend_timer[pro_id]==4)
									Add_robot_bid(pro_id);
					document.getElementById('counter_index_div_'+pro_id).innerHTML="<font color='red' size='+1'>"+calc_counter_from_time_short(Extend_timer[pro_id])+"</font>";			
							}
						else
							document.getElementById('counter_index_div_'+pro_id).innerHTML=''+calc_counter_from_time(Extend_timer[pro_id]);
						}
					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('counter_index_div_'+pro_id).innerHTML = "PAUSE";
					}
				else
					{
					if(Extend_status[pro_id]=='E')	
						{
						Extend_status[pro_id]='S';
						setTimeout('Expire_extend_bid('+pro_id+')', 1000);
						}
					else if(Extend_status[pro_id]=='N')	
						{
						Extend_status[pro_id]='E';	
						Expire_home_bid(pro_id);
						}
					else if(Extend_status[pro_id]=='P')	
						document.getElementById('counter_index_div_'+pro_id).innerHTML = "PAUSE";
					}
					Extend_timer[pro_id]=(Extend_timer[pro_id]-1);	
			}
		}
		setTimeout('Run_timer();', 950); 
}
function Run_timer_product()
{
	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]<10)
						{
							if(Extend_timer[pro_id]==8)
				    			Add_autobid(pro_id);	
							if(Extend_timer[pro_id]==4)
								Add_robot_bid(pro_id);
					document.getElementById('counter_index_div_'+pro_id).innerHTML="<font color='#dd0000' size='+1'>"+calc_counter_from_time_short(Extend_timer[pro_id])+"</font>";
						
						}
						else
					document.getElementById('counter_index_div_'+pro_id).innerHTML=''+calc_counter_from_time(Extend_timer[pro_id]);
						
						}
					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('counter_index_div_'+pro_id).innerHTML = "PAUSE";
					}
				else
					{
					if(Extend_status[pro_id]=='E')	
						{
						Extend_status[pro_id]='S';
						setTimeout('Expire_extend_bid('+pro_id+')', 1000);
						}
					else if(Extend_status[pro_id]=='N')	
						{
						Extend_status[pro_id]='E';	
						Expire_home_bid(pro_id);
						}
					else if(Extend_status[pro_id]=='P')	
						document.getElementById('counter_index_div_'+pro_id).innerHTML = "PAUSE";
					}
					Extend_timer[pro_id]=(Extend_timer[pro_id]-1);	
			}
		}
		setTimeout('Run_timer_product();', 950); 
}

function Update_timer()
{
		var doc=null;
		
		
	
	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)  {}
	        }
  		}
		
	doc.open('GET', "./timer_penny.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]);
						} 
					}
				}
				}
		  };
		  setTimeout('Update_timer();', 10000); 
		
     doc.send(null);
}	

function Update_status(Pro_id)
{
	var doc=null;
	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)  {}
	        }
  		}
	doc.open('GET', "./timer_penny.php?section=update_status&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!=0)
					{
						var Main_array=doc.responseText.split("**");	
						if(Main_array[2]!='S')
							{
							document.getElementById('bid_btn_'+Pro_id).innerHTML = Main_array[0];	
							Extend_timer[Pro_id] = parseInt(Main_array[1]);	
							Extend_status[Pro_id]=Main_array[2];
							}
					}
				}
			}
	    };
	doc.send(null);
}



function auto_update_productpage(proid,URL)
	{
		ajax();
	  if (doc){
	       doc.open("GET", "./location_penny.php?section=auto_update_productpage&proid="+proid, false);
 			doc.send(null);
			
			if(doc.responseText=='Y')
				document.location="http://www.ahabids.com/index.php?show="+URL;
		  }
		setTimeout("auto_update_productpage("+proid+",'"+URL+"');", 10000);
	}

function Update_Auction_Detail(Pro_id)
{		
	var doc=null;
	
	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)  {}
	        }
  		}
	doc.open('GET', "./timer_penny.php?section=update_bid_deatils&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!=0)
					{
					
					var Main_array=doc.responseText.split("**");
					document.getElementById('price_index_div_'+Pro_id).innerHTML = Main_array[0];	
					document.getElementById('winner_index_div_'+Pro_id).innerHTML = Main_array[1];
					//if(SESS_ID!='')
						//document.getElementById("bid_from").value = Main_array[3];
					Extend_timer[Pro_id] = parseInt(Main_array[2]);	
					}
					}
				}  
	    };
		doc.send(null);
	}
function Update_bid_table(){
		var doc=null;
	 	 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)  {}
        }
    }
	
	    doc.open('GET', "./location_penny.php?section=update_bid_table&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)
			   	{
					
					var mainarraylist=doc.responseText.split("|**|");
				   if(mainarraylist[1]=="BidHistory")
				   {
					   
       			      document.getElementById('bid_table_div1').innerHTML = mainarraylist[0];
					  if(SESS_ID!='')
						  document.getElementById("bid_from").value = mainarraylist[2];
						  
						  
					 
				   }
				}
			}
        };
	       doc.send(null);
	}	
function Expire_home_bid(pro_id) {
    ajax();
	    if (doc){
	       doc.open("GET", "./location_penny.php?section=expire_bid&pro_id=" + pro_id, false);
 			doc.send(null);
			Extend_timer[pro_id] = parseInt(doc.responseText);	
			}
}	
function Update_Auto_Bid()
{	
	var doc=null;
	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)  {}
	        }
  		}
	 doc.open('GET', "./location_penny.php?section=update_auto_bid&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 mainarraylist=doc.responseText.split("|**|"); 
						document.getElementById('div_blance').innerHTML = mainarraylist[0];
						document.getElementById('div_blance_voucher').innerHTML = mainarraylist[1];
						}
				}
				}  
	    };
		doc.send(null);
	}
function Expire_extend_bid(pro_id) {
var doc=null;
	 	 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)  {}
        }
    }
	
		doc.open('GET', "./location_penny.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'>ENDED</font>" ;
							document.getElementById('bid_btn_'+pro_id).innerHTML='<a href="index.php?show=product_penny&id='+pro_id+'&close=Y" style="text-decoration:none" class="bidbtn">SOLD</a>';
							if(Product_id==0)
							document.getElementById('sold_auction_img_'+pro_id).innerHTML = '<img src="images/mainsite/sold.png" border="0" />';
							//timedRefresh(10000);
							//update_bid_auction();
							Show_buy_auction(pro_id);
							} 
						else
							{
							Extend_status[pro_id]='E';		
							Extend_timer[pro_id] = (parseInt(arraylist[2]));	
							}
					}
				}
        };
        doc.send(null);
	}	
	
function timedRefresh(timeoutPeriod) {
	setTimeout("location.reload(true);",timeoutPeriod);
	//setTimeout("location.href='index.php?show=index_penny';",timeoutPeriod);
}

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 calc_counter_from_time(diff) {
  if (diff > 0) {
	days=Math.floor(diff / (3600*24))  
	hours=Math.floor((diff / 3600)-(days*24))
	minutes=Math.floor((diff / 3600 - hours -(days*24)) * 60)
    seconds=Math.round((((diff / 3600 - hours-(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;
  }
  if(days==0)
	  return hours + ":" + minutes + ":" + seconds;
  else	  
  	 return days +":" + 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_robot_bid(pro_id) {
		ajax();
	    if (doc){
	       doc.open("GET", "./location_penny.php?section=add_robot_bid&pro_id="+pro_id, false);
 			doc.send(null);
			}
		}

function Add_autobid(pro_id) {

		ajax();
	    if (doc){
	       doc.open("GET", "./location_penny.php?section=add_autobid&pro_id="+pro_id, false);
 			doc.send(null);
						
			}
		}
function Add_bid(pro_id) {
		ajax();
	
	    if (doc){
	       doc.open("GET", "./location_penny.php?section=add_bid&pro_id="+pro_id, false);
 			doc.send(null);
			if(parseInt(doc.responseText)==99999)
				document.location="index.php?show=login_full";
			else
				{
				
				var mainarraylist=doc.responseText.split("**");
				if(mainarraylist.length>3)
					{
					Old_Bidcounter[pro_id]=mainarraylist[3];	
					Update_Auction_Detail(pro_id);
					if(Product_id!=0)
						Update_bid_table();
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#ff0000"', 10);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#fd1313"', 70);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#fb2222"', 130);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#fb3434"', 200);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#fb4848"', 270);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#fc5a5a"', 330);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#fc7e7e"', 400);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = "#fcacac"', 470);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = ""', 530);
					
					if(mainarraylist[5]=="BO")
					    document.getElementById('div_blance_voucher').innerHTML = mainarraylist[4];
					else
					   document.getElementById('div_blance').innerHTML = mainarraylist[4];
					}
				else
					{
						if(mainarraylist[1]=="ADDBID")	
						{
							if(mainarraylist[0]==1)	
									alert(document.getElementById('ajax_alert_bid').innerHTML);
							if(mainarraylist[0]==2)
									alert(document.getElementById('ajax_alert_balance').innerHTML);	
							if(mainarraylist[0]==3)
									alert(document.getElementById('ajax_alert_highest').innerHTML);
							if(mainarraylist[0]==4)
									alert(document.getElementById('ajax_alert_closed').innerHTML);	
							if(mainarraylist[0]==5)
									alert(document.getElementById('ajax_alert_block').innerHTML);
							if(mainarraylist[0]==6)
									alert(document.getElementById('ajax_alert_won_auction').innerHTML);
						}
					}
				}
			}
}

function Show_buy_auction(item_id)
{
	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       doc.open("GET", "./location_penny.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_penny.php?section=buy_detail&pro_id=" + pro_id, false);
 			doc.send(null);
			var mainarraylist=doc.responseText.split("|**|");
			//alert(doc.responseText);
			
			if(mainarraylist[3]=="show_buy_bid")
			{
		     document.getElementById('bid_rebate_price_div_'+pro_id).innerHTML = mainarraylist[0];
			 document.getElementById('bid_rebate_totlaprice_div_'+pro_id).innerHTML = mainarraylist[1];
			 if(mainarraylist[2]==1)
			 document.getElementById('bid_rebate_main_div_'+pro_id).innerHTML = "";
			}
		  }
		setTimeout('Update_Buy_Detail('+pro_id+');',20000); 
	}
	

function show_video(id)
{
url="index.php?show=show_video&id=" + id;
window.open(url,'','fullscreen=1,location=1,menubar=0,resizable=0,scrollbars=1,status=0,titlebar=1,toolbar=0,width=300,height=250"');
}

 function validation(frm)
	{
	var error=0;
	var message="";
	var userlang=document.getElementById('userdiv').innerHTML;
	var passlang=document.getElementById('passworddiv').innerHTML;
if(frm.login.value=="" || frm.login.value==userlang)
    {		
       if(error==0)
	     frm.login.focus();
       message=message+document.getElementById('username_req_div').innerHTML+"\n";
	   error=1;
	}
if(frm.pass.value=="" || frm.pass.value==passlang)
    {		
       if(error==0)
	     frm.pass.focus();
       message=message+document.getElementById('password_req_div').innerHTML+"\n";
	   error=1;
	}
if(message)
	  {	  
	    alert(message);
		return false;
	   }
	   else
	   {	document.loginform.submit();
			return true;
	   }
	}
function validation_search(frm)
	{
	var error=0;
	var message="";
	
	if(frm.search.value=="")
		{		
		   if(error==0)
			 frm.search.focus();
		   message=message+document.getElementById('search_alert').innerHTML+"\n";
		   error=1;
		}

	   if(message)
 	  {	  
	    alert(message);
		return false;
	   }
	   else
	   {	
	   		document.search_form.submit();
			return true;
	   }
	}


	function Valid_username(login){
		ajax();
	
	  if (doc){
	       doc.open("GET", "location_penny.php?section=username&login="+login, false); 
	       doc.send(null);
		    
	      return  doc.responseText;
	    }
}

function Valid_mobile(tel){
		ajax();
	   if (doc){
	       doc.open("GET", "location_penny.php?section=mobile&tel="+tel, false); 
	       doc.send(null);
	      return  doc.responseText;
	    }
}

function Edit_Valid_mobile(tel){
    	ajax();
	   if (doc){
	       doc.open("GET", "location_penny.php?section=edit_mobile&tel="+tel, false); 
	       doc.send(null);
		  
	      return  doc.responseText;
	    }
}

function Edit_Valid_username(login){
    	ajax();
	   if (doc){
	       doc.open("GET", "location_penny.php?section=edit_username&login="+login, false); 
	       doc.send(null);
		  
	      return  doc.responseText;
	    }
}

function Valid_email(email){
		
    	ajax();
	   if (doc){
	       doc.open("GET", "location_penny.php?section=email&email="+email, false);   
	       doc.send(null);
	      return  doc.responseText;
	    }
}

function Edit_Valid_email(email){
		
    	ajax();
	   if (doc){
	       doc.open("GET", "location_penny.php?section=edit_email&email="+email, false);   
	       doc.send(null);
	      return  doc.responseText;
	    }
}

function Update_session()
	{
		ajax();
		
	   if (doc){
	       doc.open("GET", "./location_penny.php?section=update_session", false);   
	       doc.send(null);
			}
		setTimeout('Update_session();',30000);		
	}
	
function validation_friend(frm)
	{
	var error=0;
	var message="";
	
	if(frm.friend_email.value=="")
		{		
		   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;
			}
			else
			{ 
			var ret2=Valid_email(frm.friend_email.value); 
			if(ret2==1)
				{
				if(error!=1)
					frm.friend_email.focus();
					message=message+document.getElementById('email_exists').innerHTML+"\n";
					error=1;	
				}
			}
		}
	   if(message)
 	  {	  
	    alert(message);
		return false;
	   }
	   else
	   {	
	   		document.tellfriend.submit();
			return true;
	   }
	}
	
function add_to_watchlist(item_id){

	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       doc.open("GET", "./location_penny.php?section=add_to_watchlist&item_id=" + item_id, false);
		   	doc.send(null);
			
			if(doc.responseText==1)
				alert("This auction has been added to your watch list.");
			else if(doc.responseText==2)
				alert("This auction is already in your watch list.");
			}
}

function show_new_pay_voucher(voucher_code)
{
	if(voucher_code=='')
		alert("Please enter your Promo Code.");
	else
	{
	ajax();
	  if (doc){
	       doc.open("GET", "./location_penny.php?section=show_new_pay_voucher&voucher_code=" + voucher_code, false);
 			doc.send(null);
			
			var mainarraylist=doc.responseText.split("|**|");
			
			if(mainarraylist[2]=="new_pay_voucher")
			{
			  document.getElementById('show_new_pay_voucher_message').innerHTML = mainarraylist[1];
		      document.getElementById('show_new_pay_voucher').innerHTML = mainarraylist[0];
			}
		  }
	}
}

function Update_credits() {
    ajax();
	  if (doc){
	       doc.open("GET", "./timer_penny.php?section=update_credits", false);
 			doc.send(null);
			var mainarraylist=doc.responseText.split("|**|");
		   if(mainarraylist[2]=="update_balance")
		   {
		     document.getElementById('div_blance').innerHTML = mainarraylist[0];
			 document.getElementById('div_blance_voucher').innerHTML = mainarraylist[1]; 
		   }
		  }
		
	}
