
$(function(){
	bodyId = $('body').attr('id');
	bodyCl = $('body').attr('class');
	
	
	//gNav hover
	
	$('ul#gNav li').each(function(){
		gNavID = $(this).attr('id').split('gnav-')[1];
		gNavImg = $(this).find('img').attr('src').split('common/')[0];
		gNavBg = gNavImg +'common/nv_'+ gNavID +'_ro.gif';
		$(this).css('background','url('+ gNavBg + ') top left no-repeat');
		if(bodyId == gNavID){
			$(this).find('img').css('visibility','hidden');
		}else{
			if(bodyId =="top"){
				$(this).find('img').css('background-color','#ffffff');
			}else{
				$(this).find('img').css('background-color','#F5F5FA');
			}
		}
	});
	
	//sNav hover
	if(bodyId = 'professionals' && bodyCl == 'detail'){
		//postName = $('dd#postName b').text();
		//postName = $('b#categoryLabel').text();
		

		$('ul#sNav li').each(function(){
			sNavID = $(this).attr('id').split('snav-')[1];
			sNavImg = $(this).find('img').attr('src').split('images/')[0];
			sNavBg = sNavImg + 'images/snav_' + sNavID +'_ro.gif';
			$(this).css('background','url('+ sNavBg + ') 0 -500px no-repeat');
			sNavAlt = $(this).find('img').attr('alt');
			if($('dd#postName b').text() == sNavAlt){
				$(this).find('img').css('visibility','hidden');
				$(this).css('background-position','top left');
			}else{
				$(this).hover(
					function(){
						$(this).css('background-position','top left');
					}
					,function(){
						$(this).css('background-position','0 -500px');
					}
				);	
			}
		});
	}else{
		$('ul#sNav li').each(function(){
			sNavID = $(this).attr('id').split('snav-')[1];
			sNavImg = $(this).find('img').attr('src').split('images/')[0];
			sNavBg = sNavImg + 'images/snav_' + sNavID +'_ro.gif';
			$(this).css('background','url('+ sNavBg + ') 0 -500px no-repeat');

			if(bodyCl == sNavID){
				$(this).find('img').css('visibility','hidden');
				$(this).css('background-position','top left');
			}else{
				$(this).hover(
					function(){
						$(this).css('background-position','top left');
					}
					,function(){
						$(this).css('background-position','0 -500px');
					}
				);
			}

		});
	}
	//sNavII hover
	$('ul#ssNav li').each(function(){
		sNavID = $(this).attr('id').split('ssnav-')[1];
		sNavImg = $(this).find('img').attr('src').split('images/')[0];
		sNavBg = sNavImg + 'images/snav_' + sNavID +'_ro.gif';
		$(this).css('background','url('+ sNavBg + ') 0 -500px no-repeat');
		if(bodyCl == sNavID){
			$(this).find('img').css('visibility','hidden');
			$(this).css('background-position','top left');
		}else{
			$(this).hover(
				function(){
					$(this).css('background-position','top left');
				}
				,function(){
					$(this).css('background-position','0 -500px');
				}
			);
		}
	});
	
	//professionals syllabary
	/*
	$('#memberList dt span.post').each(function(){
		$(this).text('(' + $(this).text().split('/')[2] + ')');
		
	});
	*/
});


/* swapImg */
jQuery.fn.extend({
	swapImg: $(document).ready(function(){
		return $('.swapImg').each(function(){
			if($(this).attr('class').match('swapImg change')){
				//ImgPreLoad
				swapObj = new Image();
				preLoad = $(this).attr('class').split('swapImg change(')[1].split(')')[0];
				swapObj.src = preLoad;
				imgNm = $(this).attr('name',preLoad);
				
				//MouseOver
				$(this).hover(
					function(){
						$(this).attr('lowsrc',$(this).attr('src'));
						$(this).attr('src',$(this).attr('name'));
					},
					function(){
						$(this).attr('src',$(this).attr('lowsrc'));
					}
				);
			}else if($(this).attr('src').match('_no.')){
				//ImgPreLoad
				swapObj = new Image();
				imgpath = $(this).attr('src');
				preLoad = imgpath.replace('_no.','_ro.');
				swapObj.src = preLoad;
				
				$(this).hover(
					function(){
						$(this).attr('src',$(this).attr('src').replace('_no.','_ro.'));
					},
					function(){
						$(this).attr('src',$(this).attr('src').replace('_ro.','_no.'));
					}
				);
			}
		});
	})
});


