$(document).ready(function() {
	$(".mine").hide();
	$(window).resize(function() {
		changeCSS();
		centerV();
	});
	changeCSS();
	
	$('.slideshow').cycle({ 
	    fx:     'fade', 
	    speed:   1500, 
	    timeout: 1500
	});	
	$("div.homenavi a").hide();
	$("div.homenavi").not(".visited").find(".shape").hide();
	
	$("div.homenavi").not(".visited").hover(
		function(){
			$(this).find(".shape").show();
		},
		function(){
			$(this).find(".shape").hide();
		}
	);

	$("div.clk").click(function(){
		if ($(this).hasClass("gallery")){
			var section = "gallery";
		} else if ($(this).hasClass("beauty")){
			var section = "beauty";
		} else {
			var section = "coverage";
		}
		var current = $(this).find(".ci").html();
		var id = $(this).attr("id").replace("c","");
		var thisdiv = $(this);
		$.ajax({
			cache: false,
			type: "GET",
			url: "/php/getimage.php",
			dataType: "html",
			data: "id="+id+"&c="+current+"&sec="+section,
			success: function(resultdata) {
				$(thisdiv).html(resultdata);
			}
		});
	});


	$("div.homenavi").click(function(){
		var href = $(this).find("a").attr("href");
		window.location = href;
	});
	$("div.pagenavi").click(function(){
		var href = $(this).find("a").attr("href");
		window.location = href;
	});
	$("div.homenavi").each(function(){
		$(this).mousemove(function(e){
			$(this).find("a").show();
			var offset = $(this).offset();
			var os = $.client.os;
			if (os == "Windows"){
				var xoffset = 18;
			} else {
				var xoffset = 13;
			}
			$(this).find("a").css({
				top: (e.pageY + 0 - offset.top) + "px",
				left: (e.pageX + xoffset - offset.left) + "px"
			});
		});
	});
	$("div.homenavi").mouseout(function(e){
		$(this).find("a").hide();
    });
});


$(window).load(function() {
	if ($("#random").hasClass("scrolldown")){
		$("body, html").animate({ scrollTop: $(document).height() },400);
	}
	
	centerV();
	
	
});

function centerV(){
	$(".vc").each(function(){
		var wh = $(window).height();
		var th = $(this).height();
		var mt = (wh-th)/2;
		$(this).css("margin-top",mt+"px");
	})

}


function changeCSS(){
	var ww = $(window).width();
	var wh = $(window).height();
	if (ww >= 1440 && ww >= 900){
		$("#shapescss").attr("href","/css/s1440.css");
	} else if (ww >= 1024 && ww >= 750){
		$("#shapescss").attr("href","/css/s1024.css");
	} else {
		$("#shapescss").attr("href","/css/s800.css");
	}
	$(".mine").show();
}
