﻿
//=====================================	
//关闭指定页面
function doClose()
{
    window.opener=false;
	window.opener = null; 
	window.close();
}

//-----------------------------------------------
//设置文本框背景色
//-------------------- begin --------------------
function SetBackColor(_this, _focus)
{
    if (_focus == 1)
    {
        _this.style.backgroundColor = "#CCFF99";
    }
    else
    {
        _this.style.backgroundColor = "#FFFFFF";
    }
}
//--------------------- end ---------------------

//=====================================	
//打开指定页面
function openURL(sURL)
{
	_left = "0px";
	_top = "0px";
	_width = 1024-228;
	_height = window.screen.availHeight;
	if (window.screen.availWidth < _width)
	{
		_width = window.screen.availWidth;
	}
	var sFeatures = "menubar=yes,location=no,status=yes,titlebar=no,toolbar=no,resizable=yes," +
	                "fullscreen=0,scrollbars=yes,top=" + _top + ",left=" + _left;

    try{
        win = window.open(sURL, "_blank", sFeatures);
	    win.moveTo(-4,-4);
	    win.resizeTo(_width + 8,_height + 8);
	}
	catch(e){
	    openURL(sURL);
	}
}

//=====================================	
//打开指定页面---打印行程
function openURLxc(sURL)
{
	_left = "0px";
	_top = "0px";
	_width = 768-8;
	_height = window.screen.availHeight - 118;
	if (window.screen.availWidth < _width)
	{
		_width = window.screen.availWidth;
	}
	var sFeatures = "menubar=yes,location=no,status=yes,titlebar=no,toolbar=yes,resizable=yes," +
	                "fullscreen=0,scrollbars=yes,top=" + _top + ",left=" + _left + "," +
	                "width=" + _width + ",height=" + _height + "";

    window.open(sURL, "_blank", sFeatures);
}

//=====================================	
//打开指定页面---打印行程
function _openURLxc(sURL)
{
	_left = "0px";
	_top = "0px";
	_width = 768-8;
	_height = window.screen.availHeight;
	var sFeatures = "dialogWidth=" + _width + "px;DialogHeight=" + _height + "px;status=yes;resizable=yes";

	showModalDialog(sURL, "_blank", sFeatures);
}

//=====================================	
//_打开指定页面---游程详解
function _openDetail(sURL)
{
	_width = 768-8;
	_height = window.screen.availHeight - 518;
	if (window.screen.availWidth < _width)
	{
		_width = window.screen.availWidth;
	}
	_left = "0px";
	_top = (window.screen.availHeight-_height)/2;
	var sFeatures = "menubar=no,location=no,status=no,titlebar=no,toolbar=no,resizable=yes," +
	                "fullscreen=0,scrollbars=yes,top=" + _top + ",left=" + _left + "," +
	                "width=" + _width + ",height=" + _height + "";

    window.open(sURL, "_blank", sFeatures);
}

//=====================================	
//打开指定页面---游程详解
function openDetail(sURL)
{
	_width = 1024-228;
	_height = window.screen.availHeight-100;
	if (window.screen.availWidth < _width)
	{
		_width = window.screen.availWidth;
	}
	_left = (window.screen.availWidth-_width)/2;
	_top = (window.screen.availHeight-_height)/2;
	var sFeatures = "menubar=no,location=no,status=no,titlebar=no,toolbar=no,resizable=yes," +
	                "fullscreen=0,scrollbars=yes,top=" + _top + ",left=" + _left + "," +
	                "width=" + _width + ",height=" + _height + "";

    window.open(sURL, "_blank", sFeatures);
}

//=====================================	
//打开指定页面---合作伙伴
function openHzHb(sURL)
{
	_width = window.screen.availWidth-578;
	_height = window.screen.availHeight-558;
	if (window.screen.availWidth < _width)
	{
		_width = window.screen.availWidth;
	}
	_left = (window.screen.availWidth-_width)/2;
	_top = (window.screen.availHeight-_height)/2;
	var sFeatures = "menubar=no,location=no,status=yes,titlebar=no,toolbar=no,resizable=no," +
	                "fullscreen=0,scrollbars=yes,top=" + _top + ",left=" + _left + "," +
	                "width=" + _width + ",height=" + _height + "";

    window.open(sURL, "_blank", sFeatures);
}

