// JavaScript Document

function ShowSidebar()
{
	var Mleft = document.getElementById("main_left").style;
	var Mcenter = document.getElementById("main_center").style;
	var Mright = document.getElementById("main_right").style;
	var Dleft = document.getElementById("left_menu_bdy").style;
	var img = document.getElementById("main_left_sidebar_on");
	if(Mright.display == "block")
	{
		if(Dleft.display == "block")
		{
			Dleft.display = "none";
			Mleft.width = "4%";
			Mcenter.width = "78%";
			img.className = "main_left_sidebar_off";
		}
		else
		{
			Mcenter.width = "64%";
			Mleft.width = "18%";
			Dleft.display = "block";
			img.className = "main_left_sidebar_on";
		}
	}
	else
	{
		if(Dleft.display == "block")
		{
			Dleft.display = "none";
			Mleft.width = "4%";
			Mcenter.width = "96%";
			img.className = "main_left_sidebar_off";
		}
		else
		{
			Mcenter.width = "82%";
			Mleft.width = "18%";
			Dleft.display = "block";			
			img.className = "main_left_sidebar_on";
		}
	}
}

function ShowHelp()
{
	var Mleft = document.getElementById("main_left").style;
	var Mcenter = document.getElementById("main_center").style;
	var Mright = document.getElementById("main_right").style;
	var Dleft = document.getElementById("left_menu_bdy").style;
	var img = document.getElementById("main_left_sidebar_on");
	if(Dleft.display == "block")
	{
		if(Mright.display == "block")
		{
			Mright.display = "none";
			Mcenter.width = "82%";
		}
		else
		{
			Mcenter.width = "64%";
			Mright.display = "block";
		}
	}
	else
	{
		if(Mright.display == "block")
		{
			Mright.display = "none";
			Mcenter.width = "96%";
		}
		else
		{
			Mcenter.width = "82%";
			Mright.display = "block";
		}
	}
}

function ChangeOrder(N)
{
	var object = document.getElementsByName("img_darr");
	if(object[N].className == "img_darr")
	{
		object[N].className ="img_uarr";
	}
	else
	{
		object[N].className ="img_darr";
	}
}

function ChangeAllDetail(N,img)
{
	var object = document.getElementsByName("img_detail_add");
	var img = document.getElementsByName(img);
	var detail = document.getElementsByName("detail");
	if(object[N].className == "img_detail_add")
	{
		object[N].className ="img_detail_min";
		for ( var i = 0 ; i < detail.length ; i++)
		{
			img[i].innerText = "-";
			detail[i].style.display = "block";
		}
	}
	else
	{
		object[N].className ="img_detail_add";
		for ( var i = 0 ; i < detail.length ; i++)
		{
			img[i].innerText = "+";
			detail[i].style.display = "none";
		}
	}
}

function ShowMainSearch()
{
	var Tsearch = document.getElementById("main_menu_search");
	var img = document.getElementById("menu_img_add");

	if(Tsearch.style.display == "none")
	{
		Tsearch.style.display = "block";
		img.className = "img_min";
	}
	else
	{
		Tsearch.style.display = "none";
		img.className = "img_add";
	}
	
}

function ShowMainBatch()
{
	var Tsearch = document.getElementById("main_menu_search");
	var Tbatch = document.getElementById("main_menu_batch");
	var Mbatch = document.getElementById("menu_batch");
	var Msearch = document.getElementsByName("main_menu_buttom")[0];
	var img = document.getElementById("menu_img_add");
	if(Tsearch.style.display == "none")
	{
		if(Tbatch.style.display == "none")
		{
			Tbatch.style.display = "block";
			Mbatch.className = "main_menu_active";
			img.className = "img_min";
		}
		else
		{
			Tbatch.style.display = "none";
			Mbatch.className = "main_menu_buttom";
			img.className = "img_add";
		}
	}
	else
	{
		Tsearch.style.display = "none";
		Tbatch.style.display = "block";
		Msearch.className = "main_menu_buttom";
		Mbatch.className = "main_menu_active";
	}
}


function OnCancel(gURL)
{
	window.location.href = gURL;
}

