﻿//51/a/s/px
//滚屏脚本
var currentpos,timer;
function initializeScroll() { timer=setInterval("scrollwindow()",80);} 
function scrollclear(){clearInterval(timer);}
function scrollwindow() {currentpos=document.documentElement.scrollTop;window.scroll(0,++currentpos);if (currentpos != document.documentElement.scrollTop) scrollclear();} 
document.onmousedown=scrollclear;
document.ondblclick=initializeScroll;

//图片缩小
function ImgLoad(obj)
{
	var imgs = obj.getElementsByTagName("img");
	for(var i=0;i<imgs.length;i++){
		var o=imgs[i];
		if(o.complete){
			ImgLoaded(o);
		}else{
			o.onload=function(){ImgLoaded(this);};
		}
		// 点图片下一页
		var gp = document.getElementById("goPage");
		if (gp && imgs.length==1 && o.width>200){
			o.style.cursor="pointer";
			if (o.resized=="1"){
				o.setAttribute("title","ctrl+鼠标左键原大小");
				o.onclick=function(eventTag){var evt=eventTag||window.event;evt.ctrlKey ? ImgSize(this) : pager.Next()};
			}else{
				o.onclick=function(){pager.Next()};
			}
		}
	}
}

function ImgLoaded(o){
	if (o.width>imgMaxWidth){
		if (o.style.width){
			o.style.width="";
		}
		o.owidth=o.width;	// 保留原大小
		o.oheight=o.height;
		o.width=imgMaxWidth;
		o.removeAttribute("height");
		o.setAttribute("title","点击原始大小查看");
		o.style.cursor="pointer";
		o.style.display="block";
		o.vspace=5;
		o.resized=1;
		if (typeof(o.onclick)!="function"){
			o.onclick=ImgClick;
		}
//			o.onmousewheel=bbimg;
	}
}

function ImgSize(oImg){
	if (oImg.parentElement){
		if (oImg.parentElement.tagName=="A"){
			return;
		}
	}
	var imgDiv,bgDiv,bodyH,bodyW,winW,winH;
	bgDiv=document.getElementById("iwmsBImg");
	imgDiv=document.getElementById("iwmsFImg");
	bodyH=document.documentElement.scrollHeight;
	bodyW=document.documentElement.scrollWidth;
	if (self.innerHeight) { // all except Explorer
		winW = self.innerWidth;
		winH = self.innerHeight;
	}else if(document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		winW = document.documentElement.clientWidth;
		winH = document.documentElement.clientHeight;
	}else if(document.body) { // other Explorers
		winW = document.body.clientWidth;
		winH = document.body.clientHeight;
	}
	
	if (bgDiv==undefined){
		bgDiv=document.createElement("DIV");
		bgDiv.id="iwmsBImg";
		bgDiv.style.position="absolute";
		bgDiv.style.left="0px";
		bgDiv.style.top="0px";
//		bgDiv.style.filter="alpha(opacity=85)";
//		bgDiv.style.opacity="0.85";
		bgDiv.style.height=bodyH+"px";
		bgDiv.style.width=bodyW+"px";
		bgDiv.style.background="#000";
		document.body.appendChild(bgDiv);
	}
	if (imgDiv==undefined){
		imgDiv=document.createElement("DIV");
		imgDiv.id="iwmsFImg";
		imgDiv.style.position="absolute";
		imgDiv.style.top="10px";
		imgDiv.style.border="1px solid #666"
		imgDiv.style.background="#000";
		imgDiv.style.padding="8px"
		imgDiv.onclick=function(){this.style.display='none';document.getElementById("iwmsBImg").style.display='none';};
		imgDiv.onmousewheel=bbimg;
		imgDiv.title="ctrl+鼠标滚轮缩放\r\n点击图片隐藏";
		document.body.appendChild(imgDiv);
	}
	imgDiv.style.display="";
	bgDiv.style.display="";
	if(bodyW>oImg.owidth){
		imgDiv.style.left=(bodyW-oImg.owidth)/2+"px";
	}else{
		imgDiv.style.left="0px";
	}
	if(winH>oImg.oheight+22){
		imgDiv.style.top=(document.documentElement.scrollTop+(winH-oImg.oheight)/2-11)+"px";
	}else{
		imgDiv.style.top=(document.documentElement.scrollTop+10)+"px";
	}
	
	imgDiv.innerHTML="<img src='"+ oImg.src +"'/>";
}

