//////////////////////  default 

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//쿠키값
function getCookie( name ){ 
	var nameOfCookie = name + "="; 
	var x = 0; 
	while ( x <= document.cookie.length ) 
	{ 
			var y = (x+nameOfCookie.length); 
			if ( document.cookie.substring( x, y ) == nameOfCookie ) { 
					if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) 
							endOfCookie = document.cookie.length; 
					return unescape( document.cookie.substring( y, endOfCookie ) ); 
			} 
			x = document.cookie.indexOf( " ", x ) + 1; 
			if ( x == 0 ) 
					break; 
	} 
	return ""; 
}

function setCookie(name, value, expiredays)
{
	var today = new Date();
	today.setDate( today.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";";
}

function CopyClibboard(link)
{
    window.clipboardData.setData('Text', link);
    alert('RSS 주소가 복사되었습니다');
}

//페이지내용 프린트
function printPage(cssStr)
{
    printFrame.printContent ( document.getElementById("inner_content").innerHTML, cssStr );
    return;
}

function popupOpen(url,vscrollbars,vtoolbar,vmenubar,vlocation,vwidth,vheight){		

	window.open(url,'_PopUp','scrollbars='+vscrollbars+',toolbar='+vtoolbar+',menubar='+vmenubar+',location='+vlocation+',width='+vwidth+',height='+vheight+',location=no')

}

/*TopMenu -submenu 보기: 현재메뉴활성*/
var preNaviID	= "";
var preOver		= "";
var preSub		= "";
function showTopSub(naviID) {
	var subMn	= document.getElementById("sub_navi"+naviID);

	if(preNaviID != naviID || preNaviID == "") {
		if(preNaviID != "") {
			document.getElementById("sub_navi"+preNaviID).style.display	= "none";
		}
		subMn.style.display	= "block";
		preNaviID			= naviID;
	}
}

/* */
//실명인증 Open 창
function fnPopup(path)
{
	window.open('', 'popup','width=410, height=590');
	document.frmVar.var_path.value = path;
	document.frmVar.target = "popup";
	document.frmVar.action = "/message/vname_Input.php";
	document.frmVar.submit();
}

// G-PIN 인증창 Open
function fn_GPinAuth(path) {
	var sThisURL = document.location +'';
	var arrayURL = sThisURL.split('/');
	var sNewURL = '';
	var sExp = '';
	if (arrayURL[2]!='80333.dnworks.co.kr' ) {
		if( confirm('G-PIN 인증 도메인으로 이동하시겠습니까? 이동후 다시 글쓰기를 눌러주세요') )
		{
			for(var i=0;i<arrayURL.length;i++){
				if (i == 0) 
					sExp = '';
				else 
					sExp = '/';				    
				
				if (i==2) 
					sNewURL += sExp + '80333.dnworks.co.kr';
				else
					sNewURL += sExp + arrayURL[i];
			}
			top.location.href= sNewURL ;	
		}
		return;
	}

    wWidth = 360;
    wHight = 120;
    
    wX = (window.screen.width - wWidth) / 2;
    wY = (window.screen.height - wHight) / 2;
    //path = path.gsub("&","^");	// url 해석이 필요하내 ...
	//path = path+'&&mm&&';
	path = path.replace(/&/g, "^"); 
    var w = window.open("/GPIN/AuthRequest.php?path="+path, "gPinLoginWin", "directories=no,toolbar=no,left="+wX+",top="+wY+",width="+wWidth+",height="+wHight);
}


function setPosition(valueW, valueH)
{
	if(navigator.appVersion.indexOf("MSIE 7.0") > 0) {
		valueW = valueW;
		valueH = valueH + 21;
	} else {
		valueW = valueW;
		valueH = valueH - 1;
	}

	var height	= screen.height;
	var width	= screen.width;
	var leftpos = width / 2 - valueW / 2;
	var toppos	= height / 2 - valueH / 2;

	self.resizeTo(valueW, valueH);
	self.moveTo(leftpos, toppos);
	self.resizeTo(valueW, valueH);		// 이유없다 resize잘안되어서 한번더 call
}

//font-size
function getFontCookie() { 
	var fontSize = getCookie("font_size"); 
	try { 
		if ( fontSize == null ) return 12; 
		if ( fontSize.length ) return parseInt(fontSize); else return 16; 
	} catch (e) { 
		return 16; 
	} 
} 
var fontSize = getFontCookie(); 

function scaleFont(val) { 
	var content, lineHeight; 
	var oldContent = document.getElementById("oldCnt"); 
	content = document.getElementById("wrap"); 
	if (oldContent != null) 
		content = oldContent; 
		if(val	==	12){
			fontSize = val; 
			lineHeight = fontSize+Math.round(1.1*fontSize); 
			content.style.fontSize = fontSize + "px"; 
		}else if (val > 0) { 
			if (fontSize <= 18) { 
				fontSize = fontSize + val; 
				lineHeight = fontSize+Math.round(1.1*fontSize); 
				content.style.fontSize = fontSize + "px"; 
			} 
		} else { 
			if (fontSize > 8) { 
				fontSize = fontSize + val; 
				lineHeight = fontSize+Math.round(1.1*fontSize); 
				content.style.fontSize = fontSize + "px"; 
			} else { 
				lineHeight = fontSize+Math.round(1.1*fontSize); 
				content.style.fontSize = fontSize + "px"; 
			} 
		} 
	var mydate = new Date; mydate.setDate(mydate.getDate()+1000); 
	setCookie("font_size", fontSize, mydate); 
}

//수동 탭메뉴 처리
var preNavipage = "";
function showNaviPage(tabID) {
	var NaviPage		= document.getElementById(tabID);

	if(preNavipage != NaviPage) {
		if(preNavipage != "") {
			preNavipage.style.display	= "none"; //.style.visibility	= "hidden"
		}
		NaviPage.style.display	= "block";
		preNavipage					= NaviPage;
	}
	/*
	else{
		preNavipage.style.display	= "none";
		preNavipage					= "";
	}
	*/
}


function getWindow(url,w,h)
{
		var position = "width="+w+",height="+h+",left=100,top=100,toolbar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0";
		window.open( url, '', position);
}

function fn_zipsearch(frmName,zip1,zip2,addr1,addr2)
{
		var i_url = "/message/member_zipcode_search.php?fm="+frmName+"&zip1="+zip1+"&zip2="+zip2+"&addr1="+addr1+"&addr2="+addr2;
		window.open(i_url,'openZipWindow','width=450,height=350,top=10,left=10,resizable=no,menubar=no,scrollbars=no');		
		return;
}

var old = "";
function viewMenu(e)
{
	if(old != e)
	{
		if(old != "")
		{
			document.getElementById(old).style.display = "none";
		}
		document.getElementById(e).style.display = "block";
		old = e;
	}
	else
	{
		document.getElementById(e).style.display = "none";
		old = "";
	}
}


// iframe auto resize
function resizeIFrame(ifrName) { 

	var min_h = 250;
	var oIFrame = document.getElementById(ifrName);

	try {          
	  
		var oDoc = oIFrame.contentDocument || oIFrame.contentWindow.document;        

		if (/MSIE/.test(navigator.userAgent)) {
			var frmHeight = oDoc.body.scrollHeight;
		} else {
			var s = oDoc.body.appendChild(document.createElement('DIV'))
			s.style.clear = 'both';

			var frmHeight = s.offsetTop;
			s.parentNode.removeChild(s);
		}

		if (frmHeight < min_h) 
			frmHeight = min_h;

		oIFrame.style.height = frmHeight+"px";

	} catch (e) { }
}


function checkLogData(frmObj) 
{
	var sUserId		= frmObj.mem_id.value;
	var sUerPass	= frmObj.mem_pass.value;

	if(sUserId == "") {
		alert("[아이디]는  필수 입력 사항입니다.");	
		frmObj.mem_id.focus();
		return false;
	}

	if(sUerPass == "") {
		alert("[비밀번호]는 필수 입력 사항입니다");
		frmObj.mem_pass.focus();
		return false;
	}
}
function checkLogSubmit(frmObj)
{
	if(checkLogData(frmObj))
		frmObj.submit();
}

/*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 ''; 
} 

function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}

 /*
따라댕기는 퀵메뉴...

ie랑 파폭까지는 된다...
*/
var _initTop = 0;
var _layerID = "";

function FlowBanner ( id, initTop )
{
//alert(navigator.appName);
 var ns = (navigator.appName.indexOf("Netscape") != -1);
 if (ns) initTop = initTop

 var layer = document.getElementById(id);
 layer.style.top = initTop+"px";;

 _layerID = id;
 _initTop = initTop;
 _FlowBanner ();
}

function _FlowBanner ()
{
 var layer = document.getElementById(_layerID);
 var ns = (navigator.appName.indexOf("Netscape") != -1);

 if (ns){
  num = (layer.style.top.length);
  var currentTop = layer.style.top.substring(0,(num-2));
  currentTop = parseInt(currentTop);

 }else{
  var currentTop = parseInt ( layer.style.top );
 }

 if (ns){
  var baseTop = parseInt ( document.documentElement.scrollTop );
 }else{
  var baseTop = parseInt ( document.documentElement.scrollTop );
 }

 var nextTop = baseTop + _initTop;
 var distance = ( nextTop - currentTop ) / 15;

 if ( distance > 10 )
  distance = 10;
 else if ( distance < -10 )
  distance = -10;
 if (ns){
  layer.style.top = (currentTop + distance)+"px";
 }else{
  layer.style.top = currentTop + distance;
 }


 setTimeout ( "_FlowBanner()", 1 );
}



function init()
{
 FlowBanner ( "scrollB", 0 );
}
