/*
 * 	sunKING.Sliding.Gallery - Sliding with jQuery
 *  http://www.sunkingdigital.com
 *
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * Built on top of the jQuery library with the interface plugin for animation
 * http://jquery.com
 *
 *
 */
this.catagory = "ks";
this.displayAmt = "4";
this.motionSpeed = "500";
var xmlhttp;
var xmlDoc;
function loadXMLDoc(theFile) {
  xmlhttp=null;
  if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } 
  else if (window.ActiveXObject) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }

  if (xmlhttp!=null) {
    xmlhttp.onreadystatechange=loaded;
    xmlhttp.open("GET",theFile,true);
    xmlhttp.send(null);
  } else { alert('Sorry, your browser can\'t handle this script'); return; }
}

function checkReadyState(obj) {
  if(obj.readyState == 4) {
    if(obj.status == 200) { return true; }
    else { alert("Problem retrieving XML data"); }
  }
}

function loaded() {	
  if(checkReadyState(xmlhttp)) {
    xmlDoc=xmlhttp.responseXML.documentElement;
	removeAllElement();
        featuredshowTags('product','featuredproductSort');
  }
}

function removeAllElement() {
		var mainDiv = document.getElementById("burner");
		var childDiv =  document.getElementById("buttonToggle");
		mainDiv.removeChild(childDiv);
		
		var ni = document.getElementById('burner');

		var newdiv = document.createElement('div');
		newdiv.setAttribute('id','buttonToggle');
		newdiv.className="slidingGalleryContainer";
		ni.appendChild(newdiv);
		
		var ni2 = document.getElementById('buttonToggle');
		
		var newdiv2 = document.createElement('div');
		newdiv2.setAttribute('id','productSort');
		newdiv2.className="panels";
		ni2.appendChild(newdiv2);
		
		this.showTags('product','productSort');
	}

function showTags(theTag,thePlace) {
  function getTag(tag) { 
    var tmp='';
    xx=x[i].getElementsByTagName(tag);
	
    try { tmp=xx[0].firstChild.data; } 
    catch(er) { tmp=''; }    
    return(tmp); 
  }

  var xx; var x; var txt;
  x = xmlDoc.getElementsByTagName(theTag);
  txt='<div id="poop">'; 
  for (i=0; i<x.length; i++) { 
  	productName=xmlDoc.getElementsByTagName("product")[i].getAttribute("name");
	heinzUrl=xmlDoc.getElementsByTagName("product")[i].getAttribute("url");
	productCatagory=xmlDoc.getElementsByTagName("product")[i].getAttribute("cat");
	image=xmlDoc.getElementsByTagName("product")[i].getAttribute("image"); 
	xmlRegion=xmlDoc.getElementsByTagName("product")[i].getAttribute("region"); 
	runProductHome=xmlDoc.getElementsByTagName("product")[i].getAttribute("popular");
	runProductHome = "no";
	
	// NORTH AMERICA
	if(runProductHome == "no" && xmlRegion=="na" ) {
	switch (catagory) {
		case "ks":
			if(productCatagory == "KetchupAndSauces" && region == "na") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
			break;
		case "ms":
			if(productCatagory == "MealsAndSnacks" && region=="na") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
			break;
		case "sbp":
			if(productCatagory == "SoupsBeansAndPasta" && region=="na") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
			break;
		case "inf":
			if(productCatagory == "InfantFoods" && region=="na") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
		}
  	}
	// EUROPE
	if(runProductHome == "no" && xmlRegion=="eu" ) {
	switch (catagory) {
		case "ks":
			if(productCatagory == "KetchupAndSauces" && region == "eu") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
			break;
		case "ms":
			if(productCatagory == "MealsAndSnacks" && region == "eu") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
			break;
		case "sbp":
			if(productCatagory == "SoupsBeansAndPasta" && region == "eu") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
			break;
		case "inf":
			if(productCatagory == "InfantFoods" && region == "eu") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
		}
  	}
	//ASIA PACIFIC
	if(runProductHome == "no" && xmlRegion=="asia" ) {
	switch (catagory) {
		case "ks":
			if(productCatagory == "KetchupAndSauces" && region == "asia") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
			break;
		case "ms":
			if(productCatagory == "MealsAndSnacks" && region == "asia") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
			break;
		case "sbp":
			if(productCatagory == "SoupsBeansAndPasta" && region == "asia") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
			break;
		case "inf":
			if(productCatagory == "InfantFoods" && region == "asia") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
		}
  	}
//REST OF THE WORLD
	if(runProductHome == "no" && xmlRegion=="row" ) {
	switch (catagory) {
		case "ks":
			if(productCatagory == "KetchupAndSauces" && region == "row") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
			break;
		case "ms":
			if(productCatagory == "MealsAndSnacks" && region == "row") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
			break;
		case "sbp":
			if(productCatagory == "SoupsBeansAndPasta" && region == "row") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
			break;
		case "inf":
			if(productCatagory == "InfantFoods" && region == "row") {
			txt+='<div id="panel" class="panel">';
			if(heinzUrl != ""){
				if(heinzUrl.match("http") != null) {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '" target="_blank">';
				}
				else {
					txt+='<a href="' + heinzUrl +'" name="' + productName + '">';
				}
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';
				txt+='</a>';
			}
			else {
				txt+='<img src="' + image + '" alt="' + productName + '" class="productImg" align="left" border="0" alt="" />';		
			}
			txt+='</div>';
			};
		}
  	}
 }
  txt+="</div>";

  document.getElementById(thePlace).innerHTML=txt;
  this.slidingGallery.init();
}

