// JavaScript Document




var offsetfromedge=0      //offset from window edge when content is "docked". Change if desired.
var dockarray=new Array() //array to cache dockit instances
var dkclear=new Array()   //array to cache corresponding clearinterval pointers

function change_quanitity(response_box_id,item_id,response_div_id,action,item_type,r_id,size_id,s_no)
{
	
var quantity=document.getElementById(response_box_id);

	
	var error=false;
	
	if(quantity.value<=0)
	{
		alert(STR_MSG_1);	
		
		error=true;
	}
	else
	{
		var NumberToTest = quantity.value;
		var IsFound = /^-?\d+$/.test(NumberToTest);
				
			if(IsFound==true)
			{
				error=false;
				
			}
			else
			{
				alert(STR_MSG_2);
				error=true;
			}
				
				
				

		
		
	}
	
	
	if(!error)
	{	
	
	
	quantity.className="boxOff";
	xmlHttp=get_xmlhttp();
			
	var item_quantity=quantity.value;
	
			
		var url=ROOT_PATH+"ext/includes/ajx_order_activity.php?action="+action+"&item_id="+item_id+"&item_type="+item_type+"&r_id="+r_id+"&size_id="+size_id+"&quantity="+item_quantity+"&s_no="+s_no+"&";		
			
			
			
		xmlHttp.onreadystatechange=function()
		{
		  
		   
			if(xmlHttp.readyState==3)
		   { 			
			document.getElementById('loading_image').style.display="block";   
		   }  
		   
		   
			 
		  if(xmlHttp.readyState==4)
		   { 
				values=xmlHttp.responseText;
				
				 document.getElementById(response_div_id).innerHTML=values;
				
				document.getElementById('loading_image').style.display="none";   
		   }  
			 
		}
		
		var str=url;
		xmlHttp.open('GET',str,true);
		xmlHttp.send(null);	
	
	
	}
	else
	{
			quantity.focus();
			return  false;	
	}
	
	
	//alert(response_box_id);
	
}
function clear_baskit(r_id,response_div_id)
{	


	
	var check=confirm(STR_MSG_28);
	
	
	if(check==true)
	{
	
		
		xmlHttp=get_xmlhttp();
		var url=ROOT_PATH+"ext/includes/ajx_order_activity.php?action=clear_baskit&r_id="+r_id+"&";		
			
			
			
		xmlHttp.onreadystatechange=function()
		{
		  
		   
			if(xmlHttp.readyState==3)
		   { 			
			document.getElementById('loading_image').style.display="block";   
		   }  
		   
		   
			 
		  if(xmlHttp.readyState==4)
		   { 
				values=xmlHttp.responseText;
				
				 document.getElementById(response_div_id).innerHTML=values;
				
				document.getElementById('loading_image').style.display="none";  
				document.getElementById('form1').style.display="none";
		   }  
			 
		}
		
		var str=url;
		xmlHttp.open('GET',str,true);
		xmlHttp.send(null);
	
	}
	else
	{
		return false;
	}
}

function confirm_order(r_id)
{
	
	
		//window.scroll(0,150);
		
		xmlHttp=get_xmlhttp();
			
			
		var url=ROOT_PATH+"ext/includes/ajx_order_activity.php?action=check_order_status&r_id="+r_id+"&";	
			
			
		xmlHttp.onreadystatechange=function()
		{
		  
		   
			if(xmlHttp.readyState==3)
		   { 			
			document.getElementById('loading_image').style.display="block";   
		   }  
		   
		   
			 
		  if(xmlHttp.readyState==4)
		   { 
				values=xmlHttp.responseText;
				
				if(values==false)
				{
					
					var msg=document.getElementById("minimum_amount").innerHTML;
					alert(STR_MSG_3+" "+msg);
				}
				else
				{
			  		var user_type=document.getElementById('user_type').value;
					if(user_type=="guest")
					{
						document.getElementById('form1').style.display="block";
						if(signup_guest_validate())
						{
								document.frm.submit();
						}
					}
					else 
					{
						document.frm.submit();
					}
				}
				
				document.getElementById('loading_image').style.display="none";   
		   }  
			 
		}
		
		var str=url;
		xmlHttp.open('GET',str,true);
		xmlHttp.send(null);
		
	
	
	
	
	
}


function confirm_order_2(r_id)
{
	
	
		//window.scroll(0,150);
		
		xmlHttp=get_xmlhttp();
			
			
		var url=ROOT_PATH+"ext/includes/ajx_order_activity.php?action=check_order_status&r_id="+r_id+"&";	
			
			
		xmlHttp.onreadystatechange=function()
		{
		  
		   	  if(xmlHttp.readyState==4)
		   { 
				values=xmlHttp.responseText;
				
				if(values==false)
				{
					document.getElementById('form1').style.display="none";
					
				}
				else
				{
			  		document.getElementById('form1').style.display="block";
			 
		}
		
		   }
		}
		var str=url;
		xmlHttp.open('GET',str,true);
		xmlHttp.send(null);
		
	
	
	
	
	
}


