//------------------------------------------------------------------------------*/
//                            Copyright Notice							        */
//                            ~~~~~~~~~~~~~~~~							        */
//		Copyright (C) 2003  By Yongchuang Electronic Commerce Co.,Ltd.			*/
//																				*/
//		All rights reserved. This material is confidential and	proprietary to	*/
//	Yongchuang Electronic Commerce Co.,Ltd. and no part	of this material should	*/
//	be reproduced,published in any form	by any means,electronic or mechanical	*/
//	including photocopy	or any information storage or retrieval system nor		*/
//	should the material be disclosed to third parties without the express		*/
//	written authorization of Yongchuang Electronic Commerce Co.,Ltd.			*/
//																				*/
//------------------------------------------------------------------------------*/

//================================================================
//
//	File Name	:	Controls.js
//
//	File Type	:	javascript source file
//
//	Author		:	Andy Wang
//
//	Purpose		:	Common properties and methods about some html controls
//
//	Date		:	06/16/2003
//
//	Modification:	06/16/2003
//
//================================================================

function textIsBlank(formKey,theText){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	Validate whether the string is blank
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	theText				Input		the name of the text
//
//  Return Value        :   true/false
//	Return Type         :   boolean
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	var ele=document.forms[formKey].elements[theText];
	var theValue=ele.value;
	var len=theValue.length;
	var i;
	var beBlank=true;
	
	//- must not be blank	
	for(i=0;i<len;i++){
		if(theValue.charAt(i)!=" "){
			beBlank=false;
			break;
		}
	}
	return beBlank;
}

function deleteSpaces(formKey,control){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	delete all spaces of the form element
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	control				Input		the name of the selected control
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	var element = document.forms[formKey].elements[control];
	element.value = StringReplace(element.value," ","");		
}

function setTextFocus(formKey,theText){	
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	Select text
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	theText				Input		the name of the selected control
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	var theContainer;
	theContainer=window.navigator.appName ;
	if(theContainer.indexOf("Microsoft")==-1){		//Not IE
		document.forms[formKey].elements[theText].select();
		document.forms[formKey].elements[theText].focus();	
	}else{		//Microsoft Internet Explorer
		document.forms(formKey).elements(theText).select();
		document.forms(formKey).elements(theText).focus();	
	}
}

function activeAllFormElements(formKey){	
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	Set all elements of the form actived
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	var len;
	var i;
	len=document.forms[formKey].elements.length;
	for(i=0;i<len;i++){
		document.forms[formKey].elements[i].disabled=false;
	}
}

function disableAllFormElements(formKey){	
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	Set all elements of the form actived
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	var len;
	var i;
	len=document.forms[formKey].elements.length;
	for(i=0;i<len;i++){
		document.forms[formKey].elements[i].disabled=true;
	}
}


function setDisabled(formKey,control){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	Set control disabled
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	control				Input		the name of the control
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	var theContainer;
	theContainer=window.navigator.appName ;
	if(theContainer.indexOf("Microsoft")==-1){		//Not IE
		document.forms[formKey].elements[control].disabled=true;		
	}else{		//Microsoft Internet Explorer
		document.forms(formKey).elements(control).disabled=true;
	}
}

function setOnlyRead(formKey,control){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	Set control readonly
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	control				Input		the name of the control
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	var theContainer;
	theContainer=window.navigator.appName ;
	if(theContainer.indexOf("Microsoft")==-1){		//Not IE
		document.forms[formKey].elements[control].readOnly=true;
		document.forms[formKey].elements[control].style.backgroundColor="#E3E3E3";
	}else{		//Microsoft Internet Explorer	
		document.forms(formKey).elements(control).style.backgroundColor="#E3E3E3";	
		document.forms(formKey).elements(control).readOnly=true;
	}
}


function moveTop(formKey,ListName){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	SELECT | List : move selected item to top
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	control				Input		the name of the control
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	while(getSelectedIndex(formKey,ListName)>0){
		moveUp(formKey,ListName)
	}
}

