


//----------------------------------------------
//FileButton v1.0 Source By Bermann
//dobermann75@gmail.com
// ÀÌ¹ÌÁö ¹öÆ° function
//----------------------------------------------

function FileButton(imageswap, imagesrc)
{
	this.imageswap = imageswap;
	this.imagesrc = imagesrc;
	this.swapnode = document.getElementsByTagName("INPUT");
	this.filebox = document.createElement("DIV");
	this.filebox.style.width = "0px";
	this.filebox.style.height = "0px";
	this.filebox.style.position = "relative";
	this.filebox.style.overflow = "hidden";
}

FileButton.prototype =
{
	getBounds: function (tag) {
		var ret = new Object();
		if (tag.getBoundingClientRect) {
			var rect = tag.getBoundingClientRect();
			ret.left = rect.left + (document.documentElement.scrollLeft || document.body.scrollLeft);
			ret.top = rect.top + (document.documentElement.scrollTop || document.body.scrollTop);
			ret.width = rect.right - rect.left;
			ret.height = rect.bottom - rect.top;
		} else if (document.getBoxObjectFor) {
			var box = document.getBoxObjectFor(tag);
			ret.left = box.x;
			ret.top = box.y;
			ret.width = box.width;
			ret.height = box.height;
		} else {
			ret.left = tag.offsetLeft;
			ret.top = tag.offsetTop;
			ret.width = tag.offsetWidth;
			ret.height = tag.offsetHeight;
		}
		if (navigator.appName == "Microsoft Internet Explorer") {
			ret.left -= 2;
			ret.top -= 2;
		}
		return ret;
	},
	swap: function (swapnode) {
		var This = this;
		var filebox = this.filebox.cloneNode(true);
		var image = new Image();
		var imageurl = swapnode.getAttribute(this.imagesrc);
		swapnode.parentNode.insertBefore(filebox, swapnode);
		filebox.appendChild(swapnode);
		filebox.appendChild(image);
		filebox.style.width = this.getBounds(swapnode).width + "px";
		filebox.style.height = this.getBounds(swapnode).height + "px";
		image.onload = function () {
			this.parentNode.style.backgroundImage = "url(" + this.previousSibling.getAttribute(This.imagesrc) + ")";
			this.parentNode.style.backgroundRepeat = "no-repeat";
			this.parentNode.style.width = this.width + "px";
			this.parentNode.style.height = this.height + "px";
			this.previousSibling.style.filter = "alpha(opacity=0)";
			this.previousSibling.style.opacity = 0;
			this.previousSibling.style.fontSize = (Math.max(this.width, this.height) + 30) + "px";
			this.previousSibling.style.position = "relative";
			this.previousSibling.style.height = (this.height + 30) + "px";
			this.previousSibling.style.left = (0 - This.getBounds(this.previousSibling).width) + "px";
			this.previousSibling.style.top = "-10px";
			
			var parentnode = this.parentNode;
			var divForGetHTML = filebox.cloneNode(false);
			divForGetHTML.appendChild(this.previousSibling);
			parentnode.innerHTML = divForGetHTML.innerHTML;

			var fileright = This.getBounds(parentnode.firstChild).left + This.getBounds(parentnode.firstChild).width;
			var boxright = This.getBounds(parentnode).left + This.getBounds(parentnode).width;
			if (fileright < boxright) {
				parentnode.firstChild.style.left = (This.getBounds(parentnode.firstChild).left + boxright) + "px";
			}

			divForGetHTML = null;
			parentnode.firstChild.setAttribute(This.imageswap, "swapped");
		}
		image.src = swapnode.getAttribute(this.imagesrc);
	},
	write: function (source) {
		var spanid = "spanforFileButton" + new Date().getTime();
		document.write('<span id="' + spanid + '">' + source + '</span>');
		var span = document.getElementById(spanid);
		this.swap(span.firstChild);
		span.parentNode.insertBefore(span.firstChild, span);
		span = null;
	},
	run: function () {
		for (var i = 0; i < this.swapnode.length; i++) {
			var swapnode = this.swapnode[i];
			if (swapnode.type == "file" && swapnode.getAttribute(this.imageswap) == "true") {
				this.swap(swapnode);
			}
		}
	}
}
//----------------------------------------------
// ÀÌ¹ÌÁö ¹öÆ° function ³¡
//----------------------------------------------
//  ÇÃ·¡½Ã View
function flash(FlashIDName, FlashFileName, FlashWidth, FlashHeight, DNSSetting, WMODESetting, FlashBGColor, QSetting, FlashAlign, FlashHSpace)
{
	document.write('<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write('CODEBASE="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=8,0,22,0" ');
	document.write(' ID="'+FlashIDName+'" WIDTH="' + FlashWidth + '" HEIGHT="' + FlashHeight + '" ALIGN="'+FlashAlign+ '" HSPACE="' + FlashHSpace +'">');
	document.write('<PARAM NAME="movie" VALUE="'+ FlashFileName +'">');
	document.write('<PARAM NAME="quality" VALUE="'+QSetting+'">');
	document.write('<PARAM NAME="bgcolor" VALUE="'+FlashBGColor+'">');
	document.write('<PARAM NAME="wmode" VALUE="'+WMODESetting+'">');
	document.write('<PARAM NAME="allowScriptAccess" VALUE="'+DNSSetting+'">');
	document.write('<EMBED SRC="'+ FlashFileName +'"  NAME="'+FlashIDName+'"');
	document.write(' WIDTH="' + FlashWidth + '" HEIGHT="' + FlashHeight + '" QUALITY="'+QSetting+'" BGCOLOR="'+FlashBGColor+'"');
	document.write(' ALLOWSCRIPTACCESS="'+DNSSetting+'" ALIGN="'+FlashAlign+'" WMODE="'+WMODESetting+'" TYPE="application/x-shockwave-flash" ');
	document.write(' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" >');
	document.write('</EMBED>');
	document.write('</OBJECT>');
}

function goTwitter(msg,url) {
		var href = "http://twitter.com/home?status=" + encodeURIComponent(msg) + " " + encodeURIComponent(url);
		var a = window.open(href, 'twitter', '');
		if ( a ) {
			a.focus();
		}
}

function goFaceBook(msg,url) {
		var href = "http://www.facebook.com/sharer.php?u=" + url + "&t=" + encodeURIComponent(msg);
		var a = window.open(href, 'facebook', '');
		if ( a ) {
			a.focus();
		}
}

// µÎ ³¯Â¥ »çÀÌÀÇ °£°ÝÀ» ±¸ÇÔ
function dayDiff(date1, date2){
 var v1 = date1.split("-");
 var v2 = date2.split("-"); 
 
 var a1 = new Date(v1[0], v1[1] - 1, v1[2]).getTime();
 var a2 = new Date(v2[0], v2[1] - 1, v2[2]).getTime();
 

 return (a2 - a1) / (1000 * 60 * 60 * 24);
}

function numberCheck( objtext1 ) {
	var inText = objtext1.value;
    var ret;
    for (var i = 0; i <= inText.length; i++) {
		ret = inText.charCodeAt(i);
        if ( ( ret <= 47 && ret > 31) || ret >= 58 ) {
			objtext1.focus();
            return false;
		}
	}
	return true;
}


function flashObject(file_name,flashVar,width,height){
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + width + '" height="' + height + '">');
  document.write('<param name="movie" value="' + file_name + '">');
  document.write('<param name=FlashVars value="' + flashVar + '">');
  document.write('<param name="quality" value="high">');
  document.write('<param name="wmode" value="transparent">');
  document.write('<embed src="' + file_name +'" FlashVars="' + flashVar +'" width="' + width + '" height="' + height + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>');
  document.write('</object>');
}

