﻿// JScript 文件

//=======================================
//      TextBox的效果
//=======================================

var mouseoutcolor = "";
var mouseoutbgcolor = "";
function mouseover(obj,mouseovercolor,mouseoverbackcolor)
{	 mouseoutcolor = obj.style.borderColor;
	 mouseoutbgcolor = obj.style.backgroundColor;
	 obj.style.borderColor = mouseovercolor;
	 obj.style.backgroundColor = mouseoverbackcolor;
}
function mouseout(obj)
{
	 obj.style.borderColor = mouseoutcolor;
	 obj.style.backgroundColor = mouseoutbgcolor;
}
function objblur(obj,initcolor)
{
	 obj.style.borderColor = initcolor;
	 obj.style.backgroundColor = '';}
function objfocus(obj,onfocuscolor,onfocusbackcolor)
{
	 obj.style.borderColor = onfocuscolor;
	 obj.style.backgroundColor = onfocusbackcolor; 
	 mouseoutcolor = onfocuscolor;
	 mouseoutbgcolor = onfocusbackcolor; 
	 obj.select();
}


//==================================
//      复选框全选效果
//==================================
function SelectAll(obj,NoSelectID)
{
	var inputs = document.getElementsByTagName("input");
	if(obj.type = "checkbox")
	{
		if(obj.checked)
		{
			for(var i = 0; i < inputs.length; i++)
			{
				if(inputs[i].type == "checkbox" && inputs[i].id != NoSelectID)
				{
					inputs[i].checked = true;
				}
			}
		}
		else
		{
			for(var i = 0; i < inputs.length; i++)
			{
				if(inputs[i].type == "checkbox" && inputs[i].id != NoSelectID)
				{
					inputs[i].checked = false;
				}
			}
		}
	}
	else
	{
		return;
	}
}

//================================================================
//      判断是否选中要删除的记录，并询问是否确定要删除
//================================================================
function CheckDelete(objAll,ConfirmInfo)
{
	var inputs = document.getElementsByTagName("input");
	var IsChecked = false;
	for(var i = 0; i < inputs.length; i++)
	{
		if(inputs[i].type == "checkbox")
		{
			if(inputs[i].checked && inputs[i].id != objAll)
			{
				IsChecked = true;
				break;
			}
		}
	}
	if(IsChecked)
	{
		return confirm("系统提示您：\r\n\r\n" + ConfirmInfo);
	}
	else
	{
		alert("系统提示您：\r\n\r\n请选择要操作的记录！");
		return false;
	}
}

//================================================================
//      判断是否选中要删除的记录，并询问是否确定要删除
//================================================================
function CheckSelect(objAll)
{
	var inputs = document.getElementsByTagName("input");
	var IsChecked = false;
	for(var i = 0; i < inputs.length; i++)
	{
		if(inputs[i].type == "checkbox")
		{
			if(inputs[i].checked && inputs[i].id != objAll)
			{
				IsChecked = true;
				break;
			}
		}
	}
	if(IsChecked)
	{
		return true;
	}
	else
	{
		alert("系统提示您：\r\n\r\n请选择要操作的记录！");
		return false;
	}
}

//==================================================
//      检查控件的值是否为空，去除空格
//==================================================
function CheckSpace(CheckValue)
{
	var ValueLength = CheckValue.length;
	var TempValue = "";
	
	for(var i = 0; i < ValueLength; i++)
	{
	    TempValue = TempValue + " ";
	}
	
	if(TempValue == CheckValue)
	{
	    return false;
	}
	else
	{
	    return true;
	}
}

//==================================================
//             去除字符串头尾空格
//==================================================
function JSTrim(strValue)
{
    if(strValue == "" || CheckSpace(strValue) == false)
    {
        strValue = "";
        return strValue;
    }
    
    while(strValue.charAt(0) == " ")
    {   
        strValue=strValue.substring(1,strValue.length)   //去掉前面的空格   
    }
    while(strValue.charAt(strValue.length-1) == " ")   
    {   
        strValue=strValue.substring(0,strValue.length-1)   //去掉后面的空格   
    } 
        
    return strValue;
}

String.prototype.Trim = function()
{
    return JSTrim(this);
}

String.prototype.Trim = function() 
{ 
    return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 

String.prototype.LTrim = function() 
{ 
    return this.replace(/(^\s*)/g, ""); 
} 

String.prototype.RTrim = function() 
{ 
    return this.replace(/(\s*$)/g, ""); 
} 

String.prototype.AllTrim = function() 
{ 
    return this.replace(/\s/g, ""); 
}

//==================================================
//              弹出模态对话框
//==================================================
function ShowModalWindow(WindowURL,pWidth,pHeight)
{
    var ReturnValue;
    ReturnValue = window.showModalDialog(WindowURL,window,'dialogWidth:'+ pWidth +'px;dialogHeight:'+ pHeight +'px;help:no;status:no;scroll:no;');
    return ReturnValue;
}

//==================================================
//              弹出网页窗口
//==================================================
function ShowWindow(WindowURL,pWidth,pHeight)
{
    window.open (WindowURL,'MovieProvider','height='+ pHeight +',width='+ pWidth +',top=70,left=150,toolbar=no,menubar=no,scrollbars=yes, resizable=no,location=no, status=yes,alwaysRaised=yes') 
}

//==================================================
//        页面返回函数
//==================================================
function PageBack()
{
	history.go(-1);
}

function $E(objid)
{
    return document.getElementById(objid);
}

//=============================================
//        切换图片
//=============================================
function switchImage(imgName, imgSrc)
{
    if (document.images)
    {
        if (imgSrc != "none")
        {
            document.images[imgName].src = imgSrc;
        }
    }
}