// JavaScript Document

document.getElementsByClassName = function(className, tagName){
	var elems = document.body.getElementsByTagName("*");
	if( tagName != null ) elems = document.body.getElementsByTagName(tagName);
	var result=[];
	for (i=0; j=elems[i]; i++){
	  if ((" "+j.className+" ").indexOf(" "+className+" ")!=-1){
	   result.push(j);
	  }
	}
	return result;
}

//=====================错误提示==================
function sAlert(bgDiv,msgDiv){
	document.write("<bgsound src='../icons/online.wav' loop='0'>")
var msgw,msgh,bordercolor;
var sWidth,sHeight,widthpercenter;
sWidth=document.body.offsetWidth;
widthpercenter= (sWidth-403)/sWidth*50 + "%"
sHeight=document.body.scrollHeight;//屏幕高度（垂直分辨率）

document.getElementById("bgDiv").setAttribute('id','bgDiv');
document.getElementById("bgDiv").style.position="absolute";
document.getElementById("bgDiv").style.top="0";
document.getElementById("bgDiv").style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=20,finishOpacity=20";
//document.getElementById("bgDiv").style.opacity="0.6";
document.getElementById("bgDiv").style.left="0";
document.getElementById("bgDiv").style.width="100%";
document.getElementById("bgDiv").style.height=sHeight + "px";
document.getElementById("bgDiv").style.zIndex = "10000";



document.getElementById("msgDiv").style.position = "absolute";
document.getElementById("msgDiv").style.left = widthpercenter;
document.getElementById("msgDiv").style.top = "30%";
document.getElementById("msgDiv").style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
//document.getElementById("msgDiv").style.marginLeft = "-225px" ;
//document.getElementById("msgDiv").style.marginTop = -300+document.documentElement.scrollTop+"px";
document.getElementById("msgDiv").style.zIndex = "10001";

document.getElementById("bgDiv").style.display='block'
document.getElementById("msgDiv").style.display='block'
}
function removeObj(){//点击标题栏触发的事件
				document.getElementById("bgDiv").style.display='none'
				document.getElementById("msgDiv").style.display='none'
}

//函数：添加页面载入事件
function load_add(func){
	var tmp_event = window.onload;
	try{
		if(typeof (tmp_event) != 'function'){
			window.onload = function(){
				func();
			}
		}else{
			window.onload = function(){
				tmp_event();
				func();
			}
		}
	}catch(e){}
}

//常用函数重命名
function $(obj){return document.getElementById(obj);}
function $$(obj){return document.getElementsByName(obj);}
function $$$(obj){return document.getElementsByTagName(obj);}
function $$$$(obj,tag){return document.getElementsByClassName(obj,tag);}

load_add(page_load_menu);//载入系统链接
load_add(load_listline);//载入系统列表行
load_add(load_input);//载入输入框样式
load_add(load_img_cmd);//载入小图标样式

//函数：系统按钮样式特效
function page_load_menu(){
	var buttons = $$$$("btn1","input");
	for( var i=0; i<buttons.length; i++ ){
		buttons[i].onmouseover = function(){this.className = "btn2";};
		buttons[i].onmouseout  = function(){this.className = "btn1";};
		buttons[i].onfocus = function(){this.blur();};
	}
}

//函数：系统列表行特效
function load_listline(){
	var lines = $$$$("list_line_Off","tr");
	for( var i=0; i<lines.length; i++ ){
		lines[i].onmouseover = function(){this.className = "list_line_On";};
		lines[i].onmouseout  = function(){this.className = "list_line_Off";};
	}
}

//函数:小图标样式加载
function load_img_cmd(){
	var imgs = $$$$("img_cmd_Off","img");
	for( var i=0; i<imgs.length; i++ ){
		imgs[i].onmouseover = function(){this.className = "img_cmd_On";};
		imgs[i].onmouseout  = function(){this.className = "img_cmd_Off";};
	}
}

//函数：输入框样式
function load_input(){
	var lines = $$$("input");
	for( var i=0; i<lines.length; i++ ){
		if(lines[i].type=="text" || lines[i].type=="password")
		{
			lines[i].className = "ipt_text"
			lines[i].onfocus = function(){this.className="ipt_text_onfocus";try{$(this.name+"_Tip").className="TipShow";}catch(e){}};
			lines[i].onblur	=function(){this.className="ipt_text";try{$(this.name+"_Tip").className="";}catch(e){}}
		}
	}
	var textarea = $$$("textarea");
	
	for( var i=0; i<textarea.length; i++ ){
		textarea[i].className = "textarea_text"
		textarea[i].onfocus = function(){this.className="textarea_text_onfocus";};
		textarea[i].onblur	=function(){this.className="textarea_text";}
	}
}


