// JavaScript aw1011 functions
function showimages(name,style)
{
document.getElementById("mainimage").innerHTML='<img src="../images/AW1011/'+name+'_main.jpg" width="344" height="507" alt="&nbsp;"  />';
document.getElementById("topopeninginfo").style.visibility='hidden';
document.getElementById("imagetopleft").innerHTML='<img src="../images/AW1011/'+name+'_back_main.jpg" width="118" height="162"  alt="&nbsp;"  onMouseover="mainImageSwopInBack(\''+name+'\')" onMouseout="mainImageSwopIn(\''+name+'\')" />';
document.getElementById("imagetopright").innerHTML='<img src="../images/AW1011/'+name+'_detail_main.jpg" width="118" height="162"  alt="&nbsp;"   onMouseover="mainImageSwopInDetail(\''+name+'\')" onMouseout="mainImageSwopIn(\''+name+'\')"/>';
document.getElementById("imagetopleft").style.visibility='visible';
document.getElementById("imagetopright").style.visibility='visible';
document.getElementById('smallimageinfo').innerHTML='move mouse over image to enlarge';

getProductInfoAjax('AW10',style)

}

function mainImageSwopInBack(name)
{
document.getElementById("mainimage").innerHTML='<img src="../images/AW1011/'+name+'_back_main.jpg" width="344" height="507" alt="&nbsp;" />';
}

function mainImageSwopInFront(name)
{
document.getElementById("mainimage").innerHTML='<img src="../images/AW1011/'+name+'_front_main.jpg" width="344" height="507"  alt="&nbsp;" />';
}

function mainImageSwopInDetail(name)
{
document.getElementById("mainimage").innerHTML='<img src="../images/AW1011/'+name+'_detail_main.jpg" width="344" height="507" alt="&nbsp;" />';
}

function mainImageSwopIn(name)
{
document.getElementById("mainimage").innerHTML='<img src="../images/AW1011/'+name+'_main.jpg" width="344" height="507" alt="&nbsp;" />';
}


function getProductInfoAjax(collection,style)
{
xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  	alert ("Your browser does not support XMLHTTP!");
  	return;
  	} 
var url="ajax_productinfoAW10.php"; // set for database table
url=url+"?c="+collection+"&s="+style;
url=url+"&sid="+Math.random();
//document.getElementById("layerurl").innerHTML=url;
xmlhttp.onreadystatechange=collectionStateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
 }
 
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function collectionStateChanged()
{
if (xmlhttp.readyState==4)
  {
 var infoLine=xmlhttp.responseText;
   		
		document.getElementById("imagetext").innerHTML=infoLine;
		
		// extract colour info and show swatches
		var colourarray = Array('navy','cream','purple','grey','Military red');
		var swatcharray = Array('swatch_navy','swatch_cream','swatch_purple','swatch_grey','swatch_red');
		var textarray = Array('Navy','Cream Snowgoose','Purple','Grey Snowgoose','Red')
		//document.getElementById("colourinfo").innerHTML='TESTING';
		var special='Freda';
		colours='';
		for(i=0;i<5;i++)
		{
		if (infoLine.search(colourarray[i])>10 ) {colours=colours+
		'<img src="../images/AW1011/'+swatcharray[i]+'.jpg" width="80" height="100" alt="'+textarray[i]+'" title="'+textarray[i]+'" />&nbsp;';}
		}
		document.getElementById("colourinfo").innerHTML=colours;
  }
}