function item_maipulation(item_id,response_div_id,action,item_type,r_id,size_id,cat_id,sub_cat_id,s_day,e_day,s_time,e_time,item_name,s_no)
{
	
	
	if(item_id!="")
	{
		//window.scroll(0,150);
		
		xmlHttp=get_xmlhttp();
			
		var url=ROOT_PATH+"ext/includes/ajx_order_activity.php?action="+action+"&item_id="+item_id+"&item_type="+item_type+"&r_id="+r_id+"&size_id="+size_id+"&cat_id="+cat_id+"&sub_cat_id="+sub_cat_id+"&s_day="+s_day+"&e_day="+e_day+"&s_time="+s_time+"&e_time="+e_time+"&item_name_new="+item_name+"&s_no="+s_no+"";	
		
		
		xmlHttp.onreadystatechange=function()
		{
		  
		  
			if(xmlHttp.readyState==3)
		   { 			
		  	document.getElementById('loading_image').style.display="block";  
		   } 
			 
		  if(xmlHttp.readyState==4)
		   { 
				var values=xmlHttp.responseText;
				if(values==false)
				{    
					alert(""+STR_MSG_31+" \""+item_name+"'\" "+STR_MSG_32+" "+s_day+" "+STR_MSG_33+" "+e_day+" "+STR_MSG_34+" "+s_time+" "+STR_MSG_35+" "+STR_MSG_33+" "+e_time+" "+STR_MSG_35+" "+STR_MSG_36+"");
					}
					else{
			  document.getElementById(response_div_id).innerHTML=values;
			   document.getElementById('loading_image').style.display="none";  
			   confirm_order_2(r_id);
					}
		   }  
		    
			 
		}
		
		 var str=url;
		 xmlHttp.open('GET',str,true);
		 xmlHttp.send(null);
		
	}
	else
	{
		alert("plase select item ");	
	}
	
}

function form_submit(form_n,response_div_id)
{
var form_name=form_n;
var validate=validateEmailData(document.form_name);
if(validate)
{
xmlHttp=get_xmlhttp();
var url="http://www.hotbuysthisweek.com/submit_seller_email.php?Action="+document.form_name.Action.value+"&listing_id="+document.form_name.listing_id.value+"&listing_title="+document.form_name.listing_title.value+"&seller_id="+document.form_name.seller_id.value+"&client_email="+document.form_name.client_email.value+"&user_type="+document.form_name.user_type.value+"&comment="+document.form_name.comment.value+"&first_name="+document.form_name.first_name.value+"&last_name="+document.form_name.last_name.value+"&email_address="+document.form_name.email_address.value+"&phone_number="+document.form_name.phone_number.value+"&action="+document.form_name.action.value+"";	
xmlHttp.onreadystatechange=function()
		{
		  
		   
			 if(xmlHttp.readyState==2)
		   { 			
		 document.getElementById('loading_image').style.display="block";    
		   } 
			if(xmlHttp.readyState==3)
		   { 			
		  document.getElementById('loading_image').style.display="block";   
		   } 
			 
		  if(xmlHttp.readyState==4)
		   { 
				values=xmlHttp.responseText;
				document.getElementById(response_div_id).innerHTML=values;	
				}
				
				 
		   }  
		var str=url;
		xmlHttp.open('GET',str,true);
		 xmlHttp.send(null);	 
		}
		else
		{
			alert("Please filled required field");
			}
}

// JavaScript Document


function additional_maipulation(item_id,response_div_id,action,item_type,r_id,add_id,add_name,size_id,add_limit,s_no)
{

	
	if(item_id!="")
	{
		//window.scroll(0,150);
		
		xmlHttp=get_xmlhttp();
			
			if(size_id>0)
			{
				
		var url=ROOT_PATH+"ext/includes/ajx_order_activity.php?action="+action+"&item_id="+item_id+"&item_type="+item_type+"&r_id="+r_id+"&add_id="+add_id+"&add_name="+add_name+"&size_id="+size_id+"&add_limit="+add_limit+"&s_no="+s_no+"&";	
			}
			else
			{
				var url=ROOT_PATH+"ext/includes/ajx_order_activity.php?action="+action+"&item_id="+item_id+"&item_type="+item_type+"&r_id="+r_id+"&add_id="+add_id+"&add_name="+add_name+"&add_limit="+add_limit+"&s_no="+s_no+"&";	
			}
		
		xmlHttp.onreadystatechange=function()
		{
		  
		   
			 if(xmlHttp.readyState==2)
		   { 			
		 document.getElementById('loading_image').style.display="block";    
		   } 
			if(xmlHttp.readyState==3)
		   { 			
		  document.getElementById('loading_image').style.display="block";   
		   } 
			 
		  if(xmlHttp.readyState==4)
		   { 
				values=xmlHttp.responseText;
				
				if(values==false)
				{
					alert(STR_MSG_4);
				}
				else if(values==1)
				{
					alert(STR_MSG_37);
					}
				else
				{
			  		document.getElementById(response_div_id).innerHTML=values;	
				}
				
				 document.getElementById('loading_image').style.display="none";  
				 confirm_order_2(r_id);
		   }  
			 
		}
		
		 var str=url;
		xmlHttp.open('GET',str,true);
		 xmlHttp.send(null);
		
	}
	else
	{
		alert("plase select item ");	
	}
	
}