//=====================================	
//打开指定页面
function openModalDialog(sURL)
{
	_left = "0px";
	_top = "0px";
	_width = 768-8;
	_height = window.screen.availHeight;
	var sFeatures = "dialogWidth=" + _width + "px;DialogHeight=" + _height + "px;status=yes;resizable=yes";

	showModalDialog(sURL, "_blank", sFeatures);
}

//=====================================	
//打开指定页面---景点链接
function openJqURL(sURL)
{
	_left = "0px";
	_top = "0px";
	_width = 1024-8;
	_height = window.screen.availHeight - 118;
	if (window.screen.availWidth < _width)
	{
		_width = window.screen.availWidth;
	}
	var sFeatures = "menubar=yes,location=no,status=yes,titlebar=no,toolbar=yes,resizable=yes," +
	                "fullscreen=0,scrollbars=yes,top=" + _top + ",left=" + _left + "," +
	                "width=" + _width + ",height=" + _height + "";

    window.open(sURL, "_blank", sFeatures);
}

//=====================================	
//打开指定页面---区域专卖
function openAreaZm(sURL)
{
	_left = "0px";
	_top = "0px";
	_width = 1024-8;
	_height = window.screen.availHeight - 118;
	if (window.screen.availWidth < _width)
	{
		_width = window.screen.availWidth;
	}
	var sFeatures = "menubar=yes,location=no,status=yes,titlebar=no,toolbar=yes,resizable=yes," +
	                "fullscreen=0,scrollbars=yes,top=" + _top + ",left=" + _left + "," +
	                "width=" + _width + ",height=" + _height + "";

    window.open(sURL, "_blank", sFeatures);
}

//=====================================	
//打开指定页面---帮助中心
function openHelpCenter(sURL)
{
	_width = 1024;
	_height = window.screen.availHeight;
	if (window.screen.availWidth < _width)
	{
		_width = window.screen.availWidth;
	}
	_left = (window.screen.availWidth-_width)/2;
	_top = (window.screen.availHeight-_height)/2;
	var sFeatures = "menubar=no,location=no,status=no,titlebar=no,toolbar=no,resizable=yes," +
	                "fullscreen=1,scrollbars=yes,top=" + _top + ",left=" + _left + "," +
	                "width=" + _width + ",height=" + _height + "";

    try{
        win = window.open(sURL, "_blank", sFeatures);
	    win.moveTo(-4,-4);
	    win.resizeTo(_width + 8,_height + 8);
	}
	catch(e){
	    openHelpCenter(sURL);
	}
}

//=====================================	
//打开指定页面---游客报名或销售
function openLineSell(sURL)
{
	_width = 1024-128;
	_height = window.screen.availHeight-100;
	if (window.screen.availWidth < _width)
	{
		_width = window.screen.availWidth;
	}
	_left = (window.screen.availWidth-_width)/2;
	_top = (window.screen.availHeight-_height)/2-41;
	var sFeatures = "menubar=no,location=no,status=no,titlebar=no,toolbar=no,resizable=yes," +
	                "fullscreen=0,scrollbars=yes,top=" + _top + ",left=" + _left + "," +
	                "width=" + _width + ",height=" + _height + "";

    window.open(sURL, "_blank", sFeatures);
}

//=====================================	
//打开指定页面---帐单信息---用于游客
function openZdInfoForYk(sURL)
{
	_width = 1024-524;
	_height = window.screen.availHeight-248;
	if (window.screen.availWidth < _width)
	{
		_width = window.screen.availWidth;
	}
	_left = (window.screen.availWidth-_width)/2;
	_top = (window.screen.availHeight-_height)/2-41;
	var sFeatures = "menubar=no,location=no,status=no,titlebar=no,toolbar=no,resizable=yes," +
	                "fullscreen=0,scrollbars=yes,top=" + _top + ",left=" + _left + "," +
	                "width=" + _width + ",height=" + _height + "";

    window.open(sURL, "_blank", sFeatures);
}

//=====================================	
//打开指定页面---导游列表
function openPrintCList(sURL)
{
	_width = 1024-128;
	_height = window.screen.availHeight-100;
	if (window.screen.availWidth < _width)
	{
		_width = window.screen.availWidth;
	}
	_left = (window.screen.availWidth-_width)/2;
	_top = (window.screen.availHeight-_height)/2-41;
	var sFeatures = "menubar=no,location=no,status=no,titlebar=no,toolbar=no,resizable=yes," +
	                "fullscreen=0,scrollbars=yes,top=" + _top + ",left=" + _left + "," +
	                "width=" + _width + ",height=" + _height + "";

    window.open(sURL, "_blank", sFeatures);
}

