/**
   verify the email valid

   @param email the email string
   @return whether valid
 */
function verifyEmail(email){
	var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
	if(pattern.test(email)){
		return true;
	}else{
		return false;
	}
}

titleDropListUpImg = new Image();
titleDropListDownImg = new Image();
titleDropListUpImg.src = "/admin/images/title_droplist_up.gif";
titleDropListDownImg.src = "/admin/images/title_droplist_down.gif";
function titleDropList(e, self){
	if("none" == e.style.display){
		e.style.display = "";
		self.src = titleDropListUpImg.src;
	}else{
		e.style.display = "none";	
		self.src = titleDropListDownImg.src;
	}
}

function WindowOpen(url,name,width,height,resizable,scrollbars,left,top)
{
var window_open = window.open(url,name,'width='+width+',height='+height+',resizable='+resizable+',scrollbars='+scrollbars+',left='+left+',top='+top);
window_open.focus();
}

function showHelp(url){
	var poo = window.open(url, 'helpWindow', 'width=550, height=350, resizable=1, scrollbars=1');
	poo.focus();
}

function deleteConfirm(logicalUrl, physicalUrl){
	if(window.event.shiftKey){
		msg = "Physical delete(can't resume)!! Are you sure?";
		url = physicalUrl;	
	}else{
		msg = "Logical delete, Are you sure?";
		url = logicalUrl;
	}

	if(confirm(msg)){
		location.href = url;
	}else{
		return false;
	}
}


//----------- dynamic extended Class fucntion start ------------//
/**
   Class Object function
   example: 
	<SCRIPT LANGUAGE=javascript>
	<!--
	var floatMsg = new floatMsg();
	//-->
	</SCRIPT>
	<A HREF="#" ONCLICK="javascript:floatMsg.floatShow('<SPAN ONCLICK=javascript:floatMsg.floatHidden();>Message Test!</SPAN>',500,100);">Help?</A>
 */
function extendInfo(extendObj, extBtn, btnInnerHTML1, btnInnerHTML2){
	this.extendObj = extendObj;
	this.extBtn = extBtn;
	this.btnInnerHTML1 = btnInnerHTML1;
	this.btnInnerHTML2 = btnInnerHTML2;

	//initialize
	this.extInnerHTML = this.extendObj.innerHTML;
	this.extended = true;

	//member function
	this.extExtend = extExtend;
	this.extClose = extClose;
	this.changeBtn = changeBtn;
	this.btnOnClick = btnOnClick;
}

//function extendInfo(extendObj, test){
	//this.extendInfo(extendObj);
	//alert(test);
//}

function extExtend(){
	this.extendObj.innerHTML = this.extInnerHTML;
	//this.extendObj.style.display = "";
	this.extended = true;
}

function extClose(){
	this.extInnerHTML = this.extendObj.innerHTML;
	this.extendObj.innerHTML = "";
	//this.extendObj.style.display = "none";
	this.extended = false;
}

function changeBtn(){
	if("" == this.extBtn || "undefined" == this.extBtn || null == this.extBtn) return;
	if(this.btnInnerHTML1 != this.extBtn.innerHTML) this.extBtn.innerHTML = this.btnInnerHTML1;
	else this.extBtn.innerHTML = this.btnInnerHTML2;
}

function btnOnClick(){
	this.changeBtn();
	if(this.extended){
		this.extClose();
	}else{
		this.extExtend();
	}
	/*
	extIDPrefix = "_ext_";
	extBtnText = "Extend";
	if("none" == extTable.style.display){
		for(var i = 0; i < form.length; i++){
			e = form.elements[i];
			if(extIDPrefix == e.id.substr(0, 5)){
				e.disabled = false;
			}
		}
		extTable.style.display = "";
		extBtn.innerText = extBtnText + " <<<";
		//extBtn.style.textdecoration = "none";
		//extBtn.style.color = "#FFFFFF";
	}else{
		for(var i = 0; i < form.length; i++){
			e = form.elements[i];
			if(extIDPrefix == e.id.substr(0, 5)){
				e.disabled = true;
			}
		}
		extTable.style.display="none";
		//extBox.style.border="";
		//extTitle.style.backgroundColor = "";
		extBtn.innerText = extBtnText + " >>>";
		//extBtn.style.color = "";
	}
	*/
}
//----------- dynamic extended fucntion end ------------//



