function createRequestObject()
{
/* Initialising the variable xmlhttp */
	var xmlhttp=false;
	
/* Try and catch block for creating xmlhttp object according to the browser */
	try
	{
	/* The xmlhttp object is built into the Microsoft XML Parser. */
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try 
		{
		/* The xmlhttp object is built into the Microsoft IE. */
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (E) 
		{
			xmlhttp = false;
		}
	}
/* The xmlhttp object is built into the browsers other than Microsoft IE. */
	if (!xmlhttp && typeof XMLHttpRequest!='undefined')
	{
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}
var xmlhttp= createRequestObject();



function add_basket(pro_id,pro_name,rem_id,upd_id,qty)
{
var chpro_name = pro_name;
var chpro_id = pro_id;
var ch_ship_type = document.cal_form.shipping_type.value;
if(qty == 0)
{
var chqty = document.cal_form.mul_by.value;
}else
chqty = qty;
if(chpro_name.length == 0)
{
	alert('please select the product');
}

/*var chpro_name = document.add_b.pro_name.value;
var chpro_id =  document.add_b.pro_id.value;
*/
//http://www.bazara2z.com/product-details/
xmlhttp.open('GET','http://www.bazara2z.com/product-details/bazaar_func.php?' + 'product_name=' + chpro_name + '&product_id=' + chpro_id + '&get_ship_type=' + ch_ship_type + '&add_quantity=' + chqty,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState == 4 || xmlhttp.readyState == "complete")
{	
		var test = xmlhttp.responseText;
		//alert(test);
		/*if(test == 'Added to basket')										06/july 10  --> Made comment as it seems unnecessary
		{*/
		
		//document.getElementById('add_b').innerHTML = test;
		document.getElementById(rem_id).style.visibility = 'hidden';
		document.getElementById(upd_id).style.visibility = 'visible';
		update_basket();
		//document.getElementById('chat_box').style.overflow = 'auto';
		//document.chat.user_message.value = '';
		//document.getElementById('usr_name').style.visibility = 'hidden';
		/*}*/
	}
}
}

function get_cal_login(prdct_id,pro_weight)
{
var price_mul = document.cal_form.mul_by.value;
var chpro_id = prdct_id;
var ch_ship_country = document.cal_form.ship_country.value;
var ch_ship_type = document.cal_form.shipping_type.value;


if(price_mul == 0)
{
	alert('please enter the quantity');
	document.getElementById('cost_show').style.visibility = 'hidden';
	document.getElementById('price_result').style.visibility = 'hidden';
	document.cal_form.mul_by.focus();
	return false;
}//http://www.bazara2z.com/product-details/
xmlhttp.open('GET','http://www.bazara2z.com/product-details/bazaar_func.php?' + 'product_id=' + chpro_id + '&multiply_qty=' + price_mul + '&product_wt=' + pro_weight + '&ship_country=' + ch_ship_country + '&ship_type=' + ch_ship_type,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState == 4 || xmlhttp.readyState == "complete")
{	
		
		var test = xmlhttp.responseText;
		
		document.getElementById('cost_show').style.visibility = 'visible';
		//document.getElementById('price_result').style.visibility = 'visible';
		document.getElementById('cost_show').innerHTML = test;
		show_shipping(pro_weight,price_mul,ch_ship_country,ch_ship_type,prdct_id);
		//show_final_price(prdct_id);
}
	}

}

