var xmlHttp;
var styleuid;

function getNextColour(strURL){
	xmlHttp=GetXmlHttpObject();
	var url=strURL;	
	// Trap the style uid (Essential that the styleuid is the first param passed the through)
	var regex = new RegExp(/^(.*)\?styleuid=(.*)\&colouruid=(.*)$/);
	var matches = regex.exec(url);
	styleuid = matches[2];	 
	
	xmlHttp.onreadystatechange=stateChanged; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function stateChanged(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		var ele_id = 'product_img_' + styleuid;
		//alert('HERE ID >>>' + styleuid);
		document.getElementById(ele_id).style.display="inline"; // needed to override country selection de-selection
 		document.getElementById(ele_id).innerHTML=xmlHttp.responseText; 
 	} 
}

function GetXmlHttpObject(){	
  	try {    
	  	// Firefox, Opera 8.0+, Safari    
	  	xmlHttp=new XMLHttpRequest();    
	} catch (e) {    
  		// Internet Explorer    
  		try { 
	  		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");  
	  	} catch (e) {      
    		try {  
	    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");    
	    	} catch (e) {        
      			alert("Your browser does not support AJAX!");       
      			return false;        
  			}      
  		}    
  	}  	
  	return xmlHttp;	
}