
// Example: //showHideLayers(Layer1,'','show',Layer2,'','hide');
//同时显示和/或隐藏多层。
function showHideLayers()

{ 

  var i, visStr, obj, args = showHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3)

  {

    if ((obj = findObj(args[i])) != null)

    {

      visStr = args[i+2];

      if (obj.style)

      {

        obj = obj.style;

        if(visStr == 'show') visStr = 'visible';

        else if(visStr == 'hide') visStr = 'hidden';

      }

      obj.visibility = visStr;

    }

  }

}


// Example: obj = findObj("image1");
//用于在 DOM 中定位指定对象的函数。变量“theDoc”用于进行递归，不像在正常情况下那样进行传递。
function findObj(theObj, theDoc)

{

  var p, i, foundObj;

  

  if(!theDoc) theDoc = document;

  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)

  {

    theDoc = parent.frames[theObj.substring(p+1)].document;

    theObj = theObj.substring(0,p);

  }

  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];

  for (i=0; !foundObj && i < theDoc.forms.length; i++) 

    foundObj = theDoc.forms[i][theObj];

  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 

    foundObj = findObj(theObj,theDoc.layers[i].document);

  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);

  

  return foundObj;

}

//Example: preloadImages('file.gif', 'http://www.x.com/y.gif');
//用于按顺序预先载入多个图像文件的代码。
function preloadImages()

{

  if(document.images)

  {

    if(!document.imageArray) document.imageArray = new Array();

    var i,j = document.imageArray.length, args = preloadImages.arguments;

    

    for(i=0; i<args.length; i++)

    {

      if (args[i].indexOf("#")!=0)

      {

        document.imageArray[j] = new Image;

        document.imageArray[j++].src = args[i];

      }

    }

  }

}

function switchImage(imgName, imgSrc) 

{

  if (document.images)

  {

    if (imgSrc != "none")

    {

      document.images[imgName].src = imgSrc;

    }

  }

}



//用于创建幻灯片的代码。
// SCRIPT Example:

// var mySlideList1 = ['image1.gif', 'image2.gif', 'image3.gif'];

// var mySlideShow1 = new SlideShow(mySlideList1, 'slide1', 3000, "mySlideShow1");
function SlideShow(slideList, image, speed, name)
{

  this.slideList = slideList;

  this.image = image;

  this.speed = speed;

  this.name = name;

  this.current = 0;

  this.timer = 0;

}

SlideShow.prototype.play = SlideShow_play;  

function SlideShow_play()       

{

  with(this)

  {

    if(current++ == slideList.length-1) current = 0;

    switchImage(image, slideList[current]);

    clearTimeout(timer);

    timer = setTimeout(name+'.play()', speed);

  }

}

function htmlEncodeString (inputString)

{

  return escape(inputString);

}
function htmlUnencodeString (inputString)

{

  return unescape(inputString);

}
function stringToInteger (inputString)

{

  return parseInt(inputString);

}

function stringToFloat (inputString)

{

  return parseFloat(inputString);

}

function stringLength(inputString)

{

  return inputString.length;

}

function isNotaNumber (inputString)

{

  return isNaN(inputString);

}

function checkForCharacters(inputString, checkString, startingIndex)

{

  if (!startingIndex) startingIndex = 0;

  return inputString.indexOf(checkString);

}

function onlyCharacters(inputString)

{

  var searchForNumbers = /\d+/;

 return (searchForNumbers.test(inputString)) ?  false :  true;

}
function onlyNumbers(inputString)

{

  var searchForNumbers = /\D/;

  if (searchForNumbers.test(inputString)) 
  {
	  return false;
  }
  else
  {
	  return true;
  }
	
} 
function isNumberInt(inputString)

{

  return (!isNaN(parseInt(inputString))) ? true : false;

}
function isNumberFloat(inputString)
{

  return (!isNaN(parseInt(inputString))) ? true : false;

}
function redirect(URLStr) { location = URLStr; }

// Example:

// value1 = 3; value2 = 4;

