var div = document.createElement("DIV");
function msg(str,mode,scroll)
{
	var x = 0;
	var y = 0;
	var left = 0;
	var top = 0;

	if(scroll != 1)
	{
		window.scrollTo(0,0);
	}

	x = (document.documentElement.offsetWidth / 2)-260;
	y = document.documentElement.scrollTop + 100;
	left = document.body.scrollLeft + x;
	top = document.body.scrollTop + y;
	if(window.innerHeight)
	{
		myHeight = window.innerHeight + window.scrollMaxY;
	}
	else if(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ))
  	{
	    myHeight = document.body.scrollHeight;
  	}
  	else
	{
	    myHeight = document.body.offsetHeight;
	}

	html = "<div style=\"position:absolute;top:" + top + "px;left:" + left + "px;width:500px;background-color:rgb(235,235,235);font-weight:bold;text-align:left;padding:20px;z-index:101;border:1px solid rgb(102,102,102);\">" + str + "<br><br><div style=\"width:500px;text-align:center;\">";
	if(mode == 1)
	{
		html += "<button id=\"btn_ok\" onclick=\"return closemsg(1);\" style=\"width:96px;height:26px;padding:0px;border:0px;cursor:pointer;\"><img src=\"/images/btn_ok.jpg\" width=\"96\" height=\"26\" alt=\"OK\"></button>";
	}

	if(mode == 2)
	{
		html += "<button id=\"btn_ok\" onclick=\"return closemsg(1);\" style=\"width:96px;height:26px;padding:0px;border:0px;cursor:pointer;\"><img src=\"/images/btn_ok.jpg\" width=\"96\" height=\"26\" alt=\"OK\"></button><button onclick=\"return closemsg(0);\" style=\"width:100;margin-left:20px;\"><img src=\"/images/btn_cancel.jpg\" width=\"96\" height=\"26\" alt=\"Cancel\"></button>";
	}

	if(mode == 3)
	{
		html += "<button onclick=\"return closemsg(1);\" style=\"width:96px;height:26px;padding:0px;border:0px;cursor:pointer;\"><img src=\"/images/btn_cancel.jpg\" width=\"96\" height=\"26\" alt=\"Cancel\"></button>";
	}

	html += "</div></div><div style=\"position:absolute;left:0;top:0;width:100%;height:"+myHeight+"px;filter:alpha(opacity=80);-moz-opacity:.80;opacity:.80;background-color:white;z-index:100;\"></div>";
	div.innerHTML = html;
	document.body.appendChild(div);
	if(mode == 1 || mode == 2)
	{
		document.getElementById('btn_ok').focus();
	}
}

function closemsg(mode)
{
	document.body.removeChild(div);
	switch(mode)
	{
		case 1:return true;break;
		case 0:return false;break;
	}
}

function focusField(name)
{
  for(var i = 0; i < document.forms.length; ++i)
  {
    var obj = document.forms[i].elements[name];
    if (obj)
    {
      if (obj.length) { obj = obj[0]; }
      if (obj.focus) { obj.focus(); }
    }
  }
}

function FBpost(fbname, fblink, fbmessage)
{
 FB.init({
    appId:'318794799027', cookie:true,
    status:true, xfbml:true
 });


    FB.ui(
	   {
	     method: 'feed',
	     name: fbname,
	     link: fblink,
	     picture: 'http://www.namingforce.com/images/namingforce_fb.jpg',
	     caption: fbmessage
	   }
	 );
}
