﻿/* 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 InitFeatures() {
   orgSpec = document.getElementById('SKU1_Spec').innerHTML;
   orgTitle = document.getElementById('MainSpecTitle').innerHTML;
   orgPrice = document.getElementById('MainPriceWords').innerHTML;
   orgLink = document.getElementById('Main_Link').href;
}

function DtMain() {
   var dlink = document.getElementById('Main_Link').href;
   window.location = dlink;
}

var orgImage = "images/large_HAF.png";
var orgTitle = "";
var orgPrice = "";
var orgSpec = "";
var orgLink = "";
var interval = 168;
var timer;
var windowTarget = "_self"; //_self, _blank
var colorAdaTitle = "7";
var rootlocation = 'Images/250x250/';
var inibp = '';

function GetMainImage() {
   return document.getElementById("FeaturesMainImg");
}

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';

   //   AjaxControlToolkit.Animation.createAnimation({ AnimationName: "FadeIn",
   //      duration: 1.3,
   //      minimumOpacity: 0.1,
   //      maximumOpacity: 1.0,
   //      fps: 20
   //   }, img).play();

   //   var map = $get(co.mapname);

   //   for (var i = 0, j = map.childNodes; i < j; i++) {
   //      var ac = map.childNodes[i];
   //      ac.coords = '';
   //   }

   //   AjaxControlToolkit.Animation.createAnimation({ AnimationName: "resize",
   //      duration: 0.3,
   //      width: 278,
   //      height: 0,
   //      fps: 20,
   //      unit: "px"
   //   }, img).play();

   //   setTimeout("PlaShow('" + img.id + "')", 320);
}

function PlaShow(senderId) {
   var target = document.getElementById(senderId);
   AjaxControlToolkit.Animation.createAnimation({ AnimationName: "resize",
      duration: 0.3,
      width: 278,
      height: 278,
      fps: 20,
      unit: "px"
   }, target).play();
}

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;
}

function TimerTime(lblobj, compareclass) {
   timer = window.setTimeout(function() {
      if (lblobj.className != compareclass) {
         var img = GetMainImage();
         //img.src = orgImage;
         img.style.cursor = 'default';
         mainlink = "";
         //SwapToOrg();
         clearTimeout(timer);
      }
   }, interval);
}

function TopBlockMouseOver(objid, idx) {
   var lbl = document.getElementById(objid);
   lbl.className = 'SKU_inner SKU_inner_Hover';

   ChangeSpec(objid);
   ChangeTitle(objid);
   ChangePrice(objid);

   colorAdaTitle = lbl.getAttribute("name");
   ChangeImage(lbl.lang);
   //clearTimeout(timer);
}

function TopBlockMouseOut(objid) {
   var lbl = document.getElementById(objid);
   lbl.className = 'SKU_inner';

   //TimerTime(lbl, 'SKU_top SKU_a');
}

function TopOnclick(idx) {
   //RedirectTo(d_t_link[idx - 1]);
}

function BottomBlockMouseOver(objid, idx) {
   var lbl = document.getElementById(objid);
   lbl.className = 'SKU_inner SKU_inner_Hover';

   ChangeSpec(objid);
   ChangeTitle(objid);
   ChangePrice(objid)

   colorAdaTitle = lbl.getAttribute("name");
   ChangeImage(lbl.lang)
   //clearTimeout(timer);
}

function BottomBlockMouseOut(objid) {
   var lbl = document.getElementById(objid);
   lbl.className = 'SKU_inner';

   //TimerTime(lbl, 'SKU_bottom SKU_c');
}

function BottomOnclick(idx) {
   //RedirectTo(d_b_link[idx - 1]);
}

function MainOver() {
   clearTimeout(timer);
}

function MainOut() {
   var img = GetMainImage();
   //img.src = orgImage;
   img.style.cursor = 'default';
   mainlink = "";
   //SwapToOrg();
}

function SwapToOrg() {
   document.getElementById('MainSpecWords').innerHTML = orgSpec;
   document.getElementById('MainSpecTitle').innerHTML = orgTitle;
   document.getElementById('MainPriceWords').innerHTML = orgPrice;
   document.getElementById('Main_Link').href = orgLink;
}

/* end features */