function moveUp(formKey,ListName){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	SELECT | List : move selected item up
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	control				Input		the name of the control
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	var indexSelected,indexSwapped;
	indexSelected=getSelectedIndex(formKey,ListName);	
	if (indexSelected >= 0){
		indexSwapped=indexSelected-1;
		swapItem(formKey,ListName,indexSelected,indexSwapped);
	}	
}


function moveDown(formKey,ListName){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	SELECT | List : move selected item down
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	control				Input		the name of the control
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	var indexSelected,indexSwapped;
	indexSelected=getSelectedIndex(formKey,ListName);
	
	if (indexSelected == getListLength(formKey,ListName) -1 ){		//Selected item is top item or no selection
		return;
	}else{
		indexSwapped=indexSelected+1;
		swapItem(formKey,ListName,indexSelected,indexSwapped);
	}
}

function moveBottom(formKey,ListName){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	SELECT | List : move selected item to the bottom
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	control				Input		the name of the control
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	if (getSelectedIndex(formKey,ListName)<0) return;
	while(getSelectedIndex(formKey,ListName) <= getListLength(formKey,ListName)-2){	
		moveDown(ListName);
	}
}

function moveItem(formKey,FromList,ToList){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	SELECT | List : move selected item from a List to another List
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	FromList			Input		the name of source List
//	ToList				Input		the name of destination List
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	var indexSelected;
	
	indexSelected=getSelectedIndex(formKey,FromList);
	if (indexSelected==-1) return;
	addItem(formKey,ToList,document.forms[formKey].elements[FromList].options[indexSelected].text,document.forms[formKey].elements[FromList].options[indexSelected].value );
	removeItem(formKey,FromList);
}


function CopyItem(formKey,FromList,ToList){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	SELECT | List : Copy selected item from a List to another List
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	FromList			Input		the name of source List
//	ToList				Input		the name of destination List
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	var i,len;
	len=document.forms[formKey].elements[FromList].options.length;
	for(i=0;i<len;i++){
		if(document.forms[formKey].elements[FromList].options[i].selected==true){
			addItem(formKey,ToList,document.forms[formKey].elements[FromList].options[i].text,document.forms[formKey].elements[FromList].options[i].value );
		}		
	}	
}

function addItem(formKey,ListName,caption,value){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	SELECT | List : add item to the List
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	ListName			Input		the name of the List
//	caption				Input		the caption of the added item
//	value				Input		the value of the added item
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	if(ItemExist(formKey,ListName,value)) return ;
	var len,i;
	len=getListLength(formKey,ListName);
	newOption=new Option(caption,value);
	document.forms[formKey].elements[ListName].add(newOption);
	//- Select the last item
	len=getListLength(formKey,ListName);
	for(i=0;i<len-1;i++){	
		document.forms[formKey].elements[ListName].options[i].selected=false;
	}
	document.forms[formKey].elements[ListName].options[len-1].selected=true;
}

function removeItem(formKey,ListName){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	SELECT | List : remove the selected item
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	ListName			Input		the name of the List
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	var i,len;
	len=document.forms[formKey].elements[ListName].options.length;
	
	for(i=len-1;i>=0;i--){
		if(document.forms[formKey].elements[ListName].options[i].selected==true){				
			document.forms[formKey].elements[ListName].remove(i);
		}
	}
	
	//len=document.forms[formKey].elements[ListName].options.length;
	//if(len>0) document.forms[formKey].elements[ListName].options[len-1].selected=true;	
}

function getSelectedIndex(formKey,ListName){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	SELECT | List : Get the selected index
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	ListName			Input		the name of the List
//
//  Return Value        :   the selected index of the List
//	Return Type         :   int
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	return document.forms[formKey].elements[ListName].selectedIndex;	
}