function ImgClick()
{
	ImgSize(this);
}

//图片缩放
function bbimg()
{
	if (event.ctrlKey){
		var zoom=parseInt(this.style.zoom, 10)||100;
		zoom+=event.wheelDelta/12;
		if (zoom>0) this.style.zoom=zoom+'%';
		return false;
	}else{
		return true;
	}
}
// 内容样式用户定义
function ContentSize(size)
{
	var obj=document.getElementById("contenthtml");
	obj.style.fontSize=size>0 ? size+"px" : "";
	if (arguments.length==1){
		setCookie("iwmsFontSize",size,size==0?-1:1);
	}
}
function ContentBg(color)
{
	var obj=document.getElementById("bodyTd");
	obj.style.backgroundColor=color;
	if (arguments.length==1){
		setCookie("iwmsContBg",color,color.length==0?-1:1);
	}
}
function InitContStyle()
{
	var v=getCookie("iwmsFontSize");
	if (v.length>0){
		ContentSize(v,false);
	}
	v=getCookie("iwmsContBg");
	if (v.length>0){
		ContentBg(v,false);
	}
}
//***

function setCookie(name, value)		//cookies设置
{
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	if(expires!=null){
		var LargeExpDate = new Date ();
		LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24));
	}
	document.cookie = name + "=" + escape (value) + "; path=/;" +((expires == null) ? "" : (" expires=" +LargeExpDate.toGMTString()));
}

function getCookie(Name)			//cookies读取
{
	var search = Name + "=";
	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;
			}
			return unescape(document.cookie.substring(offset, end));
		}
	}
	return "";
}

String.prototype.trim = function()  
{  
	return this.replace(/(^\s*)|(\s*$)/g, "");  
}
function $(val)
{
    return document.getElementById(val);
}
function IsDisplay(ctl)
{
    var obj=$(ctl);
    obj.style.display = obj.style.display=='none' ? obj.style.display='' :obj.style.display='none';
}
function WinOpen(url,n,w,h)
{
        var left = (screen.width-w)/2;
        var top = (screen.height-h)/2;
        var f = "width="+w+",height="+h+",top="+top+",left="+left+",scrollbars=1";
        var c = window.open(url,n,f);
        return c; 
}
//返回日期
function returnDate()
{
    var day="";
    var month="";
    var ampm="";
    var ampmhour="";
    var myweekday="";
    var year="";
    mydate=new Date();
    myweekday=mydate.getDay();
    mymonth=mydate.getMonth()+1;
    myday= mydate.getDate();
    myyear= mydate.getYear();
    year=(myyear > 200) ? myyear : 1900 + myyear;
    if(myweekday == 0)
    weekday=" 星期日 ";
    else if(myweekday == 1)
    weekday=" 星期一 ";
    else if(myweekday == 2)
    weekday=" 星期二 ";
    else if(myweekday == 3)
    weekday=" 星期三 ";
    else if(myweekday == 4)
    weekday=" 星期四 ";
    else if(myweekday == 5)
    weekday=" 星期五 ";
    else if(myweekday == 6)
    weekday=" 星期六 ";
    return year+"年"+mymonth+"月"+myday+"日"+weekday;
}

function WinOpenDialog(url,w,h)
{
    var feature = "dialogWidth:"+w+"px;dialogHeight:"+h+"px;center:yes;status:no;help:no";
    //WinOpenDialog('../Common/SelectTemplate.aspx?ControlId=TextBox1&StartPath='+escape('/Template'),650,480)"
    showModalDialog(url,window,feature);
}
function CheckNumber(val)
{
   var patt=/^\d+$/;
   return patt.test(val) ;
}
function CheckNumberNotZero(val)
{
    var patt=/^[^0]\d*$/
    return patt.test(val) ; 
}
function ImgSize(val)
{

			var height = val.height;
			var width = val.width; 
			if(height>150&&width<=330)
			{
				val.height = 150;
			}
			else if(height<=150&&width>330)
			{
				val.width = 330;
			}
			else if(height>150&&width>330)
			{
				if(height/width>=150/330)
				{
					val.height = 150;
				}
				else
				{
					val.width = 330;
				}
			}
				

}

