// ==============================
// Product Selector
// ==============================
var catImagePaths;
var catNames;
var catLinks;
var catWebTrendsIdsForImage;
var catWebTrendsIdsForName;
var imageObjects = new Array();
var imageIndex = new Array();
var VXWEBS_pageCode = null;

if (typeof prodSelectorInit != 'undefined') {
	// Set initial values in catImagePaths, catNames, catLinks,
	// catWebTrendsIdsForImage and catWebTrendsIdsForName
	prodSelectorInit();
}

// Called in BODY section in HTML
function preloadproductImages() {
	var previousCatName = null;

	for (var id=0; id < catImagePaths.length; id++) {
		imageObjects[id] = new Array();
		for (var i=0; i < catImagePaths[id].length; i++) {
			imageObjects[id][i] = new Image();
			if (catImagePaths[id][i] != null && catImagePaths[id][i] != "") {
				imageObjects[id][i].src = catImagePaths[id][i];
			} else {
				imageObjects[id][i].src = "/images/spacer.gif";
			}
		}

		// Set initial image
		var index = 0;

		if (catLinks[id].length > 0 &&
		    (catLinks[id][0] == null ||
		     catLinks[id][0].indexOf("") == -1)) {
			// Consumer always shows the first product (index=0)
			// Other divisions set initial index using random value
			index = Math.floor(Math.random()*(catImagePaths[id].length));
			if (id > 0 && previousCatName != null &&
			    previousCatName == catNames[id][index]) {
				// Regenerate index to avoid same product
				index = Math.floor(Math.random()*(catImagePaths[id].length));
			}
		}

		imageIndex[id] = index;
		previousCatName = catNames[id][index];
		_changeproductInfo(id);
	}
}

function changeproductImage(id, n) {
	imageIndex[id] += n;
	_changeproductInfo(id);
}

function _changeproductInfo(id) {
	var index = imageIndex[id];

	if (index >= catImagePaths[id].length) {
		index = 0;
		imageIndex[id] = 0;
	} else if (index < 0) {
		index = catImagePaths[id].length - 1;
		imageIndex[id] = catImagePaths[id].length - 1;
	}

	var catImage = document.getElementById("productImage_" + id);
	if (catImage != null) {
		// Set onabort and onerror in the image to retry loading
		// This retry is required for IE, because IE often aborts loading image.
		var retryFunc = new Function("_retryLoadingImage('productImage_"+id+"','"+catImagePaths[id][index]+"')");
		catImage.onabort = retryFunc;
		catImage.onerror = retryFunc;

		catImage.alt = catNames[id][index];

		//if (document.all) { // doesn't work with Opera
		//	catImage.style.filter="blendTrans()";
		//	catImage.filters.blendTrans.Apply();
		//}
		catImage.src = catImagePaths[id][index];
		//if (document.all) {
		//	catImage.filters.blendTrans.Play();
		//}
	}

	var catName = document.getElementById("productName_" + id);
	if (catName != null) catName.innerHTML = catNames[id][index];

	var catMainLink = document.getElementById("productMainLink_" + id);
	var catNameLink = document.getElementById("productNameLink_" + id);

	if (catMainLink != null && catNameLink != null) {
		catMainLink.href = catLinks[id][index];
		catNameLink.href = catLinks[id][index];
		catMainLink.title = catNames[id][index];

		var imageLinkWTID = catWebTrendsIdsForImage[id][index];
		if (imageLinkWTID == null || imageLinkWTID == "") {
			imageLinkWTID = catWebTrendsIdsForName[id][index] + "_pic";
		}
		// NOTE: Create Function object, because func with params cannot be directly set in onclick
		catMainLink.onclick = new Function("return VXWEBSWebLog('"+imageLinkWTID+"')");
		catNameLink.onclick = new Function("return VXWEBSWebLog('"+catWebTrendsIdsForName[id][index]+"')");

		if (_isExternalURL(catLinks[id][index])) {
			catMainLink.target = "_blank";
			catNameLink.target = "_blank";
		} else {
			catMainLink.target = "";
			catNameLink.target = "";
		}
	}
}

function _retryLoadingImage(elementId, path) {
	var catImage = document.getElementById(elementId);
	if (catImage != null) {
		catImage.onabort = null; // no more retry
		catImage.onerror = null;
		catImage.src = path;
	}
}

