var colorkey = "taco";
var showhide = "hidden";
var layerkey = "taco";
var timerid;
var timerid2;
var pauseid;
var hideid;
var showfiche;
var timeridsub;
var timerid2sub;
var partarea = "partsarea1";
var partareatimerid2;
var setvisibilitysubtime;

/////////////////////////////////

function settoone(){
	partarea = "partsarea1";
}

function setAvailable(inventorynumber)
{
	//dive = div;
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="/includes/EcomInventoryCheckSS.php";
url=url+"?inventorynumber="+inventorynumber;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function setAvailablesize(info)
{
	allinfo = info.split(',');
	//dive = div;
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="/includes/EcomInventoryCheckSS.php";
url=url+"?inventorynumber="+allinfo[1];
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById('inventory').innerHTML=xmlhttp.responseText;
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}




///////////////////////////////////////////////////////////////

/////////////////////////////set ktm motorcycles.com image roll /////////////////////////////




/////////////////////////////////////////////////////////////////



function stoptimeout (onoff) {
	window.clearTimeout(timerid);
	
}

function settimer () {
	timerid = setTimeout("document.getElementById('mainimage').src='productimages/'+ colorkey +'_md.jpg'", 250);
}

function setImage () {
	document.getElementById("mainimage").src="productimages/"+ colorkey +"_md.jpg";
}

function setaltImage (alt) {
	document.getElementById("mainimage").src="productimages/"+ colorkey +"_alt_"+ alt +"_md.jpg";
}

function showhidedescription () {
	var myzap = document.getElementById(15001).style.height;
		if (myzap == "127px"){
		document.getElementById(15001).style.height="auto";
		}
		if (myzap != "127px"){
		document.getElementById(15001).style.height="127px";
		document.getElementById(15001).style.overflow="hidden";
		}
	}
	
	

function setclicked (thisimage, color, sku, key) {
	var numberofthumbs = color;
	var mysku = sku;
	var mycolorkey = colorkey;
	var mykey = key;
	for ( x = 1 ; x <= numberofthumbs.length  ; x++ ){
		if ("'"+ mysku +"'"=="'"+ mycolorkey +"'"|| mycolorkey == "default"){
		document.getElementById(mykey).style.background="#FFCC00";
		}
		if ("'"+ x +"'"!="'"+ key +"'"){
		document.getElementById(x).style.background="";
		}
	}}

function selectSize (tacos, sizes, models, prices, skus, title, color, ship, formodel) {
	var mysizes = document.getElementById('newSizes');
	var mymodels = document.getElementById('newModel');
	if (mysizes != null){
		hasSize (tacos, sizes, models, prices, skus, title, color, ship, formodel);
		document.getElementById('inventory').innerHTML="";
	}
	if (mymodels != null){
		var modeltacos = "newModel";
		hasSize (modeltacos, sizes, models, prices, skus, title, color, ship);
		document.getElementById('inventory').innerHTML="";
	}
	if (mysizes == null && mymodels == null){
	setAvailable(skus);
	}
	
	else
	document.getElementById("pricetosend").value = prices;
	document.getElementById("skutosend").value = skus;
	document.getElementById("titletosend").value = title + " " + color + " " + formodel + " " + ship;
	
}

function hasSize (tacos, sizes, models, prices, skus, title, color, ship, formodel) {
	
	//i=color index 1  itemarray= sm, md, lg
  var generalTitle = title;
  var generalColor = color;
  var ItemArray = sizes;
  var modelArray = models;
  var priceArray = prices;
  var skuArray = skus;
  var myEleSize ;
  var x ;
  // Empty the second drop down box of any choices
  for (var q=document.getElementById(tacos).options.length;q>=0;q--) document.getElementById(tacos).options[q]=null;
  
  // ADD Default Choice - in case there are no values
  myEleSize = document.createElement("option") ;
  myEleSize.setAttribute('value', ["0"]);
  var txt = document.createTextNode("[Select a size]");
  myEleSize.appendChild(txt)

  // newSizes.add(myEle) ;
  document.getElementById(tacos).appendChild(myEleSize)
  // Now loop through the array of individual items
  // Any containing the same child id are added to
  // the second dropdown box
  for ( x = 0 ; x < ItemArray.length || x < modelArray.length ; x++ ) {
      myEleSize = document.createElement("option") ;
      //myEle.value = x ;
	  if (priceArray[x] == null){
		var generalprice = priceArray[0];
	  }else{
		  var generalprice = priceArray[x];
		  }
	if (skuArray[x] == null){
		var generalsku = skuArray[0];
	  }else{
		  var generalsku = skuArray[x];
		  }
      myEleSize.setAttribute('value', [generalprice, generalsku, generalTitle, ItemArray[x], modelArray[x], generalColor, formodel, ship]);
      // myEle.text = ItemArray[x] ;
      var txt = document.createTextNode(ItemArray[x] || modelArray[x]);
      myEleSize.appendChild(txt)
      // newSizes.add(myEle) ;
      document.getElementById(tacos).appendChild(myEleSize);
    }
  }

function contentHide(sku) {
	document.getElementById("detailwrapper").removeChild(document.getElementById("remover"));
}

function newLink(info) {
	document.location.href = info;
}
function setPrice(info) {
	allinfo = info.split(',');
	document.getElementById("pricetosend").value = allinfo[0];
	document.getElementById("skutosend").value = allinfo[1];
	document.getElementById("titletosend").value = allinfo[2] + " " + allinfo[3]+ " " +allinfo[4]+ " " +allinfo[5]+ " " +allinfo[6]+ " " +allinfo[7];
	
	if (document.getElementById("checksize").childNodes.length == 1){
	document.getElementById("checksize").removeChild (document.getElementById("checksize").childNodes[0]);
	}
	if (document.getElementById("pricechange").childNodes.length == 2){
	document.getElementById("pricechange").removeChild (document.getElementById("pricechange").childNodes[1]);
	}
	
	var checksize = document.getElementById("checksize");
	var checkprice = document.getElementById("pricechange");
	var mySizeholder = document.createElement("span") ;
	var myPriceholder = document.createElement("span") ;

      var txtsize = document.createTextNode(allinfo[3] || allinfo[4]);
	   var txtprice = document.createTextNode(allinfo[0]);
	  
      mySizeholder.appendChild(txtsize)
	  myPriceholder.appendChild(txtprice)
	  myPriceholder.setAttribute('id', "pricer");
      // newSizes.add(myEle) ;
      document.getElementById("checksize").appendChild(mySizeholder);
	  document.getElementById("pricechange").appendChild(myPriceholder);
}

function setColor(color, price) {
	if (document.getElementById("checkcolor").childNodes.length == 1){
	document.getElementById("checkcolor").removeChild (document.getElementById("checkcolor").childNodes[0]);
	}
	if (document.getElementById("checksize").childNodes.length == 1){
	document.getElementById("checksize").removeChild (document.getElementById("checksize").childNodes[0]);
	}
	if (document.getElementById("pricechange").childNodes.length == 2){
	document.getElementById("pricechange").removeChild (document.getElementById("pricechange").childNodes[1]);
	}
	var checkcolor = document.getElementById("checkcolor");
	var myColorholder = document.createElement("span") ;
	
	var txtcolor = document.createTextNode(color + " ");
	myColorholder.appendChild(txtcolor)
	myColorholder.setAttribute('id', "colorchecker");
	document.getElementById("checkcolor").appendChild(myColorholder);
	
	var checkprice = document.getElementById("pricechange");
	var myPriceholder = document.createElement("span") ;

	   var txtprice = document.createTextNode(price);
	  
	  myPriceholder.appendChild(txtprice)
	  myPriceholder.setAttribute('id', "pricer");
      // newSizes.add(myEle) ;
	  document.getElementById("pricechange").appendChild(myPriceholder);
}

function quickbuy(whichform) {


  // if we get here, then the window hasn't been created yet, or it
  // was closed by the user.
document.getElementById(whichform).submit();

}

function validate_color() {
	if (document.getElementById('colorchecker').firstChild.nodeValue==false){
	
	alert("Select a Color by Clicking on a Thumbnail");return false
	}
	if (document.getElementById('newSizes') == null){
		
		
//		var thenewwindow; // this will hold our opened window
//		thenewwindow = window.open('','fenster','width=900, height=600, scrollbars=YES, resizable=YES, menubar=YES, location=YES, toolbar=YES');

  // first check to see if the window already exists
//  if (thenewwindow != null)
//  {
    // the window has already been created, but did the user close it?
    // if so, then reopen it. Otherwise make it the active window.
//    if (!thenewwindow.closed) {
//      thenewwindow.focus();
//document.buyform.submit();
//      return thenewwindow;

    // otherwise fall through to the code below to re-open the window
//  }
 // }

  // if we get here, then the window hasn't been created yet, or it
  // was closed by the user.
document.buyform.submit();

	
		
	}
  
  if (document.getElementById('newSizes') != null){
	  
  with (document.getElementById('newSizes')){
	
	if (value==null||value=="0"){
		alert("Select a Size from the Drop Down");return false
		}else
	{
		
//		var thenewwindow; // this will hold our opened window
//		thenewwindow = window.open('','fenster','width=900, height=600, scrollbars=YES, resizable=YES, menubar=YES, location=YES, toolbar=YES');

  // first check to see if the window already exists
//  if (thenewwindow != null)
 // {
    // the window has already been created, but did the user close it?
    // if so, then reopen it. Otherwise make it the active window.
 //   if (!thenewwindow.closed) {
//      thenewwindow.focus();
//document.buyform.submit();
//      return thenewwindow;

    // otherwise fall through to the code below to re-open the window
 // }
 // }

  // if we get here, then the window hasn't been created yet, or it
  // was closed by the user.
document.buyform.submit();

} 

  }
  }

} 

function validate_size()
{
	
with (document.getElementById('newSizes'))
{

	if (document.getElementById('newSizes') != null && value==null||value=="0")
  {alert("Select a Size from the Drop Down");return false}
else
	{
		
//		var thenewwindow; // this will hold our opened window
//		thenewwindow = window.open('','fenster','width=900, height=600, scrollbars=YES, resizable=YES, menubar=YES, location=YES, toolbar=YES');

  // first check to see if the window already exists
 // if (thenewwindow != null)
 // {
    // the window has already been created, but did the user close it?
    // if so, then reopen it. Otherwise make it the active window.
 //   if (!thenewwindow.closed) {
 //     thenewwindow.focus();
//document.buyform.submit();
 //     return thenewwindow;

    // otherwise fall through to the code below to re-open the window
 // }
 // }

  // if we get here, then the window hasn't been created yet, or it
  // was closed by the user.
document.buyform.submit();

} 

}
}


function validate_model()
{
with (document.getElementById('newModel'))
{
	if (value==null||value=="0")
  {alert("Select a Model from the Drop Down");return false}
else
	{
		
//		var thenewwindow; // this will hold our opened window
//		thenewwindow = window.open('','fenster','width=900, height=600, scrollbars=YES, resizable=YES, menubar=YES, location=YES, toolbar=YES');

  // first check to see if the window already exists
//  if (thenewwindow != null)
//  {
    // the window has already been created, but did the user close it?
    // if so, then reopen it. Otherwise make it the active window.
//    if (!thenewwindow.closed) {
//      thenewwindow.focus();
//document.buyform.submit();
//      return thenewwindow;

    // otherwise fall through to the code below to re-open the window
 // }
 // }

  // if we get here, then the window hasn't been created yet, or it
  // was closed by the user.
document.buyform.submit();

} 
}
}



function validate_form(thisform)
{
	
with (thisform)
{
//var newColor = document.getElementById('colorhead');
	//var colorbox = document.getElementById('colorchecker').firstChild.nodeValue; 
	var mysizes = document.getElementById('newSizes');
	var mymodels = document.getElementById('newModel');
	var mycolor = document.getElementById('colorhead');
	
//	if (validate_color2910AC(choice2910AC,"Choose Color")==false)
 // {choice2910AC.focus();return false}
	if (mycolor != null || mysizes != null || mymodels != null){
	if (mycolor != null){
      if(validate_color()==false){
	  mycolor.focus();return false}
	}
	
	if (mysizes != null){
      if(validate_size()==false){
	  mysizes.focus();return false}
	}
	
	if (mymodels != null){
      if(validate_model()==false){
	  mymodels.focus();return false}
	}
}

	else {
		
	//	var thenewwindow; // this will hold our opened window
	//	thenewwindow = window.open('','fenster','width=840, height=600, scrollbars=YES, resizable=YES, menubar=YES, location=YES, toolbar=YES');

  // first check to see if the window already exists
//  if (thenewwindow != null)
//  {
    // the window has already been created, but did the user close it?
    // if so, then reopen it. Otherwise make it the active window.
//    if (!thenewwindow.closed) {
//      thenewwindow.focus();
//document.buyform.submit();
//      return thenewwindow;

    // otherwise fall through to the code below to re-open the window
//  }
//  }

  // if we get here, then the window hasn't been created yet, or it
  // was closed by the user.
document.buyform.submit();

} 
	
	/*if (newColor != null){
	if (validate_color(colorbox, "Select a Color")==false)
  {newColor.focus();return false}
	} */
	
	
	 
	/* if (newModel != null){
     if (validate_model(newModel, "Select a Model from the Drop Down")==false)
  {newModel.focus();return false}
	}*/
}
}

function waititout(id){
	
	
	pauseid = setTimeout("setvisibility("+"'"+id+"'"+")", 200);
}

function stoppause () {
	window.clearTimeout(pauseid);
	
}


function stoptimeout2 () {
	window.clearTimeout(timerid2);
	if (partarea != null){
	window.clearTimeout(partareatimerid2);
	}
}

function settimer2 (id) {	
	timerid2 = setTimeout("document.getElementById("+"'"+ id +"'"+").style.visibility='hidden'", 300);
		if (partarea != null){
	partareatimerid2 = setTimeout("document.getElementById("+"'"+ partarea +"'"+").style.visibility='hidden'", 300);
		}
	
	}
	
	function stophide () {
	window.clearTimeout(hideid);
	
}
	
	
	function hideallofthem(){
	
	
	hideid = setTimeout("hideallofthemnow()", 300);
}
	
	
function hideallofthemnow (){
	
	var maincategories = document.getElementsByTagName("div").id="navdrop";
	
	
	for ( x = 1 ; x <= maincategories.length+3  ; x++ ){
		var cheese2 = ("catagory"+x);
	document.getElementById(cheese2).style.visibility="hidden";
	}
	
	for ( x = 1 ; x <= 12  ; x++ ){
		var cheeseb = ("partsarea"+x);
		
	document.getElementById(cheeseb).style.visibility="hidden";
	
	}
	
	
}
	

function setvisibility (id) {
	
		var maincategories = document.getElementsByTagName("div").id="navdrop";
		
		if (id !== "catagory1"){
			if (partarea != null){
			partareatimerid2 = setTimeout("document.getElementById("+"'"+ partarea +"'"+").style.visibility='hidden'", 0);
			}
		}
		
		for ( x = 1 ; x <= maincategories.length+3  ; x++ ){
		var cheese = id;
		var cheese2 = ("catagory"+x);
		if ("'"+ cheese2 +"'"=="'"+ id +"'"){
		document.getElementById(id).style.visibility="visible";
		
		}
		else if ("'"+ cheese2 +"'"!="'"+ id +"'"){
		document.getElementById(cheese2).style.visibility="hidden";
		}
	}
	}
	
		function stopfiche () {
	window.clearTimeout(showfiche);
	
}
	
	function showfichea() {
		showfiche = setTimeout("showfichedelay()", 300);
	}
	
	function showfichedelay() {
		document.getElementById("partsarea1").style.visibility="visible";
	}
	
	function hidefiche() {
		document.getElementById("partsarea1").style.visibility="hidden";
	}
	
	
	function stoptimeout2sub () {
	
	window.clearTimeout(timerid2sub);
	
	
}

function settimer2sub (id) {
	

	timerid2sub = setTimeout("document.getElementById("+"'"+ id +"'"+").style.visibility='hidden'", 300);
	}
	
	
			function stopvisibilitysub () {
	window.clearTimeout(setvisibilitysubtime);
	
}
	
	
	function setvisibilitysub (id) {
	
	setvisibilitysubtime = setTimeout("setvisibilitysuba('"+id+"')", 200);
	}
	
	
	
	function setvisibilitysuba (id) {
		//var wacawaca = "its here";
		
		
		var maincategories = document.getElementsByTagName("div").id="subdrop";
		
		for ( x = 1 ; x <= 12  ; x++ ){
		var cheese = id;
		var cheese2 = ("partsarea"+x);
		
		if ("'"+ cheese2 +"'"=="'"+ id +"'"){
		document.getElementById(id).style.visibility="visible";
		partarea = cheese2;
		}
		else if ("'"+ cheese2 +"'"!="'"+ id +"'"){
		document.getElementById(cheese2).style.visibility="hidden";
		}
		
	}
	}
	
	function eattacos (id) {
		var maincategories = document.getElementsByTagName("div").id="tulips";
		for ( x = 1 ; x <= 4  ; x++ ){
		var cheese = ("seccatagory"+x );
		var cheese3 = ("seccatagory"+id );
		if ("'"+ cheese3 +"'"=="'" + "seccatagory"+ x +"'"){
		document.getElementById(cheese3).style.visibility="visible";
		}
		else if ("'"+ cheese3 +"'"!="'" + "seccatagory"+ x +"'"){
		document.getElementById(cheese).style.visibility="hidden";
		}
	}
	}
	
	
	function themodelfill (cc) {
		var allccs = new Array();
	   allccs['a50'] = new Array("SX","SX JUNIOR","SX MINI","MINI ADVENTURE","SENIOR ADVENTURE","JUNIOR ADVENTURE");
	   allccs['a65'] = new Array("SX","XC");
	   allccs['a85'] = new Array("SX","XC");
	   allccs['a105'] = new Array("SX","XC");
	   allccs['a125'] = new Array("SX","EXC");
	   allccs['a144'] = new Array("SX");
	   allccs['a150'] = new Array("SX");
	   allccs['a200'] = new Array("SX","XC","XCW","EXC","MXC");
	   allccs['a250'] = new Array("SX","SXF","XC","XCF","XCW","XCFW","EXC","EXCR","MXC");
	   allccs['a300'] = new Array("XC","XCW","EXC","MXC");
	   allccs['a350'] = new Array("SXF");
	   allccs['a380'] = new Array("SX","EXC","MXC");
	   allccs['a400'] = new Array("SX","XCW","EXC","MXC");
	   allccs['a450'] = new Array("SX","SX ATV","SXF","XC","XC ATV","XCF","XCW","XCRW","EXC","EXCR","MXC");
	   allccs['a505'] = new Array("SX ATV","SXF","XCF");
	   allccs['a520'] = new Array("SX","EXC","MXC");
	   allccs['a525'] = new Array("SX","XC","XC ATV","XCW","EXC","MXC");
	   allccs['a530'] = new Array("XCW","XCRW","EXC","EXCR");
	   allccs['a540'] = new Array("SX");
	   allccs['a625'] = new Array("SMC","SXC");
	   allccs['a640'] = new Array("DUKEII","LC4SUPERMOTO","LC4","ADVENTURE");
	   allccs['a690'] = new Array("SUPERMOTO","SUPERMOTOR","SMC","ENDURO","DUKE");
	   allccs['a950'] = new Array("SUPERMOTO","SUPERMOTOR","SUPERENDUROR","ADVENTURE","ADVENTURES");
	   allccs['a990'] = new Array("ADVENTURE","ADVENTURES","SUPERDUKE","SUPERDUKER","SMT","SMR","SUPERMOTO");
	   allccs['a1190'] = new Array("RC8");
	
  //var generalCC = cc;
  
  //var ItemArray = allccs[cc];
  
 var myEleSize;
 var x ;
//   Empty the second drop down box of any choices
  for (var q=document.getElementById('breadnava').options.length;q>=0;q--) document.getElementById('breadnava').options[q]=null;
  for (var q=document.getElementById('breadnavb').options.length;q>=0;q--) document.getElementById('breadnavb').options[q]=null;
  
//   ADD Default Choice - in case there are no values
  myEleSize = document.createElement("option") ;
  myEleSize.setAttribute('value', ["0"]);
  var txt = document.createTextNode("[Select Your KTM "+cc+" Model]");
  myEleSize.appendChild(txt)

  document.getElementById('breadnava').appendChild(myEleSize)
//   Now loop through the array of individual items
  // Any containing the same child id are added to
  // the second dropdown box

  for ( x = 0; x < allccs["a"+cc].length ; x++) {
 
	//  alert (allccs[cc][1]);
      myEleSize = document.createElement("option") ;
      
     myEleSize.setAttribute('value', [cc, allccs["a"+cc][x]]);
      
    var txt = document.createTextNode(allccs["a"+cc][x]);
     myEleSize.appendChild(txt)
  
    document.getElementById('breadnava').appendChild(myEleSize);
  }
  }


function theyearfill (cc,category,fitter) {
		var allyears = new Array();
	   allyears['50SX'] = new Array("2011","2010","2009","2008","2007","2006","2005","2004","2003");
	   allyears['50SXJUNIOR'] = new Array("2010","2009","2008","2007","2006","2005","2004","2003","2001","2000");
	   allyears['50SXMINI'] = new Array("2011","2010","2009","2008");
	   allyears['50MINIADVENTURE'] = new Array("2007","2006","2005","2004","2003");
	   allyears['50SENIORADVENTURE'] = new Array("2007","2006","2005","2004","2003");
	   allyears['50JUNIORADVENTURE'] = new Array("2003","2001");
	   allyears['65SX'] = new Array("2011","2010","2009","2008","2007","2006","2005","2004","2003","2002","2001");
	   allyears['65XC'] = new Array("2010","2009","2008");
	   allyears['85SX'] = new Array("2011","2009","2008","2007","2006","2005","2004","2003");
	   allyears['85XC'] = new Array("2009","2008");
	   allyears['105SX'] = new Array("2011","2009","2008","2007","2006","2004");
	   allyears['105XC'] = new Array("2009","2008");
	   allyears['125SX'] = new Array("2011","2010","2009","2008","2007","2006","2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['125EXC'] = new Array("2001","2000","1999","1998");
	   allyears['144SX'] = new Array("2008","2007");
	   allyears['150SX'] = new Array("2011","2010","2009");
	   allyears['200SX'] = new Array("2004","2003");
	   allyears['200XC'] = new Array("2010","2009","2008","2007","2006");
	   allyears['200XCW'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['200EXC'] = new Array("2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['200MXC'] = new Array("2003","2002","2001","2000","1999","1998");
	   allyears['250SX'] = new Array("2011","2010","2009","2008","2007","2006","2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['250SXF'] = new Array("2011","2010","2009","2008","2007","2006","2005");
	   allyears['250XC'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['250XCF'] = new Array("2010","2009","2008","2007");
	   allyears['250XCW'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['250XCFW'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['250EXC'] = new Array("2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['250EXCR'] = new Array("2005","2004","2003","2002");
	   allyears['250MXC'] = new Array("2001","2000","1999","1998");
	   allyears['300XC'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['300XCW'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['300EXC'] = new Array("2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['300MXC'] = new Array("2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['350SXF'] = new Array("2011");
	   allyears['380SX'] = new Array("2002","2001","2000","1999","1998");
	   allyears['380EXC'] = new Array("2002","2001","2000","1999","1998");
	   allyears['380MXC'] = new Array("2001","2000","1999","1998");
	   allyears['400SX'] = new Array("2002","2001","2000","1999","1998");
	   allyears['400XCW'] = new Array("2010","2009","2007");
	   allyears['400EXC'] = new Array("2006","2005","2004","2003","2002","2001","2000");
	   allyears['400MXC'] = new Array("2002","2001");
	   allyears['450SX'] = new Array("2006","2005","2004","2003");
	   allyears['450SXATV'] = new Array("2009");
	   allyears['450SXF'] = new Array("2011","2010","2009","2008","2007");
	   allyears['450XC'] = new Array("2007","2006","2004");
	   allyears['450XCATV'] = new Array("2009","2008");
	   allyears['450XCF'] = new Array("2010","2009","2008");
	   allyears['450XCW'] = new Array("2011","2010","2009","2007");
	   allyears['450EXC'] = new Array("2011","2010","2009","2007","2006","2005","2004","2003");
	   allyears['450MXC'] = new Array("2005","2004","2003");
	   allyears['450EXCR'] = new Array("2008");
	   allyears['450XCRW'] = new Array("2008");
	   allyears['505XCF'] = new Array("2010","2009","2008");
	   allyears['505SXATV'] = new Array("2009");
	   allyears['505SXF'] = new Array("2010","2009","2008","2007");
	   allyears['520SX'] = new Array("2002","2001","2000");
	   allyears['520EXC'] = new Array("2002","2001","2000");
	   allyears['520MXC'] = new Array("2002","2001");
	   allyears['525SX'] = new Array("2006","2005","2004","2003");
	   allyears['525XC'] = new Array("2007","2006");
	   allyears['525XCATV'] = new Array("2009","2008");
	   allyears['525XCW'] = new Array("2007");
	   allyears['525EXC'] = new Array("2007","2006","2005","2004","2003");
	   allyears['525MXC'] = new Array("2005","2004","2003");
	   allyears['530XCW'] = new Array("2011","2010","2009");
	   allyears['530EXC'] = new Array("2011","2010","2009");
	   allyears['530EXCR'] = new Array("2008");
	   allyears['530XCRW'] = new Array("2008");
	   allyears['540SX'] = new Array("2006","2005","2004","2003","2002","2001");
	   allyears['625SMC'] = new Array("2006","2005","2004");
	   allyears['625SXC'] = new Array("2004","2003");
	   allyears['640DUKEII'] = new Array("2002","2001","2000");
	   allyears['640LC4SUPERMOTO'] = new Array("2002","2001","2000");
	   allyears['640LC4'] = new Array("2002","2001","2000","1999");
	   allyears['640ADVENTURE'] = new Array("2007","2006","2005","2003","2002","2001","2000","1999");
	   allyears['690SUPERMOTO'] = new Array("2010","2009","2008","2007");
	   allyears['690SUPERMOTOR'] = new Array("2010","2009","2008");
	   allyears['690SMC'] = new Array("2010","2009","2008");
	   allyears['690ENDURO'] = new Array("2010","2009","2008");
	   allyears['690DUKE'] = new Array("2010","2009","2008");
	   allyears['950SUPERMOTO'] = new Array("2007","2006","2005");
	   allyears['950SUPERMOTOR'] = new Array("2007");
	   allyears['950SUPERENDUROR'] = new Array("2007","2006");
	   allyears['950ADVENTURE'] = new Array("2006","2005","2004","2003");
	   allyears['950ADVENTURES'] = new Array("2006","2005","2004","2003");
	   allyears['990SMT'] = new Array("2010");
	   allyears['990SMR'] = new Array("2010");
	   allyears['990SUPERMOTO'] = new Array("2010","2009","2008");
	   allyears['990ADVENTURE'] = new Array("2010","2009","2008","2007");
	   allyears['990ADVENTURES'] = new Array("2010","2009","2008","2007");
	   allyears['990SUPERDUKE'] = new Array("2008","2007","2006","2005");
	   allyears['990SUPERDUKER'] = new Array("2008");
	   allyears['1190RC8'] = new Array("2010","2009");
	
  //var generalCC = cc;
  
  //var ItemArray = allccs[cc];
  
 var myEleSize;
 var x ;
 allinfo = cc.split(',');
//   Empty the second drop down box of any choices
  for (var q=document.getElementById('breadnavb').options.length;q>=0;q--) document.getElementById('breadnavb').options[q]=null;
  
//   ADD Default Choice - in case there are no values
  myEleSize = document.createElement("option") ;
  myEleSize.setAttribute('value', ["0"]);
  var txt = document.createTextNode("[Select Your KTM "+allinfo[0]+" "+allinfo[1]+" Year]");
  myEleSize.appendChild(txt)

  document.getElementById('breadnavb').appendChild(myEleSize)
//   Now loop through the array of individual items
  // Any containing the same child id are added to
  // the second dropdown box
  for ( x = 0; x < allyears[allinfo[0]+allinfo[1].split(' ').join('')].length ; x++) {
	  
	  if(allinfo[0] > 540){
fitment = 'StreetBikes-all';
}
if(allinfo[0] >= 125 && allinfo[0] <= 540){
fitment = 'bigbikes-all';
}
if(allinfo[0] < 125){
fitment  = '50/65/85-all';
}
if(allinfo[1].match("ATV") == 'ATV'){
fitment  = 'atv-all';
}

if(fitter.match("all") == 'all'){
category  = 'Please-Choose';
}

 
	//  alert (allccs[cc][1]);
      myEleSize = document.createElement("option") ;
      
	  
     myEleSize.setAttribute('value', ["ktm-parts-search.php?ktm-motorcycle-parts="+category+"&year="+allyears[allinfo[0]+allinfo[1].split(' ').join('')][x]+"&ktm-model="+allinfo[1].split(' ').join('-').toLowerCase()+"-"+allinfo[0]+"&fitment="+fitment]);
      
    var txt = document.createTextNode(allyears[allinfo[0]+allinfo[1].split(' ').join('')][x]);
     myEleSize.appendChild(txt)
  
    document.getElementById('breadnavb').appendChild(myEleSize);
  }
  }
  
  
  
  function newyearfill (cc,category,fitter) {
		var allyears = new Array();
	  allyears['50SX'] = new Array("2011","2010","2009","2008","2007","2006","2005","2004","2003");
	   allyears['50SXJUNIOR'] = new Array("2010","2009","2008","2007","2006","2005","2004","2003","2001","2000");
	   allyears['50SXMINI'] = new Array("2011","2010","2009","2008");
	   allyears['50MINIADVENTURE'] = new Array("2007","2006","2005","2004","2003");
	   allyears['50SENIORADVENTURE'] = new Array("2007","2006","2005","2004","2003");
	   allyears['50JUNIORADVENTURE'] = new Array("2003","2001");
	   allyears['65SX'] = new Array("2011","2010","2009","2008","2007","2006","2005","2004","2003","2002","2001");
	   allyears['65XC'] = new Array("2010","2009","2008");
	   allyears['85SX'] = new Array("2011","2009","2008","2007","2006","2005","2004","2003");
	   allyears['85XC'] = new Array("2009","2008");
	   allyears['105SX'] = new Array("2011","2009","2008","2007","2006","2004");
	   allyears['105XC'] = new Array("2009","2008");
	   allyears['125SX'] = new Array("2011","2010","2009","2008","2007","2006","2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['125EXC'] = new Array("2001","2000","1999","1998");
	   allyears['144SX'] = new Array("2008","2007");
	   allyears['150SX'] = new Array("2011","2010","2009");
	   allyears['200SX'] = new Array("2004","2003");
	   allyears['200XC'] = new Array("2010","2009","2008","2007","2006");
	   allyears['200XCW'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['200EXC'] = new Array("2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['200MXC'] = new Array("2003","2002","2001","2000","1999","1998");
	   allyears['250SX'] = new Array("2011","2010","2009","2008","2007","2006","2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['250SXF'] = new Array("2011","2010","2009","2008","2007","2006","2005");
	   allyears['250XC'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['250XCF'] = new Array("2010","2009","2008","2007");
	   allyears['250XCW'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['250XCFW'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['250EXC'] = new Array("2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['250EXCR'] = new Array("2005","2004","2003","2002");
	   allyears['250MXC'] = new Array("2001","2000","1999","1998");
	   allyears['300XC'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['300XCW'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['300EXC'] = new Array("2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['300MXC'] = new Array("2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['350SXF'] = new Array("2011");
	   allyears['380SX'] = new Array("2002","2001","2000","1999","1998");
	   allyears['380EXC'] = new Array("2002","2001","2000","1999","1998");
	   allyears['380MXC'] = new Array("2001","2000","1999","1998");
	   allyears['400SX'] = new Array("2002","2001","2000","1999","1998");
	   allyears['400XCW'] = new Array("2010","2009","2007");
	   allyears['400EXC'] = new Array("2006","2005","2004","2003","2002","2001","2000");
	   allyears['400MXC'] = new Array("2002","2001");
	   allyears['450SX'] = new Array("2006","2005","2004","2003");
	   allyears['450SXATV'] = new Array("2009");
	   allyears['450SXF'] = new Array("2011","2010","2009","2008","2007");
	   allyears['450XC'] = new Array("2007","2006","2004");
	   allyears['450XCATV'] = new Array("2009","2008");
	   allyears['450XCF'] = new Array("2010","2009","2008");
	   allyears['450XCW'] = new Array("2011","2010","2009","2007");
	   allyears['450EXC'] = new Array("2011","2010","2009","2007","2006","2005","2004","2003");
	   allyears['450MXC'] = new Array("2005","2004","2003");
	   allyears['450EXCR'] = new Array("2008");
	   allyears['450XCRW'] = new Array("2008");
	   allyears['505XCF'] = new Array("2010","2009","2008");
	   allyears['505SXATV'] = new Array("2009");
	   allyears['505SXF'] = new Array("2010","2009","2008","2007");
	   allyears['520SX'] = new Array("2002","2001","2000");
	   allyears['520EXC'] = new Array("2002","2001","2000");
	   allyears['520MXC'] = new Array("2002","2001");
	   allyears['525SX'] = new Array("2006","2005","2004","2003");
	   allyears['525XC'] = new Array("2007","2006");
	   allyears['525XCATV'] = new Array("2009","2008");
	   allyears['525XCW'] = new Array("2007");
	   allyears['525EXC'] = new Array("2007","2006","2005","2004","2003");
	   allyears['525MXC'] = new Array("2005","2004","2003");
	   allyears['530XCW'] = new Array("2011","2010","2009");
	   allyears['530EXC'] = new Array("2011","2010","2009");
	   allyears['530EXCR'] = new Array("2008");
	   allyears['530XCRW'] = new Array("2008");
	   allyears['540SX'] = new Array("2006","2005","2004","2003","2002","2001");
	   allyears['625SMC'] = new Array("2006","2005","2004");
	   allyears['625SXC'] = new Array("2004","2003");
	   allyears['640DUKEII'] = new Array("2002","2001","2000");
	   allyears['640LC4SUPERMOTO'] = new Array("2002","2001","2000");
	   allyears['640LC4'] = new Array("2002","2001","2000","1999");
	   allyears['640ADVENTURE'] = new Array("2007","2006","2005","2003","2002","2001","2000","1999");
	   allyears['690SUPERMOTO'] = new Array("2010","2009","2008","2007");
	   allyears['690SUPERMOTOR'] = new Array("2010","2009","2008");
	   allyears['690SMC'] = new Array("2010","2009","2008");
	   allyears['690ENDURO'] = new Array("2010","2009","2008");
	   allyears['690DUKE'] = new Array("2010","2009","2008");
	   allyears['950SUPERMOTO'] = new Array("2007","2006","2005");
	   allyears['950SUPERMOTOR'] = new Array("2007");
	   allyears['950SUPERENDUROR'] = new Array("2007","2006");
	   allyears['950ADVENTURE'] = new Array("2006","2005","2004","2003");
	   allyears['950ADVENTURES'] = new Array("2006","2005","2004","2003");
	   allyears['990SMT'] = new Array("2010");
	   allyears['990SMR'] = new Array("2010");
	   allyears['990SUPERMOTO'] = new Array("2010","2009","2008");
	   allyears['990ADVENTURE'] = new Array("2010","2009","2008","2007");
	   allyears['990ADVENTURES'] = new Array("2010","2009","2008","2007");
	   allyears['990SUPERDUKE'] = new Array("2008","2007","2006","2005");
	   allyears['990SUPERDUKER'] = new Array("2008");
	   allyears['1190RC8'] = new Array("2010","2009");
	
  //var generalCC = cc;
  
  //var ItemArray = allccs[cc];
  
 var myEleSize;
 var x ;
 allinfo = cc.split(',');
//   Empty the second drop down box of any choices
  for (var q=document.getElementById('breadnavb').options.length;q>=0;q--) document.getElementById('breadnavb').options[q]=null;
  
//   ADD Default Choice - in case there are no values
  myEleSize = document.createElement("option") ;
  myEleSize.setAttribute('value', ["0"]);
  var txt = document.createTextNode("[Select Your KTM "+allinfo[0]+" "+allinfo[1]+" Year]");
  myEleSize.appendChild(txt)

  document.getElementById('breadnavb').appendChild(myEleSize)
//   Now loop through the array of individual items
  // Any containing the same child id are added to
  // the second dropdown box
  for ( x = 0; x < allyears[allinfo[0]+allinfo[1].split(' ').join('')].length ; x++) {
	  
	  if(allinfo[0] > 540){
fitment = 'StreetBikes-all';
}
if(allinfo[0] >= 125 && allinfo[0] <= 540){
fitment = 'bigbikes-all';
}
if(allinfo[0] < 125){
fitment  = '50/65/85-all';
}
if(allinfo[1].match("ATV") == 'ATV'){
fitment  = 'atv-all';
}

 
	//  alert (allccs[cc][1]);
      myEleSize = document.createElement("option") ;
      
	  
     myEleSize.setAttribute('value', ["ktm-parts-search.php?ktm-motorcycle-parts=Please-Choose&year="+allyears[allinfo[0]+allinfo[1].split(' ').join('')][x]+"&ktm-model="+allinfo[1].split(' ').join('-').toLowerCase()+"-"+allinfo[0]+"&fitment="+fitment]);
      
    var txt = document.createTextNode(allyears[allinfo[0]+allinfo[1].split(' ').join('')][x]);
     myEleSize.appendChild(txt)
  
    document.getElementById('breadnavb').appendChild(myEleSize);
  }
  }

function homeyearfill (cc,category,fitter) {
		var allyears = new Array();
	   allyears['50SX'] = new Array("2011","2010","2009","2008","2007","2006","2005","2004","2003");
	   allyears['50SXJUNIOR'] = new Array("2010","2009","2008","2007","2006","2005","2004","2003","2001","2000");
	   allyears['50SXMINI'] = new Array("2011","2010","2009","2008");
	   allyears['50MINIADVENTURE'] = new Array("2007","2006","2005","2004","2003");
	   allyears['50SENIORADVENTURE'] = new Array("2007","2006","2005","2004","2003");
	   allyears['50JUNIORADVENTURE'] = new Array("2003","2001");
	   allyears['65SX'] = new Array("2011","2010","2009","2008","2007","2006","2005","2004","2003","2002","2001");
	   allyears['65XC'] = new Array("2010","2009","2008");
	   allyears['85SX'] = new Array("2011","2009","2008","2007","2006","2005","2004","2003");
	   allyears['85XC'] = new Array("2009","2008");
	   allyears['105SX'] = new Array("2011","2009","2008","2007","2006","2004");
	   allyears['105XC'] = new Array("2009","2008");
	   allyears['125SX'] = new Array("2011","2010","2009","2008","2007","2006","2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['125EXC'] = new Array("2001","2000","1999","1998");
	   allyears['144SX'] = new Array("2008","2007");
	   allyears['150SX'] = new Array("2011","2010","2009");
	   allyears['200SX'] = new Array("2004","2003");
	   allyears['200XC'] = new Array("2010","2009","2008","2007","2006");
	   allyears['200XCW'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['200EXC'] = new Array("2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['200MXC'] = new Array("2003","2002","2001","2000","1999","1998");
	   allyears['250SX'] = new Array("2011","2010","2009","2008","2007","2006","2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['250SXF'] = new Array("2011","2010","2009","2008","2007","2006","2005");
	   allyears['250XC'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['250XCF'] = new Array("2010","2009","2008","2007");
	   allyears['250XCW'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['250XCFW'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['250EXC'] = new Array("2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['250EXCR'] = new Array("2005","2004","2003","2002");
	   allyears['250MXC'] = new Array("2001","2000","1999","1998");
	   allyears['300XC'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['300XCW'] = new Array("2011","2010","2009","2008","2007","2006");
	   allyears['300EXC'] = new Array("2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['300MXC'] = new Array("2005","2004","2003","2002","2001","2000","1999","1998");
	   allyears['350SXF'] = new Array("2011");
	   allyears['380SX'] = new Array("2002","2001","2000","1999","1998");
	   allyears['380EXC'] = new Array("2002","2001","2000","1999","1998");
	   allyears['380MXC'] = new Array("2001","2000","1999","1998");
	   allyears['400SX'] = new Array("2002","2001","2000","1999","1998");
	   allyears['400XCW'] = new Array("2010","2009","2007");
	   allyears['400EXC'] = new Array("2006","2005","2004","2003","2002","2001","2000");
	   allyears['400MXC'] = new Array("2002","2001");
	   allyears['450SX'] = new Array("2006","2005","2004","2003");
	   allyears['450SXATV'] = new Array("2009");
	   allyears['450SXF'] = new Array("2011","2010","2009","2008","2007");
	   allyears['450XC'] = new Array("2007","2006","2004");
	   allyears['450XCATV'] = new Array("2009","2008");
	   allyears['450XCF'] = new Array("2010","2009","2008");
	   allyears['450XCW'] = new Array("2011","2010","2009","2007");
	   allyears['450EXC'] = new Array("2011","2010","2009","2007","2006","2005","2004","2003");
	   allyears['450MXC'] = new Array("2005","2004","2003");
	   allyears['450EXCR'] = new Array("2008");
	   allyears['450XCRW'] = new Array("2008");
	   allyears['505XCF'] = new Array("2010","2009","2008");
	   allyears['505SXATV'] = new Array("2009");
	   allyears['505SXF'] = new Array("2010","2009","2008","2007");
	   allyears['520SX'] = new Array("2002","2001","2000");
	   allyears['520EXC'] = new Array("2002","2001","2000");
	   allyears['520MXC'] = new Array("2002","2001");
	   allyears['525SX'] = new Array("2006","2005","2004","2003");
	   allyears['525XC'] = new Array("2007","2006");
	   allyears['525XCATV'] = new Array("2009","2008");
	   allyears['525XCW'] = new Array("2007");
	   allyears['525EXC'] = new Array("2007","2006","2005","2004","2003");
	   allyears['525MXC'] = new Array("2005","2004","2003");
	   allyears['530XCW'] = new Array("2011","2010","2009");
	   allyears['530EXC'] = new Array("2011","2010","2009");
	   allyears['530EXCR'] = new Array("2008");
	   allyears['530XCRW'] = new Array("2008");
	   allyears['540SX'] = new Array("2006","2005","2004","2003","2002","2001");
	   allyears['625SMC'] = new Array("2006","2005","2004");
	   allyears['625SXC'] = new Array("2004","2003");
	   allyears['640DUKEII'] = new Array("2002","2001","2000");
	   allyears['640LC4SUPERMOTO'] = new Array("2002","2001","2000");
	   allyears['640LC4'] = new Array("2002","2001","2000","1999");
	   allyears['640ADVENTURE'] = new Array("2007","2006","2005","2003","2002","2001","2000","1999");
	   allyears['690SUPERMOTO'] = new Array("2010","2009","2008","2007");
	   allyears['690SUPERMOTOR'] = new Array("2010","2009","2008");
	   allyears['690SMC'] = new Array("2010","2009","2008");
	   allyears['690ENDURO'] = new Array("2010","2009","2008");
	   allyears['690DUKE'] = new Array("2010","2009","2008");
	   allyears['950SUPERMOTO'] = new Array("2007","2006","2005");
	   allyears['950SUPERMOTOR'] = new Array("2007");
	   allyears['950SUPERENDUROR'] = new Array("2007","2006");
	   allyears['950ADVENTURE'] = new Array("2006","2005","2004","2003");
	   allyears['950ADVENTURES'] = new Array("2006","2005","2004","2003");
	   allyears['990SMT'] = new Array("2010");
	   allyears['990SMR'] = new Array("2010");
	   allyears['990SUPERMOTO'] = new Array("2010","2009","2008");
	   allyears['990ADVENTURE'] = new Array("2010","2009","2008","2007");
	   allyears['990ADVENTURES'] = new Array("2010","2009","2008","2007");
	   allyears['990SUPERDUKE'] = new Array("2008","2007","2006","2005");
	   allyears['990SUPERDUKER'] = new Array("2008");
	   allyears['1190RC8'] = new Array("2010","2009");
	
  //var generalCC = cc;
  
  //var ItemArray = allccs[cc];
  
 var myEleSize;
 var x ;
 allinfo = cc.split(',');
//   Empty the second drop down box of any choices
  for (var q=document.getElementById('breadnavb').options.length;q>=0;q--) document.getElementById('breadnavb').options[q]=null;
  
//   ADD Default Choice - in case there are no values
  myEleSize = document.createElement("option") ;
  myEleSize.setAttribute('value', ["0"]);
  var txt = document.createTextNode("[Select Year]");
  myEleSize.appendChild(txt)

  document.getElementById('breadnavb').appendChild(myEleSize)
//   Now loop through the array of individual items
  // Any containing the same child id are added to
  // the second dropdown box
  for ( x = 0; x < allyears[allinfo[0]+allinfo[1].split(' ').join('')].length ; x++) {
	  
	  if(allinfo[0] > 540){
fitment = 'StreetBikes-all';
}
if(allinfo[0] >= 125 && allinfo[0] <= 540){
fitment = 'bigbikes-all';
}
if(allinfo[0] < 125){
fitment  = '50/65/85-all';
}
if(allinfo[1].match("ATV") == 'ATV'){
fitment  = 'atv-all';
}

 
	//  alert (allccs[cc][1]);
      myEleSize = document.createElement("option") ;
      
	  
     myEleSize.setAttribute('value', ["ktm-parts/ktm-parts-search.php?ktm-motorcycle-parts=Please-Choose&year="+allyears[allinfo[0]+allinfo[1].split(' ').join('')][x]+"&ktm-model="+allinfo[1].split(' ').join('-').toLowerCase()+"-"+allinfo[0]+"&fitment="+fitment]);
      
    var txt = document.createTextNode(allyears[allinfo[0]+allinfo[1].split(' ').join('')][x]);
     myEleSize.appendChild(txt)
  
    document.getElementById('breadnavb').appendChild(myEleSize);
  }
  }
