var agent = navigator.userAgent;
var isIE = /*@cc_on!@*/0;
var version = 0;
if (isIE) {
	version = parseFloat(agent.match(/MSIE\s(\d+\.\d+)/)[1]);
}
;(function(jQuery) {
	// easing function for the flow
	jQuery.extend(jQuery.easing,{
		easeInBack: function (x, t, b, c, d, s) {
			if (s == undefined) s = 1.70158;
			return c*(t/=d)*t*((s+1)*t - s) + b;
		},
		easeOutQuart: function (x, t, b, c, d) {
			return -c * ((t=t/d-1)*t*t*t - 1) + b;
		},
		easeOutBack: function (x, t, b, c, d, s) {
			if (s == undefined) s = 1.70158;
			return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
		},
		easeOutQuad: function (x, t, b, c, d) {
			return -c *(t/=d)*(t-2) + b;
		},
		easeOutElastic: function (x, t, b, c, d) {
			var s=1.70158;var p=0;var a=c;
			if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
			if (a < Math.abs(c)) { a=c; var s=p/4; }
			else var s = p/(2*Math.PI) * Math.asin (c/a);
			return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
		},
		cubicEaseOut: function(p, n, firstNum, diff) {
			var c = firstNum + diff;
			return c*((p=p/1-1)*p*p + 1) + firstNum;
		}
	});

	jQuery.fn.machange = function(){
		var mad = jQuery(this);
		var refobj = mad.text();
		var dot = new RegExp("\-dot\-","g");
		refobj = refobj.replace("\-atmark\-","@").replace(dot,".");
		//mad.replaceChild(document.createTextNode(refobj),mad.firstChild);
		mad.empty().append(refobj);
		mad.attr('href','mailto:'+refobj);
	}



})(jQuery);

jQuery(function(jQuery){

	jQuery.preloadCssImages();
	if (!isIE) {
		jQuery('<link rel="stylesheet" type="text/css" href="http://www.voice.sc/common/voice2010/style/modern.css" />').appendTo('head');
	}
	jQuery('h1#logo a').hover(
		function() {
			jQuery('h1#logo').css({
				backgroundPosition: '50% -50px'
			});
		},
		function() {
			jQuery('h1#logo').css({
				backgroundPosition: '50% 0'
			});
		}
	);
	jQuery('dl.company dt').empty().css({
		'width': '120px',
		'height': '30px',
		'background': 'url(http://www.voice.sc/common/voice2010/style/images/logo_sb.png) no-repeat 0 50%'
	});
	jQuery('a.thickbox').fancybox({
		hideOnContentClick: true,
		titlePosition: 'over'
	});
	jQuery('#mad').machange();

	jQuery("#nav ul").lavaLamp({
		fx    : "easeOutElastic",
		speed : 600,
		click : function(event, menuItem) {
		}
	});
	if(isIE && version < 7) {
		DD_belatedPNG.fix('#nav ul li.back, dl.company dt');
	}
	if(isIE && version < 8) {
		jQuery('hr#more').replaceWith('<div class="hr"></div>');
		if(isIE && version < 7) {
			DD_belatedPNG.fix('div.hr');
			// itab
			DD_belatedPNG.fix('#itab ul.archivelist');
		}
	}

	if (isIE) {
		jQuery('#covercatch').css('display','block');
		if(isIE && version < 7) {
			DD_belatedPNG.fix('#covercatch');
		}
	} else {
		jQuery('#covercatch').hide(0).fadeIn(1000);
	}

	jQuery('#pnavi a').click(function(){
		jQuery.scrollTo('#header', 600, {easing:'easeOutBack'});
		return false;
	});

	jQuery('.footnavheader h3 a').css({
	}).toggle(
		function(){
			jQuery('#footnav').animate({height: '100px'},500, 'easeOutBack', function() {
				jQuery.scrollTo('+=100px', 500, {easing:'easeOutQuart'});
			});
			return false;
		},
		function(){
			jQuery('#footnav').animate({height: '0'}, 500, 'easeOutBack');
			return false;
		}
	);

	if (isIE) {
		if (version > 6) {
		jQuery('.container').corner({
			tl: { radius: 6 },
			tr: { radius: 6 },
			bl: { radius: 6 },
			br: { radius: 6 },
			antiAlias: true,
			autoPad: true,
			validTags: ["div"]
		});
		}
		jQuery('.footnavheader h3 a').corner({
			tl: { radius: 4 },
			tr: { radius: 4 },
			bl: { radius: 0 },
			br: { radius: 0 },
			antiAlias: true,
			autoPad: true,
			validTags: ["a"]
		});
		jQuery('#bmenu').corner({
			tl: { radius: 0 },
			tr: { radius: 0 },
			bl: { radius: 6 },
			br: { radius: 6 },
			antiAlias: true,
			autoPad: true,
			validTags: ["div"]
		});
		jQuery('#footer .pnavi a').corner({
			tl: { radius: 0 },
			tr: { radius: 0 },
			bl: { radius: 4 },
			br: { radius: 4 },
			antiAlias: true,
			autoPad: true,
			validTags: ["a"]
		});
		jQuery('.nlink a, .prev a, .next a').corner({
			tl: { radius: 5 },
			tr: { radius: 5 },
			bl: { radius: 5 },
			br: { radius: 5 },
			antiAlias: true,
			autoPad: true,
			validTags: ["a"]
		});
		jQuery('div.popupcal dd.events ul').corner({
			tl: { radius: 5 },
			tr: { radius: 5 },
			bl: { radius: 5 },
			br: { radius: 5 },
			antiAlias: true,
			autoPad: true,
			validTags: ["ul"]
		});
		jQuery('blockquote').corner({
			tl: { radius: 5 },
			tr: { radius: 5 },
			bl: { radius: 5 },
			br: { radius: 5 },
			antiAlias: true,
			autoPad: true,
			validTags: ["blockquote"]
		});

	}

	var cyclesec = 4;
	var cycleh = jQuery('#news').height();
	var cyclesize = jQuery('#news ul li').size();
	var cyclecnt = 0;

	var newsslides = function() {
		setTimeout( function() {
			cyclecnt++;
			jQuery('#news ul').animate({ 
				marginTop: '-=20'
			}, cyclesec*100 ,function() {
				if (cyclecnt < cyclesize) {
					newsslides();
				} else {
					cyclecnt = 0;
					jQuery('#news ul').css('marginTop',0);
					newsslides();
				}

			});
		}, cyclesec*1000);
	};
	newsslides();

});