var HOST = 'alogblog.com';

/*
Copyright (c) 1996-1997 Athenia Associates.
http://www.webreference.com/js/
License is granted if and only if this entire
copyright notice is included. By Tomer Shiran.
*/

function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") + (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function rememberMe (f) {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    now = now.toGMTString();
    if (f.author != undefined)
       setCookie('mtcmtauth', f.author.value, now, '/', '', '');
    if (f.email != undefined)
       setCookie('mtcmtmail', f.email.value, now, '/', '', '');
    if (f.url != undefined)
       setCookie('mtcmthome', f.url.value, now, '/', '', '');
    if (f.image != undefined)
       setCookie('mtcmtimage', f.image.value, now, '/', '', '');
}

function forgetMe (f) {
    deleteCookie('mtcmtmail', '/', '');
    deleteCookie('mtcmthome', '/', '');
    deleteCookie('mtcmtauth', '/', '');
    deleteCookie('mtcmtimage', '/', '');
    f.email.value = '';
    f.author.value = '';
    f.url.value = '';
    f.image.value = '';
}
function showSignal() {
  var signal = document.getElementById('signal');
  signal.innerHTML = '<embed src="http://wm-001.cafe24.com/bytealibaba/media/signal.wma" width="1" height="1"/>';
} 
  
function hideSignal() {
  var signal = document.getElementById('signal');
  signal.innerHTML = "";
}
function requireURL() {

  var url = document.comments_form.url.value;
  var name = document.comments_form.author.value;
  var text = document.comments_form.text.value;

  if(!commenter_name) {
  if(name.replace(/(^\s*)|(\s*$)/g,"") == '') {
     alert('이름을 적어 주세요.\nName is required. ^^');
     return false;
  }
  }
  if(url.replace(/(^\s*)|(\s*$)/g,"") == '') {
    alert('블로그 주소도 적어 주세요.\nBlog\' URL are required. ^^');
    return false;
  }

  if(text == '이 글과 관련되지 않은 질문/말씀은 포럼을 이용해 주시면 감사하겠습니다.') {
    alert('코멘트를 입력해 주십시요...');
    return false;
  }
  if(text.replace(/(^\s*)|(\s*$)/g,"") == '') {
    alert('코멘트 내용을 적어주세요.');
    return false;
  }
}
function copy_clip(meintext){
 if (window.clipboardData)
   {

   /* the IE-manier */
   window.clipboardData.setData("Text", meintext);

   /* waarschijnlijk niet de beste manier om Moz/NS te detecteren;
    het is mij echter onbekend vanaf welke versie dit precies werkt:
   */
   }
   else if (window.netscape)
   {

   /* dit is belangrijk maar staat nergens duidelijk vermeld:
    you have to sign the code to enable this, or see notes below
   */
   netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

   /* maak een interface naar het clipboard */
   var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
   if (!clip) return;

   /* maak een transferable */
   var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
   if (!trans) return;

   /* specificeer wat voor soort data we op willen halen; text in dit geval */
   trans.addDataFlavor('text/unicode');

   /* om de data uit de transferable te halen hebben we 2 nieuwe objecten
    nodig   om het in op te slaan 
   */
   var str = new Object();
   var len = new Object();

   var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);

   var copytext=meintext;

   str.data=copytext;

   trans.setTransferData("text/unicode",str,copytext.length*2);

   var clipid=Components.interfaces.nsIClipboard;

   if (!clip) return false;

   clip.setData(trans,null,clipid.kGlobalClipboard);

   }
   alert("아래 주소를 클립보드에 \"무료\"로 잘 보관해 드렸습니다(^^;;;).\n\n이곳은 \"UTF-8\" 인코딩을 사용하고 있습니다.\n\n" + meintext);
   return false;
}
function locBGImg() {
  var s = document.getElementById("individual").style;
  var y;

  if(self.innerHeight) /* all except Explorer */
  {
	y = self.innerHeight;
  }
  else if(document.documentElement&&document.documentElement.clientHeight)
  { 	/* Explorer 6 Strict Mode */
	y = document.documentElement.clientHeight;
  }
  else if (document.body) /* other Explorers */
  {
	y = document.body.clientHeight;
  }
  s.backgroundPosition = "205px " + (y - 168) + "px";
}

function previewImage() {
if(!document.getElementById("image").value) return;

var img = document.getElementById("preview-image");
var imgsrc = document.getElementById("image").value;

var re = /^http:\/\//;
if(!re.test(imgsrc)) {
  img.src = 'http://' + imgsrc;
} else {
  img.src = imgsrc;
}

while(!img.complete) {}
var fac = img.width / img.height;

if(img.width > 90) {
  img.width = 90;
  img.height = 90/fac;
}
}

function select_image() {

var img = document.getElementById("preview-image");
img.src = document.getElementById("select-menu").value;
}
function make_tb_url(cgipath, id1, id2) {

 var str = cgipath + "/" + id1 + "." + id2;
 return str;
}

function openwin(doc,w,h) {
  open(doc, '','toolbar=no,scrollbars=0,width=' + w + ',height=' + h);
}
