﻿//var $j;

//try {
//   $j = jQuery.noConflict();
//}
//catch (err) {

//}

/* ColorAdapter */

function ColorAdapter(mainColorImage, mapname, colorArray) {
   this.mainColorImage = mainColorImage;
   this.mapname = mapname;
   this.colorArray = colorArray;
}

var iColorArray = new Array(18);

function InitialColorArray() {
   var bluelightImgs = new Array('lexa_bluelight', 'LEXA-red-lights');
   var bluelight = new ColorAdapter('b-r.png', 'bluelight', bluelightImgs);

   var armorxImgs = new Array('armorx-silver', 'armorx-blue', 'armorx-red', 'armorx-yellow');
   var armorx = new ColorAdapter('s-b-r-y.png', 'armorx', armorxImgs);

   var alpha = null;

   var hafImgs = new Array('HAF-CAMOUFLAGE', 'HAF-BLUE', 'HAF-GRAY', 'HAF-GREEN', 'HAF-BLACK', 'HAF-RED');
   var haf = new ColorAdapter('g-b-gy-l-b-r.png', 'haf', hafImgs);

   var guardianImgs = new Array('guardian-ruby2', 'GUARDIAN', 'Guardian-Nvidia');
   var guardian = new ColorAdapter('sidepanel.png', 'guardian', guardianImgs);

   var vantage = null;

   var tornadoImgs = new Array('tornado-blue', 'tornado-red');
   var tornado = new ColorAdapter('b-r.png', 'tornado', tornadoImgs);

   var aztecImgs = new Array('aztec-silver', 'aztec-blue', 'aztec-orange', 'aztec-yellow');
   var aztec = new ColorAdapter('s-b-o-y.png', 'aztec', aztecImgs);

   var cyclonexImgs = new Array('cyclonex-silver', 'cyclonex-black', 'cyclonex-red');
   var cyclonex = new ColorAdapter('s-b-r.png', 'cyclonex', cyclonexImgs);

   var apollo = null;
   var csx = null;

   var armorImgs = new Array('armor', 'armor+');
   var armor = new ColorAdapter('b-w.png', 'armor', armorImgs);

   var tempest = null;

   var raidmaxImgs = new Array('raidmax-yellow', 'raidmax-black', 'raidmax-red');
   var raidmax = new ColorAdapter('b-r-y.png', 'raidmax', raidmaxImgs);

   var xaser = null;

   var v9Imgs = new Array('v9-purple', 'v9-blue', 'v9-green', 'v9-orange', 'v9-pink', 'v9-red');
   var v9 = new ColorAdapter('r-pk-o-g-bl-pp.png', 'v9', v9Imgs);

   var zalman = null;

   var tuniqImgs = new Array('Tuniq3_black', 'Tuniq3_white');
   var tuniq = new ColorAdapter('b-w.png', 'tuniq', tuniqImgs);

   iColorArray[0] = bluelight;
   iColorArray[1] = armorx;
   iColorArray[2] = alpha;
   iColorArray[3] = haf;
   iColorArray[4] = guardian;

   iColorArray[5] = vantage;
   iColorArray[6] = tornado;
   iColorArray[7] = aztec;
   iColorArray[8] = cyclonex;
   iColorArray[9] = apollo;

   iColorArray[10] = csx;
   iColorArray[11] = armor;
   iColorArray[12] = tempest;
   iColorArray[13] = raidmax;
   iColorArray[14] = xaser;
   iColorArray[15] = v9;
   iColorArray[16] = zalman;
   iColorArray[17] = tuniq;
}

/* end ColorAdapter */

/* features */

function ChangeImage(url) {
   var img = GetMainImage();
   img.src = url;
   img.style.cursor = 'pointer';

   if (typeof (iColorArray) != 'undefined') {
      var co = iColorArray[colorAdaTitle];

      var chart = document.getElementById('MainColorChart');

      if (co == null && chart != null) {
         chart.style.display = 'none';
         return;
      }

      if (chart != null) {
         chart.style.display = '';
         chart.useMap = '#' + co.mapname;
         chart.src = inibp + 'images/' + co.mainColorImage;
      }
   }
}

function ColorAdOver(seq) {
   var co = iColorArray[colorAdaTitle];

   var img = GetMainImage();
   img.src = inibp + rootlocation + co.colorArray[seq] + '.jpg';
}

function ChangeSpec(id) {
   var mainSpec = document.getElementById('MainSpecWords');
   var newSpec = document.getElementById(id + '_Spec').innerHTML;

   mainSpec.innerHTML = newSpec;
}

function ChangeTitle(id) {
   var mainTitle = document.getElementById('MainSpecTitle');
   var newTitle = document.getElementById(id + '_Title').innerHTML;


   mainTitle.innerHTML = newTitle;
}

function ChangePrice(id) {
   var mainPrice = document.getElementById('MainPriceWords');
   var target = document.getElementById(id + '_Price');
   var newPrice = target.innerHTML;

   document.getElementById('Main_Link').href = target.lang;

   mainPrice.innerHTML = newPrice;
}