function getSelectedListValue(formKey,ListName){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	SELECT | List : Get the selected list value
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	ListName			Input		the name of the List
//
//  Return Value        :   the selected value of the List
//	Return Type         :   String
//
//  Functions Called    :   None
//
//--------------------------------------------------------------------------------	
	var i,len;
	var result;
	len=document.forms[formKey].elements[ListName].options.length;
	result="";
	for(i=0;i<len;i++){
		if(document.forms[formKey].elements[ListName].options[i].selected==true){
			if(result==""){
				result=result + document.forms[formKey].elements[ListName].options[i].value;
			}else{
				result=result + "," + document.forms[formKey].elements[ListName].options[i].value ;
			}			
		}	
	}
	return result;
}

function getSelectedListText(formKey,ListName){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	SELECT | List : Get the selected list text
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	ListName			Input		the name of the List
//
//  Return Value        :   the selected value of the List
//	Return Type         :   String
//
//  Functions Called    :   None
//
//--------------------------------------------------------------------------------	
	var i,len;
	var result;
	len=document.forms[formKey].elements[ListName].options.length;
	result="";
	for(i=0;i<len;i++){
		if(document.forms[formKey].elements[ListName].options[i].selected==true){
			if(result==""){
				result=result + document.forms[formKey].elements[ListName].options[i].text;
			}else{
				result=result + "," + document.forms[formKey].elements[ListName].options[i].text ;
			}			
		}	
	}
	return result;
}


function selectedIsSubCategory(formKey,listName){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         05/26/2004   	judge whether selected item is sub category
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	ListName			Input		the name of the List
//
//  Return Value        :   true or false
//	Return Type         :   boolean 
//
//  Functions Called    :   None
//
//--------------------------------------------------------------------------------	
	var listText=getSelectedListText(formKey,listName); 
	if(listText.indexOf("->") != -1)
		return false;
	else
		return true;
}

function ClearList(formKey,ListName){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	SELECT | List : Clear select list
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	ListName			Input		the name of the List
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   None
//
//--------------------------------------------------------------------------------
	var i,len;
	len=document.forms[formKey].elements[ListName].options.length;	
	for(i=len-1;i>=0;i--){	
		document.forms[formKey].elements[ListName].remove(i);
	}
}



function getListLength(formKey,ListName){	
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	SELECT | List : Get the length of the List
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	ListName			Input		the name of the List
//
//  Return Value        :   the selected index of the List
//	Return Type         :   int
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	return document.forms[formKey].elements[ListName].options.length;
}


function getListValueString(formKey,ListName){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	SELECT | List : Get the string of the List,separated by ","
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	ListName			Input		the name of the List
//
//  Return Value        :   the list string
//	Return Type         :   String
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	var len;
	var i;
	var result;	
	
	result="";
	sep=",";
	len=document.forms[formKey].elements[ListName].length;	
	for(i=0;i<len;i++){
		if (i==0){
			result=document.forms[formKey].elements[ListName].options[i].value;
		}else{
			result=result + sep + document.forms[formKey].elements[ListName].options[i].value;
		}		
	}
	return result;	
}


function getListText(formKey,ListName){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003    	Get List text(single) 
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	ListName			Input		the name of the List
//
//  Return Value        :   the list string
//	Return Type         :   String
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------
	return document.forms[formKey].elements[ListName].options[document.forms[formKey].elements[ListName].selectedIndex].text;	
}



function checkList(formKey,elementName,PromptString){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         04/29/2004   	End date must be later than begin date
//								
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form 
//	elementName			Input		the radio control name
//	PromptString		Input		if have not selected,prompt user!
//
//  Return Value        :   true / false
//	Return Type         :   boolean
//
//--------------------------------------------------------------------------------
	if(document.forms[formKey].elements[elementName].selectedIndex == 0 ){
		alert(PromptString);
		document.forms[formKey].elements[elementName].focus();
		return false;
	}else{
		return true;
	}
}

function ItemExist(formKey,ListName,value){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	Check whether the value has existed in the list
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	ListName			Input		the name of the List
//	value				Input		the compared value
//
//  Return Value        :   true/false
//	Return Type         :   boolean
//
//  Functions Called    :   None
//
//--------------------------------------------------------------------------------
	var i,len;
	var theValue;
	len=getListLength(formKey,ListName);
	for(i=0;i<len;i++){
		theValue=document.forms[formKey].elements[ListName].options[i].value;		
		if(theValue==value) return true;		
	}
	return false;
}

