/******************************************************************************
*                                     COMMON SCRIPT
*******************************************************************************/

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_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_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 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 MN_Select(obj){
	
	document.getElementById('a').src= '/v2/img/common/top_menu01.gif';
	document.getElementById('b').src= '/v2/img/common/top_menu02.gif';
	document.getElementById('c').src= '/v2/img/common/top_menu03.gif';
	document.getElementById('d').src= '/v2/img/common/top_menu04.gif';
	document.getElementById('e').src= '/v2/img/common/top_menu05.gif';
	document.getElementById('f').src= '/v2/img/common/top_menu06.gif';
	document.getElementById('g').src= '/v2/img/common/top_menu07.gif';
	document.getElementById('h').src= '/v2/img/common/top_menu08.gif';
	document.getElementById('a_sub').style.display = 'none';
	document.getElementById('b_sub').style.display = 'none';
	document.getElementById('c_sub').style.display = 'none';
/*	document.getElementById('d_sub').style.display = 'none';*/
	document.getElementById('e_sub').style.display = 'none';
	document.getElementById('f_sub').style.display = 'none';
	document.getElementById('g_sub').style.display = 'none';
/*	document.getElementById('h_sub').style.display = 'none';
*/
	switch(obj){
		case'a':
			document.getElementById('a').src= '/v2/img/common/top_menu01_.gif';
			document.getElementById('b').title='입찰정보';
			document.getElementById('a_sub').style.display = 'block';
		break;
		
		case'b':
			document.getElementById('b').src= '/v2/img/common/top_menu02_.gif';
			document.getElementById('b').title='낙찰정보';
			document.getElementById('b_sub').style.display = 'block';
		break;

		case'c':
			document.getElementById('c').src= '/v2/img/common/top_menu03_.gif';
			document.getElementById('b').title='파워분석';
			document.getElementById('c_sub').style.display = 'block';
		break;

		case'd':
			document.getElementById('d').src= '/v2/img/common/top_menu04_.gif';
			document.getElementById('b').title='실시간맞춤정보';
		break;

		case'e':
			document.getElementById('e').src= '/v2/img/common/top_menu05_.gif';
			document.getElementById('b').title='개인서류함';
			document.getElementById('e_sub').style.display = 'block';
		break;

		case'f':
			document.getElementById('f').src= '/v2/img/common/top_menu06_.gif';
			document.getElementById('b').title='낙찰분석매니저';
			document.getElementById('f_sub').style.display = 'block';
		break;

		case'g':
			document.getElementById('g').src= '/v2/img/common/top_menu07_.gif';
			document.getElementById('b').title='입찰강좌';
			document.getElementById('g_sub').style.display = 'block';
		break;

		case'h':
			document.getElementById('h').src= '/v2/img/common/top_menu08_.gif';
			document.getElementById('b').title='고객센터';
		break;

	}
}

/*******************************
체크박스
********************************/
function check_all (el)
{
	for (i=0; i < el.length; i++) {
		el[i].checked = true;

	}
}

function check_free (el)
{
	for (i=0; i < el.length; i++) {
		el[i].checked = false;
	}
}
/*******************************
시간 
********************************/
var DAYARRAY = new Array ("일", "월", "화", "수", "목", "금", "토");

function show_date()
{
	var todate = new Date ();
	var year = todate.getYear ();
	var month = todate.getMonth () + 1;
	var day = todate.getDay ();
	var daym = todate.getDate ();
	var hours = todate.getHours ();
	var minutes = todate.getMinutes ();
	var seconds = todate.getSeconds ();
	var dn = "오전";


	if (year < 1000) year += 1900;
	if (month < 10) month = "0" + month;
	if (daym < 10) daym = "0" + daym;
	if (hours >= 12) dn = "오후";
	if (hours > 12) hours = hours - 12;
	if (hours == 0) hours = 12;
	if (minutes <= 9) minutes = "0" + minutes;
	if (seconds <= 9) seconds = "0" + seconds;

	var strdate = year + "." + month + "." + daym + "(" + DAYARRAY[day] + ")<br>" + dn + " " + hours + ":" + minutes + ":" + seconds;

	tick1.innerHTML = strdate;

	setTimeout ("show_date()", 1000);
}

function Nshow_date()
{
	var todate = new Date ();
	var year = todate.getYear ();
	var month = todate.getMonth () + 1;
	var day = todate.getDay ();
	var daym = todate.getDate ();
	var hours = todate.getHours ();
	var minutes = todate.getMinutes ();
	var seconds = todate.getSeconds ();
	var dn = "오전";


	if (year < 1000) year += 1900;
	if (month < 10) month = "0" + month;
	if (daym < 10) daym = "0" + daym;
	if (hours >= 12) dn = "오후";
	if (hours > 12) hours = hours - 12;
	if (hours == 0) hours = 12;
	if (minutes <= 9) minutes = "0" + minutes;
	if (seconds <= 9) seconds = "0" + seconds;

	var strdate = year + "/" + month + "/" + daym + " (" + DAYARRAY[day] +"요일:"+ dn + ") </span><span style='color:#000000'>" + hours + ":" + minutes + ":" + seconds;

	tick1.innerHTML = strdate;

	setTimeout ("Nshow_date()", 1000);
}

function notice_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 "";
}

/*******************************
	body onload function
********************************/
function open_fun(){
	if ( notice_getCookie( "Notice" ) != "done" )
	{
		   window.open("notice/pop_080102_education.html","","width=400, height=630"); // 팝업윈도우의 경로와 크기를 설정 하세요
	}
}

function swf( swfFile, val, height, width, color ){
	
	var html = '';
	html += '			<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	html += '			id="graph" width="'+width+'" height="'+height+'"';
	html += '			codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">';
	html += '			<param name="movie" value="'+swfFile+'" />';
	html += '			<param name="quality" value="high" />';
	html += '			<param name="bgcolor" value="'+color+'" />';
	html += '			<param name="flashVars" value="&'+val+'" />';
	html += '			<param name="allowScriptAccess" value="sameDomain" />';
	html += '			<embed src="'+swfFile+'" quality="high" bgcolor="'+color+'"';
	html += '				width="'+width+'" height="'+height+'" name="graph" align="middle"';
	html += '				play="true"';
	html += '				loop="false"';
	html += '				quality="high"';
	html += '				flashVars="'+val+'"';
	html += '				allowScriptAccess="sameDomain"';
	html += '				type="application/x-shockwave-flash"';
	html += '				pluginspage="http://www.adobe.com/go/getflashplayer">';
	html += '			</embed>';
	html += '		</object>';

	document.write(html);
}

// 컴베이스 팝업링크 /notice/pop_070416.html","eventpop","width=400, height=490

var msgBoxLayerId = 'msgBoxLayer';
function opMsgLayerOpen(id, msg, x, y ){

	if( $('#'+msgBoxLayerId).attr('id') ){
		$('#'+msgBoxLayerId).css({display:'block'});
	}else{
		jQuery('<div />')
			.attr("id", "msgBoxLayer")
			.css({position:'absolute',left: x+'px',top: y+'px'})
			.html(msg)
			.appendTo(document.body);
	}

}
function opMsgLayerClose(){	
	if(!($('#'+msgBoxLayerId))) return; 
	$('#'+msgBoxLayerId).css({display:'none'});

}


function loginPopup(url, name, option){
	var loginWin=window.open(url, name, option);
		loginWin.focus();
}
