$().ready(function(){
//global current ///////////////////////////////
var thisURL = location.href;
$('#globalNavi a').each(function(){
var linkURL = $(this).attr('href');
if (thisURL.match(linkURL)){
var thisSRC = $(this).children('img').attr('src').replace('.gif','_o.gif');
$(this).children('img').attr('src',thisSRC);
$(this).children('img').removeClass();
}
});

//menu current ///////////////////////////////
$('.parent a').each(function(){
var linkURL = $(this).attr('href');
if (thisURL.match(linkURL)){
$(this).parent('li').children('ul').show();
var thisSRC = $(this).children('img').attr('src').replace('.gif','_current.gif');
$(this).addClass('default');
$(this).children('img').attr('src',thisSRC);
$(this).children('img').removeClass();
}
});

//menu accordion ///////////////////////////////////////////

$('#acc1').click(function(){
$(this).children('a').blur().addClass('default');;
$(this).children('a').children('img').attr('src','/common/images/menu/menu02_00_current.gif');
$(this).children('ul').slideDown({easing:"easeInSine", duration:500});
$('#acc2').children('ul').slideUp({easing:"easeInSine", duration:500});
$('#acc2').children('a').children('img').attr('src','/common/images/menu/menu03_00.gif');
$('#acc2').children('a').removeClass('default');
});
$('#acc2').click(function(){
$(this).children('a').blur().addClass('default');
$(this).children('a').children('img').attr('src','/common/images/menu/menu03_00_current.gif');
$(this).children('ul').slideDown({easing:"easeInSine", duration:500});
$('#acc1').children('ul').slideUp({easing:"easeInSine", duration:500});
$('#acc1').children('a').children('img').attr('src','/common/images/menu/menu02_00.gif');
$('#acc1').children('a').removeClass('default');
});

//biggerLink ////////////////////////////////////////
$('.linkBox').biggerlink();

//Footer Copyright Year////////////////////////////////////////
$('address span').text(new Date().getFullYear());


//categoryIndex bigger Link ///////////////////////////////////
$('.idx2').bind('mouseenter',function(){
var thisIMG = $(this).children('dt').children('a').children('img');
var thisIMG2 = $(this).children('dd').children('.photo').children('img');
/*thisIMG.attr( 'src', PEPS.rollover.newimage(thisIMG.attr('src')) );*/
thisIMG2.attr( 'src', PEPS.rollover.newimage(thisIMG2.attr('src')) );
});

$('.idx2').bind('mouseleave',function(){
var thisIMG = $(this).children('dt').children('a').children('img');
var thisIMG2 = $(this).children('dd').children('.photo').children('img');
/*thisIMG.attr( 'src', PEPS.rollover.oldimage(thisIMG.attr('src')) );*/
thisIMG2.attr( 'src', PEPS.rollover.oldimage(thisIMG2.attr('src')) );
});

//IE6 Round Border Fix////////////////////////////
if ($.browser.msie && $.browser.version <= 6){
$('.round').each(function(){
var roundHeight = $(this).height();
if( roundHeight % 2 == 0){}
else { $(this).height(roundHeight + 1); }
});

var roundWidth = $('.wrapper').width() - 428;
if( roundWidth % 2 == 0){ $("#contents").css('margin-right','210px'); }
else { $("#contents").css('margin-right','209px'); }
$(window).resize(function(){
var roundWidth = $('.wrapper').width() - 428;
if( roundWidth % 2 == 0){ $("#contents").css('margin-right','210px'); }
else { $("#contents").css('margin-right','209px'); }
});
}

function iefix() {
if ($.browser.msie && $.browser.version <= 6){
$('.round').each(function(){
$(this).height('1%');
var roundHeight = $(this).height();
if( roundHeight % 2 == 0){}
else { $(this).height(roundHeight + 1); }
});
}
}


//tab switch//
$('.tab.menu a').click(function(){										 
$('.tab.menu').hide();
$('.menuCont').hide();
$('.tab.machine').show();
$('.machineCont').show();
iefix();
});
$('.tab.machine a').click(function(){										 
$('.tab.machine').hide();
$('.machineCont').hide();
$('.tab.menu').show();
$('.menuCont').show();
iefix();
});

$('.tab.topics a').click(function(){										 
$('.tab.topics').hide();
$('.topicsCont').hide();
$('.pressCont').show();
$('.tab.press').show();
iefix();
});
$('.tab.press a').click(function(){										 
$('.tab.press').hide();
$('.pressCont').hide();
$('.tab.topics').show();
$('.topicsCont').show();
iefix();
});





function floatWdw() {
var widthCtr = $(window).width() / 2;
var heightCtr = $(window).height() / 2;
var mgHeight = $('#callLater').outerHeight() /2;
var mgWidth = $('#callLater').outerWidth() /2;
$('#callLater').show().css({'top': heightCtr - mgHeight + 'px','left': widthCtr - mgWidth + 'px'});
$('.layer').show();
}
var timer = setInterval(floatWdw, 60000);
var widthCtr = $(window).width() / 2;
var heightCtr = $(window).height() / 2;
var mgHeight = $('#callLater').outerHeight() /2;
var mgWidth = $('#callLater').outerWidth() /2;

$('.calltrgr').click(function(){
$('#callLater').show().css({'top': heightCtr - mgHeight + 'px','left': widthCtr - mgWidth + 'px'});
$('.layer').show();

$('#callLater, .layer').exFixed(); 


});
$('.btnClose , .layer' ).click(function(){
	$('#callLater').hide();
	$('.layer').hide();	
});





//End of doccument ready ////////////////////////////////////////
});

// Roll over ////////////////////////////////////////

PEPS = {};
PEPS.rollover = {
init: function(){
this.preload();

$(".over").hover(
function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); },
function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); }
);},

preload: function(){
$(window).bind('load', function() {
$('.over').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
$('.idx2 img').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
});},

newimage: function( src ){
return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_o' + src.match(/(\.[a-z]+)$/)[0];
},

oldimage: function( src ){
return src.replace(/_o\./, '.');
}
};
// Roll over end ////////////////////////////////////////