	var showEnable = 1;	var showEnable2 = 1;
	var showOpen = 0;						

j$(document).ready(function(){
	cgwinit();
	initLightbox();
});

j$(window).load(function(){
setTimeout(function(){window.scrollTo(0,1)},300);
});


function cgwinit() {
	

	marginReducer();
	



var PATHNAME = location.pathname;
	showText();
	showExp();
	if (j$("#marquee").size() == 1) {
		marqueeinit();
	}
	if (j$("#keyvisualArea").size() == 1) {
		keyvisualAreainit();
	}
	if (j$("#sendmailmaga").size() == 1) {
		sendmailmagainit();
	}
	if (j$("#sendmailmagastop").size() == 1) {
		sendmailmagastopinit();
	}

	if (j$(".menu_box").size() >= 1) {
		j$("div.menu_box").hover(function() {var objTAR=j$(this);var objTARIMG=j$(this).find("a img");anbkon(objTAR,objTARIMG)},function() {var objTAR=j$(this);var objTARIMG=j$(this).find("a img");anbkof(objTAR,objTARIMG)});
	}

	if (j$("#category_menuArea").size() == 1) {
		j$("div.category_menu_box").hover(function() {var objTAR=j$(this);var objTARIMG=j$(this).find("a img");anbkon(objTAR,objTARIMG)},function() {var objTAR=j$(this);var objTARIMG=j$(this).find("a img");anbkof(objTAR,objTARIMG)});
	}

	if (j$(".blogIdxList").size() >= 1) {
		j$("div.blogIdxList").hover(function() {var objTAR=j$(this);var objTARIMG=j$(this).find("a img");anbkon(objTAR,objTARIMG)},function() {var objTAR=j$(this);var objTARIMG=j$(this).find("a img");anbkof(objTAR,objTARIMG)});
	}

	if (j$("#flashnews_listArea").size() == 1) {
		j$("#flashnews_listArea dd").hover(function() {var objTAR=j$(this);var objTARIMG=j$(this).find("a img");anbkon(objTAR,objTARIMG)},function() {var objTAR=j$(this);var objTARIMG=j$(this).find("a img");anbkof(objTAR,objTARIMG)});
	}

	if (PATHNAME.match(/^\/feature\//)) {
		j$("#gnav_01").css("background-position","0px -23px");
	}
	else if (PATHNAME.match(/^\/regular\//)) {
		j$("#gnav_02").css("background-position","0px -23px");
	}
	else if (PATHNAME.match(/^\/flashnews\//)) {
		j$("#gnav_04").css("background-position","0px -23px");
	}

	if (PATHNAME.match(/^\/flashnews\/software\//)) {
		j$("#news_navi_01").css("background-position","0px -23px");
	}
	else if (PATHNAME.match(/^\/flashnews\/hardware\//)) {
		j$("#news_navi_02").css("background-position","0px -23px");
	}
	else if (PATHNAME.match(/^\/flashnews\/event\//)) {
		j$("#news_navi_03").css("background-position","0px -23px");
	}
	else if (PATHNAME.match(/^\/flashnews\/service\//)) {
		j$("#news_navi_04").css("background-position","0px -23px");
	}
	else if (PATHNAME.match(/^\/flashnews\/contents\//)) {
		j$("#news_navi_05").css("background-position","0px -23px");
	}

	if (j$(".featureEntryTitle").size() >= 1) {
		fixheight('featureEntryTitle',3);
	}
	if (j$(".topjobtitle").size() >= 1) {
		fixheight('topjobtitle',3);
	}
	if (j$(".category_menu_box").size() >= 1) {
		fixheight('category_menu_box',3);
	}

	if (j$(".topCommonEntryHead").size() >= 1) {
		fixheight('topCommonEntryHead',3);
	}

	if (j$(".topCommonEntryBody").size() >= 1) {
		fixheight('topCommonEntryBody',3);
	}

	if (j$(".topPushHead").size() >= 1) {
		fixheight('topPushHead',2);
	}

	if (j$(".topPushBody").size() >= 1) {
		fixheight('topPushBody',2);
	}


}

function fixheight(classstr,num_l) {
	var i;
	var j;
	var heM=0;
	j$('.'+classstr).each(function(idx) {
		i=idx;
		if (heM<j$(this).height()) {
			heM=j$(this).height();
		}
		if ((i+1)%num_l == 0) {
			for (j=i+1-num_l;j<=i;j++) {
				j$('.'+classstr+":eq("+j+")").height(heM);
			}
			heM = 0;
		}
	});
	if ((i+1)%num_l != 0) {
			for (j=i+1-(i+1)%num_l;j<=i;j++) {
				j$('.'+classstr+":eq("+j+")").height(heM);
			}
	}

}

function marginReducer(){
	j$(".topInfoWrap div:last-child").css({margin:"0 20px 0 0"
										  ,float:"right"});
//	j$(".mgnT2 div:last-child").css({marginRight:"50px",float:"right"});
	j$(".mgnT2 div:last-child").css({marginRight:"50px"});

}
function showExp(){
	j$("#exp").click(function(){
		if(showEnable2 ==1){
			if(this.checked){
				showEnable2 = 0;
				j$("#hid").animate({height:"0px"},300,(function(){j$("#hidbtm").css("border","none");showEnable2 = 1;}));
			}
			else{
				showEnable2 = 0;
				j$("#hid").animate({height:"530px"},300,(function(){showEnable2 = 1;}));
			}
		}
	})
}
function showText(){
	j$("#showtext").css("cursor","pointer").click(function(){
													if(showEnable == 1){
														showEnable = 0;
													if(showOpen == 0){
													  j$("#showbox").css("border","1px #ccc solid").animate({height:"500px"},300,function(){showOpen=1;showEnable = 1;});
													}
													else{
													  j$("#showbox").animate({height:"0px"},300,function(){showOpen=0;showEnable = 1;j$(this).css("border","none");});
													}
												}
											});
	j$("#copytexttitle").click(function(){j$(this).select()})
	j$("#copytextbody").click(function(){j$(this).select()})
	
}

function sendmailmagainit () {
	var options_sendmailmaga = { 
		target:'#sendmailmaga_msg',
		beforeSubmit:showRequest_sendmailmaga,
		success:showResponse_sendmailmaga,
		timeout:5000
	}; 
	j$('#sendmailmaga').ajaxForm(options_sendmailmaga);
	j$('#sendmailmaga_calc').val('5963');
}
function showRequest_sendmailmaga(formData, jqForm, options) {
	if (j$("#sendmailmaga_mad").val() == '') {
		j$("#sendmailmaga_msg").html('メールアドレスをご記入ください。');
		return false;
	}
	if(j$("#sendmailmaga_mad").val().match(/^[a-z0-9._%-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i)){
	}
	else {
		j$("#sendmailmaga_msg").html('正しいメールアドレスをご記入ください。');
		return false;
	}
	if(confirm('メールマガジン購読を登録します。\nよろしいですか？')) {
		j$("#sendmailmaga_send").attr("disabled", "1");
	}
	else {
		return false;
	}
}
function showResponse_sendmailmaga(responseText, statusText)  {
	j$("#sendmailmaga_send").attr("disabled", "1");
	j$("#sendmailmaga_mad").attr("disabled", "1");
	alert('ご登録ありがとうございました。');
} 

function sendmailmagastopinit () {
	var options_sendmailmagastop = { 
		target:'#sendmailmagastop_msg',
		beforeSubmit:showRequest_sendmailmagastop,
		success:showResponse_sendmailmagastop,
		timeout:3000
	}; 
	j$('#sendmailmagastop').ajaxForm(options_sendmailmagastop);
	j$('#sendmailmagastop_calc').val('5963');
}
function showRequest_sendmailmagastop(formData, jqForm, options) {

	if (j$("#sendmailmagastop_mad").val() == '') {
		j$("#sendmailmagastop_msg").html('メールアドレスをご記入ください。');
		return false;
	}

	if(j$("#sendmailmagastop_mad").val().match(/^[a-z0-9._%-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i)){
	}
	else {
		j$("#sendmailmagastop_msg").html('正しいメールアドレスをご記入ください。');
		return false;
	}

	if(confirm('送信します。\nよろしいですか？')) {
		j$("#sendmailmagastop_send").attr("disabled", "1");
	}
	else {
		return false;
	}
}

function showResponse_sendmailmagastop(responseText, statusText)  {
	j$("#sendmailmagastop_send").attr("disabled", false);
} 





function anbkon(target,targetimg) {
	target.stop()
		.animate({
			backgroundColor: "#f3f3f3"
		}, 400);
	targetimg.stop()
		.animate({
			opacity: 0.6
		}, 400);
}
function anbkof(target,targetimg) {
	target.stop()
		.animate({
			backgroundColor: '#ffffff'
		}, 400);
	targetimg.stop()
		.animate({
			opacity: 1
		}, 400);
}

function keyvisualAreainit() {
			imno=0;
			intv=6000;
			timerID = setInterval('chg()', intv);
			j$("#keyvisualareactrl div").hover(function () {
				imno= j$("#keyvisualareactrl div").index(this);
				clearInterval(timerID);
				timerID = setInterval('chg()', intv);
				chg();
			},function () {});
			chg();
}
			function chg() {
				j$("#keyvisualArea a:not(:eq("+imno+"))").hide();
				j$("#keyvisualArea a:eq("+imno+")").show();
				j$("#keyvisualareactrl").css("background-position","0px "+ imno * (-37)+"px");
				imno++;
				if (imno >= 5) {
					imno = 0;
				}
			}


function marqueeinit() {
	j$.getJSON("/twit/twittertl.json", function(json){
		for (i=0; i <= 9; i++) {
			j$("#marquee-slider").append("<div>"+json[i].text+"</div>");
		}
		marqueeinit2();
	});
}

function marqueeinit2() {
	var maqno = 0;
	var maqle = j$("#marquee-slider div").length -1;
	var speed = 60;
	scr();

function scr() {
	j$("#marquee-slider div").hide();
	j$("#marquee-slider").animate({marginLeft: '193px'}, 1, "linear",function() {
		j$("#marquee-slider div").show();
		var dwid = j$("#marquee-slider div:eq("+ maqno +")").width();
		var sltime = (193 + dwid) * 1000 / speed;
		j$("#marquee-slider div").hide();
		j$("#marquee-slider div:eq("+ maqno +")").show();
		j$("#marquee-slider").animate({marginLeft: '-'+ dwid +'px'}, sltime, "linear");
		maqno ++;
		if (maqno > maqle) {
			maqno = 0;
		}
		setTimeout(function(){ scr() }, sltime);
	});
}


}

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}