/* end features */


/* awards */

// -------------------------------------------------------------------
// Drop-in Slideshow Script- By Dynamic Drive, available at: http://www.dynamicdrive.com
// Last updated: March 9th, 2007
// -------------------------------------------------------------------

var _dropinslideshowcount = 0

function dropinslideshow(imgarray, w, h, delay) {
   this.id = "_dropslide" + (++_dropinslideshowcount) //Generate unique ID for this slideshow instance (automated)
   this.createcontainer(parseInt(w), parseInt(h))
   this.delay = delay
   this.imgarray = imgarray
   var preloadimages = []
   for (var i = 0; i < imgarray.length; i++) {
      preloadimages[i] = new Image()
      preloadimages[i].src = imgarray[i][0]
   }
   this.animatestartpos = parseInt(h) * (-1) //Starting "top" position of an image before it drops in
   this.slidedegree = 10 //Slide degree (> is faster)
   this.slidedelay = 10 //Delay between slide animation (< is faster)
   this.activecanvasindex = 0 //Current "active" canvas- Two canvas DIVs in total
   this.curimageindex = 0
   this.zindex = 100
   this.isMouseover = 0
   this.init()
}


dropinslideshow.prototype.createcontainer = function(w, h) {
   document.write('<div id="' + this.id + '" style="position:relative; width:' + w + 'px; height:' + h + 'px; overflow:hidden;  z-index: 0">')
   document.write('<div style="position:absolute; width:' + w + 'px; height:' + h + 'px; top:0;"></div>')
   document.write('<div style="position:absolute; width:' + w + 'px; height:' + h + 'px; top:-' + h + 'px;"></div>')
   document.write('</div>')
   this.slideshowref = document.getElementById(this.id)
   this.canvases = []
   this.canvases[0] = this.slideshowref.childNodes[0]
   this.canvases[1] = this.slideshowref.childNodes[1]
}

dropinslideshow.prototype.populatecanvas = function(canvas, imageindex) {
   var imageHTML = '<img src="' + this.imgarray[imageindex][0] + '" style="border: 0" />'
   if (this.imgarray[imageindex][1] != "")
      imageHTML = '<a href="' + this.imgarray[imageindex][1] + '" target="' + this.imgarray[imageindex][2] + '">' + imageHTML + '</a>'
   canvas.innerHTML = imageHTML
}


dropinslideshow.prototype.animateslide = function() {
   if (this.curimagepos < 0) { //if image hasn't fully dropped in yet
      this.curimagepos = this.curimagepos + this.slidedegree
      this.activecanvas.style.top = this.curimagepos + "px"
   }
   else {
      clearInterval(this.animatetimer)
      this.activecanvas.style.top = 0
      this.setupnextslide()
      var slideshow = this
      setTimeout(function() { slideshow.rotateslide() }, this.delay)
   }
}


dropinslideshow.prototype.setupnextslide = function() {
   this.activecanvasindex = (this.activecanvasindex == 0) ? 1 : 0
   this.activecanvas = this.canvases[this.activecanvasindex]
   this.activecanvas.style.top = this.animatestartpos + "px"
   this.curimagepos = this.animatestartpos
   this.activecanvas.style.zIndex = (++this.zindex)
   this.curimageindex = (this.curimageindex < this.imgarray.length - 1) ? this.curimageindex + 1 : 0
   this.populatecanvas(this.activecanvas, this.curimageindex)
}

dropinslideshow.prototype.rotateslide = function() {
   var slideshow = this
   if (this.isMouseover)
      setTimeout(function() { slideshow.rotateslide() }, 50)
   else
      this.animatetimer = setInterval(function() { slideshow.animateslide() }, this.slidedelay)
}

dropinslideshow.prototype.init = function() {
   var slideshow = this
   this.populatecanvas(this.canvases[this.activecanvasindex], 0)
   this.setupnextslide()
   this.slideshowref.onmouseover = function() { slideshow.isMouseover = 1 }
   this.slideshowref.onmouseout = function() { slideshow.isMouseover = 0 }
   setTimeout(function() { slideshow.rotateslide() }, this.delay)
}

/* end awards */

/* compare script */

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]; }
}
function MM_changeProp(objId, x, theProp, theValue) { //v9.0
   var obj = null; with (document) {
      if (getElementById)
         obj = getElementById(objId);
   }
   if (obj) {
      if (theValue == true || theValue == false)
         eval("obj.style." + theProp + "=" + theValue);
      else eval("obj.style." + theProp + "='" + theValue + "'");
   }
}

function CompareClick(self) {
   setTimeout(function() {
      if (self.target == '') {
         alert('Please check two or more computers!');
      }
   }, 300);
}

/* end compare script */


/* Featured camings desktop */
var imagefolder = "Images/140x140w/";
function ColorTab(tar, img) {
   $("#sku" + tar)[0].src = imagefolder + img;
}

function Popshow(tar) {
   $("#sku" + tar + "_p")[0].style.display = ''; ;
}

function isNumber(val) {
   var reg = /^[0-9]*$/;
   return reg.test(val);
}
