//Open Window
function OpenWindow(Url,Width,Height,WindowObj)
{
	var ReturnStr=showModalDialog(Url,WindowObj,'dialogWidth:'+Width+'pt;dialogHeight:'+Height+'pt;status:no;help:no;scroll:yes;');
	return ReturnStr;
}
//Open Modal Window
function OpenWindowAndSetValue(Url,Width,Height,WindowObj,SetObj)
{
	var ReturnStr=showModalDialog(Url,WindowObj,'dialogWidth:'+Width+'pt;dialogHeight:'+Height+'pt;status:no;help:no;scroll:no;');
	if (ReturnStr!='007007007007') SetObj.value=ReturnStr;
	return ReturnStr;
}
//Open Editer Window
function OpenEditerWindow(Url,WindowName,Width,Height)
{
	window.open(Url,WindowName,'toolbar=0,location=0,maximize=1,directories=0,status=1,menubar=0,scrollbars=0,resizable=1,top=50,left=50,width='+Width+',height='+Height);
}
//Send Data To Server
function SendDataToServer(Url)
{
	var HTTP = new ActiveXObject("Microsoft.XMLHTTP");
	var ReturnValue=HTTP.open("POST", Url, false);
	HTTP.send("");
	return HTTP.responseText;
}
//Button MouseOver Event
function BtnMouseOver(Obj)
{
	if (event.type!='mouseout')
	{
		Obj.className='BtnMouseOver';
		if (Obj.tagName.toLowerCase()=='td' || Obj.tagName.toLowerCase()=='img') window.status=Obj.alt;
		else window.status=Obj.title;
	}
	else
	{
		window.status=top.LoginStr;
		Obj.className='BtnMouseOut';
	}
}

//判断是否数字
function CheckNumber(Obj,DescriptionStr)
{
	if (Obj.value!='' && (isNaN(Obj.value) || Obj.value<0))
	{
		alert(DescriptionStr+"应填有效数字！");
		Obj.value="";
		Obj.focus();
	}
}

//判断是否英文字母
function CheckEnglishStr(Obj,DescriptionStr)
{
	var TempStr=Obj.value,i=0,ErrorStr='',CharAscii;
	if (TempStr!='')
	{
		for (i=0;i<TempStr.length;i++)
		{
			CharAscii=TempStr.charCodeAt(i);
			if (CharAscii>=255||CharAscii<=31)
			{
				ErrorStr=ErrorStr+TempStr.charAt(i);
			}
			else
			{
				if (!CheckClassErrorStr(CharAscii))
				{
					ErrorStr=ErrorStr+TempStr.charAt(i);
				}
			}
		}
		if (ErrorStr!='')
		{
			alert(DescriptionStr+'发现非法字符:'+ErrorStr);
			Obj.focus();
			return false;
		}
		if (!(((TempStr.charCodeAt(0)>=48)&&(TempStr.charCodeAt(0)<=57))||((TempStr.charCodeAt(0)>=65)&&(TempStr.charCodeAt(0)<=90))||((TempStr.charCodeAt(0)>=97)&&(TempStr.charCodeAt(0)<=122))))
		{
			alert(DescriptionStr+'首字符只能够为数字或者字母');
			Obj.focus();
			return false;
		}
	}
	return true;
}

function CheckClassErrorStr(CharAsciiCode)
{
	var TempArray=new Array(34,47,92,42,58,60,62,63,124);
	for (var i=0;i<TempArray.length;i++)
	{
		if (CharAsciiCode==TempArray[i]) return false;
	}
	return true;
}

//
function ChooseSpecial(Special)
{
	var TempArray,TempStr;
	TempArray=Special.split("***");
	if (TempArray[0] != '')
	{
		if (document.all.SpecialID.value.search(TempArray[1])==-1)
	
		   {		if (document.all.SpecialIDText.value=='') 	document.all.SpecialIDText.value=TempArray[0];
					else document.all.SpecialIDText.value = document.all.SpecialIDText.value + ',' + TempArray[0];
					if (document.all.SpecialID.value=='') 	document.all.SpecialID.value=TempArray[1];
					else document.all.SpecialID.value = document.all.SpecialID.value + ',' + TempArray[1];
			}
	}
	if ((TempArray[0] == '')&&(TempArray[1] == 'Clean'))
	{
		document.all.SpecialID.value = '';
		document.all.SpecialIDText.value = '';
	}
	return;
}

