function setYear(){
	var d_obj = new Date();
	document.write(d_obj.getFullYear());
}

function swf_object(SWF,WID,HEI){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width='+ WID +' height='+ HEI +'>');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="allowFullScreen" value="false" />');
	document.write('<param name="movie" value="'+ SWF +'.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="'+ SWF +'.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width='+ WID +' height='+ HEI +' name="coverflow" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}
/*
function ladies_object(SWF,WID,HEI){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width='+ WID +' height='+ HEI +'>');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="allowFullScreen" value="false" />');
	document.write('<param name="movie" value="../swf/'+ SWF +'.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="../swf/'+ SWF +'.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width='+ WID +' height='+ HEI +' name="coverflow" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}
*/
function init() {
	smartRollover();
	photoChange();
	winClose();
	prepareLinks();
	border_none();
	getComment();
	tategaki("roommessage");
	tategaki("room");
}
window.onload=init;

//ロールオーバーイメージ
function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_out."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_out.", "_over."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_over.", "_out."));
				}
			}
		}
	}
}
/*
function setPng(){
	if(!document.getElementById("ladies") ){
		return false;
	}
	if(navigator.appVersion.indexOf("MSIE 6",0) != -1){
		var alpha_logo = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=images,src='../images/title/ladies.png')";
		Png("ladies",700,22,alpha_logo);
	}
}
function Png(pngID,WIDTH,HEIGHT,ALPHA){
	if(document.all){
		document.getElementById(pngID).style.width = WIDTH+"px";
		document.getElementById(pngID).style.height = HEIGHT+"px";
		document.getElementById(pngID).style.filter = ALPHA;
		document.getElementById(pngID).firstChild.style.display = "none";
	}
}
*/
function getComment(){
	if(!document.getElementById("lady_profile")){
		return false;
	}
	commentElement = document.getElementById("message");
	if(document.getElementById("movie")){
		commentElement.style.height = "290px";
	}
}

function border_none(){
	var all_link = document.links;
	for(i=0;i<all_link.length;i++){
		all_link[i].onfocus = function(){
			this.blur();
		}
	}
}
function photoChange(){

	if(!document.getElementById("image")){
		return;
	}
	
	
	var base = document.getElementById("image").getElementsByTagName("img")[0];
	base.style.display = "none";

	var imageList = new Array();
	for(i=1;i<=4;i++){
//		//imageList[i] = document.createElement("img");
		tmpImage = new Image();
		tmpImage.src = "pic0"+i+".jpg";
		imageList.push(tmpImage);
	}

	if(imageList[0].width > 300){
		base.style.marginBottom = "-50px";
		base.style.marginTop = "50px";
	}
	base.style.display = "";

	var sumArray = document.getElementsByTagName("img");
	for(i=0;i<sumArray.length;i++){

		if(sumArray[i].className == "thumb"){

			sumArray[i].onmouseover = function(){

				var targetImg = document.getElementById("image").getElementsByTagName("img")[0];

				var tmpSrc = this.src.split("thumb0");
				var tmpNumber = tmpSrc[1].split(".");
				var srcNumber = tmpNumber[0]-1;
				//var targetSrc = "pic"+tmpSrc[1];

				targetImg.src = imageList[srcNumber].src;
				
				if(imageList[srcNumber].height == 300){
					targetImg.style.marginBottom = "-50px";
					targetImg.style.marginTop = "50px";
				}else{
					targetImg.style.marginTop = "0";
				}
			
			}
		
		}
	
	}
}
function winClose(){
	if(!document.getElementById("close")){
		return false;
	}
	var btnClose = document.getElementById("close").lastChild;
	btnClose.onclick = function(){
		window.close();
	}
}

function prepareLinks() {
	if(!document.getElementsByTagName){
		return false;
	}
	var links = document.getElementsByTagName("a");
	for (var i=0; i<links.length; i++) {
		if(links[i].getAttribute("className") == "popup" || links[i].getAttribute("class") == "popup") {

			links[i].firstChild.style.filter = "alpha(opacity=70)";
			links[i].firstChild.style.opacity = "0.7";
				
			links[i].onclick = function() {
				popUp(this.getAttribute("href"));
				return false;
			}

			links[i].onmouseover = function() {
				this.firstChild.style.filter = "alpha(opacity=100)";
				this.firstChild.style.opacity = "1.0";
				return false;
			}
			links[i].onmouseout = function() {
				this.firstChild.style.filter = "alpha(opacity=70)";
				this.firstChild.style.opacity = "0.7";
				return false;
			}
		}
	}
}
function popUp(winURL) {
	var winFocus;
	winFocus = window.open(winURL,"popup","width=787,height=700,scrollbars=yes");
    winFocus.focus();
}


function tategaki(elementID){
	if(!document.getElementById(elementID)){
		return false;
	}
	fontset=new Array(
		["、","./images/font/ten.gif"],
		["【","./images/font/ue.gif"],
		["】","./images/font/shita.gif"]
	);
	str= document.getElementById(elementID).innerHTML;
	str=str.replace(/<br>/g,"＠");
	str=str.replace(/<BR>/g,"＠");
	str=str.match(/[^＠]+/gi);
	set= "<table><tr>";
	for(i=str.length;i>0;i--){
		set +="<td valign=top><table>";
		for(j=0; j<str[i-1].length; j++){
			for(k=0; k<fontset.length; k++){
				if(str[i-1].charAt(j)==fontset[k][0]){
					t='<img src="'+fontset[k][1]+'" width="11">';
					break;
				}else{
					t=str[i-1].charAt(j);
				}
			}
			set+="<tr><td>"+t+"</td></tr>";
		}
		set+="</table></td>";
	}
	set+="</tr></table>";
//	str=str.replace(\<strong\>,"<strong>");
	document.getElementById(elementID).innerHTML=set;
}


function pickupMovie(lady_id){
	//alert(lady_id);
	//document.write("../swf/pickmovie.swf?path=../movie/"+lady_id+".flv");
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="240" height="215">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="allowFullScreen" value="false" />');
	document.write('<param name="movie" value="./ladies/swf/pickupmovie.swf?path=../movie/'+ lady_id +'.flv" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="./ladies/swf/pickupmovie.swf?path=../movie/'+ lady_id +'.flv" quality="high" wmode="transparent" width="240" height="215" name="coverflow" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');

}