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 header() {
	if(!document.getElementById("index")){
		return false;
	}
	var head = document.getElementById("header");
	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="750" height="340">';
	setFlash +='<param name="allowScriptAccess" value="sameDomain" />';
	setFlash +='<param name="allowFullScreen" value="false" />';
	setFlash +='<param name="movie" value="./swf/index.swf" />';
	setFlash +='<param name="quality" value="high" />';
	setFlash +='<param name="wmode" value="transparent" />';
	setFlash +='<param name="bgcolor" value="#ffffff" />';
	setFlash +='<embed src="./swf/index.swf" quality="high" bgcolor="#ffffff" wmode="transparent" width="750" height="340" name="coverflow" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	setFlash +='</object>';
	var headflash = document.createElement("div");
		headflash.innerHTML =setFlash;
		headflash.style.position="absolute";
		headflash.style.top = 15+"px";
		headflash.style.left = 15+"px";
		headflash.style.zIndex = 1;
	//head.innerHTML =setFlash;
	head.appendChild(headflash);
}

function init() {
	if(navigator.userAgent.indexOf("Mac") != -1){
		document.body.style.letterSpacing = "-0.1em";
	}
	header();
	//pickupPng();
	//setpickPng();
	//crossfade("pickuplist",1000,3000);
	pickupCrossFade();
	setPng();
	smartRollover();
	photoChange();
	winClose();
	prepareLinks();
	border_none();
	IE_logo_link();
	setMovie();
	smartPhoneRedirect();
}
window.onload=init;

function setPng(){
	if(!document.getElementById("logo") ){
		return false;
	}
	if(navigator.appVersion.indexOf("MSIE 6",0) != -1){
		var alpha_logo = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src='../images/logo.png')";
		Png("logo",321,252,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";
	}
}
//ieロゴリンク
function IE_logo_link(){
	if(document.getElementById("logo")){
		if(navigator.appVersion.indexOf("MSIE") != -1){
			document.getElementById("logo").onclick = function(){
				location.href = "../top/";
			}
		}
	}
}

//ロールオーバーイメージ
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 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].onclick = 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];
				if(document.getElementById("movie")){
					document.getElementById("createMove").style.display ="none";
				}
				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");
	btnClose.onclick = function(){
		window.close();
	}
}

function prepareLinks() {
	if(!document.getElementsByTagName){
		return false;
	}
	if(	!document.getElementById("ladies") &&
		!document.getElementById("schedule_today") &&
		!document.getElementById("pickuplist")
		){
		return;
	}
	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=80)";
			//links[i].firstChild.style.opacity = "0.8";
				
			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=80)";
				this.firstChild.style.opacity = "0.8";
				return false;
			}*/
		}
	}
}
function popUp(winURL) {
	var winFocus;
	winFocus = window.open(winURL,"popup","width=715,height=650,scrollbars=no");
    winFocus.focus();
}

function crossfade(IDname , fadetime , speed){
	if(!document.getElementById(IDname)){
		return;
	}
	var news = document.getElementById(IDname);
	var newslinks = news.getElementsByTagName("li");
	if(newslinks.length == 1){
		return;
	}
	for(var i=0; i<newslinks.length; i++){
		newslinks[i].id = [i];
		newlength = new Array([i]);
	}
	for(var j=0; j<newslinks.length; j++){
		newlength[j]=[j];
	}
	new Crossfader(newlength, fadetime, speed );
}

var useBSNns;

if (useBSNns){
	if (typeof(bsn) == "undefined")
		bsn = {}
	var _bsn = bsn;
}else{
	var _bsn = this;
}

_bsn.Crossfader = function (divs, fadetime, delay ){
	this.nAct = -1;
	this.aDivs = divs;
	
	for (var i=0;i<divs.length;i++){
		document.getElementById(divs[i]).style.opacity = 0;
		document.getElementById(divs[i]).style.position = "absolute";
		document.getElementById(divs[i]).style.filter = "alpha(opacity=0)";
		document.getElementById(divs[i]).style.visibility = "hidden";
	}
	
	this.nDur = fadetime;
	this.nDelay = delay;
	this._newfade();
}

