/////////////////////////////////////////////////////// ·¹ÀÌ¾îÆË¾÷ »ý¼º ///////////////////////////////////////////////////
function OnLayPopupClose(oname)
{
	document.getElementById(oname).style.display = 'none';
}

function OnLayPopupSetCookie(cookiename)
{
	var expdate = new Date();
	expdate.setTime(expdate.getTime() + 1000 * 3600 * 24 * 1); // 1 ÀÏ

	setCookie(cookiename, '1', expdate);

	OnLayPopupClose('Layer'+cookiename);
}

function getCookie(name)
{
	var Found = false
	var start, end
	var i = 0
	while(i <= document.cookie.length) {
	start = i
	end = start + name.length
	if(document.cookie.substring(start,end) == name)
	{
		Found = true
		break
	}
		i++
	}
	if(Found == true)
	{
		start = end + 1
		end = document.cookie.indexOf(';',start)
		if(end<start)
		end = document.cookie.length
		return document.cookie.substring(start,end)
	}
	return ''
}

function setCookie (name, value, expires)
{
	document.cookie = name + "=" + escape (value) + "; path=/; expires=" + expires.toGMTString();
}

function OnLayPopupCreate(imgUrl, path, cookieName, Left, Top, Width, Height, usemap, dellogo)
{
	var html = "";	

	var bMap = usemap == null?false:true;
	var bLogo = dellogo == null?false:true;

	html += "<div id='Layer"+cookieName+"' style='position:absolute; left:" + Left + "px; top:" + Top + "px; width:300px; z-index:100;'>";
	html += "<table border=0 cellpadding=0 cellspacing=0 id='event_new'>";
	html += "<tr>";
	html += "<td width='" + (Width/1 + 10) + "' background='http://image.joinsland.com/index2006/common/pop_bg_top_middle.gif'><table border=0 cellpadding=0 cellspacing=0><tr><td width='" + (Width/1 + 10) + "'>";
	if (bLogo){
	}else{
	html += "<img src='http://image.joinsland.com/index2006/common/pop_bg_top_left.gif'   border='0'>"
	}
	html += "</td><td align='right'><img src='http://image.joinsland.com/index2006/common/pop_bg_top_right.gif'   border='0' usemap='#Map_"+cookieName+"_top'></td></tr></table></td>";
	html += "</tr>";
	html += "<tr>";
	html += "<td height='"+Height+"'><table border=0 cellpadding=0 cellspacing=0><tr><td background='http://image.joinsland.com/index2006/common/pop_bg_middle_left.gif' width=5></td>";
if (bMap){
	html+= "<td><img src='" + imgUrl + "' width='"+Width+"' height='"+Height+"' border='0' usemap='#Map_"+cookieName+"_popcontent'/></td>";
}else{
	if (path!="")
	{
		html+= "<td><a href='" + path + "'><img src='" + imgUrl + "' width='"+Width+"' height='"+Height+"' border='0' /></a></td>";
	}
	else
	{
			html+= "<td><img src='" + imgUrl + "' width='"+Width+"' height='"+Height+"' border='0' /></td>";
	}
}
	html+= "<td background='http://image.joinsland.com/index2006/common/pop_bg_middle_right.gif' width=5></td></tr></table></td>";
	html += "<td align='center' style='background-color:#4aa1bd;'></td>";
	html += "</tr>";
	html += "<tr>";
	html += "<td width='" + (Width/1 + 10) + "' background='http://image.joinsland.com/index2006/common/pop_bg_bottom_middle.gif'><table border=0 cellpadding=0 cellspacing=0><tr><td width='" + (Width/1 + 10) + "'>";
	html += "<a href=\"javascript:OnLayPopupSetCookie('"+cookieName+"');\"><img src='http://image.joinsland.com/index2006/common/pop_bg_bottom_left.gif'   border='0'></a></td><td align='right'><img src='http://image.joinsland.com/index2006/common/pop_bg_bottom_right.gif'   border='0' usemap='#Map_"+cookieName+"_right'></td></tr></table></td>";

	html += "</tr>";
	html += "</table>";

	html += "<map name='Map_"+cookieName+"_top'>";
	html += "<area shape='rect' coords='3,5,21,22' href=\"javascript:OnLayPopupClose('Layer"+cookieName+"');\">";
	html += "</map>";

	html += "<map name='Map_"+cookieName+"'_today' >";
	html += "<area shape='rect' coords='4,6,129,25' href=\"javascript:OnLayPopupSetCookie('"+cookieName+"');\">";
	html += "</map>";

	html += "<map name='Map_"+cookieName+"_right'>";
	html += "<area shape='rect' coords='3,6,50,21' href=\"javascript:OnLayPopupClose('Layer"+cookieName+"');\">";
	html += "</map>";

if (bMap){
	html += "<map name='Map_"+cookieName+"_popcontent'>";
	html += usemap
	html += "</map>";
}
	html += "</div> ";

	if (getCookie(cookieName) == "") document.write (html);
}


// jQuery¸¦ ÀÌ¿ëÇÏ¿© layerpopup banner »ý¼º 2009.04.07
function OnLayPopupCreate(p_url, p_option){
	var j$ = jQuery;
	var $parent = j$('#layerpopup .layer-container');
	var $options = j$.extend({
		stamp: parseInt(j$('#layerpopup input:checkbox[name=popup-cookie]').val(), 10) - 1,
		target: '_blank'
	}, p_option||{});
	var $ad = j$('<div></div>')
		.addClass('layer-ad')
		.attr('idx', $options.stamp);
	if($options.flash){
		$ad.html(createFlash($options.src, $options.width, $options.height));
	}else{
		if($options.type === 'html'){
			$ad.html($options.html);
		}else{
			var $image = j$('<img />')
				.attr('src', $options.src)
				.appendTo($ad);
			if(p_url !== ''){
				$image.wrap('<a href="' + p_url + '" target="' + $options.target + '"></a>');
			};
		};
	};
	
	$parent.append($ad);
};


function OnUrlPop(url){
	var userwidth = (screen.width);
	var userheight = (screen.height);
	window.open(url,"pop_fullwin",'scrollbars=yes,toolbar=yes,location=yes,status=yes, menubar=yes,resizable=yes,width='+userwidth+',height='+userheight+',left=0,top=0');
} 


function OnPlayFlash(src, width, height){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">')
document.write('<param name="movie" value="'+src+'">')
document.write('<param name="quality" value="high">')
document.write('<embed src="'+src+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed></object>')
}

function createFlash(src, width, height){
	var l_html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">';
	l_html += '<param name="movie" value="'+src+'">';
	l_html += '<param name="quality" value="best">';
	l_html += '<embed src="'+src+'" quality="best" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed></object>';

	return l_html;
};