/*
 * common.js
 *
 */
 


// onload event set
//
window.onload = function () { 
	if(typeof fontSize == "object"){
		fontSize.init();
	}
	if(typeof swapImage == "object"){
		swapImage.init();
	}
}


// popup
//
function fWinClosed(winVar) {
var ua = navigator.userAgent
	if( !!winVar )
		if( ( ua.indexOf('Gecko')!=-1 || ua.indexOf('MSIE 4')!=-1 ) && ua.indexOf('Win')!=-1 ) 
				return winVar.closed
			else return typeof winVar.document  != 'object'
	else return true
}
function fOpenWin(theURL,targetName,theW,theH) {
	if(fWinClosed(tWin)){
		var tWin = window;
		tWin = open(theURL,targetName,'scrollbars=yes,resizable=yes,toolbar=no,location=yes,directories=no,status=yes,menubar=no,width='+theW+',height='+theH+'');
		tWin.focus();
	}
}

// window close
//
function close_win(){
	var nvua = navigator.userAgent;
		if(nvua.indexOf('MSIE') >= 0){
			if(nvua.indexOf('MSIE 5.0') == -1) {
				top.opener = '';
			}
		}
		else if(nvua.indexOf('Gecko') >= 0){
			top.name = 'CLOSE_WINDOW';
			wid = window.open('','CLOSE_WINDOW');
		}
	top.close();
}


// easing
//
jQuery.easing.quart = function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

// page scroll
//
jQuery(document).ready(function(){
    jQuery('a[href*=#]').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var $target = jQuery(this.hash);
            $target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                jQuery('html,body').animate({ scrollTop: targetOffset }, 1200, 'quart');
                return false;
            }
        }
    });
});

// div click
jQuery(document).ready(function(){
	jQuery('div.dClick').click(function(){
		window.location = jQuery(this).find('a').attr('href');
		return false;
	});
});

jQuery(document).ready(function(){
	jQuery('div.dClick').hover(function(){
		jQuery(this).css('background-color', '#B8DEE4');
	}, function(){
		jQuery(this).css('background-color', '#e3e3e3');
	});
});

jQuery(document).ready(function(){
	jQuery('div.dColor').hover(function(){
		jQuery(this).css('background-color', '#B8DEE4');
	}, function(){
		jQuery(this).css('background-color', '#e3e3e3');
	});
});
