/*
function help(url,mwidth,mheight)
{
	if (document.all&&window.print)
		eval('window.showModelessDialog(url,"","help:0;resizable:0;status:no;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")')
	else
		eval('window.open(url,"","width='+mwidth+'px,height='+mheight+'px,resizable=0,scrollbars=0")')
}
*/
function help(url,mwidth,mheight)
{
	window.open(url,"","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=518,height=500");
}

function wizard()
{
	url = 'message.php?action=wizard&type=template';
	mwidth=600;
	mheight=500;
	if (document.all&&window.print)
		eval('window.showModelessDialog(url,"","help:0;resizable:0;status:no;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")')
	else
		eval('window.open(url,"","width='+mwidth+'px,height='+mheight+'px,resizable=0,scrollbars=0")')
}

function colortables
(
	str_tableid,
	num_header_offset,
	num_footer_offset,
	str_odd_color,
	str_even_color,
	str_mover_color,
	str_onclick_color
)
{
	if (typeof(document.all) != 'object') return;
	var obj_tables = (document.all ? document.all[str_tableid] : document.getElementById(str_tableid));
	var col_config = [];
	col_config.header_offset = (num_header_offset ? num_header_offset : 0);
	col_config.footer_offset = (num_footer_offset ? num_footer_offset : 0);
	col_config.odd_color = (str_odd_color ? str_odd_color : '#ffffff');
	col_config.even_color = (str_even_color ? str_even_color : '#dbeaf5');
	col_config.mover_color = (str_mover_color ? str_mover_color : '#6699cc');
	col_config.onclick_color = (str_onclick_color ? str_onclick_color : '#4C7DAB');

	if (obj_tables.length)
		for (var i = 0; i < obj_tables.length; i++)
		loading(obj_tables[i], col_config);
	else
		loading(obj_tables, col_config);
}

function loading(obj_table, col_config)
{
	var col_lconfig = [],
	col_trs = obj_table.rows;
	for (var i = col_config.header_offset; i < col_trs.length - col_config.footer_offset; i++) {
		col_trs[i].config = col_config;
		col_trs[i].lconfig = col_lconfig;
		col_trs[i].set_color = setcolor;
		col_trs[i].onmouseover = mouseover;
		col_trs[i].onmouseout = mouseout;
		col_trs[i].order = (i - col_config.header_offset) % 2;
		col_trs[i].onmouseout();
	}
}
function setcolor(str_color) {
	this.style.backgroundColor = str_color;
}

function mouseover () {
	if (this.lconfig.clicked != this)
		this.set_color(this.config.mover_color);
}
function mouseout () {
	if (this.lconfig.clicked != this)
		this.set_color(this.order ? this.config.odd_color : this.config.even_color);
}
function checkall(form)
{
	for(var i = 0;i < form.elements.length; i++) {var e = form.elements[i];if (e.name != 'chkall') e.checked = form.chkall.checked;}
}
function modelesswin(url,mwidth,mheight)
{
	if (document.all&&window.print)
	eval('window.showModelessDialog(url,"","help:0;resizable:0;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")')
	else
	eval('window.open(url,"","width='+mwidth+'px,height='+mheight+'px,resizable=1,scrollbars=1")')
}

/************************************************************************************************************
(C) www.dhtmlgoodies.com, October 2005

Version 1.2: Updated, November 12th. 2005

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

************************************************************************************************************/
var panelWidth = 150;	// Width of help panel
var slideSpeed = 15;	// Higher = quicker slide
var slideTimer = 10;	// Lower = quicker slide
var slideActive = true;	// Slide active ?
var initBodyMargin = 0;	// Left or top margin of your <body> tag (left if panel is at the left, top if panel is on the top)
var pushMainContentOnSlide = true;	// Push your main content to the right when sliding
var panelPosition = 1; 	// 0 = left , 1 = top

