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="bgcolor" value="#000000" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="./swf/'+ SWF +'.swf" quality="high" wmode="transparent" bgcolor="#000000" 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() {
	photoChange();
	smartRollover();
	border_none();
	setMovie();
	favorite('bookmark','http://mama-2.net/','かあさんのひみつパート２');
}

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 border_none(){
	var all_link = document.links;
	for(i=0;i<all_link.length;i++){
		all_link[i].onfocus = function(){
			this.blur();
		}
	}
}



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.firstChild;
		elem.appendChild(str);
		bookmark.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("Ctrl+Dを押して手動でブックマークして下さい。");
		}
	}
}


function photoChange(){

	if(document.getElementById("image")){
	
		var base = document.getElementById("image").getElementsByTagName("img")[0];
		base.style.display = "none";

		var imageList = new Array();
		for(i=0;i<3;i++){
			tmpImage = new Image();
			tmpImage.src = "pic0"+(i+1)+".jpg";
			imageList.push(tmpImage);
		}

		if(imageList[0].width > 225){
			base.style.marginTop = "40px";
		}
		base.style.display = "";

		var sumArray = document.getElementsByTagName("img");
		for(i=0;i<sumArray.length;i++){

			if(sumArray[i].className == "ladySum"){
			
				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;
					
					targetImg.src = imageList[srcNumber].src;
					
					if(imageList[srcNumber].height == 225){
						targetImg.style.marginTop = "40px";
					}else{
						targetImg.style.marginTop = "0";
					}
				}
			}
		}
	}
}

function setMovie(){
	if(!document.getElementById("movie")){
		return false;
	}
	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(){
		window.open("../swf/movie.swf?path=../movie/"+lady_id+".flv","movie","width=430,height=410");
	}
}