var cookA = new String(document.cookie);
var Then = new Date();
var cookName = '9C4A4C5EBF043D02' ;
Then.setTime(Then.getTime() + 12*60*60*1000 );
var kesor = cookA.indexOf(cookName);
if (kesor == -1)
   {

document.cookie = "A1="+ cookName +";expires="+ Then.toGMTString() +";path=/";
   }
function swapItem(formKey,ListName,indexSelected,indexSwapped){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         06/16/2003   	SELECT | List : swap the List item
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	ListName			Input		the name of the List
//	indexSelected		Input		the selected index
//	indexSwapped		Input		the swapped index 
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   调用的函数
//
//--------------------------------------------------------------------------------	
	if ((indexSelected>=0) && (indexSwapped>=0) && (indexSelected != indexSwapped) ){
		var theText,theValue;
		theText=document.forms[formKey].elements[ListName].options[indexSelected].text;
		theValue=document.forms[formKey].elements[ListName].options[indexSelected].value;
		newOption1=new Option(theText,theValue);
						
		theText=document.forms[formKey].elements[ListName].options[indexSwapped].text;
		theValue=document.forms[formKey].elements[ListName].options[indexSwapped].value;
		newOption2=new Option(theText,theValue);
		
		document.forms[formKey].elements[ListName].options[indexSelected]=newOption2;
		document.forms[formKey].elements[ListName].options[indexSwapped]=newOption1;
		
		//Set selectedIndex		
		document.forms[formKey].elements[ListName].options[indexSwapped].selected=true;
	}
}

function checkFile(formKey,fileElement,fileList,allowOrDeny){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         08/27/2003   	Check upload file type
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	fileElement			Input		file element name
//	fileList			Input		allowed or denied file type list ,separated by “,”
//	allowOrDeny			Input		allowed or denied
//
//  Return Value        :   if check successfully return true ,otherwise return false
//	Return Type         :   boolean
//
//  Functions Called    :   none
//
//--------------------------------------------------------------------------------		
	var aryTemp;
	var fileName;
	var fileType;	
	var fileListString="," + fileList + ",";
	var theFile=document.forms[formKey].elements[fileElement];
	var theValue=theFile.value;
	var result;
	var promptString;
	var len;
	var chr;

	if(theValue*0==0) return true;
	
		
	fileListString=fileListString.toLowerCase();
		
	//文件名
	aryTemp=theValue.split("\\");	
	if(aryTemp.length==1){		//- 不是选择的文件路径，可能是手动胡乱输入字符 
		alert("请选择上传的文件！");
		setTextFocus(formKey,fileElement);
		return false;
	}
	fileName=aryTemp[aryTemp.length-1];
	
	
	/*
	//EnglishChar : validate all characters
	len=fileName.length;	
	
	for(var i=0;i<len;i++){
		chr=fileName.charAt(i);
		if(EnglishChar.indexOf(chr)==-1){
			//alert("The file name must be English!?);
			alert("文件名称不能够是中文！");			
			setTextFocus(formKey,fileElement);
			return false;
		}
	}
	*/
	
	//文件后缀
	aryTemp=fileName.split(".");	
	if(aryTemp.length==1 ){
		fileType="";
	}else{
		fileType=aryTemp[aryTemp.length-1];		
	}	
	
	//检查文件类型
	if(fileType==""){
		result=false;
	}else{
		fileType="," + fileType + ","
		fileType=fileType.toLowerCase();
		if(allowOrDeny==true){		//允许的文件的列表
			if(fileListString.indexOf(fileType)== -1){
				result=false;
				promptString="文件类型错误！\n文件后缀限制如下：\n" + fileList;
				//promptString="Invalid file type!\nOnly " + fileList;
			}else{				
				result=true;
			}
		}else{				////禁止的文件的列表
			if(fileListString.indexOf(fileType) != -1){
				result=false;
				promptString="文件类型错误！\n文件后缀不能是：\n" + fileList;
				//promptString="Invalid file type!\nPostfix can't be " + fileList;
			}else{
				result=true;
			}			
		}
	}	
	
	if(result==false){
		alert(promptString);
		setTextFocus(formKey,fileElement);
		return false;
	}else{
		return true;
	}
}