//=====================================	
//打开指定下拉框窗口
function changeURL(sURL)
{
	var sFeatures = "menubar=no,location=no,status=no,titlebar=no,toolbar=no,resizable=no," +
	                "fullscreen=0,scrollbars=no,width=698,height=418";

    window.open(sURL, "_self", sFeatures);
}

//=====================================	
//打开指定下拉框窗口
function DataInput(sURL)
{
	var sFeatures = "menubar=no,location=no,status=no,titlebar=no,toolbar=no,resizable=no," +
	                "fullscreen=0,scrollbars=no,width=280,height=145,left=350,top=200";

    window.open(sURL, "_blank", sFeatures);
}

//=====================================	
//打开指定下拉框窗口
function AddArea(sURL)
{
	var sFeatures = "menubar=no,location=no,status=no,titlebar=no,toolbar=no,resizable=no," +
	                "fullscreen=0,scrollbars=no,width=330,height=330,left=350,top=200";

    window.open(sURL, "_blank", sFeatures);
}

//=====================================	
//打开指定下拉框窗口
function UpLoads(sURL)
{
	var sFeatures = "menubar=no,location=no,status=no,titlebar=no,toolbar=no,resizable=no," +
	                "fullscreen=0,scrollbars=no,width=310,height=100,left=350,top=200";

    window.open(sURL, "_blank", sFeatures);
}

//=====================================	
//页面参数的获取	
function getQuery(name) 
{
	var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
	var r = location.search.substr(1).match(reg);
	if (r!=null)
	return unescape(r[2]);
}

//=====================================
function fClose(PageName)
{
    var sURL = PageName + ".aspx";  
	var IsClose = encodeURI("苏[a-z]钻[A-Z]石[0-9]州"); 
	if(getQuery(IsClose)==null){
		openURL(sURL + "?" + IsClose + "=1");
		window.opener = null; 
		window.close(); 
	}
}

//=====================================
function fClose()
{
    var sURL = "Index.aspx";
	if(getQuery("js")!=null){
		openURL(sURL + "");
		window.opener = null; 
		window.close(); 
	}
}

//=====================================
//屏蔽相关事件
Enabled = function(){

	//禁用右键
	doEventDisabled("oncontextmenu");
	
	//禁止选中文本
	//doEventDisabled("onselectstart");
	//doEventDisabled("ondragstart");
}

//=====================================
//屏蔽查看源码
doClearCode = function(){ 
    var Source=document.body.firstChild.data; 
    document.open(); 
    document.close(); 
    document.body.innerHTML=Source; 
}

//=====================================	
//去字符串两边空格
function Replace(v)
{
	v = v.replace(/(^[\s]*)|([\s]*$)/g, "");
	return v;
}

//=====================================	
//提示信息
//xDisplay:是否可见
//xValue:提示内容
function Msg(xDisplay,xValue){
    showMsg("showMsg",xDisplay,xValue)
}

//=====================================	
//为指定的元素提示相关信息
//xName:指定的元素名
//xDisplay:是否可见
//xValue:提示内容
function showMsg(xName,xDisplay,xValue){
    isHide(xName,xDisplay);
    $vObj(xName).innerText = xValue;
}

//=====================================
//是否隐藏相关元素
//xName:指定的元素名
//xDisplay:是否可见
function isHide(xName,xDisplay){
	if($vObj(xName)){
		$vObj(xName).style.display = xDisplay;
	}
}

//=====================================
//将相关元素获得焦点
function GetFocus(sName){
    if($vObj(sName)){
        $vObj(sName).focus();
    }
}

//=====================================	
//获取指定元素
//vName:指定的元素名
function $vObj(vName)
{
    return document.getElementById(vName);
}

//=====================================	
//获取指定元素的值
//xName:指定的元素名
function $vObjv(vName)
{
    return $vObj(vName).value;
}

