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 +'.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();
	winClose();
	prepareLinks();
	border_none();
	setMovie();
	photoScroll();
	//setclassPng();
	//alert("");
	
	
	//*********************************
	//	イベント用関数呼び出し
	//
	//setEventImgs();
	//popupWindow(340, 535, "event", "event");
	//closeWindow();
	//
	//
	//*********************************
	
	
	//********* 年末年始ご案内用 ***********
	
	//nenmatsu("12/31～1/3はお休み致します。", "#ff0000", 230, 24);
	
	//********* 年末年始ご案内用 ***********
	
	
}
window.onload=init;


function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}







//****エロ汁熟女用関数ここから
/**
 *	ツールチップを用意し、非表示にしておく
 *	マウスオーバー・マウスアウトで表示/非表示を切り替える
 */
var setEventImgs = function() {
	var pTag = document.getElementsByTagName("p");
	for(i = 0; i < pTag.length; i++) {
		if(pTag[i].className == "photo") {
			var ladyImg = pTag[i];
			var tooltip = document.createElement("div");
			tooltip.id = "tooltip";
			tooltip.style.display = "none";
			ladyImg.appendChild(tooltip);
		}
	}
		
	var aTag = document.getElementsByTagName("a");
	for(j = 0; j < aTag.length; j++) {
		if(aTag[j].className == "event") {
			aTag[j].onmouseover = function() {
				this.parentNode.lastChild.style.display = "";
			}
			aTag[j].onmouseout = function() {
				this.parentNode.lastChild.style.display = "none";
			}
		}
	}
}


/**
 *	ポップアップウィンドウ
 *	引数は「幅」・「高さ」・「対象とするクラス名」・「ターゲット名」の4個
 *
 */
var popupWindow = function(_width, _height, _className, _targetName) {
	var options = "width=" + _width + ",height=" + _height + ",scrollbars=no";
	var _open = function(url) {
		var newWindow = window.open(url, _targetName, options);
		newWindow.focus();
	}
	
	var links = document.getElementsByTagName("a");
	for(var i = 0; i < links.length; i++) {
		if(links[i].className == _className) {
			links[i].onclick = function() {
				_open(this.getAttribute("href"));
				return false;
			}
		}
	}
}

/**
 *	ポップアップウィンドウを閉じる関数
 *
 */
var closeWindow = function() {
	if(!document.getElementById("closeBtn")) {
		return false;
	}
	var btn = document.getElementById("closeBtn");
	btn.onclick = function() {
		window.close();
	}
}
//**エロ汁関数ここまで









//********* 年末年始のご案内 ********************************
//
var nenmatsu = function(_desc, _color, _top, _left) {
	if(document.getElementById("lady_logo")) {
		return false;
	}
	var header = document.getElementById("header");
	//header.style.position = "relative";
	
	var annai = document.createElement("p");
	var eigyo = document.createTextNode("-年末年始営業のご案内-");
	var br = document.createElement("br");
	var desc = document.createTextNode(_desc);
	
	annai.appendChild(eigyo);
	//annai.appendChild(br);
	annai.appendChild(desc);
	header.appendChild(annai);
	
	annai.style.position = "absolute";
	annai.style.top = _top + "px";
	annai.style.left = _left + "px";
	annai.style.fontSize = 14 + "px";
	annai.style.fontWeight = "bold";
	annai.style.color = _color;
}
//***********************************************************





addLoadEvent(top_object);

function top_object() {
	if(!document.getElementById("top_contents")){
		return false;
	}
	var topMove = document.getElementById("top_contents");
	var setFlash = '<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="890" height="220">';
	setFlash +='<param name="allowScriptAccess" value="sameDomain" />';
	setFlash +='<param name="allowFullScreen" value="false" />';
	setFlash +='<param name="movie" value="./swf/top_movie.swf" />';
	setFlash +='<param name="quality" value="high" />';
	setFlash +='<param name="wmode" value="transparent" />';
	setFlash +='<param name="bgcolor" value="#ffffff" />';
	setFlash +='<embed src="./swf/top_movie.swf" quality="high" bgcolor="#ffffff" wmode="transparent" width="890" height="220" name="coverflow" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	setFlash +='</object>';
	topMove.innerHTML =setFlash;
}