function change_address()
{
	
	 document.getElementById("shipping_address").style.backgroundColor='white';
	 document.getElementById("shipping_address_part").style.backgroundColor='white';
	 document.getElementById("shippping_house_number").style.backgroundColor='white';
	 document.getElementById("shipping_city").style.backgroundColor='white';
		
	var shipping_address=document.getElementById("shipping_address");
	var shipping_address_part=document.getElementById("shipping_address_part");
	var shippping_house_number=document.getElementById("shippping_house_number");
	var shipping_city=document.getElementById("shipping_city");
	var address_eror=document.getElementById("shipping_address_eror");
	var address_part_eror=document.getElementById("address_part_eror");
	var city_eror=document.getElementById("shipping_city_eror");

	var shipping_check=blankvalidate(shipping_address,address_eror,"*");
	var houseno_check=blankvalidate(shippping_house_number,address_eror,"*");
	var part_check=blankvalidate(shipping_address_part,address_part_eror,"*");	
	
 	var city_check=blankvalidate(shipping_city,city_eror,"*");	 
		 
 if(shipping_check && houseno_check && part_check && city_check)
 {
	 	return true;
 }
 else
 {
	return false;
 }
			
	
	
}



function addRow(tableID)
{  
   
	   
              var table = document.getElementById(tableID);  
   
             var rowCount = table.rows.length;  
             var row = table.insertRow(rowCount);  
   
             var cell1 = row.insertCell(0);  
             var element1 = document.createElement("input");  
             element1.type = "checkbox";  
             cell1.appendChild(element1);  
  		  cell1.setAttribute('class', 'GridRowHead');
             var cell2 = row.insertCell(1);  
			 cell2.setAttribute('class', 'GridRowHead');
             cell2.innerHTML = rowCount + 1;  
   
             var cell3 = row.insertCell(2); 
			 cell3.setAttribute('class', 'GridRowHead');
             var element2 = document.createElement("input");  
             element2.type = "checkbox";  
             cell3.appendChild(element2); 
			 
			  var cell4 = row.insertCell(3); 
			 cell4.setAttribute('class', 'GridRowHead');
              
             cell4.innerHTML='asdasd'; 

			
         }  
   
function deleteRow(tableID)
{  
	 
	 try
	 {  
	 var table = document.getElementById(tableID);  
	 var rowCount = table.rows.length;  
	
		 for(var i=0; i<rowCount; i++)
		 {  
			 var row = table.rows[i];  
			 var chkbox = row.cells[0].childNodes[0];  
			 if(null != chkbox && true == chkbox.checked) 
			 {  
				 table.deleteRow(i);  
				 rowCount--;  
				 i--;  
			 }  
		
		 }  
	 }
	 catch(e) 
	 {  
		 alert(e);  
	 }  
} 


function show_row(coupon_check,coupon_tr)
{
	
if(document.getElementById(coupon_check).checked==true)
{
document.getElementById(coupon_tr).style.display="";


}
else
{
document.getElementById(coupon_tr).style.display="none";
document.getElementById('coupon_no').value='';
}


}









function dockit(el, duration){
this.source=document.all? document.all[el] : document.getElementById(el);
this.source.height=this.source.offsetHeight;
this.docheight=truebody().clientHeight;
this.duration=duration;
this.pagetop=0;
this.elementoffset=this.getOffsetY();
dockarray[dockarray.length]=this;
var pointer=eval(dockarray.length-1);
var dynexpress='dkclear['+pointer+']=setInterval("dockornot(dockarray['+pointer+'])",100);';
dynexpress=(this.duration>0)? dynexpress+'setTimeout("clearInterval(dkclear['+pointer+']); dockarray['+pointer+'].source.style.top=0", duration*1000)' : dynexpress;
eval(dynexpress);
}

dockit.prototype.getOffsetY=function(){
var totaloffset=parseInt(this.source.offsetTop);
var parentEl=this.source.offsetParent;
while (parentEl!=null){
totaloffset+=parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function dockornot(obj){
obj.pagetop=truebody().scrollTop;
if (obj.pagetop>obj.elementoffset) //detect upper offset
obj.source.style.top=obj.pagetop-obj.elementoffset+offsetfromedge+"px";
else if (obj.pagetop+obj.docheight<obj.elementoffset+parseInt(obj.source.height)) //lower offset
obj.source.style.top=obj.pagetop+obj.docheight-obj.source.height-obj.elementoffset-offsetfromedge+"px";
else
obj.source.style.top=0;
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