var slidingGallery={
	init:function(){
		slidingGallery.Features.init();
	},
	Features:{
		init:function(){
			if(smartContent.panels.length > 0) {
				smartContent.panels.length = 0;
				smartContent.init($(".panels"));
			}
			else {smartContent.init($(".panels"));}
		}
	}
}

var smartContent={
	container:null,
	panels:Array(),
	init:function(container){
		smartContent.container=$(container);
		$('.panel',smartContent.container).each(
			function(i){
				var newPanel={};
				newPanel.element=this;
				newPanel.id=this.id;
				newPanel.index=i;
				smartContent.panels[i]=newPanel;
			}
		)
		smartContent.createToggles();
		smartContent.showPanel(smartContent.panels[0]);
	},
	removeElement:function(){
		var d = document.getElementById('productSort');
		var d_nested = document.getElementById('toggle');
		if (d_nested.parentNode == d) { d.removeChild(d_nested)};
		
		smartContent.createToggles();
		smartContent.showPanel(smartContent.panels[0]);
	},
		createToggles:function(){
		var smartContentParent=$(".slidingGalleryContainer")[0];
		var toggleBtnBarLeft=document.createElement("div");
		toggleBtnBarLeft.className="toggleButtonsLeft";
		toggleBtnBarLeft.setAttribute('id',"toggle");
		smartContentParent.appendChild(toggleBtnBarLeft);
		
		var toggleBtnBarRight=document.createElement("div");
		toggleBtnBarRight.className="toggleButtonsRight";
		toggleBtnBarRight.setAttribute('id',"toggle");
		smartContentParent.appendChild(toggleBtnBarRight);

		if (smartContent.panels.length <= displayAmt) {
			next=document.createElement("a");
			next.className="next";
	
			previous=document.createElement("a");
			previous.className="previous";
		}
		else {
			next=document.createElement("a");
			next.className="next";
			next.href="#next";
			$(next).click(function() {smartContent.showNextPanel(); return false;})
	
			previous=document.createElement("a");
			previous.className="previous";
			previous.href="#previous";
			$(previous).click(function() {smartContent.showPreviousPanel(); return false;})
	
			toggleBtnBarRight.appendChild(next);
			toggleBtnBarLeft.appendChild(previous);
		} // end else

	},
	showPanel:function(panel){
		var panelWidth = ($(".panel")[0].clientWidth);
		var panelIndex = panel.index;
		var l =panelWidth*panelIndex;
		
		smartContent.container.animate({left:"-"+l+"px"},motionSpeed,"easeboth");
		smartContent.activePanelIndex=panel.index;
	},
	
	showNextPanel:function(){
		var bigContainer = ($(".slidingGalleryContainer")[0].clientWidth);
		var individualContainers = ($(".panel")[0].clientWidth);
		var traceEnd = bigContainer/individualContainers;
		
		if (smartContent.activePanelIndex<(smartContent.panels.length-[traceEnd])){
			nextIndex=smartContent.activePanelIndex+1;
		}
		else{
			nextIndex=0;
		}
		smartContent.showPanel(smartContent.panels[nextIndex]);
	},
	
	showPreviousPanel:function(panel){
		var traceStart = ($(".slidingGalleryContainer")[0].clientWidth)/($(".panel")[0].clientWidth);
		
		if (smartContent.activePanelIndex>(0)){
			nextIndex=smartContent.activePanelIndex-1;
		}
		
		else{
			nextIndex=smartContent.panels.length-displayAmt;
		}
		smartContent.showPanel(smartContent.panels[nextIndex]);
	}	
}

