﻿var BROWSER = {};
var USERAGENT = navigator.userAgent.toLowerCase();
browserVersion({ 'ie': 'msie', 'firefox': '', 'chrome': '', 'opera': '', 'safari': '', 'mozilla': '', 'webkit': '', 'maxthon': '', 'qq': 'qqbrowser' });
if (BROWSER.safari) {BROWSER.firefox = true;}
BROWSER.opera = BROWSER.opera ? opera.version() : 0;
if (BROWSER.ie) {document.documentElement.addBehavior("#default#userdata");}
function browserVersion(types) {
    var other = 1;
    for (i in types) {
        var v = types[i] ? types[i] : i;
        if (USERAGENT.indexOf(v) != -1) {
            var re = new RegExp(v + '(\\/|\\s)([\\d\\.]+)', 'ig');
            var matches = re.exec(USERAGENT);
            var ver = matches != null ? matches[2] : 0;
            other = ver !== 0 && v != 'mozilla' ? 0 : other;
        } else {var ver = 0;}
        eval('BROWSER.' + i + '= ver');
    }
    BROWSER.other = other;
}
function vod(){}
function EncodeURL(str) {return encodeURIComponent(str).replace(/\+/g, "%2b").replace(/\?/, "").replace(/\&/, "").replace(/\'/, "‘");}
function encodeURL(str) {return encodeURI(str).replace(/=/g, "%3D").replace(/\+/g, "%2B").replace(/\?/g, "%3F").replace(/\&/g, "%26");}
function htmlEncode(str) {return str.replace(/&/g, "&amp;").replace(/\"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/ /g, "&nbsp;");}
function htmlDecode(str) {return str.replace(/\&quot;/g, "\"").replace(/\&lt;/g, "<").replace(/\&gt;/g, ">").replace(/\&nbsp;/g, " ").replace(/\&amp;/g, "&");}
function javaEncode(txt) {if (!txt) {return txt;}return txt.replace("\\", "\\\\").replace("\r\n", "\n").replace("\n", "\\n").replace("\"", "\\\"").replace("\'", "\\\'");}
function javaDecode(txt) {if (!txt) {return txt;}return txt.replace("\\\\", "\\").replace("\\n", "\n").replace("\\r", "\r").replace("\\\"", "\"").replace("\\\'", "\'");}
function checkclick(msg,url){if(confirm(msg)){window.location.href=url}}function getRadioValue(name){var backValue="";$("input[name='"+name+"'][type='radio']").each(function(){if(this.checked){backValue=this.value;return false}});return backValue}function IsCheckNum(NUM){var i,j,strTemp;strTemp="0123456789";if(NUM.length==0){return 0}for(i=0;i<NUM.length;i++){j=strTemp.indexOf(NUM.charAt(i));if(j==-1){return 0}}return 1}var imageObject;function ResizeImage(obj,MaxW,MaxH){if(obj!=null){imageObject=obj}var state=imageObject.readyState;if(state!="complete"){setTimeout("ResizeImage(null,"+MaxW+","+MaxH+")",50);return}var oldImage=new Image();oldImage.src=imageObject.src;var dW=oldImage.width;var dH=oldImage.height;if(dW>MaxW||dH>MaxH){a=dW/MaxW;b=dH/MaxH;if(b>a){a=b}dW=dW/a;dH=dH/a}if(dW>0&&dH>0){imageObject.width=dW;imageObject.height=dH}}function clearOptions(obj){$("option",obj).each(function(){$(this).remove()})}function playswf(sFile,sWidth,sHeight){document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+sWidth+'" height="'+sHeight+'">  ');document.write('<param name="movie" value="'+sFile+'">');document.write('<param name="quality" value="high">');document.write('<param name="wmode" value="transparent">');document.write('<embed src="'+sFile+'" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+sWidth+'" height="'+sHeight+'"></embed>  ');document.write("</object>")}function AddFavorite(sURL,sTitle){try{window.external.addFavorite(sURL,sTitle)}catch(e){try{window.sidebar.addPanel(sTitle,sURL,"")}catch(e){alert("加入收藏失败，请使用Ctrl+D进行添加")}}}function SetHome(obj,vrl){try{obj.style.behavior="url(#default#homepage)";obj.setHomePage(vrl)}catch(e){if(window.netscape){try{netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect")}catch(e){alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");return}var prefs=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);prefs.setCharPref("browser.startup.homepage",vrl)}}}function goUrl(url){if(url==""||url==null){window.location.href="http://www.cn2che.com"}else{if(url.indexOf("http://")==0||url.indexOf("HTTP://")==0){window.location.href=url}else{window.location.href="http://www.cn2che.com"+url}}}function ShowDialogCallBack(caption,url,width,height,callback){top.window.JqueryDialog.Open(caption,url,width,height,callback)}function ShowDialog(caption,url,width,height,callback){ShowAllDialog(caption,url,width,height,false,false,true,callback)}function ShowAllDialog(caption,url,width,height,isSubmitButton,isCancelButton,isDrag,callback){top.window.JqueryDialog.Open1(caption,url,width,height,isSubmitButton,isCancelButton,isDrag,callback)}function ShowDialogGoBack(){top.window.JqueryDialog.Ok()}function getCookie(name){var cookieValue="";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}cookieValue=unescape(document.cookie.substring(offset,end))}}return cookieValue}function setCookie(cookieName,cookieValue,DayValue){var expire="";var day_value=1;if(DayValue!=null){day_value=DayValue}expire=new Date((new Date()).getTime()+day_value*86400000);expire="; expires="+expire.toGMTString();document.cookie=cookieName+"="+escape(cookieValue)+";path=/"+expire}function delCookie(cookieName){var expire="";expire=new Date((new Date()).getTime()-1);expire="; expires="+expire.toGMTString();document.cookie=cookieName+"="+escape("")+";path=/"+expire}function browse_history(cate,prdid,data,rt){if(!rt){rt=5}if(typeof prdid!="undefined"){var rows=$.cookie(cate);if(rows==null){rows=new Array(prdid,data)}else{var rindex=-1;rows=rows.split(",");for(var i=0;i<rows.length;i+=2){var _prdid=rows[i];if(_prdid==prdid){rindex=i}}if(rindex>0){rows.splice(rindex,2);rows.unshift(prdid,data)}else{if(rindex==-1){rows.unshift(prdid,data)}}if(rows.length>rt*2){rows=rows.slice(0,-2)}}$.cookie(cate,rows.toString(),{expires:365,path:"/",domain:"",secure:false});return rows}else{return $.cookie(cate)}}function getSubAreas(supoptid,suboptid,_opt){if(suboptid&&$("#"+suboptid).length>0){$("#"+suboptid).get(0).length=1}if(_opt&&$("#"+_opt).length>0){$("#"+_opt).get(0).length=1}if($("#"+supoptid).get(0).selectedIndex==0||$("#"+supoptid).val()==""||$("#"+supoptid).val()=="0"){return}$.ajax({url:"RegistOption.ashx",type:"POST",cache:false,dataType:"text",data:{action:"getSubAreas",sid:EncodeURL($("#"+supoptid).val())},success:function(transport){if(transport!="0"){var _arr=eval("("+transport+")");for(var i=0;i<_arr.length-1;i+=2){with($("#"+suboptid).get(0)){options[options.length]=new Option(_arr[i],_arr[i+1])}}}}})};
