/*
DD_roundies.addRule('#cafeXeHeader', '7px');
DD_roundies.addRule('#cafeXeContent', '7px');
DD_roundies.addRule('#cafeXeFooter', '7px');
DD_roundies.addRule('.simpleWidgetStyle', '7px');
*/

//$("#cafeXeHeader, #cafeXeContent, #cafeXeFooter, .simpleWidgetStyle").corner();

(function($) {
	jQuery(function($) {
		$(function() {
			
			
			//메뉴실행
			$('#nav').droppy({speed: 0});
			$('#nav').parent().parent().parent().parent().css("overflow","visible");
			
			$('#nav ul li:first-child').prepend('<div class="triangle"></div>');
			
			//메뉴에서 맨 끝에 보더 없애기
			$('#nav .has-subnav:last').css('border', '0px');
			
			$('div.simpleWidgetStyle h2').append('<span class="period" style="color:#999;font-weight:1200;position:relative;left:3px;">;</span>');

			//랜덤배경
			//$('#cafeXe').css("background-image", "url('http://nemesys.co.kr/layouts/cafeXE/img/white/pattern_"+Math.floor(Math.random()*13)+".png')");
			//$('#cafeXe').css("background-attachment", "fixed");
			
			//메인페이지 위젯타이틀 이미지 변환
			/*
			$('div .simpleWidgetStyle h2:contains("Nemesys.co.kr Main Banner")').html('<img src="/layouts/cafeXE/img/title/widget_title_1.jpg" />');
			$('div .simpleWidgetStyle h2:contains("About Nemesys.co.kr")').html('<img src="/layouts/cafeXE/img/title/widget_title_2.jpg" />');
			$('div .simpleWidgetStyle h2:contains("단어장 - Vocabulary Note")').html('<img src="/layouts/cafeXE/img/title/widget_title_3.jpg" />');
			$('div .simpleWidgetStyle h2:contains("동영상 - Moviez")').html('<img src="/layouts/cafeXE/img/title/widget_title_4.jpg" />');
			$('div .simpleWidgetStyle h2:contains("PDA)').html('<img src="/layouts/SKUBeautyArtInst/img/title/widget_title_5.jpg" />');
			*/			
						
			//오른쪽에 내용 슬라이딩
			$('#nav a:contains("실험실")').toggle(function(){
				//alert('wow');
				//$('#cafeXe').animate({'backgroundImage':'http://nemesys.co.kr/layouts/cafeXE/img/white/pattern_"+Math.floor(Math.random()*13)+".png'},2000);
				//$('#cafeXeHeader').animate({'left': '200px', 'opacity': 0},2000, "easeOutExpo");
				//$('#cafeXeContainer').before('<div id="insertedTopBox" style="width:948px; height:100px; border:5px #000 solid;margin:0px auto;background:#fff;-moz-border-radius:5px;-webkit-border-radius:5px;-moz-box-shadow:6px 6px 2px rgba(0, 0, 0, 0.40);-webkit-box-shadow:6px 6px 2px rgba(0, 0, 0, 0.40);letter-spacing:-1px;"><div style="padding:10px 20px;"><b>알림</b> : <span></span></div></div>').fadeIn();
			},function(){
				//$('#insertedTopBox').remove();
				//$('#cafeXeContainer').animate({'top':'0px'},1300, "easeOutExpo");
				
			});
			
			//cafeXeFooter에 내용삽입
			$('#cafeXeFooter').prepend('<div class="FooterText"><ul><li>Email / <a href="mailto:0@nemesys.co.kr">0@nemesys.co.kr</a></li><li>Reference Site / <a href="/">Nemesys.co.kr</a></li><li>Blog / <a href="http://blog.nemesys.co.kr/tt" target="_blank">Nes\'s Random Blogz</a></li><li>Mobile Clips / <a href="http://blog.nemesys.co.kr/clip/" target="_blank">Nes\'s Clipping</a></li></ul>Since 2004 <b>Nemesys.co.kr</b>  Some Right Reserved . . . 본 사이트는 IE 만 빼놓고 최적화 되었습니다~!! 또한 CSS3을 지원하는 <b>크롬</b>, <b>사파리</b> 및 <b>파폭</b>을 사용하시면 가장 잘 보입니다.</div>');
			

			//헤더 배경 흘러가게 하기
			//$("#cafeXeHeader").animate({"backgroundPosition" : "-=10000000"}, 999999999);
			//$("#cafeXeFooter").animate({"backgroundPosition" : "-=10000000"}, 999999999);
			//$("#cafeXe").animate({"backgroundPosition" : "-=10000000"}, 999999999);
			

			//sIRF - 택스트 플래시 글자로 바꾸기
			/*
			//역시.. 좀 문제가 있어서 sifr을 적용하는 것은 좀 두자...
			$.sifr({
				path: 'layouts/cafeXE/font/',
				save: true
			});
			$("h2").sifr({ font: "NanumGothic", fontSize : "30"});  
			*/

			//게시판에 추가정보가 존재하지 않을 경우에 가려줌.
			$("#cafeXeContent .extraVarsList td").each(function(){
				if($(this).text().trim() == ""){
					$(this).parent().hide();
				}
			});
			
			//배경에서 더블클릭하면 스크롤 토글됨.
			$("#cafeXeContainer").dblclick(function(e){
				//alert(e.pageY);
				if(e.pageY > ($(document).height() / 2)){
					//alert("커 / e.pageY : "+e.pageY + "$(document).height() : " + $(document).height());
					//$("body").animate({"scrollTop": 0}, $(document).height()-500, "easeOutBounce");
					$("html, body").filter(':not(:animated)').animate({"scrollTop": "0px"}, 0);
					//$("html, body").scrollTop(300);
					//$("body").animate({"opacity": "toggle"}, $(document).height()-500);
				}else{
					//alert("작아");
					$("html, body").filter(':not(:animated)').animate({"scrollTop": ($(document).height() - $(window).height())}, 0);
				}
			});
			
			//게시판에서 별점메기는 플러그인 연동
			//수정창에서
			$(".extraVarsList li input[value^=★]").clone().attr("class", "star").prependTo(".extraVarsList th:contains('별점') + td");
			$(".extraVarsList li:contains('★')").parent().remove();
			//뷰에서
			var $stars = $(".extraVarsList th:contains('별점 :') + td");
			//alert($stars.text());
			var starMaxNum = $stars.text().split("★").length-1;
			//alert(starMaxNum);
			$stars.text("");
			for(var starNum = 1; starNum < 6 ;starNum++){
				if(starNum == (starMaxNum)){
					$stars.append("<input type='radio' class='star' disabled='disabled' checked='checked' /> ");
				}else{
					$stars.append("<input type='radio' class='star' disabled='disabled' /> ");
				}
				
			}
			//수정 및 뷰 공통
			$(".extraVarsList input.star").rating();
			
			//오른쪽 메뉴 페이드 인
			/*
			var $boxes = $('.simpleWidgetStyle:eq(0)').hide(), div = 0;
			$('.simpleWidgetStyle:eq(0)').fadeIn('slow');
			//$($boxes[div++]|| []).fadeIn('slow');
			*/
			//메뉴에 손올리면 보더색상 변경 - 왠지 안되네...
			/*
			$('#sideMenus .simpleWidgetStyle:eq(0)').hover(function(){
				$(this).stop().animate({"borderColor" : "#fff"}, 500);
			}, function(){
				$(this).stop().animate({"borderColor" : "#333"}, 500);
			});
			*/

			//오른쪽메뉴 maniplulation
			if(!$.browser.msie || ($.browser.msie && $.browser.version >= 8)){				
				//$('#cafeXeBody .cafeXeExtension').hide().fadeIn(1500);
			}
			
			
			//오른쪽 메뉴에 CSS로 적용한 그림자를 안보이게 하는 속성 제거
			$('#cafeXeBody .cafeXeExtension div.simpleWidgetStyle').parent().css("overflow","visible");
			
			//오른쪽 메뉴의 각 링크 효과
			$("#sideMenus a").hover(function(){
				//$(this).stop().animate({paddingLeft: '20px'}, 500).append('<span style="color:red;letter-spacing:-1px;font-size:8pt;display:none;font-weight:normal;">~!! </span>').find('span').css('display', '');
				$(this).stop().animate({'paddingLeft': '20px'}, 200);
			}, function(){
				$(this).stop().animate({'paddingLeft': '0px'}, 200);
			});
			
			//오른쪽 메뉴 해당 페이지 진입시 효과
			$("#sideMenus li a.selected").delay(1000).animate({"backgroundColor": "#78F63B"}, 700).animate({"backgroundColor": "#fff"}, 500).animate({"backgroundColor": "#78F63B"}, 500).animate({"backgroundColor": "#fff"}, 500).animate({"backgroundColor": "#78F63B"}, 500).animate({"backgroundColor": "#fff"}, 500);
			
			//오른쪽 메뉴 타이틀 클릭시 효과
			$('.cafeXeExtension h2').css('cursor', 'pointer');
			$('.cafeXeExtension h2').click(function(){
				$(this).parent().find('div').animate({
					'height': 'toggle'
				},500);
			});
			
			
			
			
			//이미지에 손 올리면 나오는 효과
			$('.thumb').hover(function(){
				//$(this).stop().animate({"backgroundColor" : "#000"}, 500);
				$(this).stop().animate({"backgroundColor" : "#444"}, 500);
			}, function(){
				$(this).stop().animate({"backgroundColor" : "#fff"}, 500);
			});
			
			//아래는 daum.net의 ip->지역정보를 이용해 레퍼러에 삽입시키는것
			$.get('/?module=referer&act=procRefererLocationUpdate&location=' + t_address);					
			
			//메인페이지 벽돌쌓기
			if (!$.browser.msie || ($.browser.msie && $.browser.version >= 6)) {
				
				
				$('ul.widgetZineA').wrapInner('<div id="boxArray"></div>');
				
				$('#boxArray').unwrap();
				$('#boxArray li').wrap('<div class="boxes" style="width:140px;border:1px #ddd solid;padding:10px;float: left;margin:4px 0;font-size:8pt;letter-spacing:-1px;font-family:dotum;-moz-border-radius: 5px;-webkit-border-radius: 5px;line-height:140%;overflow:hidden;"></div>');
				//console.time('DM1');
				$('#boxArray li p:parent').unwrap();
				//console.timeEnd('DM1');
				$('#boxArray div p').removeClass().css("margin", "0px");
				$('#boxArray div p').css("padding", "5px 0");
				$('#boxArray div p .imgNone').parent().parent().remove();
				$('#boxArray div p .title').css({
					'display': 'block',
					'padding': '3px 0',
					'font-size': '9pt',
					'font-family': 'tahoma'
				});
				$('#boxArray div p img').css({
					'border': '3px #000 solid'
				});
				$('#boxArray div p .date, #boxArray div p .hour').css({
					'color': '#888'
				});
				
				$('#boxArray').masonry({
					columnWidth: 13,
					itemSelector: '.boxes'
				});
			}else{
				$('.widgetZineA').remove();
			}
			
			
			var typewriterStr = '';
			var addressStr = '';
			if(refererKeyword){
				typewriterStr = "혹시 <b>[" +refererKeyword+"]</b> 에 관한 내용을 이 페이지에서 못찾으셨다면 <a href='http://nemesys.co.kr/googleSearch?cx=partner-pub-1875461870171772%3A20d1r8-1o4b&cof=FORID%3A10&ie=UTF-8&q="+refererKeyword+"&sa=Search&siteurl=nemesys.co.kr%2Fendic#1045'><b>여기</b></a>를 함 눌러보시길 바랍니다.";
			}
			if(t_address){
				addressStr = "<b>["+ t_address + "]</b> 에서 오셨네요. ";
			}
			if ($.trim(typewriterStr)) {
				
				$('#cafeXeBody').before('<div id="insertedBox" style="width:948px;border:5px #000 solid;margin:20px auto;background:#fff;-moz-border-radius:5px;-webkit-border-radius:5px;display:none;-moz-box-shadow:6px 6px 2px rgba(0, 0, 0, 0.40);-webkit-box-shadow:6px 6px 2px rgba(0, 0, 0, 0.40);letter-spacing:-1px;"><div style="padding:10px 20px;"><b>알림</b> : <span></span></div></div>');
				$textBox = $("#insertedBox div span");
				$textBox.html(addressStr + typewriterStr);
				$("#insertedBox").delay(1500).fadeIn(800);
				
				$.each($.trim(refererKeyword).split(" "), function(idx, val) {
					$("div.boardRead").highlight(val);
				});
				
				$('#cafeXeContent').highlight('jQuery');
			}
			
			
			
			//번역기 실행시키기 위한 부분
			$('div.infoView ul').append('<li><img src="/layouts/cafeXE/img/etc/btn_translate.png" style="border:1px silver solid;" title="누르고 잠시 계시면 페이지의 내용을 한국어로 번역합니다" style="cursor:pointer;" /></li>')
				.click(function(){
					$('div.boardRead').translate('ko');
				});
			
			
			//트위터플러그인 실행부
			/*
			$.Juitter.start({
				searchType:"searchWord", // needed, you can use "searchWord", "fromUser", "toUser"
				searchObject:"네이버", // needed, you can insert a username here or a word to be searched for, if you wish multiple search, separate the words by comma.
		
				// The values below will overwrite the ones on the Juitter default configuration. 
				// They are optional here.
				// I'm changing here as a example only
				lang:"ko", // restricts the search by the given language
				live:"live-15", // the number after "live-" indicates the time in seconds to wait before request the Twitter API for updates.
				placeHolder:"juitterContainer", // Set a place holder DIV which will receive the list of tweets example <div id="juitterContainer"></div>
				loadMSG: "트위터 로딩중~!!", // Loading message, if you want to show an image, fill it with "image/gif" and go to the next variable to set which image you want to use on 
				imgName: "loader.gif", // Loading image, to enable it, go to the loadMSG var above and change it to "image/gif"
				total: 3, // number of tweets to be show - max 100
				readMore: "더읽기", // read more message to be show after the tweet content
				nameUser:"image", // insert "image" to show avatar of "text" to show the name of the user that sent the tweet 
				openExternalLinks:"newWindow", // here you can choose how to open link to external websites, "newWindow" or "sameWindow"
				filter:"sex->*BAD word*,porn->*BAD word*,fuck->*BAD word*,shit->*BAD word*"  // insert the words you want to hide from the tweets followed by what you want to show instead example: "sex->censured" or "porn->BLOCKED WORD" you can define as many as you want, if you don't want to replace the word, simply remove it, just add the words you want separated like this "porn,sex,fuck"... Be aware that the tweets will still be showed, only the bad words will be removed
			});
			$("#aRodrigo").click(function(){
				$(".jLinks").removeClass("on");
				$(this).addClass("on");									  
				$.Juitter.start({
					searchType:"fromUser",
					searchObject:"mrjuitter,rodrigofante",
					live:"live-120" // it will be updated every 120 seconds/2 minutes
				});
			});
			$("#aIphone").click(function(){
				$(".jLinks").removeClass("on");
				$(this).addClass("on");									   
				$.Juitter.start({
					searchType:"searchWord",
					searchObject:"iPhone,apple,ipod",
					live:"live-20"  // it will be update every 20 seconds 
				});
			});
			$("#aJuitter").click(function(){
				$(".jLinks").removeClass("on");
				$(this).addClass("on");								  
				$.Juitter.start({
					searchType:"searchWord",
					searchObject:"Juitter",
					live:"live-180" // it will be updated every 180 seconds/3 minutes
				});
			});
			$("#juitterSearch").submit(function(){
				$.Juitter.start({
				searchType:"searchWord",
					searchObject:$(".juitterSearch").val(),
					live:"live-20", // it will be updated every 180 seconds/3 minutes
					filter:"sex->*BAD word*,porn->*BAD word*,fuck->*BAD word*,shit->*BAD word*"
				});
				return false;
			});
			$(".juitterSearch").blur(function(){
			    if($(this).val()=="") $(this).val("Type a word and press enter");
			});
			$(".juitterSearch").click(function(){
			    if($(this).val()=="Type a word and press enter") $(this).val("");
			});	
			*/
			
			
			
		});
	});
}) (jQuery);

