$.importJS("/Include/marquee.js");

var tmrSlider = 0;
var hideSlider = false;
var sliderAlreadyShown = false;

var sProductText = "";
sProductText += "<a href='/Computers/Default.aspx?MnuId=14' class='navLinks'>UPS</a> | <a href='/Computers/Default.aspx?MnuId=64' class='navLinks'>USB</a> | <a href='/Computers/Default.aspx?MnuId=60' class='navLinks'>PCI Cards</a> | ";
sProductText += "<a href='/Computers/Default.aspx?MnuId=59' class='navLinks'>TV Tuners</a> | <a href='/Computers/Default.aspx?MnuId=16' class='navLinks'>Web Cams</a> | <a href='/Computers/Default.aspx?MnuId=15' class='navLinks'>Graphics Cards</a> | ";
sProductText += "<a href='/Computers/Default.aspx?MnuId=53' class='navLinks'>HDD Extenral Case</a> | <a href='/Computers/Default.aspx?MnuId=18' class='navLinks'>Mice</a> | <a href='/Computers/Default.aspx?MnuId=19' class='navLinks'>Network/Modem Cards</a> | ";
sProductText += "<a href='/Computers/Default.aspx?MnuId=65' class='navLinks'>Notebook BAGS</a>";

var arrHtml = new Array();
arrHtml['menu1'] = "";
arrHtml['menu2'] = "";
arrHtml['menu3'] = sProductText;
arrHtml['menu4'] = "<a href='/Cars/Default.aspx'>Cars</a> | <a href='/CarAccessories/Default.aspx'>Car Accessories</a> | <a href='/PreBuiltHomes/Default.aspx'>Homes</a> | <a href='/Doors/Default.aspx'>Doors</a> | <a href='/FloorTiles/Default.aspx'>Floor Tiles</a> | <a href='/Sanitaryware/Default.aspx'>Sanitaryware</a>";
arrHtml['menu5'] = "";
arrHtml['menu6'] = "<a href='/DriverDownload.aspx'>Download Drivers</a> | <a href='/ContactUs.aspx'>Contact Us</a>";


//Defin Document Ready (OnLoad) Function
$(document).ready(function() {

  //PreLoad Images
  $.preloadImages("/Images/index_06.png", "/Images/index_08.png",
                  "/Images/index_10.png", "/Images/index_12.png",
                  "/Images/index_14.png", "/Images/index_16.png",
									"/Images/menu1_norm.png", "/Images/menu1_over.png",
									"/Images/menu2_norm.png", "/Images/menu2_over.png",
									"/Images/menu3_norm.png", "/Images/menu3_over.png",
									"/Images/menu4_norm.png", "/Images/menu4_over.png",
									"/Images/menu5_norm.png", "/Images/menu5_over.png",
									"/Images/slidedown_bg.png");

  //Setup Marquee Element as Smooth Marquee
  $("#mrqLatestEntries").marquee().mouseover(function(event) {

    $(this).trigger('stop');

  }).mouseout(function(event) {

    $(this).trigger('start');

  });

  //Loop thorugh all IMG tags to Create IMAGE-ROLLOVER Effect
  $("img[hovermenu='true']").each(function(i) {

    //Attach MouseOver Event with the IMG tag in context
    $(this).mouseover(function(event) {

      //Assign an Image for Mouse Over effect
      this.src = "/Images/" + $(this).attr("id") + "_over.png";

      //Prevent default behavoiur of Event to fire
      event.preventDefault();

    });

    //Attach MouseOut Event with the IMG tag in context
    $(this).mouseout(function(event) {

      //Assign an Image for Mouse Out effect
      this.src = "/Images/" + $(this).attr("id") + "_norm.png";

      //Prevent default behavoiur of Event to fire
      event.preventDefault();

    });

  }); 	//$("img[hovermenu='true']").each(function (i){

  //Loop thorugh all IMG tags to Create SLIDE-DOWN Menu Effect
  $("img[slidedown='true']").each(function(i) {

    //Attach MouseOver Event with the IMG tag in context
    $(this).mouseover(function(event) {

      //Remove any previously assigned Timer
      tmrSlider = window.clearInterval(tmrSlider);

      //Mark Flag to false so that Slider Menu Hiding Animation will not run
      hideSlider = false;

      //Calculate Top & Left Positions for SliderMenu to be displayed at
      var topPos = new Number(($("#mnuStarter").offset().top + $("#mnuStarter").height()) - 3);
      var leftPos = new Number($("#mnuStarter").offset().left + 10);

      //Display SliderMenu to its respective location
      $("#slideContainer").css("position", "absolute");
      $("#slideContainer").css("left", leftPos + "px");
      $("#slideContainer").css("top", topPos + "px");

      //Assign HTML Contents inside SliderMenu, so that it can reflect Menu accordingly
      $("#divSlider").html(arrHtml[$(this).attr("id")]);

      if (sliderAlreadyShown == false) {
        //Show SliderMenu Container
        $("#slideContainer").show();

        //Display SliderMenu itselft with a Sliding-To-Down Animation
        $("#divSlider").animate({ top: "0px" }, { duration: 400, complete: function() {

          sliderAlreadyShown = true;

        }
        });
      }

      //Prevent default behavoiur of Event to fire
      event.preventDefault();

    });

    //Attach MouseOut Event with the IMG tag in context
    $(this).mouseout(function(event) {

      //Remove any previously assigned Timer
      tmrSlider = window.clearInterval(tmrSlider);

      //Mark Flag to true so that Slider Menu Hiding Animation can run
      hideSlider = true;

      //Assign a New Instance of Timer with a Delay of 100 Miliseconds (a little bit delayed)
      tmrSlider = window.setInterval("hideSliderDIV()", 100);

      //Prevent default behavoiur of Event to fire
      event.preventDefault();

    });

  }); 	//$("img[slidedown='true']").each(function (i){


  //Attach MouseOver Event with SliderMenu DIV
  $("#divSlider").mouseover(function(event) {

    //Mark Flag to false so that Slider Menu Hiding Animation will not run
    hideSlider = false;

    //Remove any previously assigned Timer
    tmrSlider = window.clearInterval(tmrSlider);

  }); 	//$("#divMoveIt").mouseover(function(event){

  //Attach MouseOut Event with SliderMenu DIV
  $("#divSlider").mouseout(function(event) {

    //Remove any previously assigned Timer
    tmrSlider = window.clearInterval(tmrSlider);

    //Mark Flag to true so that Slider Menu Hiding Animation can run
    hideSlider = true;

    //Assign a New Instance of Timer with a Delay of 1 Miliseconds (no delay, just like happening in an intance)
    tmrSlider = window.setInterval("hideSliderDIV()", 1);

  }); 	//$("#divMoveIt").mouseout(function(event){

}); 	//$(document).ready(function(){


//Define a Function which will be called from Timer to hide the Slider DIV
function hideSliderDIV() {
  //Check if SliderMenu hiding Flag is set to true
  if (hideSlider == true && sliderAlreadyShown == true) {

    //Hide the SliderMenu with a Slide-To-Top Animation
    $("#divSlider").animate({ top: "-30px" }, { duration: 400, complete: function() {

      //Remove any HTML Contents within SliderMenu so it can become Empty
      $("#divSlider").html("");

      //Now hide SlideMenu Container
      $("#slideContainer").hide();

      sliderAlreadyShown = false;

    }
    });

    //Remove any previously assigned Timer
    tmrSlider = window.clearInterval(tmrSlider);
  }
}