$(document).ready(function() {
  
  function showLoading() {
    $("#loading").show();
  }

  function hideLoading() {
    $("#loading").hide();
  }

  $("a").click(function() {

    var linkPath = $(this).attr("href");

    if (linkPath == "tnc.html" && $(this).attr("class") == "wpop") {
      window.open(linkPath, "fox", "width=982, height=600, scrollbars=1, resizable=1");
      return false;
    }

    if (linkPath == "disclaimer.html" && $(this).attr("class") == "wpop") {
      window.open(linkPath, "fox", "width=960, height=600, scrollbars=1, resizable=1");
      return false;
    }

    if (linkPath == "contactus.html" && $(this).attr("class") == "wpop") {
      window.open(linkPath, "fox", "width=960, height=600, scrollbars=1, resizable=1");
      return false;
    }

    if (linkPath == "career.html" && $(this).attr("class") == "wpop") {
      window.open(linkPath, "fox", "width=982, height=600, scrollbars=1, resizable=1");
      return false;
    }

    if (linkPath == "more-info.html" && $(this).attr("class") == "wpop") {
      window.open(linkPath, "fox", "width=982, height=600, scrollbars=1, resizable=1");
      return false;
    }

    if (linkPath == "fox-c-sign-up.html" && $(this).attr("class") == "wpop") {
      window.open(linkPath, "fox", "width=982, height=600, scrollbars=1, resizable=1");
      return false;
    }	
    
    if (linkPath == "fox-c-tnc.html" && $(this).attr("class") == "wpop") {
      window.open(linkPath, "fox", "width=982, height=600, scrollbars=1, resizable=1");
      return false;
    }		

    if (linkPath == "http://www.foxfashion.sg/profile/login_09.asp") {
      window.open(linkPath, "fox", "width=740, height=680, scrollbars=1, resizable=1");
      return false;
    }

    if (linkPath == "http://www.foxfashion.sg/fox-c/") {
      window.open(linkPath, "fox", "width=740, height=680, scrollbars=1, resizable=1");
      return false;
    }

    if (linkPath.indexOf("foxfashion.sg") < 0 && linkPath.indexOf("http://") >= 0) {
      window.open(linkPath, "_blank", "");
      return false;
    }

  });
  
  // $(document).pngFix();
  
  $(window).load(function() {
  	$('#flexslider-container').flexslider({
  		animation: "fade",
  		slideshow: false, 
      controlsContainer: ".flexslider-container",
      controlNav: false,
      animationDuration: 200,
      touchSwipe: false
    });
  });
  
  $(window).load(function() {
   $('#homebanner').flexslider({
      animation: "slide",
      slideshow: true,
      slideshowSpeed: 5000,
      controlNav: true,
      directionNav: false,                     
      keyboardNav: false, 
      animationLoop: false,
      controlsContainer: ".homebanner-controls",
      // manualControls: ".bannernav",
      animationDuration: 1000,
      touchSwipe: false
    });
  });

  $('a.lightbox').lightBox();

  $('.flexslider img:last').load(function(){
    $('#loading').hide();
  });


  (function(doc) {

    var addEvent = 'addEventListener',
        type = 'gesturestart',
        qsa = 'querySelectorAll',
        scales = [1, 1],
        meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];

    function fix() {
      meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
      doc.removeEventListener(type, fix, true);
    }

    if ((meta = meta[meta.length - 1]) && addEvent in doc) {
      fix();
      scales = [.25, 1.6];
      doc[addEvent](type, fix, true);
    }

  }(document));

});

