var xmlHttp;
var class_name='';
var row1_id='';
var ajax_response='';
function CreateXmlHttp()
{
 //Creating object of XMLHTTP in IE
 try
 {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
 }
 catch(e)
 {
  try
  {
   xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } 
  catch(oc)
  {
   xmlHttp = null;
  }
 }
 if(!xmlHttp && typeof XMLHttpRequest != "undefined") 
 {
  xmlHttp = new XMLHttpRequest();
 }
}

function ajax_call(prod_id,cat_id,item_id,frmid) {
 CreateXmlHttp();
	//document.getElementById('div_products').style.display='none';
	//document.getElementById('div_products_hide').style.display='block';
	var reqPath='index.php';
	var params='product_id='+prod_id+'&category_id='+cat_id+'&Itemid='+item_id+'&page=shop.cart&func=cartadd&option=com_virtuemart';
	xmlHttp.open("POST", reqPath, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	 
	xmlHttp.setRequestHeader("Content-length",params.length);
 	xmlHttp.onreadystatechange=function() {
    	 if (xmlHttp.readyState==4) {
		 	var result=xmlHttp.responseText.split('<!-- start of Products table --><div id="products_table1">');
			result=result[1].split("</div><!-- End of Products table -->");
			//document.getElementById('div_products').style.display='block';
			//document.getElementById('div_products_hide').style.display='none';
			var row_id='row_'+prod_id;
			row1_id='row1_'+prod_id;
			try
			{
				document.getElementById('products_table1').innerHTML=result[0];
			}
			catch(e)
			{
			}
			class_name=document.getElementById(row1_id).className;
			document.getElementById(row1_id).className='';
			document.getElementById(row_id).className='d';
			setTimeout(change_class,2000);
			$$('div.d').each( function(e) { e.visualEffect('highlight',{duration:3.5}) }); return false;
		}
     }

xmlHttp.send(params);
return false;
}
function ajax_call_delete(pd_id,Itemid,cat_id)
{
	//var cat_id='';
	CreateXmlHttp();
	var reqPath='index.php';
	var params='product_id='+pd_id+'&Itemid='+Itemid+'&page=shop.cart&func=cartDelete&option=com_virtuemart';
	xmlHttp.open("POST", reqPath, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	 
	xmlHttp.setRequestHeader("Content-length",params.length);
 	xmlHttp.onreadystatechange=function() {
	if (xmlHttp.readyState==4) {
		var row_id='row_'+pd_id;
		row1_id='row1_'+pd_id;
		class_name=document.getElementById(row1_id).className;
		var result=xmlHttp.responseText.split('<!-- start of Products table --><div id="products_table1">');
		if(typeof result[1]!="undefined")
		{
		result=result[1].split("</div><!-- End of Products table -->");	
		ajax_response=result[0];
		}
		else
		{
			
				var query = window.location.search.substring(1);
				var vars = query.split("&");
  				for (var i=0;i<vars.length;i++)
				{
    				var pair = vars[i].split("=");
   					if (pair[0] == 'category_id')
					{
    			    	//cat_id=pair[1];
    				}
				}
				if(cat_id == 1){
					var redirect = 'http://www.makeurmove.co.uk/shop/browse/letting-2.html';	
				}
				
				if(cat_id == 4){
					var redirect = 'http://www.makeurmove.co.uk/shop/browse/sales-2.html';
				}
			//var redirect='index.php?option=com_virtuemart&page=shop.browse&category_id='+cat_id;
			window.location=redirect;
		}
		
		document.getElementById(row1_id).className='';
		document.getElementById(row_id).className='d';
		setTimeout(change_class_del,2000);
		$$('div.d').each( function(e) { e.visualEffect('highlight1',{duration:3.5}) }); return false;
	}
	
}
xmlHttp.send(params);
return false;
}
function change_class()
{
		try
		{
			if(class_name!='')
			{
				document.getElementById(row1_id).className=class_name;
			}
		}
		catch(e)
		{
		}
		class_name='';	
		row1_id='';
		
}
function change_class_del()
{
		try
		{
			document.getElementById('products_table1').innerHTML=ajax_response;
			
		}
		catch(e)
		{
		}
		class_name='';	
		ajax_response='';	
		
}

function second_ajax_call()
{
CreateXmlHttp();
	var reqPath='index.php';
	var params='option=com_virtuemart&page=shop.browse&category_id=4&Itemid=56';
	xmlHttp.open("POST", reqPath, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	 
	xmlHttp.setRequestHeader("Content-length",params.length);
 	xmlHttp.onreadystatechange=function() {
    if (xmlHttp.readyState==4) {
		 		 var txt1="script type='text/javascript' src='ajax.js'";
				 var result=xmlHttp.responseText.split(txt1);
				 var body1=document.getElementsByTagName('body');
				 body1[0].innerHTML='';
				 body1[0].innerHTML=result[0];
			 }
	 }
xmlHttp.send(params);
return false;
}