/**
 * jQuery.ScrollTo
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 3/9/2009
*/
;(function( $ ){
	
	var $scrollTo = $.scrollTo = function( target, duration, settings ){
		$(window).scrollTo( target, duration, settings );
	};

	$scrollTo.defaults = {
		axis:'xy',
		duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1
	};

	// Returns the element that needs to be animated to scroll the window.
	// Kept for backwards compatibility (specially for localScroll & serialScroll)
	$scrollTo.window = function( scope ){
		return $(window).scrollable();
	};

	// Hack, hack, hack... stay away!
	// Returns the real elements to scroll (supports window/iframes, documents and regular nodes)
	$.fn.scrollable = function(){
		return this.map(function(){
			var elem = this,
				isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) != -1;

				if( !isWin )
					return elem;

			var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem;
			
			return $.browser.safari || doc.compatMode == 'BackCompat' ?
				doc.body : 
				doc.documentElement;
		});
	};

	$.fn.scrollTo = function( target, duration, settings ){
		if( typeof duration == 'object' ){
			settings = duration;
			duration = 0;
		}
		if( typeof settings == 'function' )
			settings = { onAfter:settings };
			
		if( target == 'max' )
			target = 9e9;
			
		settings = $.extend( {}, $scrollTo.defaults, settings );
		// Speed is still recognized for backwards compatibility
		duration = duration || settings.speed || settings.duration;
		// Make sure the settings are given right
		settings.queue = settings.queue && settings.axis.length > 1;
		
		if( settings.queue )
			// Let's keep the overall duration
			duration /= 2;
		settings.offset = both( settings.offset );
		settings.over = both( settings.over );

		return this.scrollable().each(function(){
			var elem = this,
				$elem = $(elem),
				targ = target, toff, attr = {},
				win = $elem.is('html,body');

			switch( typeof targ ){
				// A number will pass the regex
				case 'number':
				case 'string':
					if( /^([+-]=)?\d+(\.\d+)?(px)?$/.test(targ) ){
						targ = both( targ );
						// We are done
						break;
					}
					// Relative selector, no break!
					targ = $(targ,this);
				case 'object':
					// DOMElement / jQuery
					if( targ.is || targ.style )
						// Get the real position of the target 
						toff = (targ = $(targ)).offset();
			}
			$.each( settings.axis.split(''), function( i, axis ){
				var Pos	= axis == 'x' ? 'Left' : 'Top',
					pos = Pos.toLowerCase(),
					key = 'scroll' + Pos,
					old = elem[key],
					Dim = axis == 'x' ? 'Width' : 'Height';

				if( toff ){// jQuery / DOMElement
					attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] );

					// If it's a dom element, reduce the margin
					if( settings.margin ){
						attr[key] -= parseInt(targ.css('margin'+Pos)) || 0;
						attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0;
					}
					
					attr[key] += settings.offset[pos] || 0;
					
					if( settings.over[pos] )
						// Scroll to a fraction of its width/height
						attr[key] += targ[Dim.toLowerCase()]() * settings.over[pos];
				}else
					attr[key] = targ[pos];

				// Number or 'number'
				if( /^\d+$/.test(attr[key]) )
					// Check the limits
					attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max(Dim) );

				// Queueing axes
				if( !i && settings.queue ){
					// Don't waste time animating, if there's no need.
					if( old != attr[key] )
						// Intermediate animation
						animate( settings.onAfterFirst );
					// Don't animate this axis again in the next iteration.
					delete attr[key];
				}
			});

			animate( settings.onAfter );			

			function animate( callback ){
				$elem.animate( attr, duration, settings.easing, callback && function(){
					callback.call(this, target, settings);
				});
			};

			// Max scrolling position, works on quirks mode
			// It only fails (not too badly) on IE, quirks mode.
			function max( Dim ){
				var scroll = 'scroll'+Dim;
				
				if( !win )
					return elem[scroll];
				
				var size = 'client' + Dim,
					html = elem.ownerDocument.documentElement,
					body = elem.ownerDocument.body;

				return Math.max( html[scroll], body[scroll] ) 
					 - Math.min( html[size]  , body[size]   );
					
			};

		}).end();
	};

	function both( val ){
		return typeof val == 'object' ? val : { top:val, left:val };
	};

})( jQuery );

//Shadowbox Setting

var openShadowbox = function(content, player, title, width, height){

    Shadowbox.open({
		content: content,
		player: player,
		title: title,
		width: width,
		height: height
    });
};

var closeShadowbox = function(){
    parent.Shadowbox.close();
};
//<a href="javascript:void();" onclick="closeShadowbox();">xxxx</a>

	Shadowbox.loadSkin('classic', '/common/js/shadowbox/skin');
	Shadowbox.loadLanguage('en', '/common/js/shadowbox/lang');
	Shadowbox.loadPlayer(['html', 'iframe', 'img'], '/common/js/shadowbox/player');


	$(function() {
    Shadowbox.init();
});



//PopUp Window
function popitup(url,winname,width,height,scrollbars)
{
        newwindow=window.open(url,winname,'width='+width+',height='+height+',top=30,left=10,resizable=yes,scrollbars='+scrollbars+',menubar=no,toolbar=no,directories=no,location=no,status=no');
        if (window.focus) {newwindow.focus()}
        return false;
}



//Copyright Get Year

function thisYear(){
var day=new Date();
var year=day.getFullYear();
return document.write(year);
}


