
/*Changes the image of the gallery, passes onto changeSunDescription() to change the description text*/
function newBrand(brand){
	document.getElementById("image").src="images/blank.gif";
	document.getElementById("imageDescription").innerHTML="<h2 id=\"modelNumber\">Model No: </h2><h2 id=\"price\">Price: $</h2><p id=\"modelDescription\">Description: </p>";
	changeThumbs(brand);
}


/*AJAX Request to change description text*/
function changeThumbs(brand) {
	var URL = "thumbnails.php?brand="+brand;
        //create the Cross-browser XMLHttpRequest object
        if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc
               xmlhttp=new XMLHttpRequest();
              if (xmlhttp.overrideMimeType) {
                     xmlhttp.overrideMimeType('text/xml');
              }      
              xmlhttp.onreadystatechange=loadThumbs;
              xmlhttp.open("GET", URL, true);
              xmlhttp.send(null);
       } else if (window.ActiveXObject) { //IE
              xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
              if (xmlhttp) {
                     xmlhttp.onreadystatechange=loadThumbs;
                     xmlhttp.open('GET', URL, true);
                     xmlhttp.send();
              }
       }
  }
 
  // function to handle asynchronous call
  function loadThumbs() {
       if (xmlhttp.readyState==4) {
              if (xmlhttp.status==200) {
                     document.getElementById('thumbnailScroller').innerHTML=xmlhttp.responseText;
              }
       }
  }
  
  
  
  
 ///////////////////////////////////////////
 
 
 
/*Changes the image of the gallery, passes onto changeSunDescription() to change the description text*/
function changeSunModel(img,id){
	document.getElementById("image").src=img;
	changeSunDescription(id,"shades");
}


/*AJAX Request to change description text*/
function changeSunDescription(id,ref) {
	if(ref=="shades"){
	var URL = "galleryDescription.php?id="+id;
	}
	else if(ref=="opt"){
		var URL = "optgalleryDescription.php?id="+id;
	}
        //create the Cross-browser XMLHttpRequest object
        if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc
               xmlhttp=new XMLHttpRequest();
              if (xmlhttp.overrideMimeType) {
                     xmlhttp.overrideMimeType('text/xml');
              }      
              xmlhttp.onreadystatechange=loadDesc;
              xmlhttp.open("GET", URL, true);
              xmlhttp.send(null);
       } else if (window.ActiveXObject) { //IE
              xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
              if (xmlhttp) {
                     xmlhttp.onreadystatechange=loadDesc;
                     xmlhttp.open('GET', URL, true);
                     xmlhttp.send();
              }
       }
  }
 
  // function to handle asynchronous call
  function loadDesc() {
       if (xmlhttp.readyState==4) {
              if (xmlhttp.status==200) {
                     document.getElementById('imageDescription').innerHTML=xmlhttp.responseText;
              }
       }
  }
  
  
  
/*Changes the image of the optshopgallery*/
function changeOptImage(img, id){
	document.getElementById("image").src="images/"+img;
	changeSunDescription(id,"opt");
}

  
  
  