_bsn.Crossfader.prototype._newfade = function(){
	if (this.nID1)
		clearInterval(this.nID1);
	
	this.nOldAct = this.nAct;
	this.nAct++;
	if (!this.aDivs[this.nAct])	this.nAct = 0;
	
	if (this.nAct == this.nOldAct)
		return false;
	
	document.getElementById( this.aDivs[this.nAct] ).style.visibility = "visible";
	
	this.nInt = 50;
	this.nTime = 0;
	
	var p=this;
	this.nID2 = setInterval(function() { p._fade() }, this.nInt);
}

_bsn.Crossfader.prototype._fade = function(){
	this.nTime += this.nInt;
	
	var ieop = Math.round( this._easeInOut(this.nTime, 0, 1, this.nDur) * 100 );
	var op = ieop / 100;
	document.getElementById( this.aDivs[this.nAct] ).style.opacity = op;
	document.getElementById( this.aDivs[this.nAct] ).style.filter = "alpha(opacity="+ieop+")";
	
	if (this.nOldAct > -1){
		document.getElementById( this.aDivs[this.nOldAct] ).style.opacity = 1 - op;
		document.getElementById( this.aDivs[this.nOldAct] ).style.filter = "alpha(opacity="+(100 - ieop)+")";
	}
	
	if (this.nTime == this.nDur){
		clearInterval( this.nID2 );
		
		if (this.nOldAct > -1)
			document.getElementById( this.aDivs[this.nOldAct] ).style.visibility = "hidden";
		
		var p=this;
		this.nID1 = setInterval(function() { p._newfade() }, this.nDelay);
	}
}

_bsn.Crossfader.prototype._easeInOut = function(t,b,c,d){
	return c/2 * (1 - Math.cos(Math.PI*t/d)) + b;
}



function pickupPng() {
return;
	if(!document.getElementById("pickuplist") ){
		return false;
	}
	var puPng = document.createElement("div");
		puPng.id ="picklady";
		puPng.style.position="absolute";
		puPng.style.top = 0+"px";
		puPng.style.left = 0+"px";
		puPng.innerHTML ='<img src="./images/pucover.png" alt="ピックアップ" />';
		
//	if(navigator.appVersion.indexOf("MSIE 6",0) != -1){
	var pickPhoto = document.getElementById("pickuplist");
	pickPhoto.appendChild(puPng);
/*	}
	
	else {
	var pickPhoto = document.getElementById("pickuplist").getElementsByTagName("li");
		
			pickPhoto[0].appendChild(puPng);
			pickPhoto[1].appendChild(puPng);
	}
	photoLink = pickPhoto.getElementsByTagName("a");
	for (var i=0; i<photoLink.length; i++) {
		if(photoLink[i].getAttribute("className") == "popup" || photoLink[i].getAttribute("class") == "popup") {
			photoLink[i].onclick = function() {
				popUp(this.getAttribute("href"));
				return false;
			}
		}
	}

/*	pickPhoto.onclick = function(){
		popUp(this.getAttribute("href"));
	}*/
	
}
function setpickPng(){
	if(!document.getElementById("pickuplist") ){
		return false;
	}
	if(navigator.appVersion.indexOf("MSIE 6",0) != -1){
		var alpha_index = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src='./images/pucover.png')";
		Png("picklady",240,320,alpha_index);
	}
}


function setMovie(){

	if(!document.getElementById("movie")){
		return false;
	}
	var tmp_id = location.href.split("ladies/")[1];
	var lady_id = tmp_id.split("/")[0];
	var comment = document.getElementById("movie");
	


	var mPosi = document.getElementById("image");
	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="402" height="400">';
	setFlash +='<param name="allowScriptAccess" value="sameDomain" />';
	setFlash +='<param name="allowFullScreen" value="false" />';
	setFlash +='<param name="movie" value="../../ladies/swf/movie.swf?path=../movie/'+ lady_id +'.flv" />';
	setFlash +='<param name="quality" value="high" />';
	setFlash +='<param name="wmode" value="transparent" />';
	setFlash +='<param name="bgcolor" value="#ffffff" />';
	setFlash +='<embed src="../../ladies/swf/movie.swf?path=../movie/'+ lady_id +'.flv" quality="high" bgcolor="#ffffff" wmode="transparent" width="402" height="400" name="coverflow" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	setFlash +='</object>';
	var headflash = document.createElement("div");
	headflash.innerHTML =setFlash;
	headflash.id = "createMove";
	headflash.style.position="absolute";
	headflash.style.top = 0;
	headflash.style.left = 0;
	headflash.style.marginTop =40+"px";
	headflash.style.paddingLeft =0+"px";
	headflash.style.height =400+"px";
	headflash.style.width =402+"px";
	//headflash.style.background ="#ffffff";
	//headflash.style.opacity=0.5;
	//headflash.style.filter = "alpha(opacity=50)";
	//head.innerHTML =setFlash;
	mPosi.appendChild(headflash);
	headflash.style.display ="none";

	comment.onclick = function(){
		headflash.style.display ="inline";
	}
	
	
	
	
	
}


