/*スパム対策*/
<!--
function vspam(im,domain) {
  maddress = "mailto:" + im + "@" + domain;
  window.location.href = maddress;
}
// -->

//

var domain = window.location.hostname;
if(domain == ""){
	domain = "file:///Z:/00_active_client/ncool：新潟公務員法律専門学校/110215_サイトリニューアル2011/40_development/";
}else{
	domain = "http://ncool.colletomo.com/";
}


$(function(){
	
	pageScroll();
	
	//gn
	var bodyIdName = $("body").attr('id');
	if(bodyIdName == "index"){
		$("#g01 img").attr("src",domain + "/common/imgs/shared/gnav_01_on.jpg");
	}else if(bodyIdName == "ncool"){
		$("#g02 img").attr("src",domain + "/common/imgs/shared/gnav_02_on.jpg");
	}else if(bodyIdName == "guide"){
		$("#g03 img").attr("src",domain + "/common/imgs/shared/gnav_03_on.jpg");
	}else if(bodyIdName == "course"){
		$("#g04 img").attr("src",domain + "/common/imgs/shared/gnav_04_on.jpg");
	}else if(bodyIdName == "oc"){
		$("#g05 img").attr("src",domain + "/common/imgs/shared/gnav_05_on.jpg");
	}else if(bodyIdName == "seminar"){
		$("#g06 img").attr("src",domain +"/common/imgs/shared/gnav_06_on.jpg");
	}else if(bodyIdName == "admission"){
		$("#g07 img").attr("src",domain + "/common/imgs/shared/gnav_07_on.jpg");
	}else if(bodyIdName == "highschool"){
		$("#t01 img").attr("src",domain + "/common/imgs/shared/tnav_01_on.png");
	}else if(bodyIdName == "society"){
		$("#t02 img").attr("src",domain + "/common/imgs/shared/tnav_02_on.png");
	}else if(bodyIdName == "parent"){
		$("#t03 img").attr("src",domain + "/common/imgs/shared/tnav_03_on.png");
	}
	
	rollOver();
	
	//
	$("#breadList li:last").addClass("last");
	
	//
	$("#gNav ul li").hover(function(){
		$("ul:not(:animated)",this).fadeIn("fast");
	},
	function(){
		$("ul",this).fadeOut("fast");
	})
		
	//JC
	function mycarousel_initCallback(carousel){
    	// Disable autoscrolling if the user clicks the prev or next button.
    	carousel.buttonNext.bind('click', function() {
        	carousel.startAuto(0);
    	});

    	carousel.buttonPrev.bind('click', function() {
        	carousel.startAuto(0);
    	});

    	// Pause autoscrolling if the user moves with the cursor over the clip.
    	carousel.clip.hover(function() {
        carousel.stopAuto();
    	}, function() {
        	carousel.startAuto();
    	});
	};
	
	//fb
    $('#fBannerArea').jcarousel({
		scroll:1,							
        auto: 3,
		wrap: 'last',
        initCallback: mycarousel_initCallback
    });
	
	//pt
	var offset = $("#pageTop").offset();
	var topPadding = 300;
	$(window).scroll(function() {
		if ($(window).scrollTop() > offset.top) {
			$("#pageTop").stop().animate({
				marginTop: $(window).scrollTop() - offset.top + topPadding
			});
		} else {
			$("#pageTop").stop().animate({
				marginTop: 0
			});
		};
	});

	/*$(".entryBox li").hover(function() {
		$(this).css("background","#fffff4");
	}).mouseout(function() {
		$(this).css("background","#fff");
	}).click(function(){
		window.location=$(this).find("a").attr("href");
		return false;
    });
	*/

});


function pageScroll(){
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
   			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
   			if ($target.length) {
  				var targetOffset = $target.offset().top;
  				$('html,body')
  				.animate({scrollTop: targetOffset}, 1000);
    			return false;
			}
		}
 	});
}

function rollOver(){
	var postfix = '_on';
	$('#gNav img, #hNav img, #tNav img, .over').not('[src*="'+ postfix +'."]').each(function() {
		var img = $(this);
		var src = img.attr('src');
		var src_on = src.substr(0, src.lastIndexOf('.'))
		           + postfix
		           + src.substring(src.lastIndexOf('.'));
		$('<img>').attr('src', src_on);
		img.hover(
			function() {
				img.attr('src', src_on);
			},
			function() {
				img.attr('src', src);
			}
		);
	});
}

//画像preload
function preload(arrayOfImages) {
    $(arrayOfImages).each(function(){
        $('<img/>')[0].src = this;
        // Alternatively you could use:
        // (new Image()).src = this;
    });
}

function popupWin(url,wx,wy,wName){
	st = "scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no";
	if(wy == ''){
		wy = screen.height - (screen.height*0.15);
	}
	x = (screen.width  - wx) / 2;
	y = ((screen.height - wy) / 2) - 30;
	newwin = window.open(url,wName,"left="+x+",top="+y+",width="+wx+",height="+wy+","+st);
	newwin.focus();
}

