jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
// ロールオーバー

function initRollOverImages() {
  var image_cache = new Object();
  $("img.swap").each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_on = this.src.substr(0, dot) + '_over' + this.src.substr(dot, 4);
    image_cache[this.src] = new Image();
    image_cache[this.src].src = imgsrc_on;
    $(this).hover(
      function() { this.src = imgsrc_on; },
      function() { this.src = imgsrc; });
  });
}

$(document).ready(initRollOverImages);

// スムーズスクロール
jQuery(document).ready(function($) {

	
	jQuery.easing.quart = function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	};  
	
	$(function () {
		$('.pagetop, .link_top a').click(function () {
			$('html,body').animate({ scrollTop: 0 }, 1000, 'quart');
			return false;
		});
	});
});


// 戻るボタンでのover解除

//window.onunload=function(){}




// フォントサイズ調整
/*
*/

jQuery(function($){
    //変数にクッキー名を入れる
    var history = $.cookie('fontSize');
	
    //適用する箇所を指定。今回は部分的に#test内のpに
    var elm = $('#wrapper');
	
    //変数が空ならfontMを、空でなければクッキーに保存しておいたものを適用
    (!history)? elm.addClass('fontM'):elm.addClass(history);
	
    //クリックしたら実行
    $('li','#switchBox').click(function(){
	
        //クリックした要素のID名を変数にセット
        var setFontSize = this.id;
	    
        //クッキーに変数を保存
    	$.cookie('fontSize', setFontSize);
		
        //一度classを除去して、変数をclassとして追加
        elm.removeClass().addClass(setFontSize);
    });
});


//タブ切り替え
$(function () {
    var tabContainer = $('div.menuBox2 div');
    tabContainer.hide().filter(':first').show();
    $('div.menuBox2 ul.nav a').click(function () {
       tabContainer.hide();
       tabContainer.filter(this.hash).fadeIn("slow");
       $('div.menuBox2 ul.nav a').removeClass('selected');
       $(this).addClass('selected');
       return false;
    })
    .filter(':first').click();
});

//サイドバーニュース読み込み
$(function(){
$("#tab-01").load("http://www.omniversal.jp/index_dummy.html #topnews");
$("#tab-02").load("http://www.omniversal.jp/index_dummy.html #topmarkets");
});