/* features nb */

function InitFeaturesnb() {
   orgSpecnb = document.getElementById('SKU9_Spec').innerHTML;
   orgTitlenb = document.getElementById('MainSpecTitle2').innerHTML;
   orgPricenb = document.getElementById('MainPriceWords2').innerHTML;
   orgLinknb = document.getElementById('Main_Link2').href;
}

function LtMain() {
   var llink = document.getElementById('Main_Link2').href;
   window.location = llink;
}

var orgImagenb = "images/large_HAF.png";
var orgTitlenb = "";
var orgPricenb = "";
var orgSpecnb = "";
var orgLinknb = "";

var interval = 168;
var timer;
var windowTarget = "_self"; //_self, _blank

function GetMainImagenb() {
   return document.getElementById("FeaturesMainImg2");
}

function ChangeImagenb(url) {
   var img = GetMainImagenb();
   img.src = url;
   img.style.cursor = 'pointer';
}

function ChangeSpecnb(id) {
   var mainSpec = document.getElementById('MainSpecWords2');
   var newSpec = document.getElementById(id + '_Spec').innerHTML;

   mainSpec.innerHTML = newSpec;
}

function ChangeTitlenb(id) {
   var mainTitle = document.getElementById('MainSpecTitle2');

   var newTitle = document.getElementById(id + '_Title').innerHTML;

   mainTitle.innerHTML = newTitle;
}

function ChangePricenb(id) {
   var mainPrice = document.getElementById('MainPriceWords2');
   var target = document.getElementById(id + '_Price');
   var newPrice = target.innerHTML;

   document.getElementById('Main_Link2').href = target.lang;

   mainPrice.innerHTML = newPrice;
}

function TimerTimenb(lblobj, compareclass) {
   timer = window.setTimeout(function() {
      if (lblobj.className != compareclass) {
         var img = GetMainImage();
         //img.src = orgImage;
         img.style.cursor = 'default';
         mainlink = "";
         //SwapToOrg();
         clearTimeout(timer);
      }
   }, interval);
}

function TopBlockMouseOvernb(objid, idx) {
   document.getElementById(objid + "_Inner").className = 'SKU_inner_nb SKU_inner_nb_Hover';

   ChangeSpecnb(objid);
   ChangeTitlenb(objid);
   ChangePricenb(objid)
   ChangeImagenb(document.getElementById(objid).lang)
   //clearTimeout(timer);
}

function TopBlockMouseOutnb(objid) {
   var lbl = document.getElementById(objid + "_Inner");
   lbl.className = 'SKU_inner_nb';

   //TimerTime(lbl, 'SKU_top_nb SKU_a');
}

function TopOnclicknb(idx) {
   //RedirectTo(d_t_link[idx - 1]);
}

function BottomBlockMouseOvernb(objid, idx) {
   document.getElementById(objid + "_Inner").className = 'SKU_inner_nb SKU_inner_nb_Hover';

   ChangeSpecnb(objid);
   ChangeTitlenb(objid);
   ChangePricenb(objid)
   ChangeImagenb(document.getElementById(objid).lang)
   //clearTimeout(timer);
}

function BottomBlockMouseOutnb(objid) {
   var lbl = document.getElementById(objid + "_Inner");
   lbl.className = 'SKU_inner_nb';

   //TimerTime(lbl, 'SKU_bSKU_bottom_nbottom SKU_c');
}

function BottomOnclicknb(idx) {
   //RedirectTo(d_b_link[idx - 1]);
}

function MainOvernb() {
   clearTimeout(timer);
}

function MainOutnb() {
   var img = GetMainImage();
   //img.src = orgImage;
   img.style.cursor = 'default';
   mainlink = "";
   //SwapToOrg();
}

function SwapToOrgnb() {
   document.getElementById('MainSpecWords2').innerHTML = orgSpecnb;
   document.getElementById('MainSpecTitle2').innerHTML = orgTitlenb;
   document.getElementById('MainPriceWords2').innerHTML = orgPricenb;
   document.getElementById('Main_Link2').href = orgLinknb;
}