//Page Anc Scroll
 $(function() {  
   $('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 - 20;  
        $('html,body')  
          .animate({scrollTop: targetOffset}, 800);  
         return false;  
      }  
     }  
   });  
 });  


//Search

			function goDown(){
			$('#Results').ScrollTo(600);
			}
			function goUp(){
			$('#GlobalNavi').ScrollTo(600);
			}
			function writeHTML(obj){
			$("#Results").html(obj);
			}
			function resizeSWF(targ,heig){
			$(targ).height(heig);
			}
			function help(mess){
			alert(mess);
			}


//Bookmark
function bookmark(address,sitename) {
	if (window.sidebar) {
	window.sidebar.addPanel(sitename, address,"");
	} else if( document.all ) {
	window.external.AddFavorite(address, sitename);
	} else if( window.opera && window.print ) {

	return true;
	}else {
	alert("Ctrl + D を押してください")
	}
}


//Hide Content Timer

function HideContent(id,year,month,date,hour,minute) {
	var dn = new Date();
	var dt = new Date(year,month-1,date,hour,minute);

	if(dn.getTime() > dt.getTime()){
		$(id).css("display","none");
	}else{
	}
}

//Open Content Timer

function OpenContent(id,year,month,date,hour,minute) {
	var dn = new Date();
	var dt = new Date(year,month-1,date,hour,minute);

	if(dn.getTime() > dt.getTime()){
		$(id).css("display","block");
	}else{
	}
}

/*
 * IE PNG Fix v1.4
 *
 * Copyright (c) 2006 Takashi Aida http://www.isella.com/aod2/
 *
 */

// IE5.5+ PNG Alpha Fix v1.0RC4
// (c) 2004-2005 Angus Turnbull http://www.twinhelix.com

// This is licensed under the CC-GNU LGPL, version 2.1 or later.
// For details, see: http://creativecommons.org/licenses/LGPL/2.1/

if (typeof IEPNGFIX == 'undefined') {
//--============================================================================

var IEPNGFIX = {
	blank:  'https://www.can-do.co.jp/api/pngfix/blank.gif',
	filter: 'DXImageTransform.Microsoft.AlphaImageLoader',

	fixit: function (elem, src, method) {
		if (elem.filters[this.filter]) {
			var filter = elem.filters[this.filter];
			filter.enabled = true;
			filter.src = src;
			filter.sizingMethod = method;
		}
		else {
			elem.style.filter = 'progid:' + this.filter +
				'(src="' + src + '",sizingMethod="' + method + '")';
		}
	},

	fixwidth: function(elem) {
		if (elem.currentStyle.width == 'auto' &&
			elem.currentStyle.height == 'auto') {
			elem.style.width = elem.offsetWidth + 'px';
		}
	},

	fixchild: function(elem, recursive) {
		if (!/MSIE (5\.5|6\.|7\.)/.test(navigator.userAgent)) return;

		for (var i = 0, n = elem.childNodes.length; i < n; i++) {
			var childNode = elem.childNodes[i];
			if (childNode.style) {
				if (childNode.style.position) {
					childNode.style.position = childNode.style.position;
				}
				else {
					childNode.style.position = 'relative';
				}
			}
			if (recursive && childNode.hasChildNodes()) {
				this.fixchild(childNode, recursive);
			}
		}
	},

	fix: function(elem) {
		if (!/MSIE (5\.5|6\.|7\.)/.test(navigator.userAgent)) return;

		var bgImg =
			elem.currentStyle.backgroundImage || elem.style.backgroundImage;

		if (elem.tagName == 'IMG') {
			if ((/\.png$/i).test(elem.src)) {
				this.fixwidth(elem);
				this.fixit(elem, elem.src, 'scale');
				elem.src = this.blank;
				elem.runtimeStyle.behavior = 'none';
			}
		}
		else if (bgImg && bgImg != 'none') {
			if (bgImg.match(/^url[("']+(.*\.png)[)"']+$/i)) {//
				var s = RegExp.$1;
//'
				this.fixwidth(elem);
				elem.style.backgroundImage = 'none';
				this.fixit(elem, s, 'scale'); // crop | image | scale

				if (elem.tagName == 'A' && elem.style) {
					if (!elem.style.cursor) {
						elem.style.cursor = 'pointer';
					}
				}

				this.fixchild(elem);
				elem.runtimeStyle.behavior = 'none';
			}
		}
	},

	hover: function(elem, hvImg) {
		var bgImg = elem.style.backgroundImage;

		if (!bgImg && elem.currentStyle) bgImg = elem.currentStyle.backgroundImage;

		if (elem.tagName == 'IMG' && hvImg) {
			var image = elem.src;
			elem.onmouseover = function() {
				elem.src = hvImg;
				IEPNGFIX.fix(elem);
			};
			elem.onmouseout = function() {
				elem.src = image;
				IEPNGFIX.fix(elem);
			};
		}
		else if (bgImg && bgImg != 'none' && hvImg) {
			elem.onmouseover = function() {
				elem.style.backgroundImage = 'url(' + hvImg + ')';
				IEPNGFIX.fix(elem);
			};
			elem.onmouseout = function() {
				elem.style.backgroundImage = bgImg;
				IEPNGFIX.fix(elem);
			};
		}

		IEPNGFIX.fix(elem);
	}
};

//--============================================================================
} // end if (typeof IEPNGFIX == 'undefined')



