$(document).ready(function(){

/*----------
jquery.cookie.js
----------*/
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
}
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;
}
};

/*----------
sizeChange.js
----------*/

CONTAINER = $("#Container");
var CHANGE = $("#FontSizeChange");
CONTAINER.css("font-size",$.cookie('fsize'));
CHANGE.show().css("cursor","pointer");

//リロードした時にクッキーに保存されたフォントサイズが18px以上であれば、拡大ボタンを消す
if(!$.cookie('fsize')=="") {
var cookiesize = $.cookie('fsize').replace("px","");
if((cookiesize*1) > 17){$("dd#FontLarge").hide();}
}
$("dd#FontLarge",CHANGE).click(Big);
$("dd#FontReset",CHANGE).click(Reset);


function Big(){
	var FontSize = CONTAINER.css("font-size");
	//alert(FontSize); //現在のフォントサイズ
	var FontSizeBig = parseInt(FontSize)+1;
	//18px以上になったら拡大ボタンを消す
	if(FontSizeBig > 17){
		$("dd#FontLarge").fadeOut("nomal");
	}
	//alert(FontSizeBig); 1px足したフォントサイズ
	CONTAINER.css("font-size",FontSizeBig+"px");
	$.cookie("fsize", null);
	$.cookie("fsize",FontSizeBig+"px",{expires:7,path:'/'});
};

function Reset(){
	CONTAINER.css("font-size","13px");
	$.cookie("fsize", null);
	$.cookie("fsize","13px",{expires:7,path:'/'});
	$("dd#FontLarge").show();
};


/*----------
check_box_change.js
----------*/

	var INPUT = $("ul.ListHover input");
	var LI = $("ul.ListHover li");
	//INPUT.removeAttr('checked','checked');
    INPUT.change(function(){
		var index = INPUT.index(this);
		var CLASS = LI.eq(index).attr("class");
		if(CLASS == LI.eq(index).attr("class").replace(/On/,"")){
		LI.eq(index).attr("class",CLASS+"On");
			} else {
		var CLASSOFF = CLASS.replace(/On/,"");
		LI.eq(index).attr("class",CLASSOFF);
		}
	})

//リロード時にチェックが入ってればクラスをつける
$('#SearchBox01 input[type=checkbox]').each(function () { //AREA
	if($(this).attr('checked')){
		$(this).parent().addClass("On");
	} else {
		$(this).parent().removeClass("On");
	}
});

// チェックボックス　全選択/解除
$('#AreaAll').change(function(){
	//$(this).parent('ul:eq(0)').find(':checkbox').attr('checked',this.checked);
	if (!$("input",this).attr('checked')){
	$('#AreaSelect li').removeClass("On").find(':checkbox').attr('checked','');
	} else {
	$('#AreaSelect li').addClass("On").find(':checkbox').attr('checked','checked');
	}
});

// トップ-ステップ01 偶数行にのみクラスを指定
	$('#LearnList ol > li:nth-child(even)').addClass('Even');
	$('#SearchCriteria tr:nth-child(even)').addClass('Even');



// cnslt FAQの開閉 - modify:100804 ODS
 
	var _Q = $("#FaqBox dt");
	var _A = $("#FaqBox dd");
	_A.css("display","none");
							
	_Q.toggle(function(){
		$("+dd",this).slideDown("fast");
		$(this).addClass("Selected");
		return false;
	},
	function(){
		$("+dd",this).slideUp("fast");
		$(this).removeClass("Selected");
		return false;
	}).css("cursor","pointer").mouseover(function() {
		$(this).addClass("Over");
	}).mouseout(function() {
		$(this).removeClass("Over");
	});



/*----------------------------------------------
*
* 	Rollover Script
* 	create:10-03-04
*
----------------------------------------------*/
 
$("img,input:image").mouseover(function(){
		//src属性に_off.が含まれる場合に実行
		if($(this).attr("src").match(/_off\./)) {
				//src属性の_off.を_on.に置換
				$(this).attr("src",$(this).attr("src").replace('_off.', '_on.'));
				$(this).mouseout(function(){
						//マウスアウトでsrc属性の_on.を_off.に置換
						$(this).attr("src",$(this).attr("src").replace('_on.', '_off.'));
				})
		}
}).each(function(){
		if($(this).attr("src").match(/_off\./)) {
				//_on画像をプリロード
				var img = $("<img>,<input>:image").attr("src",$(this).attr("src").replace('_off.', '_on.'))
		}
});


});


/*----------------------------------
Popup window
----------------------------------*/

function m_win(url,windowname,width,height) {
 var features="location=no, menubar=no, status=yes, scrollbars=yes, resizable=yes, toolbar=no";
 if (width) {
  if (window.screen.width > width)
   features+=", left="+(window.screen.width-width)/2;
  else width=window.screen.width;
  features+=", width="+width;
 }
 if (height) {
  if (window.screen.height > height)
   features+=", top="+(window.screen.height-height)/2;
  else height=window.screen.height;
  features+=", height="+height;
 }
 window.open(url,windowname,features);
}

/*
	label内の画像をクリック可能に
**************************************/
//以下IEのみ対応
/*@cc_on
window.attachEvent('onload', function(){
	// まず、label内の画像に自分がクリックされたらlabelにクリックを投げる関数を定義する
	var label_img_enclick = function(label) {
		var imgs = label.getElementsByTagName('img');
		for (var i = 0, l = imgs.length;i < l; ++i)
			imgs[i].attachEvent('onclick',function(){
				label.click();
			});
	};
	// ページ内のlabelタグを走査し、for属性を持ち、対応するinput要素が存在する場合、上記関数を適用する
	var labels = document.getElementsByTagName('label');
	for (var i = 0, l = labels.length;i < l; ++i) {
		var label = labels[i], input;
		if (label.htmlFor
				&& (input = document.getElementById(label.htmlFor)) 
				&& /input/i.test(input.tagName)
			 ) {
			label_img_enclick(label);
		}
	}
});
@*/