//后台登陆首页检查
function admin_login_chk()
{
  var username=$("username").value;
  var password=$("password").value;
  var seed=$("seed").value;
  var color="Red"
  if (username=="" || username==null)
  {
    $("loginerr").innerHTML="<font color='" + color + "'>请先输入登陆用户名！</font><br />";
    $("username").focus();
    return false;
  }
  if (password=="" || password==null)
  {
    $("loginerr").innerHTML="<font color='" + color + "'>请先输入登陆密码！</font><br />";
    $("password").focus();
    return false;
 }
  if (seed=="" || seed==null)
  {
    $("loginerr").innerHTML="<font color='" + color + "'>请先输入验证码！</font><br />";
    $("seed").focus();
    return false;
 }
  return true;
}

//管理页列表全选
function select_all(frm)
{
  var slength=0;
  if (frm.sel_id==null) { return false; }
  var sall=frm.sel_all.checked;
  if (frm.sel_id.length)
  {
    slength=frm.sel_id.length;
    for (var i=0;i<slength;i++) { frm.sel_id[i].checked=sall; }
  }
  else { frm.sel_id.checked=sall; }
}
//递归列表选子类
function checkedbox_all(obj){
	var str1=obj.check_pri_id
	var str2=obj.check_id
	if(obj.checked){
		checkedbox_pri(obj,str1,obj.checked)
	}
	checkedbox_sub(obj,str2,obj.checked)
	}
//选择父类
function checkedbox_pri(obj,str,chkbool){
	var objarr=$$(obj.name)
	for (i=0;i<objarr.length;i++){
			if (objarr[i].check_id==str) {
				objarr[i].checked=chkbool;
				checkedbox_pri(objarr[i],objarr[i].check_pri_id,chkbool)
				}
		}
	}
//选择子类
function checkedbox_sub(obj,str,chkbool){
	var objarr=$$(obj.name)
	for (i=0;i<objarr.length;i++){
			if (objarr[i].check_pri_id==str) {
				objarr[i].checked=chkbool;
				if(objarr[i].issubitem!=0) 	checkedbox_sub(objarr[i],objarr[i].check_id,chkbool)
			}
	
		}
	}

//主屏，前进，后退，刷新
function explorer_do(do_str){
	switch(do_str){
		case "pre":history.forward();break;
		case "next":history.back();break;
		case "reload":window.parent.frame_main.location.reload();;break;
		}
	}

//选取颜色
function SelectColor(tcstr,urlstr)
{
  var c=window.showModalDialog(urlstr + "NewsManagement/ftb.colorpicker.aspx","s","dialogWidth=300px;dialogHeight=270px;status=0");
  var d=c;
  if (c && c!="")
  {
    if (d.length==7) { d=d.substr(1,d.length); }
    eval("window.document.all."+tcstr+".value=d;window.document.all."+tcstr+".style.backgroundColor=c;");
  }
}
//清除颜色
function ClearColor(tcstr)
{
  eval("window.document.all."+tcstr+".value='';window.document.all."+tcstr+".style.backgroundColor='';");
}

//选择时间
function select_time(st_obj)
{
  var showx=event.screenX-event.offsetX-14;
  var showy=event.screenY-event.offsetY-168;
  var retval=window.showModalDialog("Select_Data.asp?"+st_obj.value,"","dialogWidth:197px; dialogHeight:210px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;Resizable=no;");
  if( retval!=null ) { st_obj.value=retval; }
}

//图片的等比缩放
function MyImage(Img){  
var image=new Image();  
    image.src=Img.src;  
    width=260;//预先设置的所期望的宽的值 
    height=200;//预先设置的所期望的高的值 
    if(image.width>width||image.height>height){//现有图片只有宽或高超了预设值就进行js控制 
    w=image.width/width; 
    h=image.height/height; 
    if(w>h){//比值比较大==>宽比高大 
    //定下宽度为width的宽度 
    Img.width=width; 
    //以下为计算高度 
    Img.height=image.height/w; 

    }else{//高比宽大 
    //定下宽度为height高度 
    Img.height=height; 
    //以下为计算高度 
    Img.width=image.width/h; 
     }
    }
}

//设置导航样式
function SetNav(index)
{
    for(var i=1;i<=9;i++)
    {
        $("Nav_"+i).className="Normal";
    }
    $("Nav_"+index).className="Current";
}

//输出登陆或者直接订购的选择层
function ShowLoginDiv()
{
    document.write("<div id='LoginDiv'>");
    document.write("    <div id='TopClose'><img src=\"/images/closediv.jpg\" alt=\"点击关闭,直接订购\" onclick=\"divClose('LoginDiv');\" /></div>");
    document.write("    <div id='MainDiv'><iframe src='/Ticket/ForUserLogin.aspx' width='100%' height='400' scrolling='no' frameborder='0' /></div>");
    document.write("</div");
    
    $("LoginDiv").style.left=(document.body.offsetWidth-700)/2;
}

function divClose(ctr)
{
    $(ctr).style.display="none";
}


function LoginDivOK(name,tel,mobile,email)
{
    parent.$("CustomerName").value=name;
    parent.$("CustomerTel").value=tel;
    parent.$("CustomerMobile").value=mobile;
    parent.$("CustomerEmail").value=email;
    
    parent.divClose('LoginDiv');
}