function Dosusite(Source)
{
	var TempArray,TempStr;
	TempArray=Source.split("***");
	if (TempArray[0] != '')
	{
		if (document.NewsForm.TxtSourceText.value.indexOf(TempArray[0])<0)
		{
			if (typeof(TempArray[1])=='undefined') TempStr=TempArray[0];
			else TempStr='<a href='+TempArray[1].replace(/[\"\']/,'')+'>'+TempArray[0]+'</a>';
			if (document.NewsForm.TxtSourceText.value=='') 	document.NewsForm.TxtSourceText.value=TempArray[0];
			else document.NewsForm.TxtSourceText.value = document.NewsForm.TxtSourceText.value + ',' + TempArray[0];
			if (document.NewsForm.TxtSource.value=='') 	document.NewsForm.TxtSource.value=TempArray[0];
			else document.NewsForm.TxtSource.value = document.NewsForm.TxtSource.value + ',' + TempArray[0];
		}
	}
	if ((TempArray[0] == '')&&(TempArray[1] == 'Clean'))
	{
		document.NewsForm.TxtSource.value = '';
		document.NewsForm.TxtSourceText.value = '';
	}
	return;
}

function Dokesite(KeyWords)
{
	if (KeyWords!='')
	{
		if (document.NewsForm.KeywordText.value.search(KeyWords)==-1)
		{
			if (document.NewsForm.KeyWords.value=='') document.NewsForm.KeyWords.value=KeyWords;
			else document.NewsForm.KeyWords.value=document.NewsForm.KeyWords.value+','+KeyWords;
			if (document.NewsForm.KeywordText.value=='') document.NewsForm.KeywordText.value=KeyWords;
			else document.NewsForm.KeywordText.value=document.NewsForm.KeywordText.value+','+KeyWords;
		}
	}
	if (KeyWords == 'Clean')
	{
		document.NewsForm.KeyWords.value = '';
		document.NewsForm.KeywordText.value = '';
	}
	return;
}

function Doauthsite(Author)
{
	var TempArray,TempStr;
	TempArray=Author.split("***");
	if (TempArray[0] != '')
	{
		if (document.NewsForm.AuthorText.value.indexOf(TempArray[0])<0)
		{
			if (typeof(TempArray[1])=='undefined') TempStr=TempArray[0];
			else TempStr='<a href='+TempArray[1].replace(/[\"\']/,'')+'>'+TempArray[0]+'</a>';
			if (document.NewsForm.AuthorText.value=='') 	document.NewsForm.AuthorText.value=TempArray[0];
			else document.NewsForm.AuthorText.value = document.NewsForm.AuthorText.value + ',' + TempArray[0];
			if (document.NewsForm.Author.value=='') 	document.NewsForm.Author.value=TempArray[0];
			else document.NewsForm.Author.value = document.NewsForm.Author.value + ',' + TempArray[0];
		}
	}
	if ((TempArray[0] == '')&&(TempArray[1] == 'Clean'))
	{
		document.NewsForm.Author.value = '';
		document.NewsForm.AuthorText.value = '';
	}
	return;
}

function Editsite(Editer1)
{
	var TempArray,TempStr;
	TempArray=Editer1.split("***");
	if (TempArray[0] != '')
	{
		if (document.NewsForm.EditerText.value.indexOf(TempArray[0])<0)
		{
			if (typeof(TempArray[1])=='undefined') TempStr=TempArray[0];
			else TempStr='<a href='+TempArray[1].replace(/[\"\']/,'')+'>'+TempArray[0]+'</a>';
			if (document.NewsForm.EditerText.value=='') 	document.NewsForm.EditerText.value=TempArray[0];
			else document.NewsForm.EditerText.value = document.NewsForm.EditerText.value + ',' + TempArray[0];
			if (document.NewsForm.Editer.value=='') 	document.NewsForm.Editer.value=TempArray[0];
			else document.NewsForm.Editer.value = document.NewsForm.Editer.value + ',' + TempArray[0];
		}
	}
	if ((TempArray[0] == '')&&(TempArray[1] == 'Clean'))
	{
		document.NewsForm.Editer.value = '';
		document.NewsForm.EditerText.value = '';
	}
	return;
}

function ChooseSystem(DownSystem)
{
	if (DownSystem != '')
		{	
			if (document.DownForm.SystemType.value.search(DownSystem)==-1)
			{
				if (document.DownForm.SystemType.value=='') document.DownForm.SystemType.value=DownSystem;
				else document.DownForm.SystemType.value = document.DownForm.SystemType.value + '/' + DownSystem;
			}
		}
	if (DownSystem == 'Clean') document.DownForm.SystemType.value = '';
	return;
}

//////////////////////////////////////////////////////////////////
/*var MouseOverObj=null;
var MouseOverPageLocation='';
function document.onmouseover()
{
	MouseOverObj=event.srcElement;
	MouseOverPageLocation=location.href;
	//var DocumentBodyObj=MouseOverObj;
	//while ((DocumentBodyObj.parentElement)&&(DocumentBodyObj.tagName!='BODY')) DocumentBodyObj=DocumentBodyObj.parentElement;
	//if ((DocumentBodyObj)&&(DocumentBodyObj.tagName=='BODY')) DocumentBodyObj.focus();
}*/

function AnalyKeyWord()
{
	var returnValue='',TempObj=MouseOverObj;
	returnValue=GetKeyWord(MouseOverObj,0);
	if (returnValue=='')
	{
		while ((TempObj.children)&&(TempObj.children.length==1)) TempObj=TempObj.children(0);
		return GetKeyWord(TempObj,1);
	}
	else return returnValue;
}

function GetKeyWord(Obj,flag)
{
	var TagString='',returnValue='';
	if (!Obj) return;
	TagString=Obj.tagName;
	switch (TagString)
	{
		case 'INPUT':
			if (Obj.type=='button') returnValue=Obj.value;
			else
			{
				if (Obj.id) returnValue=Obj.id;
				else returnValue=Obj.name;
			}
			break;
		case 'SELECT':
			if (Obj.id) returnValue = Obj.id;
			else returnValue = Obj.name;
			break;
		case 'TEXTAREA':
			if (Obj.id) returnValue = Obj.id;
			else returnValue = Obj.name;
			break;
		case 'IMG':
			if (Obj.alt) returnValue = Obj.alt;
			else returnValue = Obj.title;
			break;
		default :
			if (flag) returnValue=Obj.innerText;
			else returnValue='';
			break;
	}
	return returnValue;
}

//全选
function checkAll(obj){
	for(var i=0;i<obj.elements.length;i++){
		var e = obj.elements[i];
		if(e.checked==false){
			e.checked = true;
		}else{
			e.checked = false;
		}
	}
}

//判断复选框是否选中
function chkChecked(obj){
	var flg = 0;
	for(var i=0;i<obj.elements.length;i++){
		var e = obj.elements[i];
		if(e.name=='checked'&&e.checked==true){
			flg = 1;
			break;
		}
	}
	if(!flg){
		alert('请至少选择一条记录！')
		return false;
	}else return true;
}

//创建ajax控件 可适应IE7.0
function Ajax(){
	var ajaxObj = null;
	if(window.ActiveXObject){
		try{
			ajaxObj = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(e1){
			try{
				ajaxObj = new ActiveXObject("MSXML2.XMLHTTP");
			}catch(e2){
				try{
					ajaxObj = new ActiveXObject("MSXML3.XMLHTTP");
				}catch(e3){
					alert("创建Ajax失败："+e3)
				}
			}
		}
	}else if(window.XMLHttpRequest){
		ajaxObj = new XMLHttpRequest();
	}else{
		alert("未能识别的浏览器");
	}
	return ajaxObj;
}

/*网站功能JS函数*/
//获得表单对象
function $(){
	var elements = new Array();
  	for (var i=0; i<arguments.length; i++){
    	var element = arguments[i];
    	if(typeof element == 'string')
      		element = document.getElementById(element);

    	if(arguments.length == 1)
      		return element;

    	elements.push(element);
  }
  return elements;
}

function addEFriend(uno,rnm){
	if(confirm('确定要把 '+rnm+' 加为业务伙伴吗?'))
	{
		window.open('/Manage/EFriend/EFriendAdd.asp?BEnterNo='+uno+'','','toolbar=0,location=0,maximize=1,directories=0,status=1,menubar=0,scrollbars=0,resizable=1,top=50,left=50,width=200,height=90');
	}
}

//在页面中插入Flash
function insertFlash(Path,Width,Height,Transparent,Scale){
	 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"/>'
	 if (Transparent) {Temp+=' <param name="wmode" value="transparent"/>';T='wmode="transparent"'}
	 if (!Scale) {
	 //scale参数设置为ExactFit时可能会引起舞台显示不完整
		Temp+='<param name="scale" value="ExactFit"/>'
		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+' scale="ExactFit"/>'
	 }else{
		//使用默认的scale参数showAll时舞台不能被缩放
		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+' />'
	 }
	 Temp+='</object>'
	 document.write(Temp);
}

//+---------------------------------------------------  
//| 求两个时间的天数差 日期格式为 YYYY-MM-dd   
//+---------------------------------------------------  
function daysBetween(DateOne,DateTwo)
{   
    var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ('-'));  
    var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ('-')+1);  
    var OneYear = DateOne.substring(0,DateOne.indexOf ('-'));  
  
    var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ('-'));  
    var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ('-')+1);  
    var TwoYear = DateTwo.substring(0,DateTwo.indexOf ('-'));  
  
    var cha=((Date.parse(OneMonth+'/'+OneDay+'/'+OneYear)- Date.parse(TwoMonth+'/'+TwoDay+'/'+TwoYear))/86400000);   
    return cha;
}

//+---------------------------------------------------  
//| 字符串转成日期类型   
//| 格式 MM/dd/YYYY MM-dd-YYYY YYYY/MM/dd YYYY-MM-dd  
//+---------------------------------------------------  
function StringToDate(DateStr)  
{   
  
    var converted = Date.parse(DateStr);  
    var myDate = new Date(converted);  
    if (isNaN(myDate))  
    {   
        //var delimCahar = DateStr.indexOf('/')!=-1?'/':'-';  
        var arys= DateStr.split('-');  
        myDate = new Date(arys[0],--arys[1],arys[2]);  
    }  
    return myDate;  
}

//+---------------------------------------------------  
//| 日期时间检查  
//| 格式为：YYYY-MM-DD HH:MM:SS  
//+---------------------------------------------------  
function CheckDateTime(str)  
{   
    var reg = /^(\d+)-(\d{ 1,2 })-(\d{ 1,2 }) (\d{ 1,2 }):(\d{ 1,2 }):(\d{ 1,2 })$/;   
    var r = str.match(reg);   
    if(r==null)return false;   
    r[2]=r[2]-1;   
    var d= new Date(r[1],r[2],r[3],r[4],r[5],r[6]);   
    if(d.getFullYear()!=r[1])return false;   
    if(d.getMonth()!=r[2])return false;   
    if(d.getDate()!=r[3])return false;   
    if(d.getHours()!=r[4])return false;   
    if(d.getMinutes()!=r[5])return false;   
    if(d.getSeconds()!=r[6])return false;   
    return true;   
} 

//+---------------------------------------------------  
//| 日期合法性验证  
//| 格式为：YYYY-MM-DD或YYYY/MM/DD  
//+---------------------------------------------------  
function IsValidDate(DateStr)   
{   
    var sDate=DateStr.replace(/(^\s+|\s+$)/g,''); //去两边空格;   
    if(sDate=='') return true;   
    //如果格式满足YYYY-(/)MM-(/)DD或YYYY-(/)M-(/)DD或YYYY-(/)M-(/)D或YYYY-(/)MM-(/)D就替换为''   
    //数据库中，合法日期可以是:YYYY-MM/DD(2003-3/21),数据库会自动转换为YYYY-MM-DD格式   
    var s = sDate.replace(/[\d]{ 4,4 }[\-/]{ 1 }[\d]{ 1,2 }[\-/]{ 1 }[\d]{ 1,2 }/g,'');   
    if (s=='') //说明格式满足YYYY-MM-DD或YYYY-M-DD或YYYY-M-D或YYYY-MM-D   
    {   
        var t=new Date(sDate.replace(/\-/g,'/'));   
        var ar = sDate.split(/[-/:]/);   
        if(ar[0] != t.getYear() || ar[1] != t.getMonth()+1 || ar[2] != t.getDate())   
        {   
            //alert('错误的日期格式！格式为：YYYY-MM-DD或YYYY/MM/DD。注意闰年。');   
            return false;   
        }   
    }   
    else   
    {   
        //alert('错误的日期格式！格式为：YYYY-MM-DD或YYYY/MM/DD。注意闰年。');   
        return false;   
    }   
    return true;   
} 

//默认选定Select值
function option_select(s1,s1_value)
{
	for (i=0;i<s1.length;i++)
	{
		if (s1.options[i].value==s1_value)
		{
			s1.selectedIndex=i;
		}			
	}
}