function _isExternalURL(input) {
	if (input == null) return false;
	input = input.toLowerCase();
	return (input.indexOf("http://") == 0 || input.indexOf("https://") == 0);
}




function VXWEBS_setPageCode(pageCode) {
	VXWEBS_pageCode = pageCode;
}

if (typeof VXWEBS_init != 'undefined') {
	VXWEBS_init();
}

function VXWEBS(id) {
	if (VXWEBS_pageCode != null && VXWEBS_pageCode != "" &&
	    id != null && id != "") {
		id = VXWEBS_pageCode + id;

	}
	return true;
}
function prodSelectorInit() {

			
			catImagePaths = [[
			
					"/images/ProductSelector/led_S1100.jpg"
					,"/images/ProductSelector/led_S6100.jpg"
					,"/images/ProductSelector/led_s4100.jpg"
					,"/images/ProductSelector/led_xmitter.jpg"
					,"/images/ProductSelector/led_xmitterdbl.jpg"
					,"/images/ProductSelector/led_patriot.jpg"
					,"/images/ProductSelector/led_xilworklight.jpg"
					,"/images/ProductSelector/led_clix.jpg"
					,"/images/ProductSelector/led_hilworklight.jpg"
					,"/images/ProductSelector/led_tantrum.jpg"
					,"/images/ProductSelector/led_360bulbs.jpg"
					,"/images/ProductSelector/led_rivets.jpg"
					,"/images/ProductSelector/led_pods.jpg"
					,"/images/ProductSelector/led_billetpods.jpg"
					,"/images/ProductSelector/led_minimotion.jpg"
					,"/images/ProductSelector/led_flexmotionundercar.jpg"
					,"/images/ProductSelector/led_flexmotionmini.jpg"
					,"/images/ProductSelector/led_flashlight.jpg"
				
			
				],[
				
					"/images/ProductSelector/hid_atv-utv.jpg"
					,"/images/ProductSelector/hid_8550.jpg"
					,"/images/ProductSelector/hid_8500.jpg"
					,"/images/ProductSelector/hid_6550.jpg"
					,"/images/ProductSelector/hid_6500.jpg"
					,"/images/ProductSelector/hid_6550CR.jpg"
					,"/images/ProductSelector/hid_5750.jpg"
					,"/images/ProductSelector/hid_5700.jpg"
					,"/images/ProductSelector/hid_4500.jpg"
					,"/images/ProductSelector/hid_4400.jpg"
					,"/images/ProductSelector/hid_4600.jpg"
					,"/images/ProductSelector/hid_5500.jpg"
					,"/images/ProductSelector/hid_6600.jpg"
				
			
				],[
									
					"/images/ProductSelector/halogen_bulbs.jpg"
					,"/images/ProductSelector/halogen_8510.jpg"
					,"/images/ProductSelector/halogen_6510.jpg"
					,"/images/ProductSelector/halogen_6010.jpg"
					,"/images/ProductSelector/halogen_5710.jpg"
					,"/images/ProductSelector/halogen_5710NH.jpg"
					,"/images/ProductSelector/halogen_5510.jpg"
					,"/images/ProductSelector/halogen_4610.jpg"
					,"/images/ProductSelector/halogen_4510.jpg"
					,"/images/ProductSelector/halogen_sealedbeam.jpg"
					,"/images/ProductSelector/halogen_snowbulbs.jpg"
					,"/images/ProductSelector/HALOGEN_6504.jpg"
					,"/images/ProductSelector/halogen_fog-driving.jpg"
					,"/images/ProductSelector/halogen_vxtoffroad.jpg"
					,"/images/ProductSelector/halogen_4410.jpg"
				
			]];

			
			catNames = [[
			
				"Solstice Solo S1100<br>2'' Inter-Locking LED Light"
					,"S6100<br>6'' Round LED Light"
					,"S4100<br>4'' Square LED Light"
					
					,"Single Stack Xmitter<br>LED Light Bars 4'' - 52''"

					,"Double Stack Xmitter <br>LED Light Bars 8'' - 22''"
					
					,"Made in USA Patriot<br>LED Off Road Light Bar"

					,"High Intensity<br>Rugged LED Work Light"

					,"Clix Battery Powered<br>Multipurpose Pods"

					,"LED Work Light<br>Durable & Rechargeable"	
								
					,"Tantrum LED Strobe,<br>Dome, and Rock Kits"

					,"360 <br>Replacement Bulbs"

					,"Rivet <br>4 LED Packs"

					,"LED Dome<br>& Rock Light Pods"
					
					,"Billet LED Dome<br>& Rock Light Pods"

					,"Mini Motion <br>6'' or 12'' LED Bars"

					,"Flex Motion <br>LED Undercar Kits"

					,"Flex Motion <br>6'' or 12'' Miniatures"

					,"Aluminum LED<br>Flash Light Twin Packs"

				],[
				
					"ATV & UTV HID<br>Headlight Upgrade Kits"
					,"8550<br>8.7'' 50 Watt HID"
					
					,"8500<br>8.7'' 35 Watt HID"
				
					,"6550<br>6.7'' 50 Watt HID"
					
					,"6500<br>6.7'' 35 Watt HID"

					,"6550CR<br>6.7'' 50 Watt HID"

										,"5750<br>5'' x 7'' 50 Watt HID"
					
					,"5700<br>5'' x 7'' 35 Watt HID"
					,"4500<br>5'' 35 Watt HID"

					,"4400<br>4'' x 4'' 35 Watt HID"

					,"4600<br>4.6'' Oval 35 Watt HID"

					,"5500<br>5.5'' 35 Watt HID"

					,"6600<br>6.2'' x 5.9'' 50 Watt HID"

					,"OEM <br>Replacement HID"

					,"Multipurpose<br>HID Fog Lights"
				
			
				],[
				
					
					"Superwhite<br>Halogen Insert Bulbs"
					,"Tungsten 100 Watt<br>Halogen-Hybrid 8510"
					,"Tungsten 100 Watt<br>Halogen-Hybrid 6510"
					,"6010 <br>6'' 100 Watt Light"
					,"Tungsten 100 Watt<br>Halogen-Hybrid 5710"
					,"Tungsten 100 Watt<br>Halogen-Hybrid 5710NH"
					,"Tungsten 100 Watt<br>Halogen-Hybrid 5510"
					,"Tungsten 100 Watt<br>Halogen-Hybrid 4610"
					,"Tungsten 100 Watt<br>Halogen-Hybrid 4510"
					,"Sealed Beam<br>Replacement Housings"

					,"Snow Machine<br>Halogen Upgrade Bulbs"

					,"6504<br>6.7'' Hi \ Lo Beam"

					,"Fog &<br>Driving Lights"

					,"VX-T Series<br>Off Road Lights"					
					
					

					,"4410 <br>4'' Square 100 Watt Light"


				
			]];

			
			catLinks = [[
			
"/led/S1100"				
,"/led/S6100"
,"/led/S4100"
,"/led/xmitter"
,"/led/xmitterdbl"
,"/led/patriot"
,"/led/xilworklight"
,"/led/clix"
,"/led/hilworklight"
,"/led/tantrum"
,"/led/360bulbs"
,"/led/rivets"
,"/led/pods"
,"/led/billetpods"
,"/led/minimotion"
,"/led/flexmotionundercar"
,"/led/flexmotionmini"
,"/led/flashlight"
				
			
				],[
"/hid/atv-utv"		
,"/hid/8550"
,"/hid/8500"
,"/hid/6550"
,"/hid/6500"
,"/hid/6550CR"
,"/hid/5750"
,"/hid/5700"
,"/hid/4500"
,"/hid/4400"
,"/hid/4600"
,"/hid/5500"
,"/hid/6600"
				
			
				],[
"/halogen/bulbs"
,"/halogen/8510"
,"/halogen/6510"
,"/halogen/6010"
,"/halogen/5710"
,"/halogen/5710NH"
,"/halogen/5510"
,"/halogen/4610"
,"/halogen/4510"
,"/halogen/sealedbeam"
,"/halogen/snowbulbs"
,"/HALOGEN/6504"
,"/halogen/fog-driving"
,"/halogen/vxtoffroad"
,"/halogen/4410"	
			
			]];
			
			catWeighting = [[
			
					"0"
					
					,"0"
					,"0"
				
					,"100"
				
					,"0"
				
					,"0"
					
					,"0"
				
					,"0"
				
					,"0"
				
					,"0"
				
					,"0"
				
					,"0"
					
					,"0"
				
					,"0"
				
					,"0"
				
					,"0"
				
					,"0"
				
					,"0"
				
			
				],[
				
					"9"
				
				
					,"9"
					
					,"9"
					
					,"9"
				
					,"9"
				
					,"9"
				
					,"9"
				
					,"9"
				
					,"9"
				
					,"9"
				
					,"9"
				
					,"9"
				
					,"9"
				
			
				],[
				
					"10"
				,"10"
					,"10"
				,"10"
				,"10"
				,"10"
				,"10"
				,"10"
				,"10"
					,"10"
				
					,"10"
				
					,"10"
				
					,"10"
				
					,"10"
				
					,"10"
				
					,"10"
					
				
			]];


			
			catWebTrendsIdsForName = [[
			
"led_s1100"				
,"led_S6100"
,"led_s4100"
,"led_xmitter"
,"led_xmitterdbl"
,"led_patriot"
,"led_xilworklight"
,"led_clix"
,"led_hilworklight"
,"led_tantrum"
,"led_360bulbs"
,"led_rivets"
,"led_pods"
,"led_billetpods"
,"led_minimotion"
,"led_flexmotionundercar"
,"led_flexmotionmini"
,"led_flashlight"
				
			
				],[
"hid_atv-utv"	
,"hid_8550"
,"hid_8500"
,"hid_6550"
,"hid_6500"
,"hid_6550CR"
,"hid_5750"
,"hid_5700"
,"hid_4500"
,"hid_4400"
,"hid_4600"
,"hid_5500"
,"hid_6600"
				
			
				],[
				
"halogen_bulbs"
,"halogen_8510"
,"halogen_6510"
,"halogen_6010"
,"halogen_5710"
,"halogen_5710nh"
,"halogen_5510"
,"halogen_4610"
,"halogen_4510"
,"halogen_sealedbeam"
,"halogen_snowbulbs"
,"HALOGEN_6504"
,"halogen_fog-driving"
,"halogen_vxtoffroad"
,"halogen_4410"
				
			]];

			
			catWebTrendsIdsForImage = [[
			
				
"led_s1100v1"				
,"led_S6100v1"
,"led_s4100v1"
,"led_xmitterv1"
,"led_xmitterdblv1"
,"led_patriotv1"
,"led_xilworklightv1"
,"led_clixv1"
,"led_hilworklightv1"
,"led_tantrumv1"
,"led_360bulbsv1"
,"led_rivetsv1"
,"led_podsv1"
,"led_billetpodsv1"
,"led_minimotionv1"
,"led_flexmotionundercarv1"
,"led_flexmotionminiv1"
,"led_flashlightv1"
				
			
				],[
"hid_atv-utvv1"
,"hid_8550v1"
,"hid_8500v1"
,"hid_6550v1"
,"hid_6500v1"
,"hid_6550CRv1"
,"hid_5750v1"
,"hid_5700v1"
,"hid_4500v1"
,"hid_4400v1"
,"hid_4600v1"
,"hid_5500v1"
,"hid_6600v1"
				
			
				],[
				
"halogen_bulbsv1"
,"halogen_8510v1"
,"halogen_6510v1"
,"halogen_6010v1"
,"halogen_5710v1"
,"halogen_5710nhv1"
,"halogen_5510v1"
,"halogen_4610v1"
,"halogen_4510v1"
,"halogen_sealedbeamv1"
,"halogen_snowbulbsv1"
,"HALOGEN_6504v1"
,"halogen_fog-drivingv1"
,"halogen_vxtoffroadv1"
,"halogen_4410v1"
				
			]];
		}
