/* ***********************************

	横浜市交通安全協会
	commmon.js
	2011.02
	要　jQuery1.4.2
	
************************************ */

/*  popup
---------------------------------------------------------- */

function popup(sLocation, sWindowName){
	//alert('pop');
	var setMenubar = "no";
	var setToolbar = "no";
	var setLocation = "yes";
	var setDirectories = "no";
	var setStatus = "yes";
	var setScrollbars = "yes";
	var setResizable = "yes";

	var setCondition = "width=600,height=600,left=10,top=10,menubar=" + setMenubar + ",toolbar=" + setToolbar + ",location=" + setLocation + ",directories=" + setDirectories + ",status=" + setStatus + ",scrollbars=" + setScrollbars + ",resizable=" + setResizable;
	var setWindow = window.open(sLocation, sWindowName, setCondition);
	setWindow.focus();
	//return false;
}

function popup_live(sLocation, sWindowName){
	var setMenubar = "no";
	var setToolbar = "no";
	var setLocation = "yes";
	var setDirectories = "no";
	var setStatus = "yes";
	var setScrollbars = "yes";
	var setResizable = "yes";

	var setCondition = "width=660,height=600,left=10,top=10,menubar=" + setMenubar + ",toolbar=" + setToolbar + ",location=" + setLocation + ",directories=" + setDirectories + ",status=" + setStatus + ",scrollbars=" + setScrollbars + ",resizable=" + setResizable;
	var setWindow = window.open(sLocation, sWindowName, setCondition);
	setWindow.focus();
	return false;
}

function popup_map(sLocation, sWindowName){
	//alert('pop');
	var setMenubar = "no";
	var setToolbar = "no";
	var setLocation = "yes";
	var setDirectories = "no";
	var setStatus = "yes";
	var setScrollbars = "yes";
	var setResizable = "yes";

	var setCondition = "width=600,height=430,left=10,top=10,menubar=" + setMenubar + ",toolbar=" + setToolbar + ",location=" + setLocation + ",directories=" + setDirectories + ",status=" + setStatus + ",scrollbars=" + setScrollbars + ",resizable=" + setResizable;
	var setWindow = window.open(sLocation, sWindowName, setCondition);
	setWindow.focus();
	//return false;
}

function popup_enq(sLocation, sWindowName){
	//alert('pop');
	var setMenubar = "no";
	var setToolbar = "no";
	var setLocation = "yes";
	var setDirectories = "no";
	var setStatus = "yes";
	var setScrollbars = "yes";
	var setResizable = "yes";

	var setCondition = "width=700,height=600,left=30,top=10,menubar=" + setMenubar + ",toolbar=" + setToolbar + ",location=" + setLocation + ",directories=" + setDirectories + ",status=" + setStatus + ",scrollbars=" + setScrollbars + ",resizable=" + setResizable;
	var setWindow = window.open(sLocation, sWindowName, setCondition);
	setWindow.focus();
	//return false;
}


/* 背景色変更
---------------------------------------------------------- */
$(function(){
	var yDate = new Date();
	var nowH = yDate.getHours();
	var con = $('#container');
	
	if(18 <= nowH || nowH <= 4){
		con.removeClass('con_day').addClass('con_night');
	}
	if(16 <= nowH && nowH <= 18){
		con.removeClass('con_day').addClass('con_evening');
	}
	
});





/* nav_g active
---------------------------------------------------------- */
$(function(){
	var fullLoc = String(document.location);
	var locArray = fullLoc.split("/");
	var gLoc = locArray[3]; //alert(gLoc);
	//var gLoc_2 = locArray[4];
	var Btn = $('#nav li a');
	
	// gloval navigation
	Btn.each(function(){
		var th = String(this.href);
		var linkLocArray = th.split("/");
		var linkLoc = linkLocArray[3];
		if(linkLoc == gLoc){
			$(this).parent().addClass('ac');
		}
	});

});



/*  
---------------------------------------------------------- */
$(function(){
	// クラス名「blank」のリンクは別ウィンドウで開く
	$("a.blank").attr({target: "_blank"});
	$("a.parent").attr({target: "_parent"});
		   
	// アンカースクロール
	$("a[href^='#']").click(function(){$.scrollTo($(this).attr("href"),{axis:'y',duration:500,easing:'swing',queue:true});return false;});
	
	// リンクをポップアップで開く
	$('a.popup').each(function(){
		var L = $(this).attr('href');
		var W = $(this).attr('rel');
		$(this).attr('href','javascript:popup("'+ L +'","'+ W +'");');
	});
	$('a.popup').bind('click',function(event){
		event.stopPropagation();
	});
	
	
	// IE6PNG対策
	if (typeof document.body.style.maxHeight != "undefined") {
		
	} else {
		// IE6, older browsers
		setTimeout("DD_belatedPNG.fix('.pngfix')",50);
	}
	
});