//----------- float message class start ------------//
/**
   Class Object function
 */
function floatMsg(floatBoxID, contentLabelID, bgColor){
	this.brOK = navigator.javaEnabled()?true:false
	this.ns4 = (document.layers)?true:false
	this.ie4 = (document.all)?true:false

	//property
	this.floatBoxID = "";
	this.floatBoxShadowID = "";
	this.contentLabelID = "";
	this.contentLabelShadowID = "";
	this.floatBox = null;
	this.floatBoxShadow = null;
	this.contentLabel = null;
	this.contentLabelShadow = null;
	this.bgColor = "";

	//member function
	this.floatConfig = floatConfig;
	this.floatShow = floatShow;
	this.floatHidden = floatHidden;
	this.floatFill = floatFill;
	this.floatPreDraw = floatPreDraw;

	//initialize
	this.floatConfig(floatBoxID, contentLabelID, bgColor);
	this.floatPreDraw();

	if(!this.ns4){
		this.floatBox = document.all[this.floatBoxID];
		this.floatBoxShadow = document.all[this.floatBoxShadowID];
		this.contentLabel = document.all[this.contentLabelID];
		this.contentLabelShadow = document.all[this.contentLabelShadowID];
	}else{
		this.floatBox = document.layers[this.floatBoxID];
		this.floatBoxShadow = document.layers[this.floatBoxShadowID];
		this.contentLabel = document.layers[this.contentLabelID];
		this.contentLabelShadow = document.layers[this.contentLabelShadowID];	
	}
}

function floatConfig(floatBoxID, contentLabelID, bgColor){
	if("" == floatBoxID || "undefined" == floatBoxID || null == floatBoxID) floatBoxID = "_calendarFloatBox";
	if("" == contentLabelID || "undefined" == contentLabelID || null == contentLabelID) contentLabelID = "_calendarContentLabel";
	if("" == bgColor || "undefined" == bgColor || null == bgColor) bgColor = "#FFFFFF";
	this.floatBoxID = floatBoxID;
	this.contentLabelID = contentLabelID;
	this.contentLabelShadowID = this.contentLabelID + "Shadow";
	this.floatBoxShadowID = this.floatBoxID + "Shadow";
	this.bgColor = bgColor;
}

function floatPreDraw(){
	table = "<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=0 BGCOLOR=\"#000000\">\n" +
			"<TR>\n<TD>\n" +
			"<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=4 WIDTH=\"100%\" BGCOLOR=\"" + this.bgColor + "\">\n" +
			"<TR>\n" +
			"<TD>\n<FONT face=\"verdana,arial\" size=\"1\" COLOR=\"black\"><SPAN ID=" + this.contentLabelID + "></SPAN></TD>\n" +
			"<TD WIDTH=12 VALIGN=top><INPUT TYPE=button VALUE='X' STYLE='font-size:8pt;' ONCLICK='javascript:{" + this.floatBoxID + ".style.visibility = \"hidden\"; " + this.floatBoxShadowID + ".style.visibility = \"hidden\";}'></TD>\n" +
			"</TR>\n" +
			"</TABLE>\n" +
			"</TD>\n" +
			"</TR>\n" +
			"</TABLE>\n";
	table1 = "<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=0>\n" +
			"<TR>\n<TD>\n" +
			"<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=4 WIDTH=\"100%\" BGCOLOR=\"#808080\">\n" +
			"<TR>\n" +
			"<TD>\n<FONT face=\"verdana,arial\" size=\"1\" COLOR=\"black\"><SPAN ID=" + this.contentLabelShadowID + "></SPAN></TD>\n" +
			"<TD WIDTH=12 VALIGN=top><INPUT TYPE=button VALUE='X' STYLE='font-size:8pt;'></TD>\n" +
			"</TR>\n" +
			"</TABLE>\n" +
			"</TD>\n" +
			"</TR>\n" +
			"</TABLE>\n";

	if(this.ns4){
		document.write('<layer id="' + this.floatBoxShadowID + '" visibility="hide">' + table1 + '<\/layer>');
		document.write('<layer id="' + this.floatBoxID + '" visibility="hide">' + table + '<\/layer>');
	}else{
		document.write('<div id="' + this.floatBoxShadowID + '" style="position:absolute; visibility:hidden; ">' + table1 + '<\/div>');
		document.write('<div id="' + this.floatBoxID + '" style="position:absolute; visibility:hidden; ">' + table + '<\/div>');
	}
}