function ShowMenu(N,Nobject)
{
	var img = document.getElementsByName("onoff");
	var object = document.getElementById(Nobject);
	if(img[N].className == "img_add")
	{
		img[N].className = "img_min";
		object.style.display = "block"; 
	}
	else
	{
		img[N].className = "img_add";
		object.style.display = "none"; 
	}
}

function ChangeNumber(objectname,A)
{
	var object = document.getElementById(objectname);
	if(A == 0)
	{
		object.disabled = true;
	}
	else if(A == 1)
	{
		object.disabled = false;
	}
}

function OpenMode(sURL,sWIDTH,sHEIGHT)
{
	var obj = new Object();
	if(sWIDTH != "unfiend" || sHEIGHT != "unfiend")
	{
		sWIDTH = Math.round(sWIDTH*screen.width/1024);
		sHEIGHT =Math.round(sHEIGHT*screen.height/768);
		var variable = "dialogWidth:" + sWIDTH + "px;dialogHeight:" + sHEIGHT + "px;status:no;help:no;";
	}
	else
	{
		var variable = "status:no;help:no";
	}
	window.showModalDialog(sURL,obj,variable);
}

function CheckAll(form,object)
{
	for(var i = 0 ; i < form.elements.length ; i++)
	{
		var E = form.elements[i];
		if((E.name  != object.name) && (E.type == "checkbox"))
		{
				E.checked = object.checked;
		}
	}
}

function LineMouseOver(object)
{
	if(object.className == "lineMouseDown")
	{
		return false;
	}
	else
	{
		object.className = "lineMouseOver";
	}
}

function LineMouseOut(object,N)
{
	if(object.className == "lineMouseDown")
	{
		return false;
	}
	else
	{
		if(N % 2 == 0)
		{
			object.className = "even";
		}
		else
		{
			object.className = "odd";
		}
	}
}

function LineMouseDown(object,N)
{
	if(object.className == "lineMouseDown")
	{
		if(N % 2 == 0)
		{
			object.className = "even";
		}
		else
		{
			object.className = "odd";
		}
	}
	else
	{
		object.className = "lineMouseDown";
	}
}

function LineMouseOver(object)
{
	if(object.className == "lineMouseDown")
	{
		return false;
	}
	else
	{
		object.className = "lineMouseOver";
	}
}

function LineMouseOut(object,N)
{
	if(object.className == "lineMouseDown")
	{
		return false;
	}
	else
	{
		if(N % 2 == 0)
		{
			object.className = "even";
		}
		else
		{
			object.className = "odd";
		}
	}
}

function LineMouseDown(object,N)
{
	if(object.className == "lineMouseDown")
	{
		if(N % 2 == 0)
		{
			object.className = "even";
		}
		else
		{
			object.className = "odd";
		}
	}
	else
	{
		object.className = "lineMouseDown";
	}
}

function ShowDetail(N)
{
	N = N - 1;
	var img = document.getElementsByName("add");
	var object = document.getElementsByName("detail");
	if(img.length >=1)
	{
		if(img[N].innerText == "+")
		{
			for(var i = 0 ; i < document.getElementsByName("detail").length ; i++)
			{
				img[i].innerText = "+";
				object[i].style.display = "none";
			}
			img[N].innerText = "-";
			object[N].style.display = "block";
		}
		else
		{
				img[N].innerText = "+";
				object[N].style.display = "none";
		}
	}
}

function ShowAdvanced()
{
	var object = document.getElementsByName("advanced");
	for( var i = 0 ; i <object.length ; i++)
	{
		if(object[i].style.display == "none")
		{
			object[i].style.display = "block";
		}
		else
		{
			object[i].style.display = "none";
		}
	}
}

function ChangeTR(object,TRName)
{
	var Tobject = document.getElementsByName(TRName);
	if(object.options[object.selectedIndex].value == 1)
	{
		Tobject[1 - 1].style.display = "block";
		Tobject[2 - 1].style.display = "none";
	}
	else if(object.options[object.selectedIndex].value >= 2)
	{
		Tobject[1 - 1].style.display = "none";
		Tobject[2 - 1].style.display = "block";
	}
}