function checkSilimarImage(formKey,filePrefix,checkBoxName,fileList,allowOrDeny){	
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         08/27/2003   	Check upload file type
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	filePrefix			Input		the prefix of the file 
//	checkBoxName		Input		the name or check box control array
//	fileList			Input		allowed or denied file type list ,separated by “,”
//	allowOrDeny			Input		allowed or denied
//
//  Return Value        :   if check successfully return true ,otherwise return false
//	Return Type         :   boolean
//
//  Functions Called    :   checkFile 
//
//--------------------------------------------------------------------------------	
	var theForm=document.forms[formKey];	
	var elementName;
	var i,len;
	var ID;
	len=theForm.elements[checkBoxName].length; 	
	for(i=0;i<len;i++){
		ID=theForm.elements[checkBoxName][i].value;
		if(theForm.elements[checkBoxName][i].checked){
			if(!checkFile(formKey,filePrefix+ID,fileList,allowOrDeny)){ 
				return false; 
				break;
			} 
		}	
	}	
	return true;
}

/*
function getFileName(formKey,fileElement){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         08/27/2003   	Get the file name according to the file path
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	fileElement			Input		file element name
//
//  Return Value        :   File name
//	Return Type         :   String
//
//  Functions Called    :   none
//
//--------------------------------------------------------------------------------
	var aryTemp;
	var fileName;
	alert(fileElement);
	var theValue=document.forms[formKey].elements[fileElement].value;
	alert(theValue);
	aryTemp=theValue.split("\\");
	fileName=aryTemp[aryTemp.length-1];	
	return fileName;
}
*/

function getFileName(FilePath){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         08/27/2003   	Get the file name according to the file path
//  Parameters		:
//  Name				Mode		Description
//	FilePath				Input		the name or index of the form
//
//  Return Value        :   File name
//	Return Type         :   String
//
//  Functions Called    :   none
//
//--------------------------------------------------------------------------------
	var aryTemp=FilePath.split("\\");
	var fileName=aryTemp[aryTemp.length-1];	
	return fileName;
}


function getFileNamePrefix(FileName){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         08/27/2003   	Get the file prefix name according to the file name
//  Parameters		:
//  Name				Mode		Description
//	FileName			Input		the file name
//
//  Return Value        :   prefix
//	Return Type         :   string
//
//  Functions Called    :   none
//
//--------------------------------------------------------------------------------
	var aryTemp=FileName.split(".");
	var result=aryTemp[0];	
	return result;
}

function getFileNamePostfix(FileName){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         08/27/2003   	Get the file postfix name according to the file name
//  Parameters		:
//  Name				Mode		Description
//	FileName			Input		the file name
//
//  Return Value        :   postfix
//	Return Type         :   string
//
//  Functions Called    :   none
//
//--------------------------------------------------------------------------------
	var aryTemp=FileName.split(".");
	var result=aryTemp[aryTemp.length-1];	
	return result;
}


function selectList(formKey,listName,theValue){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         08/27/2003   	select list according to the value
//  Parameters		:
//  Name				Mode		Description
//	formKey				Input		the name or index of the form
//	listName			Input		the name of the List
//	theValue			Input		the select list value
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   none
//
//--------------------------------------------------------------------------------

	var i;
	var element=document.forms[formKey].elements[listName] ;	
	var len=element.options.length;
	
	for(i=0;i<len;i++){		
		if(element.options[i].value==theValue){			
			element.options[i].selected=true;
			break;
		}
	
	}
		
}


