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="bgcolor" value="#090909" />');
	document.write('<embed src="'+ SWF +'.swf" quality="high"  bgcolor="#090909" 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() {
	crossfade("pickuplist",1000,3000);
	smartRollover();
	border_none();
	setPng();
	winClose();
	prepareLinks();
	photoChange();
	favorite('bookmark','http://www.momohimechan.com/','桃姫');
	setMovie();

}
window.onload=init;




function setPng(){
	if(!document.getElementById("menu") ){
		return false;
	}
	if(navigator.appVersion.indexOf("MSIE 6",0) != -1){
	var menuCover = document.createElement("div");
		menuCover.id ="cover";
		menuCover.style.position="absolute";
		menuCover.style.top = 0+"px";
		menuCover.style.left = 0+"px";
		menuCover.innerHTML ='<img src="./images/menuCover.png" width="820" height="61" />';
	var menu = document.getElementById("menu");
		menu.appendChild(menuCover);
		var alpha_logo = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src='../images/menuCover.png')";
		Png("cover",820,61,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 setclassPng(){
	if(!document.getElementById("rankTitle") ){
		return false;
	}
	if(navigator.appVersion.indexOf("MSIE 6",0) != -1){
		var alpha_up = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src='./images/heart.png')";
		classPng("heart",61,58,alpha_up);

	}
}

function classPng(pngClass,WIDTH,HEIGHT,ALPHA){
	var alphaArray = document.getElementsByTagName("div");
	for(i=0;i<alphaArray.length;i++){
		if(alphaArray[i].getAttribute("className") == pngClass || alphaArray[i].getAttribute("class") == pngClass){
			alphaArray[i].style.width = WIDTH+"px";
			alphaArray[i].style.height = HEIGHT+"px"
			alphaArray[i].style.filter = ALPHA;
			alphaArray[i].firstChild.style.display = "none";
		}
	}
}
//ieロゴリンク
function IE_logo_link(){
	if(document.getElementById("logo")){
		if(navigator.appVersion.indexOf("MSIE") != -1){
			document.getElementById("logo").style.cursor ="pointer";
			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 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.marginTop = "50px";
				}else{
					targetImg.style.marginTop = "0";
				}
			
			}
		
		}
	
	}
}

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");
	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;
    winFocus = window.open(winURL,"popup","width=697,height=600,scrollbars=yes");
    winFocus.focus();
}

function favorite(markID,markURL,markTitle){
	if(!document.getElementById(markID)){
		 return false;
	}
	var bookmark = document.getElementById(markID);
	if(navigator.userAgent.indexOf("Opera",0) != -1){
		var elem = document.createElement("a");
		elem.href = markURL;
		elem.title = markTitle;
		elem.rel = "sidebar";
		var str = bookmark.ParentNode;
		elem.appendChild(str);
		str.appendChild(elem);
	}
	bookmark.onclick =function(){
	if(navigator.appVersion.indexOf("MSIE",0) != -1){
			window.external.AddFavorite(markURL,markTitle);
		}else if(navigator.userAgent.indexOf("Firefox",0) != -1){
			window.sidebar.addPanel(markTitle,markURL,'');
		}else if(navigator.userAgent.indexOf("Opera",0) != -1){
			return;
		}else{
			alert("WindowsはCtrl+D | MacはCmd+D を押して手動でブックマークして下さい。");
		}
	}
}




function crossfade(IDname , fadetime , speed){
	if(!document.getElementById(IDname)){
		return;
	}
	var news = document.getElementById(IDname);
	var newslinks = news.getElementsByTagName("li");
	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 setMovie(){

	if(!document.getElementById("movie")){
		return false;
	}
	var element = document.createElement("div");
	element.id = "black";
	document.body.insertBefore(element,document.body.firstChild);
	element.style.display = "none";
	//フレームを含む高さの振り分け//
	if(navigator.appVersion.indexOf("MSIE 6",0) != -1){
		element.style.height = document.body.clientHeight;
	}else if(navigator.userAgent.indexOf("Firefox",0) != -1){
		element.style.height = document.documentElement.clientHeight + window.scrollMaxY +"px";
	}else{
		element.style.height =  document.body.scrollHeight +"px";
	}

	//divを作成しidをつけ、最初に作ったdivの直下(bodyから2つ目)に設置//
	var iframe = document.createElement("div");
	iframe.id= "lady";
	document.body.insertBefore(iframe,document.body.firstChild.nextSibling);
	iframe.style.display = "none";
	

	var tmp_id = location.href.split("ladies/")[1];
	var lady_id = tmp_id.split("/")[0];
	var comment = document.getElementById("movie");
	
	var movieBtn =document.createElement("div");
	movieBtn.id = "createMove";
	
	comment.appendChild(movieBtn);
	comment.onclick = function(){

		//var moveFocus;
		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="430" height="410">';
		setFlash +='<param name="allowScriptAccess" value="sameDomain" />';
		setFlash +='<param name="allowFullScreen" value="false" />';
		setFlash +='<param name="movie" value="../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="../swf/movie.swf?path=../movie/'+lady_id+'.flv" quality="high" bgcolor="#ffffff" wmode="transparent" width="430" height="410" name="coverflow" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		setFlash +='</object>';
		setFlash +='<p id="moveclose"> close </p>';
		iframe.innerHTML = setFlash;
		iframe.style.width = "430px";
		iframe.style.left = "50%";
		iframe.style.marginLeft ="-215px";
		element.style.display = "inline";
		iframe.style.display = "inline";
		if(document.documentElement.scrollTop){
			newTop = document.documentElement.scrollTop;
		}else{
			newTop = document.body.scrollTop;
		}
		iframe.style.top = newTop + "px" ;
		//表示・非表示の実行//
		element.onclick = function(){
			element.style.display = "none";
			iframe.style.display = "none";
			iframe.firstChild.removeAttribute("src");
		}
		document.getElementById("moveclose").onclick = function(){
			element.style.display = "none";
			iframe.style.display = "none";
			iframe.firstChild.removeAttribute("src");
		}
		return false;
	}
}