function setcatagory(val)
	{
		this.catagory = val;
		this.toggleDivs();
	};
	
	function toggleDivs()
	{
		$(".active").each(function(){$(this).removeClass("active")});
		this.removeAllElement();
		switch (catagory)
		{
			case "ks":
				document.getElementById('1').className = 'active';
				break;
			case "ms":
				document.getElementById('2').className = 'active';
				break;
			case "sbp":
				document.getElementById('3').className = 'active';
				break;
			case "inf":
				document.getElementById('4').className = 'active';
		}
	}

/************************** 
*FEATURED PRODUCT SCROLLER*
***************************/

function featuredshowTags(theTag,thePlace) {
  /*function getTag(tag) { 
    var tmp='';
    xx=x[i].getElementsByTagName(tag);
	
    try { tmp=xx[0].firstChild.data; } 
    catch(er) { tmp=''; }    
    return(tmp); 
  }*/

  var xx; var x; var txt;
  x = xmlDoc.getElementsByTagName("brand");
  txt='<div id="featuredpoop">'; 
  for (i=0; i<x.length; i++) { 

  	featuredproductName=xmlDoc.getElementsByTagName("brand")[i].getAttribute("name");
	featuredheinzUrl=xmlDoc.getElementsByTagName("brand")[i].getAttribute("url");
	featuredImage=xmlDoc.getElementsByTagName("brand")[i].getAttribute("image"); 
	isPowerBrand=xmlDoc.getElementsByTagName("brand")[i].getAttribute("powerbrand");
	isRegion=xmlDoc.getElementsByTagName("brand")[i].getAttribute("region");
        regionRW=xmlDoc.getElementsByTagName("brand")[i].getAttribute("rw");
        regionNA=xmlDoc.getElementsByTagName("brand")[i].getAttribute("na");
        regionEU=xmlDoc.getElementsByTagName("brand")[i].getAttribute("eu");
        regionAP=xmlDoc.getElementsByTagName("brand")[i].getAttribute("ap");	
        switch (region) {
	case "row":
	if(isPowerBrand == "true" && regionRW == "true") {
		txt+='<div id="featuredpanel" class="featuredpanel">';
		txt+='<a class="productLink" href="/our-food/' + featuredheinzUrl +'">';
	        txt+='<img src="http://media.heinz.com/media/ourfoods/popularproducts/logos/' + featuredImage + '" border="0" alt="' + featuredproductName +'" />';
		txt+='</a>';
		txt+='</div>';
		};
	break;
         case "na":
	if(isPowerBrand == "true" && regionNA == "true") {
		txt+='<div id="featuredpanel" class="featuredpanel">';
		txt+='<a class="productLink" href="/our-food/' + featuredheinzUrl +'">';
	        txt+='<img src="http://media.heinz.com/media/ourfoods/popularproducts/logos/' + featuredImage + '" border="0" alt="' + featuredproductName +'" />';
		txt+='</a>';
		txt+='</div>';
		};
	break;
         case "asia":
	if(isPowerBrand == "true" && regionAP == "true") {
		txt+='<div id="featuredpanel" class="featuredpanel">';
		txt+='<a class="productLink" href="/our-food/' + featuredheinzUrl +'">';
	        txt+='<img src="http://media.heinz.com/media/ourfoods/popularproducts/logos/' + featuredImage + '" border="0" alt="' + featuredproductName +'" />';
		txt+='</a>';
		txt+='</div>';
		};
	break;
         case "eu":
	if(isPowerBrand == "true" && regionEU == "true") {
		txt+='<div id="featuredpanel" class="featuredpanel">';
		txt+='<a class="productLink" href="/our-food/' + featuredheinzUrl +'">';
	        txt+='<img src="http://media.heinz.com/media/ourfoods/popularproducts/logos/' + featuredImage + '" border="0" alt="' + featuredproductName +'" />';
		txt+='</a>';
		txt+='</div>';
		};
	break;
 	 }
      }
  txt+="</div>";
  
  document.getElementById(thePlace).innerHTML=txt;
  this.featuredslidingGallery.init();
  var featuredpanelIndex = 0;
}
var featuredslidingGallery={
	init:function(){
		featuredslidingGallery.Features.init();
		
	},
	Features:{
		init:function(){
			if(featuredsmartContent.featuredpanels.length > 0) {
				featuredsmartContent.featuredpanels.length = 0;
				featuredsmartContent.init($(".featuredpanels"));
			}
			else {featuredsmartContent.init($(".featuredpanels"));}
		}
	}
}

