function loadpic(source) {
   el = document.getElementById("picture");
   el.src = source;
}

function getImage(parent) { 
 var el = parent.firstChild; 
 while (el) {  // walk through till as long as there's an element 
  if (el.nodeName.toUpperCase() == "IMG") { // found an image 
    // flickr uses "_s" suffix for small, and "_m" for big images respectively 
    return el.src.replace(/_s\.jpg$/, "_m.jpg"); 
  } 
  el = el.nextSibling; 
  } 
  return ""; 
} 

    (function () {
		var carousel;
                
        YAHOO.util.Event.onDOMReady(function (ev) {
            var carousel    = new YAHOO.widget.Carousel("container", {
                        animation: { speed: 0.5 }
                });

			 
			 carousel.on("itemSelected", function (index) { 
	    	   var item = carousel.getElementForItem(index); 
	 
			   if (item) { 
	            loadpic(getImage(item)); 
			   } 
	   	     }); 

			carousel.set("isCircular", true);             
			carousel.set("numVisible", [1, 1]);
			carousel.render(); // get ready for rendering the widget
            carousel.show();   // display the widget
			el = document.getElementById('container');
			el.style.width="1267px";
			el = document.getElementById('pics');
			el.style.width="1190px";
            //carousel.startAutoPlay();
        });
})();