//ロールオーバーイメージ
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 border_none(){
	var all_link = document.links;
	for(i=0;i<all_link.length;i++){
		all_link[i].onfocus = function(){
			this.blur();
		}
	}
}

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].onclick = function() {
				popUp(this.getAttribute("href"));
				return false;
			}
		}
	}
}
function popUp(winURL) {
	var winFocus;
    if(window.screen.height <=700){
		winFocus = window.open(winURL,"popup","width=510,height=680,scrollbar=yes");
    }
    winFocus = window.open(winURL,"popup","width=517,height=670,scrollbars=yes");
    winFocus.focus();
}
/*---------------------------------*/
var moveArea = "";
var interval = "";
var nowX = 0;
var photoCount = 1;
function photoScroll(){
	if(!document.getElementById("scroll")){
		return;
	}
	var parentDiv = document.getElementById("scroll");
	var moveParam = 0;
	var interval = "";
	
	var leftBtn = parentDiv.getElementsByTagName("li")[0].getElementsByTagName("img")[0];
	var rightBtn = parentDiv.getElementsByTagName("li")[1].getElementsByTagName("img")[0];
	moveArea = parentDiv.getElementsByTagName("div")[0];
	
	var photoList = moveArea.getElementsByTagName("img");
	var moveAreaWidth = 0;
	for(i=0;i<photoList.length;i++){
		moveAreaWidth += photoList[i].width;
	}
	moveArea.style.width = moveAreaWidth+"px";
	//moveArea.style.overflow = "auto";
	
	if(photoList.length == 1){
		leftBtn.style.display = "none";
		rightBtn.style.display = "none";
	}else{
		rightBtn.style.display = "block";
	}
	
	leftBtn.onclick = function(){
		photoCount--;
		if(photoCount == 1){
			this.style.display = "none";
			rightBtn.style.display = "block";
		}else{
			rightBtn.style.display = "block";
		}
		moveParam += 300;
		clearInterval(interval);
		interval = setInterval("scrollAction("+moveParam+")",1);
	}
	
	rightBtn.onclick = function(){
		photoCount++;
		if(photoCount == photoList.length){
			leftBtn.style.display = "block";
			this.style.display = "none";
		}else{
			leftBtn.style.display = "block";
		}
		moveParam -= 300;
		clearInterval(interval);
		interval = setInterval("scrollAction("+moveParam+")",1);
	}
}

function scrollAction(targetX){
//moveArea.parentNode.style.overflow = "visible";
	if(nowX < (targetX+1) && nowX > (targetX-1)){
		nowX = targetX;
		clearInterval(interval);
		moveArea.style.left = nowX+"px";
		return;
	}
	nowX += (targetX-nowX)/8;
	moveArea.style.left = nowX+"px";

}

function setMovie(){

	if(!document.getElementById("movie") || !document.getElementById("scroll")){
		return;
	}

	var tmp_id = location.href.split("ladies/")[1];
	var lady_id = tmp_id.split("/")[0];
	var movieBtn = document.getElementById("movie");
	movieBtn.getElementsByTagName("a")[0].removeAttribute("href");
	movieBtn.style.cursor = "pointer";

	movieBtn.onclick = function(){
		/*swf = makePlayer(lady_id);
		swf.style.position = "absolute";
		swf.style.top = "40px";
		swf.style.left = "35px";
		document.body.appendChild(swf);*/
		window.open("../swf/movie.swf?path=../movie/"+lady_id+".flv","movie","width=430,height=410");
	}
}

function makePlayer(lady_id){
	
	var obj = document.createElement("div");
	obj.innerHTML = "<embed/>";
	flash = obj.firstChild;
	flash.src = "../swf/movie.swf";
	flash.quality = "high";
	flash.height = "410";
	flash.width = "430";
	flash.setAttribute("wmode","transparent");
	flash.setAttribute("FlashVars","path=../movie/"+lady_id+".flv");
	flash.setAttribute("type","application/x-shockwave-flash");
	flash.setAttribute("pluginspage","http://www.macromedia.com/go/getflashplayer");
	
	return flash;

}

function pickupMovie(lady){
	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="180">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="allowFullScreen" value="false" />');
	document.write('<param name="movie" value="swf/pickup_movie.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<param name="FlashVars" value="path=../ladies/movie/'+lady+'.flv" />');
	document.write('<embed src="swf/pickup_movie.swf" FlashVars="path=../ladies/movie/'+lady+'.flv" quality="high" wmode="transparent" bgcolor="#ffffff" width="240" height="180" name="coverflow" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}