function floatShow(message, width, height){
	if(this.brOK){
		this.floatFill(message);
		var floatBoxShadowLeft, floatBoxShadowRight, floatBoxShadowTop, floatBoxShadowBottom;
		var floatBoxLeft, floatBoxRight, floatBoxTop, floatBoxBottom;
		var bodyRight, bodyBottom;
		floatBoxShadowWidth = width;
		floatBoxShadowHeight = height;
		floatBoxWidth = width;
		floatBoxHeight = height;
		if(this.ns4){
			if("" != width && "undefined" != width && null != width) this.floatBoxShadow.width = width;
			if("" != height && "undefined" != height && null != height) this.floatBoxShadow.height = height;
			this.floatBoxShadow.visibility = "show";
			if(event) this.floatBoxShadow.left = event.clientX + 10;
			if(event) this.floatBoxShadow.top = event.clientY + 10;

			if("" != width && "undefined" != width && null != width) this.floatBox.width = width;
			if("" != height && "undefined" != height && null != height) this.floatBox.height = height;
			this.floatBox.visibility = "show";
			if(event) this.floatBox.left = event.clientX + 10;
			if(event) this.floatBox.top = event.clientY + 10;
		}else{
			//if("" != width && "undefined" != width && null != width) this.floatBoxShadow.style.width = width;
			//if("" != height && "undefined" != height && null != height) this.floatBoxShadow.style.height = height;

			//if("" != width && "undefined" != width && null != width) this.floatBox.style.width = width;
			//if("" != height && "undefined" != height && null != height) this.floatBox.style.height = height;

			this.floatBox.style.visibility = "visible";
			this.floatBoxShadow.style.visibility = "visible";
			//floatBoxLeft = document.body.scrollLeft + event.clientX;
			//floatBoxTop = document.body.scrollTop + event.clientY;
//alert(event);
			if(event){
				leftEdge = event.clientX;
				rightEdge = document.body.clientWidth - event.clientX;
				topEdge = event.clientY;
				bottomEdge = document.body.clientHeight - event.clientY;

				if(this.floatBox.offsetWidth > rightEdge && rightEdge < leftEdge){
					this.floatBox.style.left = document.body.scrollLeft + event.clientX - this.floatBox.offsetWidth;
					this.floatBoxShadow.style.left = document.body.scrollLeft + event.clientX - this.floatBox.offsetWidth + 5;
				}else{
					this.floatBox.style.left = document.body.scrollLeft + event.clientX;
					this.floatBoxShadow.style.left = document.body.scrollLeft + event.clientX + 5;
				}

				if(this.floatBox.offsetHeight > bottomEdge && bottomEdge < topEdge){
					this.floatBox.style.top = document.body.scrollTop + event.clientY - this.floatBox.offsetHeight;
					this.floatBoxShadow.style.top = document.body.scrollTop + event.clientY - this.floatBox.offsetHeight + 5;
				}else{
					this.floatBox.style.top = document.body.scrollTop + event.clientY;
					this.floatBoxShadow.style.top = document.body.scrollTop + event.clientY + 5;
				}
			}
		}
	}
}

function floatHidden(){
	if(this.brOK){
		if(this.ns4){
			this.floatBox.visibility = "hide";
			this.floatBoxShadow.visibility = "hide";
		}else{
			this.floatBox.style.visibility = "hidden";
			this.floatBoxShadow.style.visibility = "hidden";
		}
	}
}

function floatFill(message){
	// Replace the contents of the tooltip
	if (!this.ns4){
		this.contentLabel.innerHTML = message;
		this.contentLabelShadow.innerHTML = message;
		this.contentLabelShadow.style.visibility = "hidden";
	}else {
		// In NS, insert a table to work around
		// stylesheet rendering bug.
		// NS fails to apply style sheets when writing
		// contents into a positioned element.
		this.contentLabel.document.open();
		this.contentLabel.document.write(message);
		this.contentLabel.document.close();
		this.contentLabelShadow.document.open();
		this.contentLabelShadow.document.write(message);
		this.contentLabelShadow.document.close();
		this.contentLabelShadow.visibility = "hide";
	}
}
//----------- float message class end ------------//