//プリロード
img_another=new Image();
img_another.src='another.gif';


function imgView(aaa,w,h,m_file,comment){
/*
	x=window.event.clientX;
	y=window.event.clientY;
	document.getElementById("imgWin_diary_illusts").style.left=x;
	document.getElementById("imgWin_diary_illusts").style.top=y;
*/
	if(comment == 0)comment='';
	document.getElementById("imgWin_diary_illusts").style.display="block";
	var str ="";
	str = str+'<div id="dip_diary_illusts"><a href="#;" onclick="imgDel()"><img src="close_red.gif" style="width:16px; height:16px;" border="0"></a>';
	if(m_file != 0){
/*		str = str+'　<a href="calender.php?L='+m_file+'">でかいの</a>';*/
		str = str+'　<a href="#;" onclick="lImageopen(\'LimageArea\',\''+m_file+'\');">でかいの</a>';
	}
	str = str+'<br>';
	str = str+'<img src="'+aaa+'" width="'+w+'" height="'+h+'" style="border:1px solid #999999;"><br>';
	str = str+'<p align="center" style="margin:0px; margin-top:5px; font-size:80%;">'+comment+'</p></div>';
	outputLAYER("imgWin_diary_illusts",str);
}

//--------------------------------------------------------------------
//--XMLHttpRequestオブジェクト生成関数 
// 書式 createHttpRequest()
// 例   httpoj = createHttpRequest()
// 戻値 XMLHttpRequestオブジェクトまたはnull
// http://allabout.co.jp/career/javascript/closeup/CU20030920/index.htm
//--------------------------------------------------------------------
function createHttpRequest(){
	if(window.ActiveXObject){
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				return null;
	 		}
	 	}
	} else if(window.XMLHttpRequest){
		return new XMLHttpRequest();
	} else {
		return null;
	}
}

/*絵日記イラストのレーティング変更関数*/
function illut_rating(illust_id,rate){
	var ajaxOBJ = createHttpRequest();
	/*IE対策。タイムスタンプを付与してキャッシュを抑制*/
	var date = new Date();
	var timestamp = date.getTime();
	rateChangePhpUrl="AjaxRateChange.php?iid="+illust_id+"&r="+rate+"&time=" + timestamp;
	ajaxOBJ.open("GET", rateChangePhpUrl);
	ajaxOBJ.onreadystatechange = function() {
		if (ajaxOBJ.readyState == 4 && ajaxOBJ.status == 200) {
			document.getElementById("showRate"+illust_id).innerHTML = ajaxOBJ.responseText;
		}else{
			document.getElementById("showRate"+illust_id).innerHTML = '<IMG src="images/now_loading.gif" ALT="" class="nowloading">';
		}
	}
	ajaxOBJ.send("");
}



function imgView_favorite(file_path,w,h,m_file,a_file,w2,h2,comment,rating,year,month,month2,date2){
	if(comment == 0)comment='';
	document.getElementById("imgWin_diary_illusts").style.display="block";
	var str ="";
	str = str+'<div id="dip_diary_illusts"><a href="#;" onclick="imgDel()"><img src="close_red.gif" style="width:16px; height:16px;" border="0"></a>';
	if(m_file != 0){
		str = str+'<a href="javascript:void(0);" onclick="lImageopen(\'LimageArea\',\''+m_file+'\',\''+w2+'\',\''+h2+'\');"><img src="large.gif" title="でかいの" width="80" height="16" alt="でかいの" border="0" style="margin-left:5px;"></a>';
	}
	if(a_file != 0){
		str = str+'<a href="javascript:void(0);" onclick="lImageopen(\'LimageArea\',\''+a_file+'\',\''+w2+'\',\''+h2+'\');"><img src="another.gif" title="別版" width="80" height="16" alt="別版" border="0" style="margin-left:5px;"></a>';
	}
	str = str+'<br>';
	str = str+'<img src="'+file_path+'" width="'+w+'" height="'+h+'" style="border:1px solid #999999;"><br>';
	str = str+'<p align="center" style="margin:0px; margin-top:5px; font-size:95%;">'+comment+'<br>';
/* 日記へのリンク前削除 2011.02.11
	if(year>=2007){
		str=str+'<a href="http://www.finetrick.net/diary/index.html?p='+year+','+month2+','+date2+'#'+date2+'" class="honbun">＜日記＞</a></p>';
	}else{
		str=str+'</p>';
	}
*/
	str=str+'</p>';

	str = str+'<form action="calender.php?day='+file_path.substr(8,8)+'" method="POST" style="margin:0px; padding:5px; text-align:center;">';
	str = str+'<table cellspacing="0" cellpadding="5" border="0" style="width:100%; border:1px dotted #dddd99; background-color:#ffffcc;" align="center"><tr><td width="60%" align="center">';
	str = str+'(<span style="color:red;" id="showRate'+year+month2+date2+'">'+rating+'</span>)[ 評価 ]：';
	str = str+'<input type="button" class="rate_cahge" name="rating_down" id="rating_down" value="−" onclick="illut_rating(\''+year+month2+date2+'\',-1)">';
	str = str+'<input type="button" class="rate_cahge" name="rating_up" id="rating_up" value="+" onclick="illut_rating(\''+year+month2+date2+'\',1)">';
	str = str+'<input type="hidden" name="target_name" value="'+file_path+'">';
	str = str+'<input type="hidden" name="year" value="'+year+'">';
	str = str+'<input type="hidden" name="month" value="'+month+'">';
	str = str+'</td></tr></table>';
	str = str+'</form>';
//	str = str+'<p style="text-align:right; margin:0px; padding:0px; padding-right:5px;"><a href="details.php?illust='+file_path+'" target="detail" onclick="window.open(\'details.php?illust='+file_path+'\', \'detail\', \'width=800,height=600,scrollbars=yes\'); "><img src="admin.gif" width="70" height="19" border="0"></a></p>';
	str = str+'</div>';
	illut_rating(year+month2+date2,0);
	outputLAYER("imgWin_diary_illusts",str);
}


function lImageopen(open,imgFile,w,h){
	eval(open).style.display='block';
	document.getElementById('overlay').style.display='block';
	w_position=-w/2;
	document.getElementById(open).style.marginLeft=w_position;
	document.getElementById(open).innerHTML='<a href="#;" onclick="lImageclose(\''+open+'\');"><img src="close_button.gif" width="16" height="16" alt="閉じる" border="0" style="margin:5px;"></a><br><div style="padding:10px; padding-top:5px; padding-bottom:20px; margin:0px; background-color:#ffffff;"><img src="'+imgFile+'" alt="拡大" style="border:1px solid #cccccc;"></div>';
}

function lImageclose(hide){
	document.getElementById('overlay').style.display='none';
	eval(hide).style.display='none';
}


function imgDel(){
/*
	document.getElementById("imgWin_diary_illusts").style.display="none";
*/
	none="";
	outputLAYER("imgWin_diary_illusts",none);
}
	
function outputLAYER(layName,html){
	if(document.getElementById){        //N6,Moz,IE5,IE6用
	  document.getElementById(layName).innerHTML=html
	
	} else if(document.all){                       //IE4用
	  document.all(layName).innerHTML=html
	
	} else if(document.layers) {                   //NN4用
	   with(document.layers[layName].document){
	     open()
	     write(html)
	     close()
	  }
	}
}

/*
function send_date(date){
//	alert(date);
}
*/

function subWindow(ON,OFF){
	eval(ON).style.display='block';
	eval(OFF).style.display='none';
}

function closeMenu(OBJ){
	eval(OBJ).style.display='none';
}
