﻿// JScript 文件

function findObj(n, d) { 
		 var p,i,x; 
		 if(!d) d=document; 
		 if((p=n.indexOf("?"))>0&&parent.frames.length) { 
					d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} 
		 if(!(x=d[n])&&d.all) 
		 x=d.all[n]; 
		 for (i=0;!x&&i<d.forms.length;i++) 
			 x=d.forms[i][n]; 
		 for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
			 x=findObj(n,d.layers[i].document); 
		 if(!x && d.getElementById) 
			 x=d.getElementById(n); 
		 return x; 
	 } 
function Price_fun(Dight) {
    Dight=Dight/1000+0.003;
　　Dight =(Dight*Math.pow(10,2)/Math.pow(10,2)).toFixed(2);
　　Dight=Dight*1000;
　　return Dight; 
　　}
function ForDight1(Dight,How) {
　　Dight =(Dight*Math.pow(10,How)/Math.pow(10,How)).toFixed(How); 
　　return Dight; 
　　}
Number.prototype.toFixed=function(len)
　　{
　　var add = 0;
　　var s,temp;
　　var s1 = this + "";
　　var start = s1.indexOf(".");
　　if(s1.substr(start+len+1,1)>=5)add=1;
　　var temp = Math.pow(10,len);
　　s = Math.floor(this * temp) + add;
　　return s/temp;
　　} 

/**
* Cookie plugin
*
* Copyright (c) 2006 ziqiu.zhang 
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* 使用举例：
    //注： 写入时，subName参数请传递空值或null
    //写入Cookies-值为字符串，即不包含子键
    $.cookie("singleKey", "", "singleKey-value", { expires: 1, path: "/", secure: false })
    //读取Cookies-根据主键
    alert("singleKey:" + $.cookie("singleKey"));

    //写入Cookies-值为对象，则每个属性名为子键的名称，属性值为子键值
    var subNameObj = { subName1: "aaa", subName2: "bbb", subName3: "ccc" };
    $.cookie("multiKey", "", subNameObj, { expires: 1, path: "/", secure: false });
    //读取Cookies-根据主键
    alert("multiKey:" + $.cookie("multiKey"));
    //读取Cookies-根据主键和子键
    alert("multiKey,subName1:" + $.cookie("multiKey", "subName1"));
*
*/

jQuery.cookie = function(name, subName, value, options)
{
	if (typeof value != 'undefined')
	{ // name and value given, set cookie
		options = options || {};
		if (value === null)
		{
			value = '';
			options.expires = -1;
		}
		var expires = '';
		if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString))
		{
			var date;
			if (typeof options.expires == 'number')
			{
				date = new Date();
				date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
			} else
			{
				date = options.expires;
			}
			expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
		}
		// CAUTION: Needed to parenthesize options.path and options.domain
		// in the following expressions, otherwise they evaluate to undefined
		// in the packed version for some reason...
		var path = options.path ? '; path=' + (options.path) : ';path=/';
		var domain = options.domain ? '; domain=' + (options.domain) : '';
		var secure = options.secure ? '; secure' : '';
	
		//If value is an object, each property will be a sub key;
		if (typeof value == "object")
		{
			var k = 0;
			var tempResult = "";
			for (var tempValue in value)
			{
				if (k > 0)
				{
					tempResult += "&";
				}
				tempResult += tempValue + "=" + encodeURIComponent(value[tempValue]);
				k++;
			}
			value = tempResult;
		}
		else
		{
			value = encodeURIComponent(value);
		}

		document.cookie = [name, '=', value, expires, path, domain, secure].join('');
	} else
	{ // only name given, get cookie
		var cookieValue = null;
		if (document.cookie && document.cookie != '')
		{
			var cookies = document.cookie.split(';');
			for (var i = 0; i < cookies.length; i++)
			{
				var cookie = jQuery.trim(cookies[i]);
				// Does this cookie string begin with the name we want?
				if (cookie.substring(0, name.length + 1) == (name + '='))
				{
					cookieValue = decodeURIComponent(cookie.substring(name.length + 1));

					//Search sub key
					if (typeof subName != 'undefined' && subName != null && subName != "")
					{
						var subCookies = cookieValue.toString().split('&');
						for (var j = 0; j < subCookies.length; j++)
						{
							var subCookie = jQuery.trim(subCookies[j]);
							if (subCookie.substring(0, subName.length + 1) == (subName + '='))
							{
								cookieValue = decodeURIComponent(subCookie.substring(subName.length + 1));
								break;
							}
						}
					}

					break;
				}

			}
		}
		return cookieValue;
	}
};