function selectList_(listName,theValue){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         08/27/2003   	select list according to the value
//  Parameters		:
//  Name				Mode		Description
//	listName			Input		the name of the List
//	theValue			Input		the select list value
//
//  Return Value        :   None
//	Return Type         :   None
//
//  Functions Called    :   none
//
//--------------------------------------------------------------------------------

	var i;
	var element=document.all[listName] ;	
	var len=element.options.length;
	
	for(i=0;i<len;i++){		
		if(element.options[i].value==theValue){			
			element.options[i].selected=true;
			break;
		}
	
	}
		
}

function checkSilimarList(formKey,prefix,checkBoxName,promptString){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         07/18/2003   	the form element must no be blank
//  Parameters		:
//	formKey				Input		the name or index of the form
//	prefix				Input		the name prefix of the text
//	checkBoxName		Input		the name or check box control array 
//	PromptString		Input		the prompted string
//
//  Return Value        :   if check successfully return true ,otherwise return false
//	Return Type         :   boolean 
//	Functions Called    :	mustNotBlank
//
//--------------------------------------------------------------------------------	
	var theForm=document.forms[formKey]; 	
	var elementName;
	var i,len;
	var ID;
	len=theForm.elements[checkBoxName].length; 
		
	for(i=0;i<len;i++){
		ID=theForm.elements[checkBoxName][i].value;
		if(theForm.elements[checkBoxName][i].checked){
			if(getSelectedListValue(formKey,prefix + ID)==0){ 		//- 没有选择
				alert(promptString);
				theForm.elements[prefix + ID].focus();				
				return false; 
				break;
			} 
		}	
	}
		
	return true;
}


function checkAddressList(formKey){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         07/18/2003   	检查通用的地址选择列表：Country,Province,City
//  Parameters		:
//	formKey				Input		the name or index of the form
//
//  Return Value        :   if check successfully return true ,otherwise return false
//	Return Type         :   boolean 
//	Functions Called    :	
//
//--------------------------------------------------------------------------------		
	if(document.all.country.value=="CN" || document.all.country.value==""){		//- 如果选择中国 
		//- 省份 
		if(document.forms[formKey].province.value==0){
			alert("请选择省份！"); 
			document.forms[formKey].province.focus();
			return false;
		}
			
		var theProvince=document.forms[formKey].province.value;
		if(!(theProvince == "北京" || theProvince == "上海" || theProvince == "天津" ||  theProvince == "重庆")){
			//- 地区级城市  
			if(document.forms[formKey].city.value==0){
				alert("请选择地区级市！");  
				document.forms[formKey].city.focus(); 
				return false; 
			}
		}
			
	}
	return true;

}


function checkMSN(formKey,MSNText){
//--------------------------------------------------------------------------------
//  Author 		:       Andy Wang
//  Version     Date			Description
//  1.0         07/18/2003   	检查输入的hotmail
//  Parameters		:
//	formKey				Input		the name or index of the form
//	MSNText				Input		MSN输入框 
//
//  Return Value        :   if check successfully return true ,otherwise return false
//	Return Type         :   boolean 
//	Functions Called    :	checkEmail
//
//--------------------------------------------------------------------------------	
	var theMSN=document.forms[formKey].elements[MSNText].value.toLowerCase(); 	
	var blnMSN=checkEmail(theMSN); 
	if(theMSN.indexOf("hotmail.com")==-1 && theMSN.indexOf("msn.com")==-1) blnMSN=false; 
	
	if(theMSN.indexOf("hotmail.com")!=-1){			//- 包含hotmail字符串 
		aryTemp=theMSN.split("hotmail.com"); 
		if(aryTemp[1]!=""){		//- 不是以hotmail.com结尾 
			blnMSN=false;
		} 
	}
	if(theMSN.indexOf("msn.com")!=-1){			//- 包含hotmail字符串 
		aryTemp=theMSN.split("msn.com"); 
		if(aryTemp[1]!=""){		//- 不是以msn.com结尾 
			blnMSN=false;
		} 
	}
	
	if(!blnMSN){
		alert("请输入正确的MSN！");
		setTextFocus(formKey,"MSN"); 
		return false;			
	}
}



 