//=====================================	
//打开导游列表
//xName:指定的元素名
function open_printCList(vName)
{
    var URL = "printCList.aspx?printLineID=";
    var printLineID = $vObjv('txtLineID');
    if(printLineID!=""){
        URL += printLineID;
        
        openPrintCList(URL);
    }
    else{
        alert("请输入线路编号！！");
        $vObj('txtLineID').focus();
    }
}

//=====================================
//数秒钟后自动还原提示信息
function isDefault(sTime){
	if(sTime==""){
		sTime = 1500;
	}
    window.clearTimeout(tt);
    var tt = setTimeout(clearDoInfo,sTime);
}

//=====================================
//还原提示信息
function clearDoInfo(){
    if($vObj("LabInfo")){
        var LabInfo = $vObjv("LabInfo");
        if(LabInfo != "暂无操作!"){
            $vObj("LabInfo").value = "暂无操作!";
        }
    }
}

//=====================================	
//刷新页面
function doRefreshWindow()
{
	window.location.reload();
}

//=====================================	
//事件控制
function EventControl()
{
	event.returnValue = false;
}

//=====================================	
//事件禁止的处理
function doEventDisabled(xObj)
{
	window.document.attachEvent(xObj,EventControl);
}
//关于页面对象的获取
function $vObj(obj){
    return document.getElementById(obj);
}

//对象的显示与隐藏
//Obj:对象Id值
//ShowOrHide:显示还是隐藏
function ObjShowOrHidden(Obj,ShowOrHide){

    if($vObj(Obj)){
        $vObj(Obj).style.display = ShowOrHide;
    }
}

//=======================================================
//对象显示还是隐藏
//=======================================================
function ObjIsShow(ObjName){

    if($vObj(ObjName)){
        if($vObj(ObjName).style.display=="none"){
            ObjShowOrHidden(ObjName,"block");
        }
        else{
            ObjShowOrHidden(ObjName,"none");
        }
    }
}
//=======================================================
//对象显示还是隐藏文字的提醒
//=======================================================
function ObjIsShowForAlt(Aobj,ObjName){

    if($vObj(ObjName)){
        if($vObj(ObjName).style.display=="none"){
            if(Aobj){
                Aobj.innerText = "显示";
            }
        }
        else{
            if(Aobj){
                Aobj.innerText = "隐藏";
            }
        }
    }
}
//=======================================================

//=======================================================
//树的设计
//=======================================================

//=======================================================
//中国节点打开与折叠
function ChinaOpenClose(China){

    if($vObj(China).style.display=="block"){
        ObjShowOrHidden(China,"none");
    }
    else{
        ObjShowOrHidden(China,"block");
    }
}

//=======================================================
//省份节点打开与折叠
function ProvinceOpenClose(Province){

    if($vObj(Province).style.display=="none"){
        ObjShowOrHidden(Province,"block");
    }
    else{
        ObjShowOrHidden(Province,"none");
    }
}
        
//=======================================================
//皮肤更换的操作
function Skin(BusColor,JsColor){    
    SetCookie("BusColor",BusColor);
    SetCookie("JsColor",JsColor);
    GetSkin();
    doRefreshWindow();
}

//设置到Cookie中
//=======================================================
function SetCookie (name, value) {
    var expire_days = 30;         //(保存的天数)
    var expire_date = new Date(); //new Date("December 31, 3666");//长期有效的办法
    var ms_from_now = expire_days*24*60*60*1000;
    expire_date.setTime(expire_date.getTime() + ms_from_now);
    var expire_string = expire_date.toGMTString();
    document.cookie = name + "=" + escape (value)+ ";expires=" +expire_string;
}

//从Cookie中获取
//=======================================================
function getCookieByName(name){

    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
    if(arr=document.cookie.match(reg))
    return arr[2];
    else
    return null
}
function GetCookie(Name) {
    var search = Name + "=";
    var returnvalue = "";
    if (document.cookie.length > 0){
        offset = document.cookie.indexOf(search);
        if(offset != -1) { 
            offset += search.length;
            end = document.cookie.indexOf(";", offset); 
            if (end == -1)
                  end = document.cookie.length;
            returnvalue=unescape(document.cookie.substring(offset,end));
        }
    }
    return returnvalue;
}