if (typeof prodSelectorInit != 'undefined') {
	// Set initial values in catImagePaths, catNames, catLinks,
	// catWebTrendsIdsForImage and catWebTrendsIdsForName
	prodSelectorInit();
}

// Called in BODY section in HTML
function preloadproductImages() {
	var previousCatName = null;

	for (var id=0; id < catImagePaths.length; id++) {
		imageObjects[id] = new Array();
		for (var i=0; i < catImagePaths[id].length; i++) {
			imageObjects[id][i] = new Image();
			if (catImagePaths[id][i] != null && catImagePaths[id][i] != "") {
				imageObjects[id][i].src = catImagePaths[id][i];
			} else {
				imageObjects[id][i].src = "/images/spacer.gif";
			}
		}

		// Set initial image
		var index = 0;

		if (catLinks[id].length > 0 &&
		    (catLinks[id][0] == null ||
		     catLinks[id][0].indexOf("") == -1)) {
			// Consumer always shows the first product (index=0)
			// Other divisions set initial index using random value
			index = Math.floor(Math.random()*(catImagePaths[id].length));
			if (id > 0 && previousCatName != null &&
			    previousCatName == catNames[id][index]) {
				// Regenerate index to avoid same product
				index = Math.floor(Math.random()*(catImagePaths[id].length));
			}
		}

		imageIndex[id] = index;
		previousCatName = catNames[id][index];
		_changeproductInfo(id);
	}
}

