$(function(){
//	$('a[rel=lightbox]').lightBox({fixedNavigation:false});
	$('a[rel=window]').live("click",function(){
		var url = $(this).attr("href");
		window.open(url,'','')
		return false;
	});

	//女性詳細
	$("a[rel=girldetail]").live("click",function(){
		var url = $(this).attr("href");

		var Left=((screen.width-820)/2);
		var Top=((screen.height-800)/2);

		var lady = window.open(url, 'ladyDetail', 'width=820,height=800, left='+Left+', top='+Top+', status=1, menubar=0, scrollbars=1, resizable=0');
		if(window.focus){ lady.focus(); }
		return false;
	});

	$("a[rel=newsLink]").live("click",function(){
		var newsurl = $(this).attr("href");

		$.ajax({
			type: "get",
			url: newsurl,
			cache: false,
			beforeSend: function(){
				$("#newsComment").html("<img src='/img/loading.gif' />");
			},
			dataType: "html",
			success: function(data){
				$("#newsComment").show().html(data);
			}
		});

		return false;
	});

	$("a[rel=photolink]").live("click",function(){
		var photourl = $(this).attr("href");

		$.ajax({
			type: "get",
			url: photourl,
			cache: false,
			beforeSend: function(){
				$("#mailBox").html("<img src='/img/loading.gif' />");
			},
			dataType: "html",
			success: function(data){
				$("#mailBox").show().html(data);
			}
		});

		return false;
	});

	$("a[rel=topicsLink]").live("click",function(){
		var topicsurl = $(this).attr("href");

		$.ajax({
			type: "get",
			url: topicsurl,
			cache: false,
			beforeSend: function(){
				$("#topicsComment").html("<img src='/img/loading.gif' />");
			},
			dataType: "html",
			success: function(data){
				$("#topicsComment").show().html(data);
			}
		});

		return false;
	});

	var x,y,scrollTop,mouseY, mouseX,scrollLeft;
	$(window.document).mousemove(function(e){
		x = e.pageX;
		y = e.pageY;
		mouseY = e.pageY;
		mouseX = e.pageX;
		$("#loading").css("left",x);
		$("#loading").css("top",y);
//		scrollTop = window.pageYOffset || document.documentElement.scrollTop;
		scrollFigure = document.documentElement.scrollTop || document.body.scrollTop;
		scrollTop = document.documentElement.clientHeight || document.body.scrollHeight;
		scrollTop = scrollTop + (scrollFigure*2);
		scrollLeft = document.documentElement.clientWidth || window.innerWidth;

	});

    $("#bookmark").click(function(){
        var a='http://www.machioku.com/';
        b=document.title;
        s=window.sidebar;

        if(/*@cc_on!@*/false){
            external.AddFavorite(a,b)
        }else if(s){
            s.addPanel(b,a,'')
        }else{
            alert('非対応です')
        };

        return false;
    });

    initRollovers();
});
//rollover
function initRollovers() {
	if (!document.getElementById) return

	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}

			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}