//=======================================================
//获取用户设置好的皮肤样式
function GetSkin(){

    if($vObj("BusCss")){
        var BusColor = getCookieByName("BusColor");
        if(BusColor==null||BusColor==""){
            BusColor = "BusBlue";
        }
        $vObj("BusCss").href = "Jspt/CssStyle/" + BusColor + ".css";
    }
    if($vObj("JsCss")){
        var JsColor = getCookieByName("JsColor");
        if(JsColor==null||JsColor==""){
            JsColor = "JsBlue";
        }
        $vObj("JsCss").href = "CssStyle/" + JsColor + ".css";
    }
}
//=======================================================

//=======================================================
//这是把事件动作绑定到某个对象上的函数
//=======================================================
function attachObject2(objid,color){
	if($vObj(objid)){
		with($vObj(objid)){
			onmouseover=function(){
			with(this){
					style.background='#4747F9'; //这是鼠标移上去时的背景颜色
					style.border='1px solid #ffffff'; //边框
					style.color='#ffffff'; //文字颜色
				}
			}
			onmouseout=function(){
			with(this){
					style.background=''; //这是鼠标离开时的背景颜色
					style.border='0px solid #336699'; //边框
					style.color=color; //文字颜色
				}
			}
		}
	}
}

//=======================================================
function attachObject(objid){
	attachObject2(objid,"");
}

/* 
这是把事件动作绑定到菜单上的函数
*/
function attachXMenu(objid){
var tds=objid.getElementsByTagName('td');
	for(var i=0;i<tds.length;i++){
		with(tds[i]){
			onmouseover=function(){
			with(this){
			        if(this.id!="tdMyInfos" &&
			           this.id!="tdLineMgrs"){
					    /*filters[0].apply();*/
					    style.background='#FEFFFD'; //这是鼠标移上去时的背景颜色
					    style.border='1px solid #ff6600'; //边框
					    style.color='#ffffff'; //文字颜色
					    /*filters[0].play();*/
					}
				}
			}
			onmouseout=function(){
			with(this){
			        if(this.id!="tdMyInfos" &&
			           this.id!="tdLineMgrs"){
					    /*filters[0].apply();*/
					    /*style.background='#336699'; //这是鼠标离开时的背景颜色*/
					    style.background=''; //这是鼠标离开时的背景颜色
					    style.border='0px solid #336699'; //边框
					    style.color='#ffffff'; //文字颜色
					    /*filters[0].play();*/
					}
				}
			}
		}
	}
}	
//=======================================================
//随机数的产生
//=======================================================
function rnd(){ 
	var today=new Date(); 
	var jran=today.getTime(); 

	var ia=9301; 
	var ic=49297; 
	var im=233280; 
	jran = (jran*ia+ic) % im; 
	return jran/(im*1.0); 
}; 

//=======================================================
//随机数的获取
//=======================================================
function rand(number){ 
	return Math.ceil(rnd()*number); 
}; 

//=======================================================
//获取当天日期时间
function DateNow()
{
	var d, s = "";							  // 声明变量。
	d = new Date();                           // 创建 Date 对象。
	s += d.getYear() + "-";                   // 获取年份。
	s += (d.getMonth() + 1) + "-";            // 获取月份。
	s += d.getDate() + " ";					  // 获取日。
	s += d.getHours() + ":";				  // 获取时。
    s += d.getMinutes() + ":";				  // 获取分。
    s += d.getSeconds();					  // 获取秒。
	return(s);                                // 返回日期时间。
}
//获取当天日期
function DateToday()
{
	var d, s = "";							  // 声明变量。
	d = new Date();                           // 创建 Date 对象。
	s += d.getYear() + "-";                   // 获取年份。
	s += (d.getMonth() + 1) + "-";            // 获取月份。
	s += d.getDate();						  // 获取日。
	return(s);                                // 返回日期。
}
//获取年份
function GetSingleYear()
{
	var d = new Date();
	var yearNum = d.getYear().toString();
	yearNum = yearNum.substring(2,4);
	return yearNum;
}

//=======================================================
//快捷查询树的展开与折叠
function ShowFLT(imgObj,imgName,Name,i,AllCount) {
	var TrLine = eval(Name + i);

	if (TrLine.style.display == 'none'){
		TrLine.style.display = 'block';
		imgObj.src = '../../image/Tree/Open.gif';
	}
	else {
		TrLine.style.display = 'none';
		imgObj.src = '../../image/Tree/Close.gif';
	}
}

//=======================================================