/*-------------------------------------------------
  DevenStudio Common JavaScript Library
  ver. 0.05
  Mfd. 2007.05.13
 ------------------------------------------------*/

/* --- JavaScript String Method --- */

// Trim String
String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

// Count Chars.
String.prototype.occurs = function(ch)
{
    return this.split(ch).length-1;
}

// Match Digit.
String.prototype.isDigit = function()
{
    var s = this.Trim();
    return (s.replace(/\d/g, "").length == 0);
}

// Match Numeric Or '_'
String.prototype.isAlpha = function()
{
    return (this.replace(/\w/g, "").length == 0);
}

// Match Numeric.
String.prototype.isNumber = function()
{
    var s = this.Trim();
    return (s.search(/^[+-]?[0-9.]*$/) >= 0);
}
  
// Match length.
String.prototype.lenb = function()
{
    return this.replace(/[^\x00-\xff]/g,"**").length;
}

// Match Chinese Chars.
String.prototype.isInChinese = function()
{
    return (this.length != this.replace(/[^\x00-\xff]/g,"**").length);
}

// Match Date.
String.prototype.isDate = function()
{
    var p;
    var re1 = /(\d)[年./-](\d)[月./-](\d)[日]?$/;
    var re2 = /(\d)[月./-](\d)[日./-](\d)[年]?$/;
    var re3 = /(\d)[月./-](\d)[日./-](\d)[年]?$/;
    if(re1.test(this))
    {
        p = re1.exec(this);
        return new Date(p[1],p[2],p[3]);
    }
    if(re2.test(this))
    {
        p = re2.exec(this);
        return new Date(p[3],p[1],p[2]);
    }
    if(re3.test(this))
    {
        p = re3.exec(this);
        return new Date(p[3],p[1],p[2]);
    }
    
    return false;
}

// Check in list.
String.prototype.isInList = function(list)
{
    var re = eval("/["+list+"]/");
    return re.test(this);
}

// Match E-Mail.
String.prototype.isEmail = function()
{
    var re = /[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+/i;
    return re.test(this);
}



/* --- DevenStudio Method --- */

//set first focus
function FirstFocus()
{
	document.forms.SelForm.elements[0].focus();
}

//Enter Move Next Focus(IE)
function NextFocus()
{
	if (event.keyCode == 13) event.keyCode = 9;
}

/*------------------------------------------------------------
FAV
------------------------------------------------------------*/
function ShowEdit(strURL)
{
	window.open(strURL,'EditFav','menubar=no,toolbar=no,location=no,status=no,scrollbars=no,resizable=no,modal=yes,width=500,height=220,left=' + ((screen.availWidth-500)*.5) + ',top=' + ((screen.availHeight-300)*.3));
}

function doSelAll(objName,objToSet)
{
	var objBox=document.getElementsByName(objName);
	for(var i=0;i<objBox.length;i++)
	{
		objBox[i].checked=objToSet.checked;
	}
}

function doCmd(strCmd,strArgs)
{
	document.getElementById("txtCmd").value = strCmd + "," + strArgs;
	__doPostBack('txtCmd','');
}

/*------------------------------------------------------------
HeadMemu
------------------------------------------------------------*/
function onSelect(param)
{
	var objs = document.getElementsByTagName("a");
	for(var i = 0;i < objs.length;i++)
		objs[i].className = "";
	param.className = "selected";
}

/*------------------------------------------------------------
WriteFlash
------------------------------------------------------------*/
function WriteHeadFlash(Path,Width,Height,Transparent)
{
	var Temp,T = "";
	Temp = '<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="FlashH" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="'+Width+'" height="'+Height+'">';
	Temp += '<param name="movie" value="'+Path+'"/>';
	Temp += '<param name="quality" value="High"/>';
	Temp += '<param name="scale" value="ExactFit"/>';
	if (Transparent)
	{
		Temp += ' <param name="wmode" value="transparent"/>';
		T = 'wmode="transparent"';
	}
	Temp += '<embed src="'+Path+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="FlashH" width="'+Width+'" height="'+Height+'" quality="High" '+T+'></embed>';
	Temp += '</object>';
	document.write(Temp);
}

/*------------------------------------------------------------
FirstShow:
example: DispMagicEmot(144,350,500);
------------------------------------------------------------*/
function DispMagicEmot(MagicID,H,W)
{
  MagicFaceUrl = "../Flash/show.swf";;
  var obj=document.getElementById("ctl00_MainContent_MagicFace");
  obj.innerHTML = '<OBJECT codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + W + '" height="' + H + '"><PARAM NAME=movie VALUE="'+ MagicFaceUrl +'"><param name=menu value=false><PARAM NAME=quality VALUE=high><PARAM NAME=play VALUE=false><param name="wmode" value="transparent"><embed src="' + MagicFaceUrl +'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"; type="application/x-shockwave-flash" width="' + W + '" height="' + H + '"></embed>';
  obj.style.top = (document.body.scrollTop+((document.body.clientHeight)/2))+"px";
  obj.style.left = (document.body.scrollLeft+((document.body.clientWidth-480)/2))+"px";
  obj.style.visibility = 'visible';
  MagicID += Math.random();
  setTimeout("MM_showHideLayers('ctl00_MainContent_MagicFace','','hidden')",8000);
  NowMeID = MagicID;
}

function MM_showHideLayers()
{
	var i,p,v,obj,args=MM_showHideLayers.arguments;
		obj=document.getElementById("ctl00_MainContent_MagicFace");
	for (i=0; i<(args.length-2); i+=3)
		 if (obj)
		 {
			v=args[i+2];
			if (obj.style)
			{
				obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v;
			}
			obj.visibility=v;
		}
}

