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();
//	IE_logo_link();
	tategaki("roommessage");
	tategaki("room");
	smartPhoneRedirect();
}
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];

	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);
	}

	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;
				
			
			}
		
		}
	
	}
}
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>');

}

function smartPhoneRedirect(){

	if(document.getElementById("image")){
		return;
	}
	

	var career = new Array("iPhone",  			// Apple iPhone
							"iPod", 			// Apple iPod touch
							"incognito", 		// Other iPhone browser
							"webmate", 			// Other iPhone browser
							"Android", 			// 1.5+ Android
							"dream", 			// Pre 1.5 Android
							"CUPCAKE", 			// 1.5+ Android
							"blackberry9500",	// Storm
							"blackberry9530",	// Storm
							"blackberry9520",	// Storm v2
							"blackberry9550",	// Storm v2
							"blackberry 9800",	// Torch
							"webOS",			// Palm Pre Experimental
							"s8000", 			// Samsung Dolphin browser
							"bada",				// Samsung Dolphin browser
							"Googlebot-Mobile"	// the Google mobile crawler
						);

	var user = navigator.userAgent;
	
	for(i=0;i<career.length;i++){
		
		if(user.indexOf(career[i]) != -1){
			
			var btn = document.createElement("div");
			btn.style.fontFamily = 'Meiryo,"ヒラギノ角ゴ Pro W3","Hiragino Kaku Gothic Pro W3","ＭＳ Ｐゴシック",sans-serif';
			btn.style.fontSize = "36px";
			btn.style.cursor = "pointer";
			btn.style.textAlign = "center";
			btn.style.margin = "0";
			btn.style.padding = "0";
			btn.style.fontWeight = "bold";
			btn.style.width = "100%";
			btn.style.height = "100px";
			btn.style.lineHeight = "100px";
			btn.style.color = "#ffffff";
			btn.style.textShadow = "0px -1px 1px #000000";
			btn.style.border = "solid 1px #b6429f";
			btn.style.background = "-webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#cc6699))";
			
			btn.innerHTML = 'スマートフォン版はコチラ';
			
			btn.onclick = function(){
				
				document.cookie = "mode=sp;path=/;";
				location.href = "/sp/";

			}
			document.body.insertBefore(btn,document.body.firstChild);
			
			break;
		}
	}
	return;

}