/* end features nb */

/* 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 */

/* custom configurator */

var llink = new Array();
var rlink = new Array();
var blink = new Array();
var mainlink = "";

function GetPrefix() {
   var url = window.location.toString();

   var prefix = "";

   if (url.indexOf("IbpPages/") != -1) {
      prefix = "../";
   }

   return prefix;
}

var custorgImage = "images/cc_MAIN.jpg";
var custinterval = 168;
var custtimer;
var custwindowTarget = "_self"; //_self, _blank

function custGetMainImage() {
   return document.getElementById("MainImg");
}

function custChangeImage(url) {
   var img = custGetMainImage();

   var prefix = GetPrefix();
   var imglo = "";
   if (prefix == "") {
      imglo = "Images/";
   }
   else {
      imglo = "../Images/";
   }

   img.src = imglo + url;
   //alert(img.src);
   img.style.cursor = 'pointer';
}

function RedirectTo(link) {
   if (custwindowTarget == "_self") {
      window.location = link;
   }
   else {
      window.open(link);
   }
}

function TimerTime(lblobj, compareclass) {
   custtimer = window.setTimeout(function() {
      if (lblobj.className != compareclass) {
         var img = custGetMainImage();
         img.src = custorgImage;
         img.style.cursor = 'default';
         mainlink = "";
         clearTimeout(custtimer);

         document.getElementById("cc_MainSpec").style.display = 'none';
         document.getElementById("cc_MainPrice").style.display = 'none';
      }
   }, custinterval);
}


function LeftLabelMouseOver(objid, idx) {
   var lbl = document.getElementById(objid);
   lbl.className = 's_hover s_left';

   custChangeImage(lbl.lang)
   clearTimeout(custtimer);
   mainlink = llink[idx - 1];

   ChangeMainInfo(objid);
}

function LeftLabelMouseOut(objid) {
   var lbl = document.getElementById(objid);
   lbl.className = 's_left';

   TimerTime(lbl, 's_hover s_left');
}

function RightLabelMouseOver(objid, idx) {
   var lbl = document.getElementById(objid);
   lbl.className = 's_hover s_right';

   custChangeImage(lbl.lang)
   clearTimeout(custtimer);
   mainlink = rlink[idx - 1];

   ChangeMainInfo(objid);
}

function ChangeMainInfo(objid) {
   var spec = document.getElementById(objid + "_Spec").innerHTML;
   var price = document.getElementById(objid + "_Price").innerHTML;
   
   var ms = document.getElementById("cc_MainSpec");
   var mp = document.getElementById("cc_MainPrice");

   ms.style.display = '';
   mp.style.display = '';
   
   ms.innerHTML = spec;
   mp.innerHTML = price;
}

function RightLabelMouseOut(objid) {
   var lbl = document.getElementById(objid);
   lbl.className = 's_right';

   TimerTime(lbl, 's_hover s_right');}

function BottomLabelMouseOver(objid, idx) {
   var lbl = document.getElementById(objid);
   lbl.className = 's_hover s_bottom';

   custChangeImage(lbl.lang)
   clearTimeout(custtimer);

   mainlink = blink[idx - 1];

   ChangeMainInfo(objid);
}

function BottomLabelMouseOut(objid) {
   var lbl = document.getElementById(objid);
   lbl.className = 's_bottom';

   TimerTime(lbl, 's_hover s_bottom');
}

function custMainOver() {
   clearTimeout(custtimer);
}

function custMainOut() {
   var img = custGetMainImage();
   img.src = custorgImage;
   img.style.cursor = 'default';
   mainlink = "";
}

function custMainClick() {
   if (mainlink != "") {
      RedirectTo(mainlink);
   }
}

/* end custom configurator */

/* 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) {
   var target = $get("sku" + tar);

   target.src = imagefolder + img;
}

function Popshow(tar) {
   var target = $get("sku" + tar + "_p");
   target.style.display = '';
}

function isNumber(val) {
   var reg = /^[0-9]*$/;
   return reg.test(val);
}