function get_cal(prdct_id,pro_weight)
{
	
var price_mul = document.cal_form.mul_by.value;
var chpro_id = prdct_id;
var ch_ship_country = document.cal_form.ship_country.value;
var ch_ship_type = document.cal_form.shipping_type.value;


if(price_mul == 0)
{
	alert('please enter the quantity');
	document.getElementById('cost_show').style.visibility = 'hidden';
	document.getElementById('price_result').style.visibility = 'hidden';
	document.cal_form.mul_by.focus();
	return false;
}//http://www.bazara2z.com/product-details/
xmlhttp.open('GET','http://www.bazara2z.com/product-details/bazaar_func.php?' + 'product_id=' + chpro_id + '&multiply_qty=' + price_mul + '&product_wt=' + pro_weight + '&ship_country=' + ch_ship_country + '&ship_type=' + ch_ship_type,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState == 4 || xmlhttp.readyState == "complete")
{	
		
		var test = xmlhttp.responseText;
		document.getElementById('cost_show').style.visibility = 'visible';
		document.getElementById('cost_show').innerHTML = test;
		document.getElementById('rem').style.display='none';
		document.getElementById('no_add').style.display='block';
		
}
	}

}

function get_cal_onchange(prdct_id,pro_weight)
{
	
var price_mul = document.cal_form.mul_by.value;
var chpro_id = prdct_id;
var ch_ship_country = document.cal_form.ship_country.value;
var ch_ship_type = document.cal_form.shipping_type.value;


if(price_mul == 0)
{
	alert('please enter the quantity');
	document.getElementById('cost_show').style.visibility = 'hidden';
	document.getElementById('price_result').style.visibility = 'hidden';
	document.cal_form.mul_by.focus();
	return false;
}//http://www.bazara2z.com/product-details/
xmlhttp.open('GET','http://www.bazara2z.com/product-details/bazaar_func.php?' + 'product_id=' + chpro_id + '&multiply_qty=' + price_mul + '&product_wt=' + pro_weight + '&ship_country=' + ch_ship_country + '&ship_type=' + ch_ship_type,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState == 4 || xmlhttp.readyState == "complete")
{	
		
		var test = xmlhttp.responseText;
		var checkfunofaddcard = (test.substr(3,5));		
		document.getElementById('cost_show').style.visibility = 'visible';
		document.getElementById('rem').style.display='none';
		
		document.getElementById('rem').style.display='none';
		document.getElementById('no_add').style.display='block';
		
		document.getElementById('cost_show').innerHTML = test;
		
		if(checkfunofaddcard != 'orry ')	{		
		document.getElementById('rem').style.display='block';
		}
		show_shipping(pro_weight,price_mul,ch_ship_country,ch_ship_type,prdct_id);	
		//show_final_price(prdct_id);
}
	}

}

function show_shipping(prodct_weight,mul_qty,ship_cntry,ship_type,prod_id)
{
	
	var chqty = document.cal_form.mul_by.value; //http://www.bazara2z.com/product-details/
xmlhttp.open('GET','http://www.bazara2z.com/product-details/bazaar_func.php?multiply_qty=' + mul_qty + '&product_wt=' + prodct_weight + '&show_pro=' + 1 + '&ship_country=' + ship_cntry + '&ship_type=' + ship_type,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {  
	if(xmlhttp.readyState == 4 || xmlhttp.readyState == "complete")
	{	
	var test = xmlhttp.responseText;
	
		if(test == null)
		{
		document.getElementById('no_add').style.visibility = 'visible';
		document.getElementById('rem').style.visibility = 'hidden' ;
		}
		else
		{
			if(document.getElementById('added').style.visibility != 'visible')
			{
				document.getElementById('rem').style.visibility = 'visible' ;
			}
			
			document.getElementById('no_add').style.visibility = 'hidden' ;
		
		}
		document.getElementById('shp_cost').innerHTML = test;
		
	}
	}
	//
}

function show_final_price(pr_id)
{
	var show_pr = '1';
	xmlhttp.open('GET','http://www.bazara2z.com/product-details/bazaar_func.php?show_price=' + show_pr + '&product_id=' + pr_id,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {  
	if(xmlhttp.readyState == 4 || xmlhttp.readyState == "complete")
	{	
		var test = xmlhttp.responseText;
	document.getElementById('pr_price').innerHTML = test;
		
	}
	}
}



function add_basket_b(pro_id,pro_name)
{
alert('dsaf');
alert(pro_id);
alert(pro_name);
/*alert(name);
alert(pro_id);
*/}

function update_basket()
{
	var upd = 1;//http://www.bazara2z.com/product-details/
	xmlhttp.open('GET','http://www.bazara2z.com/product-details/bazaar_func.php?upd_bask=' + upd,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState == 4 || xmlhttp.readyState == "complete")
{	
		var test = xmlhttp.responseText;
		document.getElementById('cart_count').innerHTML = test;
		
		/*document.getElementById('chat_box').innerHTML = test;
		document.getElementById('chat_box').style.overflow = 'auto';
		document.chat.user_message.value = '';
		document.getElementById('usr_name').style.visibility = 'hidden';
		*/
	}
	}

}

function check_limit(checkp_id,checkp_qty,sh_lim_id)
{
	
	xmlhttp.open('GET','http://www.bazara2z.com/product-details/bazaar_func.php?check_limit_id=' + checkp_id + '&check_limit_qty=' + checkp_qty,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState == 4 || xmlhttp.readyState == "complete")
{	
		var test = xmlhttp.responseText;
		document.getElementById(sh_lim_id).innerHTML = test;
		
	}
	}

}




