var Img_exist_global=true;
var _Img_width_global="";
var _Img_height_global="";
var now_date;
var from_date = '20110422';
var to_date = '20110509';
var link1=true;
var link1Href="http://mitak.or.kr/board_view.php?gubn=data&id=107&curpage=1&searchfield=&searchword=";
var link1Coords="286,300,451,344";
var link1Target="_blank";
var link2=false;
var link2Href="";
var link2Coords="";
var link2Target="_blank";
var link3=false;
var link3Href="";
var link3Coords="";
var link3Target="_blank";
var link4=false;
var link4Href="";
var link4Coords="";
var link41Target="_blank";
var link5=false;
var link5Href="";
var link5Coords="";
var link5Target="_blank";

function ImgDoesNotExist(){
	//alert("fail");
	Img_exist_global = false;
}

function getNowDate()
{
    var now = new Date();
    now_date = now.getYear()+''+fncLPAD((now.getMonth()+1))+''+fncLPAD(now.getDate());
}


function fncLPAD(num)
{
    if(num<10) return '0'+num;
    else return ''+num;
}

function CheckDate(){
	getNowDate();
	if(from_date<=now_date&&now_date<=to_date)
		return true;
	
	return false;
}

function ImgLoaded(width,height){
	
	
	Img_exist_global = true;
	_Img_width_global = width;
	_Img_height_global = height;
	if ( (getEventCookie("eventPopupLayerCookie") == ''||getEventCookie("eventPopupLayerCookie") == null)&&CheckDate()){
		drawLayerPopup();
	}
}

function drawLayerPopup(){
	//document.getElementById('_Main_Layer_event_popup').style.width=_Img_width_global;
	//document.getElementById('_Main_Layer_event_popup').style.height=_Img_height_global;
	document.getElementById('_Main_Layer_event_popup').style.visibility='';
	//if(Img_exist_global){
	document.getElementById("_Main_Layer_event_popup").style.left = ((document.body.scrollWidth/2)-parseInt(_Img_width_global)-50);
	
	var coordstr=(parseInt(_Img_width_global)-190)+","+(parseInt(_Img_height_global)-26)+","+_Img_width_global+","+_Img_height_global;
	document.getElementById('mapCoords').coords=coordstr;
	
		
	if(link1 == true){
		document.getElementById('map1Coords').coords=link1Coords;
		document.getElementById('map1Coords').href=link1Href;
		document.getElementById('map1Coords').target=link1Target;
	}
	if(link2 == true){
		document.getElementById('map2Coords').coords=link2Coords;
		document.getElementById('map2Coords').href=link2Href;
		document.getElementById('map2Coords').target=link2Target;
	}
	if(link3 == true){
		document.getElementById('map3Coords').coords=link3Coords;
		document.getElementById('map3Coords').href=link3Href;
		document.getElementById('map3Coords').target=link3Target;
	}
	if(link4 == true){
		document.getElementById('map4Coords').coords=link4Coords;
		document.getElementById('map4Coords').href=link4Href;
		document.getElementById('map4Coords').target=link4Target;
	}
	if(link5 == true){
		document.getElementById('map5Coords').coords=link5Coords;
		document.getElementById('map5Coords').href=link5Href;
		document.getElementById('map5Coords').target=link5Target;
	}
	
	
	document.getElementById("_Main_Layer_event_popup").style.zIndex=9000;
	document.getElementById("_Main_Layer_event_popup").onmousedown=PopMove2;
	document.getElementById("_Main_Layer_event_popup").onmouseup=Function("MoveEnabled=false");
	document.body.onresize=getWindowResizingEvent;
		
	//}
}

function getWindowResizingEvent(){
	document.getElementById("_Main_Layer_event_popup").style.left = ((document.body.scrollWidth/2)-parseInt(_Img_width_global)-50);
}

function getEventCookie(sName)
{
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
	var aCrumb = aCookie[i].split("=");
	if (sName == aCrumb[0])
	  return unescape(aCrumb[1]);
  }

  return null;
}

function setEventcookie( name, value, expiredays ){
    var todayDate = new Date();
    todayDate.setDate( todayDate.getDate() + expiredays );
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function closeWin(){
    
	setEventcookie( "eventPopupLayerCookie", "done" , 1); // 1=하룻동안 공지창 열지 않음
	document.getElementById('_Main_Layer_event_popup').style.visibility='hidden';
}

isIE=document.all;

function PopMove2(e){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(document.getElementById("_Main_Layer_event_popup").style.left);
    nowY=parseInt(document.getElementById("_Main_Layer_event_popup").style.top);
    oldx = isIE ? event.clientX-nowX : e.clientX-nowX
    oldy = isIE ? event.clientY-nowY : e.clientY-nowY
    MoveEnabled=true;

    document.onmousemove=PopMove;
}

 

function PopMove(e){
    if (!MoveEnabled) return; 

    document.getElementById("_Main_Layer_event_popup").style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
    document.getElementById("_Main_Layer_event_popup").style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
    return false;
}