function CheckHas(uri,input,fileldName,tableName)
{
   var inputStr = escape(input);
   var fileldNameStr = escape(fileldName);
   var tableNameStr = escape(tableName);
   var paramStr = "Input="+input+"&FileldName="+fileldNameStr+"&TableName="+tableNameStr;
   var flag = XmlHttpPostMethodText(uri,paramStr)
   if(flag==1)
   {
        return true;
   }
   else
   {
        return false;
   } 
}
var tid=0;
function ShowTabs(cid)
{
    if(cid!=tid)
    {
        $("TabTitle"+tid).className="title5";
        $("TabTitle"+cid).className="title6";
        $("Tabs"+tid).style.display="none";
        $("Tabs"+cid).style.display="";
        tid=cid;
    }
}


//获取颜色
function GetColor(img_val,input_val)
{
	var PaletteLeft,PaletteTop
	var obj = $("colorPalette");
	ColorImg = img_val;
	ColorValue = $(input_val);
	if (obj){
		PaletteLeft = getOffsetLeft(ColorImg)
		PaletteTop = (getOffsetTop(ColorImg) + ColorImg.offsetHeight)
		if (PaletteLeft+150 > parseInt(document.body.clientWidth)) PaletteLeft = parseInt(event.clientX)-260;
		if (PaletteTop > parseInt(document.body.clientHeight)) PaletteTop = parseInt(document.body.clientHeight)-165;
		obj.style.left = PaletteLeft + "px";
		obj.style.top = PaletteTop + "px";
		if (obj.style.visibility=="hidden")
		{
			obj.style.visibility="visible";
		}else {
			obj.style.visibility="hidden";
		}
	}
}
function getOffsetTop(elm) {
	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent){
		mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetTop;
}
function getOffsetLeft(elm) {
	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent) {
		mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetLeft;
}

function setColor(color)
{
	if(ColorImg.id=='FontColorShow' && color=="#") color='#000000';
	if(ColorImg.id=='FontBgColorShow' && color=="#") color='#FFFFFF';
	if (ColorValue){ColorValue.value = color.substr(1);}
	if (ColorImg && color.length>1){
		ColorImg.src='../../Images/Rect.gif';
		ColorImg.style.backgroundColor = color;
	}else if(color=='#'){ ColorImg.src='../../Images/rectNoColor.gif';}
	$("colorPalette").style.visibility="hidden";
}

function SelectAll(trigger, container) {
    var obj = $(trigger);
    var chks = document.getElementById(container).getElementsByTagName("input");
    for (var i = 0; i < chks.length; i++) {
        if (chks[i].type == "checkbox") {
            chks[i].checked = obj.checked;
        }
    }
}
 function   coder(str)   
  {   
        var   s   =   "";   
        if   (str.length   ==   0)   return   "";   
        for   (var   i=0;   i<str.length;   i++)   
        {   
              switch   (str.substr(i,1))   
              {   
                      case   "<"     :   s   +=   "&lt;";       break;   
                      case   ">"     :   s   +=   "&gt;";       break;   
                      case   "&"     :   s   +=   "&amp;";     break;   
                      case   "   "     :   s   +=   "&nbsp;";   break;   
                      case   "\""   :   s   +=   "&quot;";   break;   
                      case   "\n"   :   s   +=   "<br>";       break;   
                      default       :   s   +=   str.substr(i,1);   break;   
              }   
        }   
        return   s;   
  }   