function del_basket(delb_id)
{
	
	xmlhttp.open('GET','http://www.bazara2z.com/product-details/bazaar_func.php?del_id=' + delb_id,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState == 4 || xmlhttp.readyState == "complete")
{	
		
		var test = xmlhttp.responseText;
	window.location = 'cart.php';	
		
		/*document.getElementById('chat_box').innerHTML = test;
		document.getElementById('chat_box').style.overflow = 'auto';
		document.chat.user_message.value = '';
		document.getElementById('usr_name').style.visibility = 'hidden';
		*/
	}
	}

}

function update_qty(updb_id,upd_name)
{
	var upd_qty = document.getElementById(upd_name).value; 
	xmlhttp.open('GET','http://www.bazara2z.com/product-details/bazaar_func.php?upd_id=' + updb_id + '&update_qty=' + upd_qty,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState == 4 || xmlhttp.readyState == "complete")
{	
		var test = xmlhttp.responseText;
		window.location = 'cart.php';
		/*document.getElementById('chat_box').innerHTML = test;
		document.getElementById('chat_box').style.overflow = 'auto';
		document.chat.user_message.value = '';
		document.getElementById('usr_name').style.visibility = 'hidden';
		*/
		
	}
	}

}


function val_bank_mail()
{
	
var ch_mail = document.bank_form.email.value;
if(ch_mail.length == 0)
{
	document.getElementById('err_bank_mail').innerHTML = 'email id is required';
}
else
{
xmlhttp.open('GET','http://www.bazara2z.com/product-details/bazaar_func.php?bank_val_mail=' + ch_mail,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState == 4 || xmlhttp.readyState == "complete")
{	
		var test = xmlhttp.responseText;
		document.getElementById('err_bank_mail').innerHTML = test;
		/*document.getElementById('chat_box').innerHTML = test;
		document.getElementById('chat_box').style.overflow = 'auto';
		document.chat.user_message.value = '';
		document.getElementById('usr_name').style.visibility = 'hidden';
		*/
		
	}
	}
}
}

function check_bank_password()
{
var ch_pass = document.bank_form.password.value;

if(ch_pass.length == 0)
	{
	document.getElementById('err_bank_password').innerHTML = 'please enter a password';
	}
	else if(ch_pass.length < 6)
	{
	document.getElementById('err_bank_password').innerHTML = 'password should be atleast 6 charachters';
	}
	else
	document.getElementById('err_bank_password').innerHTML = '';
	
}

function check_re_password()
{

var ch_repass = document.bank_form.re_password.value;
var ch_password = document.bank_form.password.value;
if(ch_repass != ch_password)
{
	document.getElementById('err_bank_repassword').innerHTML = 'passwords dont match';
}
	else
	document.getElementById('err_bank_repassword').innerHTML = '';
}





