$(document).ready(function() {
	bindRollOver();
	bindFlashMessage();
});

var bindFlashMessage = function() {
	if ($('#flashMessage').html() != null) {
		$('#flashMessage').hide();
		alert($('#flashMessage').html());
	}
}

var bindRollOver = function() {
	$('.roll-over').mouseover(function() {
		$(this).attr('src', $(this).attr('src').replace('_on',''));
		$(this).attr('src', $(this).attr('src').replace('.','_on.'));
	});
	$('.roll-over').mouseout(function() {
		$(this).attr('src', $(this).attr('src').replace('_on',''));
	});
}

var setContentSize = function() {
	// var contentHeight = $(window).height() - 120;
	var contentHeight = $(document).height() - 250;
	$('#content').height(contentHeight);
}

var lPopup = function(id, title, src, width, height) {
	if ($('#'+id).attr('id') == id) {
		var newEle = $('#'+id);
	} else {
		// ·¹ÀÌ¾î »ý¼º
		var newEle = $('#lPopupTpl').clone();
		newEle.attr('id', id);
		newEle.width(width);
		newEle.height(height +24);
		newEle.css('top', '50px');
		newEle.css('left', '50px');
		$('body').append(newEle);
		$('#'+id+' p.title').html(title);
		$('#'+id+' iframe').width(width);
		$('#'+id+' iframe').height(height);
	}

	$('#'+id+' iframe').attr('src', src);
	// ·¹ÀÌ¾î Ç¥½Ã
	newEle.show();

	// µå·¡±× ¼³Á¤
	$('#'+id).draggable({handle:"div.title-box"});
	$('#'+id+' div.title-box').mouseover(function() {
		$('#'+id).css('border', '1px solid #f1f1f1');
	});
	$('.l-popup div.title-box').mouseout(function() {
		$('#'+id).css('border', '1px solid #000000');
	});
	// ´Ý±â¹öÆ° ¼³Á¤
	$('#'+id+' .btn-close').click(function () {
		$('#'+id).hide();
	});
}

var lPopupClose = function(now) {
	alert(now.attr('class'));
	$(this).parents('div.l-popup').each(function() {
		alert();
	});
}

var closePopup = function(popupName) {
	setCookie(popupName, 1, 1);
	self.close();
}

// ÄíÅ° ÀúÀå
var setCookie = function(name, value, expiredays) {
	var todayDate = new Date(); 
	todayDate.setDate(todayDate.getDate() + expiredays); 
	document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
}
