/**
 * author Remy Sharp
 * url http://remysharp.com/2009/01/26/element-in-view-event-plugin/
 */
(function ($) {
    function getViewportHeight() {
        var height = window.innerHeight; // Safari, Opera
        var mode = document.compatMode;

        if ( (mode || !$.support.boxModel) ) { // IE, Gecko
            height = (mode == 'CSS1Compat') ?
            document.documentElement.clientHeight : // Standards
            document.body.clientHeight; // Quirks
        }

        return height;
    }

    $(window).scroll(function () {
        var vpH = getViewportHeight(),
            scrolltop = (document.documentElement.scrollTop ?
                document.documentElement.scrollTop :
                document.body.scrollTop),
            elems = [];
        
        // naughty, but this is how it knows which elements to check for
        $.each($.cache, function () {
            if (this.events && this.events.inview) {
                elems.push(this.handle.elem);
            }
        });

        if (elems.length) {
            $(elems).each(function () {
                var $el = $(this),
                    top = $el.offset().top,
                    height = $el.height(),
                    inview = $el.data('inview') || false;

                if (scrolltop > (top + height) || scrolltop + vpH < top) {
                    if (inview) {
                        $el.data('inview', false);
                        $el.trigger('inview', [ false ]);                        
                    }
                } else if (scrolltop < (top + height)) {
                    if (!inview) {
                        $el.data('inview', true);
                        $el.trigger('inview', [ true ]);
                    }
                }
            });
        }
    });
    
    // kick the event to pick up any elements already in view.
    // note however, this only works if the plugin is included after the elements are bound to 'inview'
    $(function () {
        $(window).scroll();
    });
})(jQuery);
$(function () {
	$('nav #nav1,nav #nav2,nav #nav3,nav #nav4,nav #nav5').localScroll(); 
	$("body").height($(window).height() + 9476 );　$(window).scroll(function() {
	if 
	($(window).scrollTop() >= ($("body").height() - $(window).height())) {　$(window).scrollTop(1);}
	else if 
	($(window).scrollTop() == 0) {　$(window).scrollTop($("body").height() - $(window).height() - 1);}});
	
	$(window).scroll(function () {
		var ScrTop = $(document).scrollTop();

		$('body').val(ScrTop);

		if ($('body').val() < 1629) {
			$("nav li a").removeClass("active");
			$("nav li#nav1 a").addClass("active");
		}
		if ($('body').val() > 1629) {
			$("nav li a").removeClass("active");
			$("nav li#nav2 a").addClass("active");
		}
		if ($('body').val() > 2981) {
			$("nav li a").removeClass("active");
			$("nav li#nav3 a").addClass("active");
		}
		if ($('body').val() > 4966) {
			$("nav li a").removeClass("active");
			$("nav li#nav4 a").addClass("active");
		}
		if ($('body').val() > 6580) {
			$("nav li a").removeClass("active");
			$("nav li#nav5 a").addClass("active");
		}
		if ($('body').val() > 9704) {
			$("nav li a").removeClass("active");
			$("nav li#nav6 a").addClass("active");
		}
	});
});