//IE和firefox通用的复制到剪贴板的JS函数
function copyToClipboard(txt) 
{        
     if(window.clipboardData)
     {
        window.clipboardData.clearData(); 
        window.clipboardData.setData("Text", txt);
        alert("复制成功！")
     } 
     else if(navigator.userAgent.indexOf("Opera") != -1) 
     {
        window.location = txt;
     }
     else if (window.netscape)
     {
       try 
       {
          netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
       }
       catch (e)
       {
          alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
       }
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip)
               return;
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if (!trans)
               return;
        trans.addDataFlavor('text/unicode');
        var str = new Object();
        var len = new Object();
        var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
        var copytext = txt;
        str.data = copytext;
        trans.setTransferData("text/unicode",str,copytext.length*2);
        var clipid = Components.interfaces.nsIClipboard;
        if (!clip)
               return false;      
        clip.setData(trans,null,clipid.kGlobalClipboard); 
        alert("复制成功！") 
     } 
}  

function ShowHidden(obj,Is,abs)
{
    if($(obj).style.display=="")
   {
        $(obj).style.display='none';
       if(abs=="left") 
             Is.className="down_bg";
       else if(abs=="right")
            Is.className="modelTitleDown";  
       Is.title='点击显示' ;
   } 
   else
   {
        $(obj).style.display='';
       if(abs=="left") 
           Is.className="up_bg"; 
       else if(abs=="right")
           Is.className="modelTitle";
       Is.title='点击隐藏' ;
    } 
}


function GetReadUserInfo()
{
    document.write("<script type='text/javascript' src='~/ajaxpro/prototype.ashx'></script>");
    document.write("<script type='text/javascript' src='~/ajaxpro/core.ashx'></script>");
    document.write("<script type='text/javascript' src='~/ajaxpro/converter.ashx'></script>");
    document.write("<script type='text/javascript' src='~/ajaxpro/common_ReadUserInfo,App_Web_oaidv3np.ashx'></script>");
    common_ReadUserInfo.ReadUserInfo("",UserInfo_Call_Back);
}



function NextForm(Myid,Url){
    document.getElementById("MyDid").value=Myid;
    form1.action=Url;
    form1.target="_blank"
    form1.submit()
}

function GetColumnContent(SystemId, ColumnId, Myurl) {    
    var MyRetuern = XmlHttpPostMethodText("/Common/CommondHandler.ashx", "param=ColumContent&&Myurl="+Myurl+"&ColumId=" + ColumnId);
    if (MyRetuern.length > 0) {
        document.getElementById("TDColumnConetent").innerHTML = unescape(MyRetuern);
    }
    
}

var Choose="IdNum0";

function ReturnTabs(obj,Myobj){
     clickStyle()
 if (Myobj=="2"){
     Choose=obj;
     document.getElementById(Choose).className="MenuDivR";
     document.getElementById(Choose+"_1").className="MenuLiR";
  }else if(Myobj=="1"){
     document.getElementById(obj).className="MenuDivR";
     document.getElementById(obj+"_1").className="MenuLiR";
  }else{
     document.getElementById(Choose).className="MenuDivR";
     document.getElementById(Choose+"_1").className="MenuLiR";}
}

function clickStyle(){
    var num=document.getElementById("MenuTD").getElementsByTagName("div").length;
    var i;
    for(i=0;i <num;i++){
        document.getElementById("IdNum"+i.toString()).className="MenuDiv";
        document.getElementById("IdNum"+i.toString()+"_1").className="MenuLi";
    }
}

//二级菜单
function GetTitleName(TitleName){
    var MyTitleName = TitleName;
    var TempMyTitleName = MyTitleName.split("|");
    for (Ti = 1; Ti < TempMyTitleName.length; Ti++) {        
        var MyRetuern = XmlHttpPostMethodText("/Common/CommondHandler.ashx", "param=title&MyTitleName=" + TempMyTitleName[Ti]);
        if (MyRetuern.length > 0) {            
            document.getElementById("odiv" +parseInt(Ti+1)).innerHTML = unescape(MyRetuern);
        }
    }
}