function check_bank_nickname()
{
	
var ch_nickname = document.bank_form.nick_name.value;
if(ch_nickname.length == 0)
{
	document.getElementById('err_bank_nick').innerHTML = 'please enter the nick name';
}
else

{


xmlhttp.open('GET','http://www.bazara2z.com/product-details/bazaar_func.php?bank_nick_name=' + ch_nickname,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState == 4 || xmlhttp.readyState == "complete")
{	
		var test = xmlhttp.responseText;
		document.getElementById('err_bank_nick').innerHTML = test;
		/*document.getElementById('chat_box').innerHTML = test;
		document.getElementById('chat_box').style.overflow = 'auto';
		document.chat.user_message.value = '';
		document.getElementById('usr_name').style.visibility = 'hidden';
		*/
		
	}
	}
}
}



function bank_checkout_val()
{

var val_bank_mail = document.bank_form.email.value;
var val_bank_password = document.bank_form.password.value;
var val_bank_repassword = document.bank_form.re_password.value;
var val_bank_nickname = document.bank_form.nick_name.value;



//-----> email id validation 

if(val_bank_mail.length == 0)
{
	document.getElementById('err_bank_mail').innerHTML = 'email id is required';
	return false;
}
else
{


xmlhttp.open('GET','http://www.bazara2z.com/product-details/bazaar_func.php?bank_val_mail=' + val_bank_mail,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState == 4 || xmlhttp.readyState == "complete")
{	
		var test = xmlhttp.responseText;
		if(test.length != 0)
		{
		document.getElementById('err_bank_mail').innerHTML = test;
		return false;
		/*document.getElementById('chat_box').innerHTML = test;
		document.getElementById('chat_box').style.overflow = 'auto';
		document.chat.user_message.value = '';
		document.getElementById('usr_name').style.visibility = 'hidden';
		*/
		}
	}
	}
}

// ---------> password and retype password validation

if(val_bank_password.length == 0)
{
	document.getElementById('err_bank_password').innerHTML = 'please enter a password';
	return false;
}
	if(val_bank_password.length < 6)
	{
	document.getElementById('err_bank_password').innerHTML = 'password should be atleast 6 characters';
	return false;
	}
	
	if(val_bank_repassword != val_bank_password)
	{
	document.getElementById('err_bank_repassword').innerHTML = 'passwords dont match';
	return false;
	}


// ---------> nick name validation 

if(val_bank_nickname.length == 0)
{
	document.getElementById('err_bank_nick').innerHTML = 'nick name is required';
	return false;
}
else
{
		

xmlhttp.open('GET','http://www.bazara2z.com/product-details/bazaar_func.php?bank_nick_name=' + val_bank_nickname,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState == 4 || xmlhttp.readyState == "complete")
{	
		var test = xmlhttp.responseText;
		if(test.length != 0)
		{
		document.getElementById('err_bank_nick').innerHTML = test;
		return false;
		/*document.getElementById('chat_box').innerHTML = test;
		document.getElementById('chat_box').style.overflow = 'auto';
		document.chat.user_message.value = '';
		document.getElementById('usr_name').style.visibility = 'hidden';
		*/
		}
	}
	}

}
	
}

/*function insert_data()
{

var chname = document.chat.user_name.value;
var chmessage = document.chat.user_message.value;
var chinsert = '1';
//chat-insert.php?' + 'name=' + chname + '&message=' + chmessage
if(chname.length <= 0)
{
	alert('please enter the name');
	return false;
}
xmlhttp.open('GET','chat-insert.php?' + 'name=' + chname + '&message=' + chmessage + '&chat_ins=' + chinsert,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {
	if(xmlhttp.readyState == 4 || xmlhttp.readyState == "complete")
{	
		var test = xmlhttp.responseText;
		
		document.getElementById('chat_box').innerHTML = test;
		document.getElementById('chat_box').style.overflow = 'auto';
		document.chat.user_message.value = '';
		document.getElementById('usr_name').style.visibility = 'hidden';
		
	}
}
*/
//document.getElementById('sub_category1').style.visibility = 'visible';
//}