/* =================================

================================= */
onload = function() {
  draw1();
  draw2();
  draw3();
  draw4();
  draw5();
  draw6();
  draw7();
  draw8();
  draw9();
  draw10();
  draw11();
  draw12();
  draw13();
};
function draw1() {
  var canvas = document.getElementById('c1');
  if ( ! canvas || ! canvas.getContext ) { return false; }
  var ctx = canvas.getContext('2d');
  ctx.beginPath();
  ctx.fillStyle = '#B4E9E2';
  ctx.rect(0,0, 5000,655);
  ctx.fill();
}
function draw2() {
  var canvas = document.getElementById('c2');
  if ( ! canvas || ! canvas.getContext ) { return false; }
  var ctx = canvas.getContext('2d');
  ctx.beginPath();
  ctx.fillStyle = '#B4E9E2';
  ctx.rect(0,0, 5000,655);
  ctx.fill();
}
function draw3() {
  var canvas = document.getElementById('c3');
  if ( ! canvas || ! canvas.getContext ) { return false; }
  var ctx = canvas.getContext('2d');
  ctx.beginPath();
  ctx.fillStyle = '#B4E9E2';
  ctx.rect(0,0, 5000,655);
  ctx.fill();
}
function draw4() {
  var canvas = document.getElementById('c4');
  if ( ! canvas || ! canvas.getContext ) { return false; }
  var ctx = canvas.getContext('2d');
  ctx.beginPath();
  ctx.fillStyle = '#B4E9E2';
  ctx.rect(0,0, 5000,655);
  ctx.fill();
}
function draw5() {
  var canvas = document.getElementById('c5');
  if ( ! canvas || ! canvas.getContext ) { return false; }
  var ctx = canvas.getContext('2d');
  ctx.beginPath();
  ctx.fillStyle = '#B4E9E2';
  ctx.rect(0,0, 5000,655);
  ctx.fill();
}
function draw6() {
  var canvas = document.getElementById('c6');
  if ( ! canvas || ! canvas.getContext ) { return false; }
  var ctx = canvas.getContext('2d');
  ctx.beginPath();
  ctx.fillStyle = '#B4E9E2';
  ctx.rect(0,0, 5000,655);
  ctx.fill();
}
function draw7() {
  var canvas = document.getElementById('c7');
  if ( ! canvas || ! canvas.getContext ) { return false; }
  var ctx = canvas.getContext('2d');
  ctx.beginPath();
  ctx.fillStyle = '#B4E9E2';
  ctx.rect(0,0, 5000,655);
  ctx.fill();
}
function draw8() {
  var canvas = document.getElementById('c8');
  if ( ! canvas || ! canvas.getContext ) { return false; }
  var ctx = canvas.getContext('2d');
  ctx.beginPath();
  ctx.fillStyle = '#B4E9E2';
  ctx.rect(0,0, 5000,655);
  ctx.fill();
}
function draw9() {
  var canvas = document.getElementById('c9');
  if ( ! canvas || ! canvas.getContext ) { return false; }
  var ctx = canvas.getContext('2d');
  ctx.beginPath();
  ctx.fillStyle = '#B4E9E2';
  ctx.rect(0,0, 5000,655);
  ctx.fill();
}
function draw10() {
  var canvas = document.getElementById('c10');
  if ( ! canvas || ! canvas.getContext ) { return false; }
  var ctx = canvas.getContext('2d');
  ctx.beginPath();
  ctx.fillStyle = '#B4E9E2';
  ctx.rect(0,0, 5000,655);
  ctx.fill();
}
function draw11() {
  var canvas = document.getElementById('c11');
  if ( ! canvas || ! canvas.getContext ) { return false; }
  var ctx = canvas.getContext('2d');
  ctx.beginPath();
  ctx.fillStyle = '#B4E9E2';
  ctx.rect(0,0, 5000,655);
  ctx.fill();
}
function draw12() {
  var canvas = document.getElementById('c12');
  if ( ! canvas || ! canvas.getContext ) { return false; }
  var ctx = canvas.getContext('2d');
  ctx.beginPath();
  ctx.fillStyle = '#B4E9E2';
  ctx.rect(0,0, 5000,655);
  ctx.fill();
}
function draw13() {
  var canvas = document.getElementById('c13');
  if ( ! canvas || ! canvas.getContext ) { return false; }
  var ctx = canvas.getContext('2d');
  ctx.beginPath();
  ctx.fillStyle = '#FFF';
  ctx.rect(0,0, 5000,655);
  ctx.fill();
}


document.createElement("section");
document.createElement("article");
document.createElement("aside");
document.createElement("header");
document.createElement("footer");
document.createElement("nav");
document.createElement("dialog");
document.createElement("figure");
document.createElement("audio");
document.createElement("video");
document.createElement("embed");
document.createElement("m");
document.createElement("meter");
document.createElement("time");
document.createElement("canvas");
document.createElement("command");
document.createElement("datagrid");
document.createElement("details");
document.createElement("datalist");
document.createElement("datatemplate");
document.createElement("rule");
document.createElement("nest");
document.createElement("event-source");
document.createElement("output");
document.createElement("progress");





$(function() {
	$(".popup").click(function(){
		window.open(this.href, "privacy","width=680,height=900,resizable=yes,scrollbars=yes");
		return false;
	});
});


















