// JavaScript Document

//define global variables
var oldpod;

function BrowsCheck(el,pod)
{
	
if(el.addEventListener)
		{
				el.addEventListener('click',function(el){ModifyImage(pod)},false);				
		}
				else if (el.attachEvent)
		{
    			el.attachEvent('onclick',function(el){ModifyImage(pod)});				
		}	
}


function ModifyImage(pod)
{
		var gt = document.getElementById('picholder');
		var nold = oldpod;
		if (oldpod==pod)
		{
			return false;
		}
		else 
		{
			document.getElementById(nold).removeChild(document.getElementById(nold).firstChild);
			gt.removeChild(gt.firstChild);
			CrImage(gt,pod);
		}
}


function CrImage(gt,pod){
		var icon_num = pod.substring(pod.length,pod.length-1); 
	 	var im = document.createElement("img");
     	im.setAttribute("src","../../img/nav/imicon"+icon_num+".jpg");
	 	document.getElementById(pod).appendChild(im);
	 	var im = document.createElement("img");
        im.setAttribute("src","../../img/our_workpic/"+pod+".jpg");
		im.setAttribute("alt"," "+pod+".jpg");
	    gt.appendChild(im);
        oldpod = pod;		
}


function ImageCon()
{





  if (document.getElementById && document.createTextNode) 
 {
    var divs=document.getElementsByTagName('div');
    for (var i=0;i<divs.length;i++)
    {   
        if(divs[i].className=="activediv")
		{
			var el = document.getElementById(divs[i].id);
			var icon_num = (divs[i].id).substring((divs[i].id).length,(divs[i].id).length-1);
			var dimicon = el.style.background="url(../../img/nav/imicondim"+icon_num+".jpg)";
			var pod = el.id;
			var addlis = BrowsCheck(el,pod);
		}
	}        
  }
}


function DeftImage(){
	var gt = document.getElementById('picholder');
	var im = document.createElement("img");
	
	// check for first pod (or node) after argument 'picholder'
	
	if(gt.nextSibling.nodeType == 3)				//checks for whitespaing which occurs in Gecko and Mozilla browsers
	{   
		var firstim=gt.nextSibling.nextSibling;  //works for firefox
	}
	else
    {
        var firstim=gt.nextSibling              //workaround for ie6
    }
		oldpod = firstim.id;
		oldpodimage = oldpod.substring(oldpod.length,oldpod.length-10);
		oldpodfolder = oldpod.substring(oldpod.length-10,0);
		im.setAttribute("src","../../img/our_workpic/"+oldpod+".jpg");
		im.setAttribute("alt"," "+oldpodimage+".jpg");
	    gt.appendChild(im);
		var icon_num = oldpod.substring(oldpod.length,oldpod.length-1); 		//trim character from the div id
        var im = document.createElement("img");
        im.setAttribute("src","../../img/nav/imicon"+icon_num+".jpg");
	    firstim.appendChild(im);			
	    ImageCon();
}

window.onload=function(){DeftImage();}