// messageBox("text message %s and %s", value1, value2);

// this message box will display the text "text message 3 and 4"

function messageBox()

{

  var i, msg = "", argNum = 0, startPos;

  var args = messageBox.arguments;

  var numArgs = args.length;

  if(numArgs)

  {

    theStr = args[argNum++];

    startPos = 0;  endPos = theStr.indexOf("%s",startPos);

    if(endPos == -1) endPos = theStr.length;

    while(startPos < theStr.length)

    {

      msg += theStr.substring(startPos,endPos);

      if (argNum < numArgs) msg += args[argNum++];

      startPos = endPos+2;  endPos = theStr.indexOf("%s",startPos);

      if (endPos == -1) endPos = theStr.length;

    }

    if (!msg) msg = args[0];

  }

  alert(msg);

}

function messageWindow(title, msg)

{

  var width="300", height="125";

  var left = (screen.width/2) - width/2;

  var top = (screen.height/2) - height/2;

  var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;

  var msgWindow = window.open("","msgWindow", styleStr);

  var head = '<head><title>'+title+'</title></head>';

  var body = '<center>'+msg+'<br><p><form><input type="button" value="   Done   " onClick="self.close()"></form>';

  msgWindow.document.write(head + body);

}

function JumpManagementPage(url)
{
	window.location.href=url;
}

function JumpPage(page)
{
	document.all("txtpage").value=page;
	document.mainform.submit();
}

function DrawImage(ImgD,width){
	var flag=false;
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		flag=true;
	
		if(image.width>width){ 
			ImgD.width=width;
			ImgD.height=(image.height*width)/image.width;
		}else{
			ImgD.width=image.width; 
			ImgD.height=image.height;
		}		
		
	}
} 
function DrawImage2(ImgD,width,height){
	var flag=false;
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		flag=true;
		var widthD = image.width; 
		var heightD = image.height;
		if(widthD>width){ 
			
			heightD=(heightD*width)/widthD;
			widthD=width;
		}
	
		if(heightD>height){ 
			
			widthD=(widthD*height)/heightD;
			heightD=height;
			
		}
		ImgD.width=widthD; 
		ImgD.height=heightD;
		
		
	}
}
function isEmail(strEmail) {
 if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
  return true;
 else
  return false;
}

function CheckNumber(obj)
{
	if (!isNaN(obj.value) && obj.value != "")
	{
		obj.value=Math.round(parseFloat(obj.value)*100)/100;
	}
	else
	{
		obj.value = 0;
	}
}

//函数名：fucCheckTEL
//功能介绍：检查是否为电话号码
//参数说明：要检查的字符串
//返回值：1为是合法，0为不合法
function fucCheckTEL(TEL)
{
	var i,j,strTemp;
	strTemp="0123456789-()# ";
	for (i=0;i<TEL.length;i++)
	{
		j=strTemp.indexOf(TEL.charAt(i));	
		if (j==-1)
		{
		//说明有字符不合法
			return 0;
		}
	}
	//说明合法
	return 1;
}



function login()
{
	if (document.all("txtUserLoginID").value.replace(" ","") == "") 
	{
		alert("请输入用户名");
		return false;
	}
	
	if (document.all("txtUserPassword").value.replace(" ","") == "") 
	{
		alert("请输入密码");
		return false;
	}
	document.all("loginsubmit").value="1"
	document.frmLogin.submit();
}

function OrderSearch()
{
	if (document.all("txtOrderNumber").value.replace(" ","") == "")
	{
		alert("请输入您要查询的订单编号");
		return false;
	}
	document.frmOrderSearch.submit();
}

function ProductSearch()
{
	//if (document.frmProductSearch("sltSearchType").value == "")
	//{
	//	alert("请选择您要以何种方式查询商品");
	//	return false;
	//}
	if (document.frmProductSearch("txtKey").value.replace(" ","") == "")
	{
		alert("请输入您要查询的商品关键字");
		return false;
	}
	document.frmProductSearch.submit();
}