var ajaxPath="";

function setAjaxPath( path )
{
	ajaxPath=path;
}

function onBasketRemove( sender, contentId, title, input )
{
	if (!confirm('Remove '+title+' from basket?'))
	{
		return false;
	}
	input.value=0;
	return onBasketUpdateQuantity( this, contentId, 0, "" );
}

function onBasketUpdateQuantity( sender, contentId, quantity, urlAppend )
{
	var xmlhttp=false;
	try 
	{
	 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");	
	} 
	catch (e) 
	{
		try 
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (E) 
		{
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
	{
		return true;
	}

	document.all.basketform.basketcheckout.disabled=true;
	sender.disabled=true;
	//sender.all.form.basketcheckout.disabled=true;	
	
	xmlhttp.open("GET", ajaxPath+"/BasketUpdate.aspx?contentId="+escape( contentId )+"&quantity_"+contentId+"="+escape( quantity )+urlAppend+"&ajax="+new Date(),true);
	
	xmlhttp.onreadystatechange=function() 
	{
		if (xmlhttp.readyState==4) 
		{
			document.all.basketform.innerHTML=xmlhttp.responseText;
			var row=eval( "document.all.basketitemrow"+contentId);
			if (row!=null)
				row.className='basketitemhi';
		}
	}
	
	xmlhttp.send(null);
	return false;
}

function onBasketUpdateCountry( sender, select )
{
	var xmlhttp=false;
	try 
	{
	 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch (e) 
	{
		try 
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (E) 
		{
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
	{
		return true;
	}

	sender.disabled=true;
	sender.form.basketcheckout.disabled=true;	
	//sender.basketform.basketcheckout.disabled=true;	
	countryId=select.options[ select.selectedIndex ].value;

	xmlhttp.open("GET", ajaxPath+"/BasketUpdate.aspx?countryId="+escape( countryId )+"&ajax="+new Date(),true);
	xmlhttp.onreadystatechange=function() 
	{
		if (xmlhttp.readyState==4) 
		{
			document.all.basketform.innerHTML=xmlhttp.responseText;
			document.all.basketcarriagerow.className='basketcarriagehi';
		}
	}
	xmlhttp.send(null);
	return false;
}
function flashAlert( id )
{
	clearAlert( id, 4 );
}
function clearAlert( id, count )
{
	var control=eval('document.all.'+id);
	if (--count%2==0)
		control.className='value';
	else
		control.className='valuehi';
		
	if (count>0)
		setTimeout( "clearAlert('"+id+"',"+count+")", 500 );
}
function captureLink( )
{
	var xmlhttp=false;
	try 
	{
	 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch (e) 
	{
		try 
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (E) 
		{
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
	{
		return true;
	}

	xmlhttp.open("GET", "/LogEscape.aspx?href="+escape( this.href )+"&referer="+escape(window.location)+"&text="+escape(this.innerText),true);
	xmlhttp.send(null);
}
function captureLinks()
{
	var basehref=window.location.protocol+"//"+window.location.host;
	for (i=0; i<document.links.length ; i++) 
	{
		var link=document.links[i];
		var href=link.href;
		if (link.href.indexOf('http')==0 && href.indexOf(basehref)==-1 && link.onclick==null)
		{
			link.onclick=captureLink;
		}
	}
}
setTimeout("captureLinks()",1000);