var featuredsmartContent={
	container:null,
	featuredpanels:Array(),
	init:function(container){
		featuredsmartContent.container=$(container);
		$('.featuredpanel',featuredsmartContent.container).each(
			function(i){
				var newfeaturedpanel={};
				newfeaturedpanel.element=this;
				newfeaturedpanel.id=this.id;
				newfeaturedpanel.index=i;
				featuredsmartContent.featuredpanels[i]=newfeaturedpanel;
			}
		)
		featuredsmartContent.createfeaturedtoggles();
		featuredsmartContent.showfeaturedpanel(featuredsmartContent.featuredpanels[0]);
	},
	removeElement:function(){
		var d = document.getElementById('featuredproductSort');
		var d_nested = document.getElementById('featuredtoggle');
		if (d_nested.parentNode == d) { d.removeChild(d_nested)};
		
		featuredsmartContent.createfeaturedtoggles();
		featuredsmartContent.showfeaturedpanel(featuredsmartContent.featuredpanels[0]);
	},
		createfeaturedtoggles:function(){
		var featuredsmartContentParent=$(".featuredslidingGalleryContainer")[0];
		var featuredtoggleBtnBarLeft=document.createElement("div");
		featuredtoggleBtnBarLeft.className="featuredtoggleButtonsLeft";
		featuredtoggleBtnBarLeft.setAttribute('id',"featuredtoggle");
		featuredsmartContentParent.appendChild(featuredtoggleBtnBarLeft);
		
		var featuredtoggleBtnBarRight=document.createElement("div");
		featuredtoggleBtnBarRight.className="featuredtoggleButtonsRight";
		featuredtoggleBtnBarRight.setAttribute('id',"featuredtoggle");
		featuredsmartContentParent.appendChild(featuredtoggleBtnBarRight);

		next=document.createElement("a");
		next.className="featurednext";
		next.href="#";
		$(next).click(function() {featuredsmartContent.showNextfeaturedpanel(); return false;})

		previous=document.createElement("a");
		previous.className="featuredprevious";
		previous.href="#";
		$(previous).click(function() {featuredsmartContent.showPreviousfeaturedpanel(); return false;})

		featuredtoggleBtnBarRight.appendChild(next);
		featuredtoggleBtnBarLeft.appendChild(previous);

	},
	showfeaturedpanel:function(featuredpanel){
		var featuredpanelWidth = ($(".featuredpanel")[0].clientWidth);
		var featuredpanelIndex = featuredpanel.index;
		var l =featuredpanelWidth*featuredpanelIndex;
		
		featuredsmartContent.container.animate({left:"-"+l+"px"},'slow',"easeboth");
		featuredsmartContent.activefeaturedpanelIndex=featuredpanel.index;
	},
	
	showNextfeaturedpanel:function(){
		var bigContainer = ($(".featuredslidingGalleryContainer")[0].clientWidth);
		var individualContainers = ($(".featuredpanel")[0].clientWidth); 
		var traceEnd = bigContainer/individualContainers;
		if (featuredsmartContent.activefeaturedpanelIndex<(featuredsmartContent.featuredpanels.length-[traceEnd])){
			nextIndex=featuredsmartContent.activefeaturedpanelIndex+1;
		}
		else{
			nextIndex=0;
		}
		featuredsmartContent.showfeaturedpanel(featuredsmartContent.featuredpanels[nextIndex]);
	},
	
	showPreviousfeaturedpanel:function(featuredpanel){
		var traceStart = ($(".featuredslidingGalleryContainer")[0].clientWidth)/($(".featuredpanel")[0].clientWidth);
		if (featuredsmartContent.activefeaturedpanelIndex>(0)){
			nextIndex=featuredsmartContent.activefeaturedpanelIndex-1;
		}else{
			nextIndex=featuredsmartContent.featuredpanels.length-1;
		}
		featuredsmartContent.showfeaturedpanel(featuredsmartContent.featuredpanels[nextIndex]);
	}	
}

	


this.xmlFile = "../../data/products.xml";
window.onload=function(){
 loadXMLDoc(xmlFile);
}