function changeproductImage(id, n) {
	imageIndex[id] += n;
	_changeproductInfo(id);
}

function _changeproductInfo(id) {
	var index = imageIndex[id];

	if (index >= catImagePaths[id].length) {
		index = 0;
		imageIndex[id] = 0;
	} else if (index < 0) {
		index = catImagePaths[id].length - 1;
		imageIndex[id] = catImagePaths[id].length - 1;
	}

	var catImage = document.getElementById("productImage_" + id);
	if (catImage != null) {
		// Set onabort and onerror in the image to retry loading
		// This retry is required for IE, because IE often aborts loading image.
		var retryFunc = new Function("_retryLoadingImage('productImage_"+id+"','"+catImagePaths[id][index]+"')");
		catImage.onabort = retryFunc;
		catImage.onerror = retryFunc;

		catImage.alt = catNames[id][index];

		//if (document.all) { // doesn't work with Opera
		//	catImage.style.filter="blendTrans()";
		//	catImage.filters.blendTrans.Apply();
		//}
		catImage.src = catImagePaths[id][index];
		//if (document.all) {
		//	catImage.filters.blendTrans.Play();
		//}
	}

	var catName = document.getElementById("productName_" + id);
	if (catName != null) catName.innerHTML = catNames[id][index];

	var catMainLink = document.getElementById("productMainLink_" + id);
	var catNameLink = document.getElementById("productNameLink_" + id);

	if (catMainLink != null && catNameLink != null) {
		catMainLink.href = catLinks[id][index];
		catNameLink.href = catLinks[id][index];
		catMainLink.title = catNames[id][index];

		var imageLinkWTID = catWebTrendsIdsForImage[id][index];
		if (imageLinkWTID == null || imageLinkWTID == "") {
			imageLinkWTID = catWebTrendsIdsForName[id][index] + "_pic";
		}
		// NOTE: Create Function object, because func with params cannot be directly set in onclick
		catMainLink.onclick = new Function("return VXWEBS('"+imageLinkWTID+"')");
		catNameLink.onclick = new Function("return VXWEBS('"+catWebTrendsIdsForName[id][index]+"')");

		if (_isExternalURL(catLinks[id][index])) {
			catMainLink.target = "_blank";
			catNameLink.target = "_blank";
		} else {
			catMainLink.target = "";
			catNameLink.target = "";
		}
	}
}

function _retryLoadingImage(elementId, path) {
	var catImage = document.getElementById(elementId);
	if (catImage != null) {
		catImage.onabort = null; // no more retry
		catImage.onerror = null;
		catImage.src = path;
	}
}

function _isExternalURL(input) {
	if (input == null) return false;
	input = input.toLowerCase();
	return (input.indexOf("http://") == 0 || input.indexOf("https://") == 0);
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// ==============================
// End
// ==============================

//<--
function dropdown(mySel)
{
var myWin, myVal;
myVal = mySel.options[mySel.selectedIndex].value;
if(myVal)
   {
   if(mySel.form.target)myWin = parent[mySel.form.target];
   else myWin = window;
   if (! myWin) return true;
   myWin.location = myVal;
   }
return false;
}
//-->