// main menu
$(function(){
	if($.browser.version == "6.0"){
		$('#main_wrap .main_intro').pngFix();
	}
	$("#main_menu_01").mouseover(function(){$(".sub_menu").hide();$("#sub_menu_01").show();});
	$("#main_menu_02").mouseover(function(){$(".sub_menu").hide();$("#sub_menu_02").show();});
	$("#main_menu_03").mouseover(function(){$(".sub_menu").hide();$("#sub_menu_03").show();});
	$("#main_menu_04").mouseover(function(){$(".sub_menu").hide();$("#sub_menu_04").show();});
	$("#main_menu_05, #main_menu_06, #main_menu_07").mouseover(function(){$(".sub_menu").hide();});
	$('#main_wrap .main_intro .btn_l, #main_wrap .main_intro .btn_r').hover(
		function(){$(this).find('img').show();},
		function(){$(this).find('img').hide();}
	);

});


// cafe print layer
$(function(){
	$("#scrapt_layer").mouseover(function(){$(".scrapt_layer").show();});
	$(".scrapt_layer").mouseleave(function(){$(".scrapt_layer").hide();});
});

	function clickMenu(choiceId) {
		if (!document.getElementsByTagName) return false;
		if (!document.getElementById) return false;
		if (!document.getElementById(choiceId)) return false; // 하위 호환성 체크
		var menu = document.getElementById(choiceId); 
		var links = menu.getElementsByTagName("img");
		for (var i = 0 ; i < links.length ; i++ ) {
			var iSrc = links[i].getAttribute("src");
			var chanSrc = iSrc.substring(0,iSrc.lastIndexOf("_o"));
			if (chanSrc.indexOf("_on") == -1) { //_on 문자열이 존재하지 않으면
				var chanSrc = chanSrc + "_on.gif";
				links[i].setAttribute("chanSrc",chanSrc);
				links[i].setAttribute("origSrc",iSrc);
				links[i].onmouseover = function() {
					this.src = this.getAttribute("chanSrc");
				}
				links[i].onmouseout = function() {
					this.src = this.getAttribute("origSrc");
				}
			}
		}
	}

	function chanImg() {
		clickMenu("tabMenu")
	}

	function getElementsByClassName(clsName,parentNode) {
		var arr = new Array();
		if (parentNode == null) {
			var elems = document.getElementsByTagName("*");
		} else {
			var elems = parentNode.getElementsByTagName("*");
		}
		for ( var cls, i = 0; ( elem = elems[i] ); i++ ) {
			if ( elem.className == clsName ) {
				arr[arr.length] = elem;
			}
		}
		return arr;
	}
	function tabDisplay(tab,content,num,type) {
		for (var i=0; i<content.length; i++) {
			content[i].style.display = 'none';
			content[num].style.display = 'block';
		}
	}
	function tabAct(tab,content,num,type) {
		tab[num].onclick = function() {
			tabDisplay(tab,content,num);
			return false;
		}
		
	}

function clickMenu(choiceId) {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById(choiceId)) return false; // 하위 호환성 체크
	var menu = document.getElementById(choiceId); 
	var links = menu.getElementsByTagName("img");
	for (var i = 0 ; i < links.length ; i++ ) {
		var iSrc = links[i].getAttribute("src");
		var chanSrc = iSrc.substring(0,iSrc.lastIndexOf("_o"));
		if (chanSrc.indexOf("_on") == -1) { //_on 문자열이 존재하지 않으면
			var chanSrc = chanSrc + "_on.gif";
			links[i].setAttribute("chanSrc",chanSrc);
			links[i].setAttribute("origSrc",iSrc);
			links[i].onmouseover = function() {
				this.src = this.getAttribute("chanSrc");
			}
			links[i].onmouseout = function() {
				this.src = this.getAttribute("origSrc");
			}
		}
	}
}


function postTwitter(strMsg, strUrl) {
	var sang = encodeURIComponent("[상상마당]");
	var strLink = "http://mobile.twitter.com/home?status=" +sang+" "+ encodeURIComponent(strMsg) + " / " + encodeURIComponent(strUrl)+" ";
	var popWin = window.open(strLink, 'Twitter', '');
	if (popWin) {
		 popWin.focus();
	}
}

