﻿
/*外部リンクをブランク表示*/
$(function() {   
  $(".blank").attr("target","_blank");  
});


/*ブックマーク*/
function addBookmark(title,url) {
    if (window.sidebar) {
        window.sidebar.addPanel(title, url,"");
    } else if( document.all ) {
        window.external.AddFavorite( url, title);
    } else if( window.opera && window.print ) {
        return true;
    }
}




//オプショナルツアーglobalNavi

$(document).ready(function() {
  var toggle = function(direction, display) {
    return function() {
      var self = this;
      var dl = $("ul", this);
      if( dl.css("display") == display && !self["block" + direction] ) {
        self["block" + direction] = true;
        dl["slide" + direction]("fast", function() {
          self["block" + direction] = false;
        });
      }
    };
  }
  $("li.nav").hover(toggle("Down", "none"), toggle("Up", "block"));
  $("li.nav ul").hide();

	});

$(document).ready(function() {
   var gNavObj = '#' + $('body').attr('id') + 'Nav';
    if ($('#globalNavi li').filter(gNavObj).size() == 1) {
        $gNavObj = $(gNavObj).find('a:first img');
        var src = $gNavObj.attr('src');
        var ftype = src.substring(src.lastIndexOf('.'), src.length);
        var hsrc = src.replace(ftype, '_ov' + ftype);
        $gNavObj.attr('src', hsrc);
    }

  $("a,input[type=image]'").focus(function () {
        $(this).blur();
    })

	var postfix = '_ov';
	$('.over').not("[src*='_ov.']").each(function() {
		var img = $(this);
		var src = img.attr('src');
		var src_on = src.substr(0, src.lastIndexOf('.'))
		           + postfix
		           + src.substring(src.lastIndexOf('.'));
		$('<img>').attr('src', src_on);
		img.hover(
			function() {
				img.attr('src', src_on);
			},
			function() {
				img.attr('src', src);
			}
		);
	});
});



//tab

$(function(){
$('#tabs div').hide();
$('#tabs div div').show();
$('#tabs div:first').show();
$('#tabs ul li:first').addClass('active');
$('#tabs ul li a').click(function(){ 
$('#tabs ul li').removeClass('active');
$(this).parent().addClass('active'); 
var currentTab = $(this).attr('href'); 
$('#tabs div').hide();
$('#tabs div div').show();
$("#"+currentTab).show();
return false;
});
});



/*---------------------------------

ゆくるポン表紙アーカイブ

---------------------------------*/
$(document).ready(function() {
	$(".acv_list li:eq(1)").addClass("newMag");
	$(".ul_list li:last").addClass("end");
});




/*---------------------------------

フロートマージン制御

---------------------------------*/
$(document).ready(function() {
	
	/*忘年会*/
	$("#bounenkai .itemBlock:even").css("margin-right", "10px");
	
	/*-----*/
	$("div.kankou div.randomdisplay div:even").css("margin-right", "10px");
});


/*---------------------------------

カーソール表示

---------------------------------*/
$(function() {
	$(".car_list li label").mouseover(function () {
		$(this).css({"cursor":"pointer"});	
	});
});


/*---------------------------------

フォーム要素

---------------------------------*/
$(function() {
	$("input[type='text'],textarea").addClass("txt_base_style");
	
	/*フォーカス*/
	$("input[type='text'],textarea")
		.focus(function() {
			$(this).addClass("focus_style");
		})
		.blur(function() {
			$(this).removeClass("focus_style");
		});	
});





/*---------------------------------

半角英数字

---------------------------------*/
function chkCode(id) {
  work='';
  for (lp=0;lp<id.value.length;lp++) {
    unicode=id.value.charCodeAt(lp);
    if ((0xff0f<unicode) && (unicode<0xff1a)) {
      work+=String.fromCharCode(unicode-0xfee0);
    } else if ((0xff20<unicode) && (unicode<0xff3b)) {
      work+=String.fromCharCode(unicode-0xfee0);
    } else if ((0xff40<unicode) && (unicode<0xff5b)) {
      work+=String.fromCharCode(unicode-0xfee0);
    } else {
      work+=String.fromCharCode(unicode);
    }
  }
  id.value=work; /* 半角処理のみ */
  //id.value=work.toUpperCase(); /* 大文字に統一する場合に使用 */
  //id.value=work.toLowerCase(); /* 小文字に統一する場合に使用 */
}


/*---------------------------------

ランダム表示

---------------------------------*/
jQuery(function($) {

$.fn.extend({
	randomdisplay : function(num) {
		return this.each(function() {
			var chn = $(this).children().hide().length;
			for(var i = 0; i < num && i < chn; i++) {
				var r = parseInt(Math.random() * (chn - i)) + i;
				$(this).children().eq(r).show().prependTo($(this));
			}
		});
	}
});

$(function(){
	$(".randomdisplay").each(function() {
		$(this).randomdisplay($(this).attr("title"));
	});
});

});



/*---------------------------------

analytics

---------------------------------*/

