// For Main Nav
$(document).ready(function() {

$.fn.hoverClass = function(c) {
	return this.each(function() {
		$(this).hover(
			function() { $(this).addClass(c); },
			function() { $(this).removeClass(c); }
		);
	});
};

$("#mainNavigation li").hover(
  function(){ $("ul", this).fadeIn("fast"); },
  function() { }
);

if(document.all) {
  $("#mainNavigation li").hoverClass("sfHover");
}

// Show popup
var popup = $("#popup").overlay({api: true});
window.show_popup = function(popup_content) {
  document.getElementById('popup_content').innerHTML = popup_content;
  document.getElementById('popup_content').style.minHeight = '132px'
  popup.load();
}

// For bigtarget links
if($('ol.bigTarget h6 a').size()) {
  $('ol.bigTarget h6 a').bigTarget()
}

// Input quantity field
$('.input_qty_field').keydown(function(event) {
  if(event.shiftKey == true || $.inArray(event.which, [8, 9, 35, 36, 37, 38, 39, 40, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105]) == -1) {
    return false
  }else {
    return true
  }
})
$('.input_qty_field').keyup(function() {
  if(!this.value.toString().match(/^[1-9][0-9]{0,2}$/)) {
    var search_pos = this.value.search(/[1-9][0-9]{0,2}$/)
    if(search_pos != -1) {
      this.value = this.value.slice(search_pos)
    }else {
      this.value = '0'
    }
  }else {
    return true
  }
})

red_flag_countries = [5/*American Samoa*/, 45/*China*/, 82/*Ghana*/, 117/*Korea, Republic of*/, 163/*Northern Mariana Islands*/, 177/*Puerto Rico*/, 88/*Guam*/, 80/*Georgia*/, 137/*Marshall Islands*/, 245/*Caroline Islands*/, 238, 239/*Virgin Islands (US and British)*/, 180/*Romania*/, 34/*Bulgaria*/, 99/*Hungary*/, 55/*Croatia*/, 199/*Slovenia*/, 130/*Macedonia*/, 3/*Albania*/, 256/*Serbia (Yugoslavia)*/, 28/*Bosnia*/, 198/*Slovakia*/, 58/*Czech Republic*/, 68/*Estonia*/, 121/*Latvia*/, 127/*Lithuania*/, 144/*Moldova*/, 228/*Ukraine*/, 21/*Belarus*/, 160/*Nigeria*/, 133/*Malasia*/, 102/*Indonesia*/, 175/*Poland*/, 136/*Malta*/, 244/*Zimbabwe*/, 143/*Federated state of Micronesia*/, 113/*Kazahstan*/]
red_flag_states = [60, 61, 62, 63, 64, 65]
});
//--------------------------------------------------------

// For sIFR
var burbank = {
  src: '/shared/swf/burbank.swf'
};
// You probably want to switch this on, but read <http://wiki.novemberborn.net/sifr3/DetectingCSSLoad> first.
// sIFR.useStyleCheck = true;
sIFR.activate(burbank);
sIFR.replace(burbank, {
  selector: 'h1'
  ,css: {
	'.sIFR-root': { 'color': '#FFFFFF' }
  	}
  ,wmode: 'transparent'
  //,fitExactly: true
  ,offsetTop: 4
  //,tuneHeight: 0
  //,tuneWidth: 5
  ,ratios: [6, 1.24, 7, 1.21, 8, 1.18, 10, 1.16, 11, 1.13, 12, 1.12, 13, 1.11, 15, 1.1, 17, 1.09, 19, 1.08, 22, 1.07, 26, 1.06, 32, 1.05, 41, 1.04, 58, 1.03, 97, 1.02, 1.01]
});
sIFR.replace(burbank, {
  selector: 'h2'
  ,css: ['a { color: #FFFFFF; text-decoration: none; }', 'a:hover { color: #fffa99; }', '.sIFR-root {color: #FFFFFF;}']
  ,wmode: 'transparent'
  //,fitExactly: true
  //,tuneWidth: 5
  ,ratios: [6, 1.24, 7, 1.21, 8, 1.18, 10, 1.16, 11, 1.13, 12, 1.12, 13, 1.11, 15, 1.1, 17, 1.09, 19, 1.08, 22, 1.07, 26, 1.06, 32, 1.05, 41, 1.04, 58, 1.03, 97, 1.02, 1.01]
});
sIFR.replace(burbank, {
  selector: 'h3.light'
  ,css: {
	'.sIFR-root': { 'color': '#91D159' }
  	}
  ,wmode: 'transparent'
  //,fitExactly: true
  //,tuneWidth: 5
  ,ratios: [6, 1.24, 7, 1.21, 8, 1.18, 10, 1.16, 11, 1.13, 12, 1.12, 13, 1.11, 15, 1.1, 17, 1.09, 19, 1.08, 22, 1.07, 26, 1.06, 32, 1.05, 41, 1.04, 58, 1.03, 97, 1.02, 1.01]
});

sIFR.replace(burbank, {
  selector: 'h3'
  ,css: {'.sIFR-root': {'color':'#397b00'}, '.red': {'color':'#ff0000', 'font-size':'16px'}}
  ,wmode: 'transparent'
  ,ratios: [6, 1.24, 7, 1.21, 8, 1.18, 10, 1.16, 11, 1.13, 12, 1.12, 13, 1.11, 15, 1.1, 17, 1.09, 19, 1.08, 22, 1.07, 26, 1.06, 32, 1.05, 41, 1.04, 58, 1.03, 97, 1.02, 1.01]
  //fitExactly: true,
  //tuneWidth: 5    
});