function pickupCrossFade(){
	
	if(!document.getElementById("pickuplist")){
		return;
	}
	if(document.getElementById("no_pickup")){
		document.getElementById("no_pickup").style.display = "block";
		return;
	}
	if(!document.getElementById("pickuplist").getElementsByTagName("li")){
		return;
	}
	if(document.getElementById("pickuplist").getElementsByTagName("li").length == 1){
		document.getElementById("pickuplist").getElementsByTagName("li")[0].style.display = "block";
		return;
	}
	var ulWrap = document.getElementById("pickuplist");
	ulWrap.style.position = "relative";
	//ulWrap.style.position = "relative";
	liList = ulWrap.getElementsByTagName("li");
	liList[0].style.display = "block";
	for(i=0;i<liList.length;i++){
		if(i != 0){
			liList[i].style.display = "none";
		}
		liList[i].style.opacity = "0";
		liList[i].style.position = "absolute";
		liList[i].style.zIndex = 100-i;
	
	}
	liList[0].style.opacity = "1";
	setInterval("alphaMaker()",60);

}

var nowOpacity = 100;
var nextOpacity = 0;
var nowTarget = 0;
var nextTarget = 1;
var waitLimit = 60;
var counter = 0;
var waitFlag = "on";

function alphaMaker(){
	

	targetFade = document.getElementById("pickuplist").getElementsByTagName("li");
	
	if(waitFlag == "on"){
		counter++;
		if(counter > waitLimit){
			waitFlag = "off";
			counter = 0;
		}
	}else{

		nowOpacity -= 8;
		nextOpacity += 8;

		if(nowOpacity > -1){

			if(!targetFade[nextTarget]){
				nextTarget = 0;
			}
			if(!targetFade[nowTarget]){
				nowTarget = 0;
			}
			targetFade[nextTarget].style.display = "block";
			if(navigator.userAgent.indexOf("MSIE") != -1){
				targetFade[nowTarget].style.filter = "alpha(opacity="+nowOpacity+")";
				targetFade[nextTarget].style.filter = "alpha(opacity="+nextOpacity+")";
			}else{
				targetFade[nowTarget].style.opacity = (nowOpacity/100);
				targetFade[nextTarget].style.opacity = (nextOpacity/100);
			}

		}else{

			targetFade[nowTarget].style.filter = "alpha(opacity=0)";
			targetFade[nextTarget].style.filter = "alpha(opacity=100)";
			targetFade[nowTarget].style.opacity = 0;
			targetFade[nextTarget].style.opacity = 1;
			
			targetFade[nowTarget].style.display = "none";
		
			nowTarget++;
			nextTarget++;
			nowOpacity = 100;
			nextOpacity = 0;
			
			waitFlag = "on";
		}
	}
}

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.whiteSpace = "nowrap";
			btn.style.textShadow = "0px -1px 1px #004800";
			btn.style.border = "solid 1px #004800";
			btn.style.background = "-webkit-gradient(linear, left top, left bottom, from(#59c259), to(#004800))";
			
			btn.innerHTML = 'スマートフォン版はコチラ';
			
			btn.onclick = function(){
				
				document.cookie = "mode=sp;path=/;";
				
				host_name = location.host;
				now_url = location.href;
				urlArray = now_url.split(host_name);
				spURL = urlArray.join(host_name+"/sp");
				spURL = spURL.replace("link/","");

				location.href = spURL;
			}

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

}