function GetContentName(TitleName) {
    var MyTitleName = TitleName    
    var MyRetuern = XmlHttpPostMethodText("/Common/CommondHandler.ashx", "param=1&MyTitleName=" + MyTitleName);
    if (MyRetuern.length > 0) {
        document.getElementById("cHtml").innerHTML = unescape(MyRetuern);
    }
}

function GetArticleContent(Id) {
    var MyRetuern = XmlHttpPostMethodText("/Common/CommondHandler.ashx", "param=ArticleContent&Id=" + Id);
    if (MyRetuern.length > 0) {
        document.getElementById("contentHtml").innerHTML = unescape(MyRetuern);
    }
}
//绑定链接
function getAjaxLink() {      
    var text = XmlHttpPostMethodText("/Common/CommondHandler.ashx", "param=Links");        
    var dic = document.getElementById("Select1");
    var list = text;
    var classList = text.split('|');    
    dic.options.length = 1;
    for (var i = 0; i < classList.length; i++) {
        var tmp = classList[i].split(",");
        dic.add(new Option(tmp[0], tmp[1]));
    }
}
//点击链接
function OnChangeLink() {    
    var obj = document.getElementById("Select1");
    if (obj.value == "")
    { return; } else {
        window.open(obj.value);        
    }
}
function GetColumnId() {
    var ColumnName = document.getElementById("ColumnName").value;
    if (ColumnName == "") { ColumnName = "公司动态"; }
    var MyRetuern = XmlHttpPostMethodText("/Common/CommondHandler.ashx", "param=GetColid&ColumnName=" + ColumnName);
    if (MyRetuern.length > 0) {
        window.location = "News-" + MyRetuern + ".aspx";
    } else { window.location = "News.aspx"; }
}


function GetArtId(ArtlcleId) {
    document.getElementById("ArtlcleId").value = ArtlcleId;    
    form1.action = "News.aspx";
    form1.target = "_self";
    form1.submit();
}
function RecommendSubmit(Url, Str, colid) {
    document.getElementById("Recommend").value = Str;    
    form1.action = Url + "-" + colid + ".aspx";
    form1.target = "_self";
    form1.submit();
}
var Guestbook = function() {
    return {
  SetHome: function(obj) {
            var url = "http://" + window.location.host;
            try {
                obj.style.behavior = 'url(#default#homepage)'; obj.setHomePage(url);
            }
            catch (e) {
                if (window.netscape) {
                    try {
                        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                    }
                    catch (e) {
                    }
                    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                    prefs.setCharPref('browser.startup.homepage', url);
                }
            }
        },
        //添加到收藏夹
        AddFavorite: function() {
            var url = window.location.href;
            try {
                window.external.addFavorite(url, document.title);
            }
            catch (e) {
                try {
                    window.sidebar.addPanel(document.title, url, "");
                }
                catch (e) {
                }
            }
        }
    };
} ();

var ChooseLab = "MyTd0";
function MM_ShowLayers(vobj) {
   var obj=document.getElementById(vobj);
       obj.className= (obj.className.length > 0 ? " " : "sfhovert");
       obj.parentNode.className="sfhover";
 }
function search() {    
    var searchStr = document.getElementById("TxtKeyword").value;
    if (searchStr == null || searchStr == "" || searchStr == "请输入关键字") { alert("请输入关键字"); return false; }
        form1.action = "Products.aspx?str="+escape(searchStr)+"&Myid=0";
        form1.target = "_blank";
        form1.submit();  
}

function searchstr(){
    var searchStr=document.getElementById("TxtKeyword").value="";
}
function btntit(x) {
	switch(x){
	    case 0:
	        window.navigate("index.aspx");
		    break;
	    case 1:
	        window.navigate("Company.aspx");
	        break;
 	    case 2:
		    window.navigate("News.aspx");
		    break;
	    case 3:
		    window.navigate("Products.aspx?str=&Myid=0");
		    break;
		 case 4:
	        window.navigate("Solutions.aspx");
		    break;
		 case 5:
		    window.navigate("Success.aspx");
		    break;
	     case 6:
		    window.navigate("Industry.aspx");
		    break;
		 case 7:
	        window.navigate("ContactUs.aspx");
		    break;   
	}
}