function ShowBetween(sValue,Index)
{
	var object = document.getElementsByName("between");
	sValue = sValue.options[sValue.selectedIndex].value;
	if(sValue == 3)
	{
		object[Index - 1].style.display = "block";
	}
	else
	{
		object[Index - 1].style.display = "none";
	}
}


function ShowSpecialTimeMin(Time, TimeHour, TimeMinute, TimeSecond)
{
	if (Time.value != null && Time.value != '')
	{
		TimeHour.disabled = false;
		TimeMinute.disabled = false;
		TimeSecond.disabled = false;
	}
	else
	{
		TimeHour.value = "00";
		TimeMinute.value = "00";
		TimeSecond.value = "00";
		TimeHour.disabled = true;
		TimeMinute.disabled = true;
		TimeSecond.disabled = true;
	}
}

function ShowSpecialTimeMax(Time, TimeHour, TimeMinute, TimeSecond)
{
	if (Time.value != null && Time.value != '')
	{
		TimeHour.disabled = false;
		TimeMinute.disabled = false;
		TimeSecond.disabled = false;
	}
	else
	{
		TimeHour.value = "23";
		TimeMinute.value = "59";
		TimeSecond.value = "59";
		TimeHour.disabled = true;
		TimeMinute.disabled = true;
		TimeSecond.disabled = true;
	}
}

/**
 *	resolve the bug of oss-70
 */
var resetcomparearr = new Array();
var resetdatearr = new Array();
function restclick()
{
	/*
		Description:if you choose the "Bewteen" in this checkbox,it will show the text of the "To",
					while, when you press the button "Reset",this checkbox changed to "More Than",
					but the text of the "To" still exist.
	*/
	for (var i = 0; i < resetcomparearr.length; i++)
	{
		if(document.getElementById(resetcomparearr[i]) != null && document.getElementById(resetcomparearr[i]).style.display != "none")
		{
			document.getElementById(resetcomparearr[i]).style.display = "none";
		}
	}
	/*
		Description:if you have the "Date" in you HTML,and this element have the exact time of "Hour",
					"Minute" and "Second",while, when you press the button "Reset",the default time ("00:00:00"
					or "23:59:59") have disappeared.
	*/
	for(var j = 0; j < resetdatearr.length; j++)
	{
		minhour = resetdatearr[j] + "MinHour";
		minminute = resetdatearr[j] + "MinMinute";
		minsecond = resetdatearr[j] + "MinSecond";
		maxhour = resetdatearr[j] + "MaxHour";
		maxminute = resetdatearr[j] + "MaxMinute";
		maxsecond = resetdatearr[j] + "MaxSecond";
		if (document.getElementById(minhour) != null &&
			document.getElementById(minminute) != null &&
			document.getElementById(minsecond) != null &&
			document.getElementById(maxhour) != null &&
			document.getElementById(maxminute) != null &&
			document.getElementById(maxsecond) != null)
		{
			document.getElementById(minhour).value = "00";
			document.getElementById(minhour).disabled = true;
			document.getElementById(minminute).value = "00";
			document.getElementById(minminute).disabled = true;
			document.getElementById(minsecond).value = "00";
			document.getElementById(minsecond).disabled = true;
			document.getElementById(maxhour).value = "23";
			document.getElementById(maxhour).disabled = true;
			document.getElementById(maxminute).value = "59";
			document.getElementById(maxminute).disabled = true;
			document.getElementById(maxsecond).value = "59";
			document.getElementById(maxsecond).disabled = true;
		}
	}
}

/**
 *  resolve the problem of JavaScript function parseInt();
 *	parseInt(09) == 0; but I look forward to the value of 9;
 */
function kickzero(zeroarr)
{
	if(zeroarr.length > 1)
	{
		var thisarr = zeroarr.substring(0,1);
		if(parseInt(thisarr) == 0)
		{
			return kickzero(zeroarr.substring(1,zeroarr.length));
		}
		else
		{
			return zeroarr;
		}
	}
	return zeroarr;
}

function DisplayShow(objname)
{
	var object = document.getElementsByName(objname);
	for( var i = 0 ; i <object.length ; i++)
	{
		if(object[i].style.display == "none")
		{
			object[i].style.display = "block";
		}
		else
		{
			object[i].style.display = "none";
		}
	}
}