// Analytics
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-4752290-6']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

//Another Window
$(function(){
$('a').filter(function(){
return (new RegExp('http:\/\/(?!'+location.hostname +')')).test(this.href);
}).attr('target','_blank');
});

// Image:hover Alpha
$(document).ready(function(){
$(".alpha").fadeTo(0,1.0);
$(".alpha").hover(
function(){
        $(this).fadeTo(200,0.5);
    },
    function(){
        $(this).fadeTo(200,1.0);
    });
$(".box img").fadeTo(0,1.0);
$(".box img").hover(
function(){
        $(this).fadeTo(200,0.5);
    },
    function(){
        $(this).fadeTo(100,1.0);
    });
$("#sideBnr a").fadeTo(0,1.0);
$("#sideBnr a").hover(
function(){
        $(this).fadeTo(200,0.7);
    },
    function(){
        $(this).fadeTo(100,1.0);
    });
});

/*
 * Droppy 0.1.2
 * (c) 2008 Jason Frame (jason@onehackoranother.com)
 */
$.fn.droppy = function(options) {
    
  options = $.extend({speed: 300}, options || {});
  
  this.each(function() {
    
    var root = this, zIndex = 1000;
    
    function getSubnav(ele) {
      if (ele.nodeName.toLowerCase() == 'li') {
        var subnav = $('> ul', ele);
        return subnav.length ? subnav[0] : null;
      } else {
        return ele;
      }
    }
    
    function getActuator(ele) {
      if (ele.nodeName.toLowerCase() == 'ul') {
        return $(ele).parents('li')[0];
      } else {
        return ele;
      }
    }
    
    function hide() {
      var subnav = getSubnav(this);
      if (!subnav) return;
      $.data(subnav, 'cancelHide', false);
      setTimeout(function() {
        if (!$.data(subnav, 'cancelHide')) {
          $(subnav).slideUp(options.speed);
        }
      }, 30);
    }
  
    function show() {
      var subnav = getSubnav(this);
      if (!subnav) return;
      $.data(subnav, 'cancelHide', true);
      $(subnav).css({zIndex: zIndex++}).slideDown(options.speed);
      if (this.nodeName.toLowerCase() == 'ul') {
        var li = getActuator(this);
        $(li).addClass('hover');
        $('> a', li).addClass('hover');
      }
    }
    
    $('ul, li', this).hover(show, hide);
    $('li', this).hover(
      function() { $(this).addClass('hover'); $('> a', this).addClass('hover'); },
      function() { $(this).removeClass('hover'); $('> a', this).removeClass('hover'); }
    );
    
  });
  
};
$(function() {
$('#gNavi').droppy({speed: 100});
});

//Colorbox
$(function(){
$('a[rel="colorbox"],a[href$=".jpg"], a[href$=".gif"], a[href$=".png"],a[href$=".JPG"], a[href$=".GIF"], a[href$=".PNG"]').colorbox({maxHeight:"95%",maxWidth:"95%",current: "{current} of {total}",initialWidth: "50",initialHeight:"50"});
});

$(function(){

//Font Size
var FontSize = [];
FontSize["S"] = 12;
FontSize["M"] = 13;
FontSize["L"] = 15;

var ChangeBtn = "#fSize img";
var SearchImg = ["#fSmall img","#fMedium img","#fLarge img"];

function FontSizeSet(fs){
$("body").css("font-size",fs+"px");
};

function OnFont(){
$(this).attr("src",$(this).attr("src"));
};
function OvFont(io){
$(io).attr("src",$(io).attr("src").replace(/^(.+)(\.[a-z]+)$/,"$1_ov$2"));
};
function OffFont(io){
$(io).attr("src",$(io).attr("src").replace(/^(.+)_ov(\.[a-z]+)$/,"$1$2"));
};

function FontCookie(ck){
$.cookie("fontsize",ck,{path:'/',expires:7});
};

function CookieChack(fs){
return $.cookie("fontsize")==fs;
};

function LoadFont(fs,si){
FontSizeSet(FontSize[fs]);
OvFont(SearchImg[si]);
};
if(CookieChack("fSmall")){
LoadFont("S",0);
}
else if(CookieChack("fMedium")){
LoadFont("M",1);
}
else if(CookieChack("fLarge")){
LoadFont("L",2);
}
else {
FontCookie("fMedium");
LoadFont("S",1);
};

function ImgPreload(io){
$(ChangeBtn).not(SearchImg[io]).each(function(){
$("<img>").attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/,"$1_ov$2"));
});
};
if(CookieChack("fSmall")){
ImgPreload(0);
}
else if(CookieChack("fMedium")){
ImgPreload(1);
}
else if(CookieChack("fLarge")){
ImgPreload(2);
};

$(ChangeBtn)
.hover(
function(){
if(!$(this).attr("src").match("_ov")){
OvFont(this);
};
},
function(){
if($(this).attr("src").match("_ov")){
if(CookieChack("fSmall")){
OffFont(SearchImg[1]),OffFont(SearchImg[2]);
}
else if(CookieChack("fMedium")){
OffFont(SearchImg[0]),OffFont(SearchImg[2]);
}
else if(CookieChack("fLarge")){
OffFont(SearchImg[0]),OffFont(SearchImg[1]);
};
};
});

function ClickFont(ck,fs,io1,io2){
FontCookie(ck);
FontSizeSet(FontSize[fs]);
OffFont(SearchImg[io1]),OffFont(SearchImg[io2]);
OnFont();
};
$(SearchImg[0]).click(function(){
ClickFont("fSmall","S",1,2);
});
$(SearchImg[1]).click(function(){
ClickFont("fMedium","M",0,2);
});
$(SearchImg[2]).click(function(){
ClickFont("fLarge","L",0,1);
});
});