/* Don't change these values */
var slideLeftPanelObj=false;
var slideInProgress = false;
var startScrollPos = false;
var panelVisible = false;
function initSlideLeftPanel(expandOnly)
{
	if(slideInProgress)return;
	if(!slideLeftPanelObj){
		if(document.getElementById('dhtmlgoodies_leftPanel')){	// Object exists in HTML code?
			slideLeftPanelObj = document.getElementById('dhtmlgoodies_leftPanel');
			if(panelPosition == 1)slideLeftPanelObj.style.width = '100%';
		}else{	// Object doesn't exist -> Create <div> dynamically
			slideLeftPanelObj = document.createElement('DIV');
			slideLeftPanelObj.id = 'dhtmlgoodies_leftPanel';
			slideLeftPanelObj.style.display='none';
			document.body.appendChild(slideLeftPanelObj);
		}

		if(panelPosition == 1){
			slideLeftPanelObj.style.top = "-" + panelWidth + 'px';
			slideLeftPanelObj.style.left = '0px';
			slideLeftPanelObj.style.height = panelWidth + 'px';
		}else{
			slideLeftPanelObj.style.left = "-" + panelWidth + 'px';
			slideLeftPanelObj.style.top = '0px';
			slideLeftPanelObj.style.width = panelWidth + 'px';
		}


		if(!document.all || navigator.userAgent.indexOf('Opera')>=0)slideLeftPanelObj.style.position = 'fixed';;
	}

	if(panelPosition == 0){
		if(document.documentElement.clientHeight){
			slideLeftPanelObj.style.height = document.documentElement.clientHeight + 'px';
		}else if(document.body.clientHeight){
			slideLeftPanelObj.style.height = document.body.clientHeight + 'px';
		}
		var leftPos = slideLeftPanelObj.style.left.replace(/[^0-9\-]/g,'')/1;
	}else{
		if(document.documentElement.clientWidth){
			slideLeftPanelObj.style.width = document.documentElement.clientWidth + 'px';
		}else if(document.body.clientHeight){
			slideLeftPanelObj.style.width = document.body.clientWidth + 'px';
		}
		var leftPos = slideLeftPanelObj.style.top.replace(/[^0-9\-]/g,'')/1;


	}
	slideLeftPanelObj.style.display='block';

	if(panelPosition==1)
		startScrollPos = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	else
		startScrollPos = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
	if(leftPos<(0+startScrollPos)){
		if(slideActive){
			slideLeftPanel(slideSpeed);

		}else{
			document.body.style.marginLeft = panelWidth + 'px';
			slideLeftPanelObj.style.left = '0px';
		}
	}else{
		if(expandOnly)return;
		if(slideActive){
			slideLeftPanel(slideSpeed*-1);
		}else{
			if(panelPosition == 0){
				if(pushMainContentOnSlide)document.body.style.marginLeft =  initBodyMargin + 'px';
				slideLeftPanelObj.style.left = (panelWidth*-1) + 'px';
			}else{
				if(pushMainContentOnSlide)document.body.style.marginTop =  initBodyMargin + 'px';
				slideLeftPanelObj.style.top = (panelWidth*-1) + 'px';
			}
		}
	}

	if(navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('Opera')<0){
		window.onscroll = repositionHelpDiv;

		repositionHelpDiv();
	}
	window.onresize = resizeLeftPanel;

}

function resizeLeftPanel()
{
	if(panelPosition == 0){
		if(document.documentElement.clientHeight){
			slideLeftPanelObj.style.height = document.documentElement.clientHeight + 'px';
		}else if(document.body.clientHeight){
			slideLeftPanelObj.style.height = document.body.clientHeight + 'px';
		}
	}else{
		if(document.documentElement.clientWidth){
			slideLeftPanelObj.style.width = document.documentElement.clientWidth + 'px';
		}else if(document.body.clientWidth){
			slideLeftPanelObj.style.width = document.body.clientWidth + 'px';
		}
	}
}

function slideLeftPanel(slideSpeed){
	slideInProgress =true;
	var scrollValue = 0;
	if(panelPosition==1)
		var leftPos = slideLeftPanelObj.style.top.replace(/[^0-9\-]/g,'')/1;
	else
		var leftPos = slideLeftPanelObj.style.left.replace(/[^0-9\-]/g,'')/1;

	leftPos+=slideSpeed;
	okToSlide = true;
	if(slideSpeed<0){
		if(leftPos < ((panelWidth*-1) + startScrollPos)){
			leftPos = (panelWidth*-1) + startScrollPos;
			okToSlide=false;
		}
	}
	if(slideSpeed>0){
		if(leftPos > (0 + startScrollPos)){
			leftPos = 0 + startScrollPos;
			okToSlide = false;
		}
	}


	if(panelPosition==0){
		slideLeftPanelObj.style.left = leftPos + startScrollPos + 'px';
		if(pushMainContentOnSlide)document.body.style.marginLeft = leftPos - startScrollPos + panelWidth + 'px';
	}else{
		slideLeftPanelObj.style.top = leftPos + 'px';
		if(pushMainContentOnSlide)document.body.style.marginTop = leftPos - startScrollPos + panelWidth + 'px';

	}
	if(okToSlide)setTimeout('slideLeftPanel(' + slideSpeed + ')',slideTimer); else {
		slideInProgress = false;
		if(slideSpeed>0)panelVisible=true; else panelVisible = false;
	}

}