//이미지게시판 이미지 시퀜셜로 페이드 인 되게 하기 callee를 사용하기 때문에 따로 빼주어야 함. 
/*
var thumbImg = 0;
var $thumbs;
(function($) {
	jQuery(function($) {
		$(function() {
			$thumbs = $('div.thumb img').hide();
		});
	});
}) (jQuery);
(function($) {
	jQuery(function($) {
		$(function() {
			$($thumbs[thumbImg++]|| []).fadeIn(200, arguments.callee);
		});
	});
}) (jQuery);
*/

//손올리면 커지는 이미지 베너
(function($) {
    jQuery(function($) {
      $(function() {
	//move the image in pixel
	var move = -15;
	
	//zoom percentage, 1.2 =120%
	var zoom = 1.2;

	//On mouse over those thumbnail
	$('.zitem').hover(function() {
		
		//Set the width and height according to the zoom percentage
		width = $('.zitem').width() * zoom;
		height = $('.zitem').height() * zoom;
		
		//Move and zoom the image
		$(this).find('img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:200});
		
		//Display the caption
		$(this).find('div.caption').stop(false,true).fadeIn(200);
	},
	function() {
		//Reset the image
		$(this).find('img').stop(false,true).animate({'width':$('.zitem').width(), 'height':$('.zitem').height(), 'top':'0', 'left':'0'}, {duration:100});	

		//Hide the caption
		$(this).find('div.caption').stop(false,true).fadeOut(200);
	});
	


//우측에 있는 손올리면 갈라지는 베너
//Custom settings
	var style_in = 'easeOutBounce';
	var style_out = 'jswing';
	var speed_in = 800;
	var speed_out = 300;	

	//Top and bottom
	var	top = $('.qitem').height() * (-1); 
	var	bottom = $('.qitem').height(); 

	$('.qitem').each(function () {

		//retrieve all the details of the image before removing it
		url = $(this).find('a').attr('href');
		img = $(this).find('img').attr('src');
		alt = $(this).find('img').attr('img');
		width = $(this).width() / 4; 
		height = $(this).height(); 
		
		//remove the image and append 4 div into it
		$('img', this).remove();
		$(this).append('<div class="bar1"></div><div class="bar2"></div><div class="bar3"></div><div class="bar4"></div>');
		
		//set the image as background image to all the bars
		$(this).children('div').css('background-image','url('+ img + ')');

		//Divide the image into 4 bars and rebuild the image
		$(this).find('div.bar1').css({top:0, left:0, width:width, height:height, backgroundPosition:'0 0' });	
		$(this).find('div.bar2').css({top:0, left:width, width:width, height:height, backgroundPosition:(width*-1) + 'px 0' });	
		$(this).find('div.bar3').css({bottom:0, left:width*2, width:width, height:height, backgroundPosition:(width*-2) + 'px 0' });	
		$(this).find('div.bar4').css({bottom:0, left:width*3, width:width , height:height, backgroundPosition:(width*-3) + 'px 0' });

	}).hover(function () {
		
		//Move those bar, 1st and 3rd move upward, 2nd and 4th move downward
		$(this).find('div.bar1').stop(false, true).animate({top:top}, {duration:speed_out, easing:style_out});	
		$(this).find('div.bar2').stop(false, true).animate({top:bottom}, {duration:speed_out, easing:style_out});	
		$(this).find('div.bar3').stop(false, true).animate({top:top}, {duration:speed_out, easing:style_out});	
		$(this).find('div.bar4').stop(false, true).animate({top:bottom}, {duration:speed_out, easing:style_out});	
				
	},
	
	function () {

		//Back to default position
		$(this).find('div.bar1').stop(false, true).animate({top:0}, {duration:speed_in, easing:style_in});	
		$(this).find('div.bar2').stop(false, true).animate({top:0}, {duration:speed_in, easing:style_in});	
		$(this).find('div.bar3').stop(false, true).animate({top:0}, {duration:speed_in, easing:style_in});	
		$(this).find('div.bar4').stop(false, true).animate({top:0}, {duration:speed_in, easing:style_in});	
	
	}).click (function () {
		
		//make the whole box clickable
		window.location = $(this).find('a').attr('href');	
	});


	//하일라이터 설정
	$(".jhighlight").jhighlight( {  
	    screencolor     : 'black',   
	    screenopacity   : '0.6',  
	    overlaycolor    : 'transparent',  
	    boxshadow       : '0px 0px 30px white',  
	    animationspeed  : 500,  
	    autoload        : false,  
	    autoloadobject  : "",  
	    autoplay        : false,  
	    autoplaydelay   : 1000,  
	    description     : false  
	});  





      });
    });
}) (jQuery);


//IE6이하 png파일 문제 해결
function setPng24(obj) {
    obj.width=obj.height=1;
    obj.className=obj.className.replace(/\bpng24\b/i,'');
    obj.style.filter =
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
    obj.src=''; 
    return '';
} 

