// JavaScript Document
function so_clearInnerHTML(obj) {
	while(obj.firstChild) obj.removeChild(obj.firstChild);
}

function setFirst()
{
so_clearInnerHTML(document.getElementById("switchingPhoto"));

var eDIV = document.createElement("div");          
var eIMG = document.createElement("img");
eIMG.setAttribute("src",switchContent[0]);          
eIMG.setAttribute("alt","Product Photo"); 
eIMG.setAttribute("height",switchHeight[0]); 
eIMG.setAttribute("width",switchWidth[0]); 

eDIV.appendChild(eIMG);
document.getElementById("switchingPhoto").appendChild(eDIV);

so_clearInnerHTML(document.getElementById("switchingText"));
          
var eDIV = document.createElement("div");         
eDIV.appendChild(document.createTextNode(switchText[0]));
eAnchor = document.createElement("a");         
eAnchor.setAttribute("href",linkAddress[0]);
eAnchor.appendChild(document.createTextNode(linkText[0]));          
eDIV.appendChild(eAnchor);          
document.getElementById("switchingText").appendChild(eDIV);          
}

var jCounter = 0;


function next(){

so_clearInnerHTML(document.getElementById("switchingPhoto"));


	if(jCounter < switchContent.length-1){
		jCounter=jCounter+1;
          so_clearInnerHTML(document.getElementById("switchingPhoto"));
          
          var eDIV = document.createElement("div");          
          var eIMG = document.createElement("img");
          eIMG.setAttribute("src",switchContent[jCounter]);          
          eIMG.setAttribute("alt","Product Photo");   
          eIMG.setAttribute("height",switchHeight[jCounter]); 
          eIMG.setAttribute("width",switchWidth[jCounter]);      
                
          eDIV.appendChild(eIMG);
          document.getElementById("switchingPhoto").appendChild(eDIV);
          
          so_clearInnerHTML(document.getElementById("switchingText"));
                    
          var eDIV = document.createElement("div");         
          eDIV.appendChild(document.createTextNode(switchText[jCounter]));
          eAnchor = document.createElement("a");        
          eAnchor.setAttribute("href",linkAddress[jCounter]);
          eAnchor.appendChild(document.createTextNode(linkText[jCounter]));          
          eDIV.appendChild(eAnchor);          
          document.getElementById("switchingText").appendChild(eDIV);             		
	}
	else{
          jCounter=0;
          so_clearInnerHTML(document.getElementById("switchingPhoto"));
          
          var eDIV = document.createElement("div");          
          var eIMG = document.createElement("img");
          eIMG.setAttribute("src",switchContent[jCounter]);          
          eIMG.setAttribute("alt","Product Photo");   
          eIMG.setAttribute("height",switchHeight[jCounter]); 
          eIMG.setAttribute("width",switchWidth[jCounter]);                 
          eDIV.appendChild(eIMG);
          document.getElementById("switchingPhoto").appendChild(eDIV);
          
          so_clearInnerHTML(document.getElementById("switchingText"));
                    
          var eDIV = document.createElement("div");         
          eDIV.appendChild(document.createTextNode(switchText[jCounter]));
          eAnchor = document.createElement("a");         
          eAnchor.setAttribute("href",linkAddress[jCounter]);
          eAnchor.appendChild(document.createTextNode(linkText[jCounter]));          
          eDIV.appendChild(eAnchor);          
          document.getElementById("switchingText").appendChild(eDIV);         
     }
	
}

     
function prev(){



     so_clearInnerHTML(document.getElementById("switchingPhoto"));

	if(jCounter > 0 ){
		jCounter=jCounter-1;
          so_clearInnerHTML(document.getElementById("switchingPhoto"));
          
          var eDIV = document.createElement("div");          
          var eIMG = document.createElement("img");
          eIMG.setAttribute("src",switchContent[jCounter]);          
          eIMG.setAttribute("alt","Product Photo");   
          eIMG.setAttribute("height",switchHeight[jCounter]); 
          eIMG.setAttribute("width",switchWidth[jCounter]);     
           
          eDIV.appendChild(eIMG);
          document.getElementById("switchingPhoto").appendChild(eDIV);
          
          so_clearInnerHTML(document.getElementById("switchingText"));
                    
          var eDIV = document.createElement("div");         
          eDIV.appendChild(document.createTextNode(switchText[jCounter]));
          eAnchor = document.createElement("a");
          eAnchor.setAttribute("class", "blueLink");          
          eAnchor.setAttribute("href",linkAddress[0]);
          eAnchor.appendChild(document.createTextNode(linkText[jCounter]));          
          eDIV.appendChild(eAnchor);          
          document.getElementById("switchingText").appendChild(eDIV);         
	}
	else{
		jCounter=switchContent.length-1;
          so_clearInnerHTML(document.getElementById("switchingPhoto"));
          
          var eDIV = document.createElement("div");          
          var eIMG = document.createElement("img");
          eIMG.setAttribute("src",switchContent[jCounter]);          
          eIMG.setAttribute("alt","Product Photo");  
          eIMG.setAttribute("height",switchHeight[jCounter]); 
          eIMG.setAttribute("width",switchWidth[jCounter]);     
            
          eDIV.appendChild(eIMG);
          document.getElementById("switchingPhoto").appendChild(eDIV);
          
          so_clearInnerHTML(document.getElementById("switchingText"));
                    
          var eDIV = document.createElement("div");         
          eDIV.appendChild(document.createTextNode(switchText[jCounter]));
          eAnchor = document.createElement("a");
          eAnchor.setAttribute("class", "blueLink");          
          eAnchor.setAttribute("href",linkAddress[0]);
          eAnchor.appendChild(document.createTextNode(linkText[jCounter]));          
          eDIV.appendChild(eAnchor);          
          document.getElementById("switchingText").appendChild(eDIV);             
     }
}