function repositionHelpDiv()
{
	if(panelPosition==0){
		var maxValue = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		slideLeftPanelObj.style.top = maxValue;
	}else{
		var maxValue = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
		slideLeftPanelObj.style.left = maxValue;
		var maxTop = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		if(!slideInProgress)slideLeftPanelObj.style.top = (maxTop - (panelVisible?0:panelWidth)) + 'px';
	}
}

function cancelEvent()
{
	return false;
}
function keyboardShowLeftPanel()
{
		initSlideLeftPanel();
		return false;

}

function leftPanelKeyboardEvent(e)
{
	if(document.all)return;

	if(e.keyCode==112)
	{
		initSlideLeftPanel();
		return false;
	}
}

function setLeftPanelContent(text)
{
	document.getElementById('leftPanelContent').innerHTML = text;
	initSlideLeftPanel(true);

}
if(!document.all)document.documentElement.onkeypress = leftPanelKeyboardEvent;
document.documentElement.onhelp  = keyboardShowLeftPanel;

var currentlyActiveInputRef = false;
var currentlyActiveInputClassName = false;

function highlightActiveInput()
{
	if(currentlyActiveInputRef){
		currentlyActiveInputRef.className = currentlyActiveInputClassName;
	}
	currentlyActiveInputClassName = this.className;
	this.className = 'inputHighlighted';
	currentlyActiveInputRef = this;


}

function blurActiveInput()
{
	this.className = currentlyActiveInputClassName;


}


function initInputHighlightScript()
{
	var tags = ['INPUT','TEXTAREA'];

	for(tagCounter=0;tagCounter<tags.length;tagCounter++){
		var inputs = document.getElementsByTagName(tags[tagCounter]);
		for(var no=0;no<inputs.length;no++){
			if(inputs[no].className && inputs[no].className=='doNotHighlightThisInput')continue;

			if(inputs[no].tagName.toLowerCase()=='textarea' || (inputs[no].tagName.toLowerCase()=='input' && inputs[no].type.toLowerCase()=='text'))
			{
				inputs[no].onfocus = highlightActiveInput;
				inputs[no].onblur = blurActiveInput;
			}
		}
	}
}
function showtips()
{
	if(tips.style.display=="none")
	{
		tips.style.display="";
	}
	else
	{
		tips.style.display="none";
	}
}
function showadv(obj)
{
	for (i=1; i< myArray.length+100; i++)
	{
		if (obj==i)
		{
			if (document.getElementById("siteengine"+i))
			{
		 		document.getElementById("siteengine"+i).style.display = "";
		 	}
		}
		else
		{
			if (document.getElementById("siteengine"+i))
			{
		 		document.getElementById("siteengine"+i).style.display = "none";
		 	}
		}
	}
}
// 取得地址栏中的styleid值
function  getstyleid()
{
	//构造参数对象并初始化
	var  name,value,i;
	var  str=parent.location.href;//获得浏览器地址栏URL串
	var  num=str.indexOf("?")
	str=str.substr(num+1);//截取“?”后面的参数串
	var  arrtmp=str.split("&");//将各参数分离形成参数数组
	for(i=0;i  <  arrtmp.length;i++)
	{
		num=arrtmp[i].indexOf("=");
		if(num>0)
		{
			name=arrtmp[i].substring(0,num);//取得参数名称
			if(name=='styleid')
			{
				value=arrtmp[i].substr(num+1);//取得参数值
				return value;
			}
			// this[name]=value;//定义对象属性并初始化
		}
	}
}

function refreshurl(URL)
{
	parent.location.href =URL;
}