function postMe2day(strMsg, strUrl) {
	var sang = encodeURIComponent("[상상마당]");
	//var strLink = "http://me2day.net/posts/new?new_post[tags]="+sang+"&new_post[body]="+"&quot"+encodeURIComponent(strMsg)+"&quot:"+encodeURIComponent(strUrl);
	//var strLink = "http://me2day.net/posts/new?new_post[tags]="+sang+"&new_post[body]="+encodeURIComponent(strMsg)+" &quot"+encodeURIComponent("링크")+"&quot:"+encodeURIComponent(strUrl);
	var strLink = "http://m.me2day.net/posts/new?new_post[tags]="+""+"&new_post[body]="+sang+" "+encodeURIComponent(strMsg)+" / "+encodeURIComponent(strUrl);
	
	var popWin = window.open(strLink, 'Me2day', '');
	if (popWin) {
		popWin.focus();
	}
}

	
function chanImg() {
	clickMenu("tabMenu")
}

/*▼▼ addLoadEvent ▼▼*/
function addLoadEvent(func){ //함수 선언
	var oldonload = window.onload; //이전 함수값 저장
	if(typeof window.onload != 'function'){ //윈도우가 로드되었을때 함수 호출 여부 판단
		window.onload = func; // 호출된 함수가 없을 경우 그냥 함수 실행
	}else{
		window.onload = function(){ //호출된 함수가 있을 경우에 이전 함수 뒤에 함수 추가
		oldonload();
		func();
		}
	}
}

addLoadEvent(chanImg);


/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.1, 11.09.2007
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([237-9n-zA-Z]|1\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(s(m){3.fn.pngFix=s(c){c=3.extend({P:\'blank.gif\'},c);8 e=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 5.5")!=-1);8 f=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 6.0")!=-1);p(3.browser.msie&&(e||f)){3(2).B("img[n$=.C]").D(s(){3(2).7(\'q\',3(2).q());3(2).7(\'r\',3(2).r());8 a=\'\';8 b=\'\';8 g=(3(2).7(\'E\'))?\'E="\'+3(2).7(\'E\')+\'" \':\'\';8 h=(3(2).7(\'F\'))?\'F="\'+3(2).7(\'F\')+\'" \':\'\';8 i=(3(2).7(\'G\'))?\'G="\'+3(2).7(\'G\')+\'" \':\'\';8 j=(3(2).7(\'H\'))?\'H="\'+3(2).7(\'H\')+\'" \':\'\';8 k=(3(2).7(\'V\'))?\'float:\'+3(2).7(\'V\')+\';\':\'\';8 d=(3(2).parent().7(\'href\'))?\'cursor:hand;\':\'\';p(2.9.v){a+=\'v:\'+2.9.v+\';\';2.9.v=\'\'}p(2.9.w){a+=\'w:\'+2.9.w+\';\';2.9.w=\'\'}p(2.9.x){a+=\'x:\'+2.9.x+\';\';2.9.x=\'\'}8 l=(2.9.cssText);b+=\'<y \'+g+h+i+j;b+=\'9="W:X;white-space:pre-line;Y:Z-10;I:transparent;\'+k+d;b+=\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;\';b+=\'J:K:L.t.M(n=\\\'\'+3(2).7(\'n\')+\'\\\', N=\\\'O\\\');\';b+=l+\'"></y>\';p(a!=\'\'){b=\'<y 9="W:X;Y:Z-10;\'+a+d+\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;">\'+b+\'</y>\'}3(2).hide();3(2).after(b)});3(2).B("*").D(s(){8 a=3(2).11(\'I-12\');p(a.A(".C")!=-1){8 b=a.13(\'url("\')[1].13(\'")\')[0];3(2).11(\'I-12\',\'none\');3(2).14(0).15.J="K:L.t.M(n=\'"+b+"\',N=\'O\')"}});3(2).B("input[n$=.C]").D(s(){8 a=3(2).7(\'n\');3(2).14(0).15.J=\'K:L.t.M(n=\\\'\'+a+\'\\\', N=\\\'O\\\');\';3(2).7(\'n\',c.P)})}return 3}})(3);',[],68,'||this|jQuery||||attr|var|style||||||||||||||src|navigator|if|width|height|function|Microsoft|appVersion|border|padding|margin|span|px|indexOf|find|png|each|id|class|title|alt|background|filter|progid|DXImageTransform|AlphaImageLoader|sizingMethod|scale|blankgif|appName|Internet|Explorer|parseInt|MSIE|align|position|relative|display|inline|block|css|image|split|get|runtimeStyle'.split('|'),0,{}))