/*
文件名:jquery.liu.select.js
功能说明:本js文件为jquery类库的一个插件,主要实现对select的操作.
作者:John Liu
编写日期:2008/03/12
*/
//得到select项的个数
jQuery.fn.select_size = function()
{
    return jQuery(this).get(0).options.length;
}
//获得选中项的索引
jQuery.fn.getSelectedIndex = function()
{
    return jQuery(this).get(0).selectedIndex;
}
//获得当前选中项的文本
jQuery.fn.getSelectedText = function()
{
    if(this.select_size() == 0)
    {
        return "下拉框中无选项";
    }
    else
    {
        var index = this.getSelectedIndex();      
        return jQuery(this).get(0).options[index].text;
    }
}
//获得当前选中项的值
jQuery.fn.getSelectedValue = function()
{    
    if(this.select_size() == 0)
    {
        return "下拉框中无选中值";
    }
    else
    {
        return jQuery(this).val();
    }
}
//设置select中值为value的项为选中
jQuery.fn.setSelectedValue = function(value)
{
    jQuery(this).get(0).value = value;
}
//设置select中文本为text的第一项被选中
jQuery.fn.setSelectedText = function(text)
{
    var isExist = false;
    var count = this.select_size();
    for(var i=0;i<count;i++)
    {
        if(jQuery(this).get(0).options[i].text == text)
        {
            jQuery(this).get(0).options[i].selected = true;
            isExist = true;
            break;
        }
    }
    if(!isExist)
    {
        alert("下拉框中不存在该项");
    }
}
//设置选中指定索引项
jQuery.fn.setSelectedIndex = function(index)
{
    var count = this.select_size();    
    if(index >= count || index < 0)
    {
        alert("选中项索引超出范围");
    }
    else
    {
        jQuery(this).get(0).selectedIndex = index;
    }
}
//判断select项中是否存在值为value的项
jQuery.fn.isExistItem = function(value)
{
    var isExist = false;
    var count = this.select_size();
    for(var i=0;i<count;i++)
    {
        if(jQuery(this).get(0).options[i].value == value)
        {
            isExist = true;
            break;
        }
    }
    return isExist;
}
//向select中添加一项，显示内容为text，值为value,如果该项值已存在，则提示
jQuery.fn.addOption = function(text,value)
{
    if(this.isExistItem(value))
    {
        alert("待添加项的值已存在");
    }
    else
    {
        jQuery(this).get(0).options.add(new Option(text,value));
    }
}
//删除select中值为value的项，如果该项不存在，则提示
jQuery.fn.removeItem = function(value)
{    
    if(this.isExistItem(value))
    {
        var count = this.select_size();        
        for(var i=0;i<count;i++)
        {
            if(jQuery(this).get(0).options[i].value == value)
            {
                jQuery(this).get(0).remove(i);
                break;
            }
        }        
    }
    else
    {
        alert("待删除的项不存在!");
    }
}
//删除select中指定索引的项
jQuery.fn.removeIndex = function(index)
{
    var count = this.select_size();
    if(index >= count || index < 0)
    {
        alert("待删除项索引超出范围");
    }
    else
    {
        jQuery(this).get(0).remove(index);
    }
}
//删除select中选定的项
jQuery.fn.removeSelected = function()
{
    var index = this.getSelectedIndex();
    this.removeIndex(index);
}
//清除select中的所有项
jQuery.fn.clearAll = function()
{
    jQuery(this).get(0).options.length = 0;
}






function LTrim(str){ //去掉字符串 的头空格
    var i;
    for(i=0;i<str.length;i++){ 
        if(str.charAt(i)!=" "&&str.charAt(i)!=" ") break;
    }
    str = str.substring(i,str.length);
    return str;
}
function RTrim(str)
{
    var i;
    for(i=str.length-1;i>=0;i--){
        if(str.charAt(i)!=" "&&str.charAt(i)!=" ") break;
    }
    str = str.substring(0,i+1);
    return str;
}

function Trim(str){
    return LTrim(RTrim(str)); 
}

function jump(count,targ,url) {   
                window.setTimeout(function(){   
                    count--;   
                    if(count > 0) {   
                        $(targ).attr('innerHTML', count);   
                        jump(count,targ,url);   
                    } else {   
                        location.href=url;   
                    }   
                }, 1000);   
            }   

function email_check(Value)
{
 if(Value.length!=0)
  {
    if (Value.charAt(0)=="." ||       
         Value.charAt(0)=="@"||      
         Value.indexOf('@', 0) == -1 ||
         Value.indexOf('.', 0) == -1 ||
         Value.lastIndexOf("@")==Value.length-1 ||
         Value.lastIndexOf(".")==Value.length-1)
     {
        return false;
      }
      else
      {
        return true;
      }
   }
 else
  {
    return false;
   }
}

