//v1.0
//copyright 2006 adobe systems, inc. all rights reserved.
//v1.7
// flash player version detection
// detect client browser type
// copyright 2005-2007 adobe systems incorporated. all rights reserved.
var isie = (navigator.appversion.indexof("msie") != -1) ? true : false;
var iswin = (navigator.appversion.tolowercase().indexof("win") != -1) ? true : false;
var isopera = (navigator.useragent.indexof("opera") != -1) ? true : false;
function controlversion()
{
var version;
var axo;
var e;
// note : new activexobject(strfoo) throws an exception if strfoo isn't in the registry
try {
// version will be set for 7.x or greater players
axo = new activexobject("shockwaveflash.shockwaveflash.7");
version = axo.getvariable("$version");
} catch (e) {
}
if (!version)
{
try {
// version will be set for 6.x players only
axo = new activexobject("shockwaveflash.shockwaveflash.6");
// installed player is some revision of 6.0
// getvariable("$version") crashes for versions 6.0.22 through 6.0.29,
// so we have to be careful.
// default to the first public version
version = "win 6,0,21,0";
// throws if allowscripaccess does not exist (introduced in 6.0r47)
axo.allowscriptaccess = "always";
// safe to call for 6.0r47 or greater
version = axo.getvariable("$version");
} catch (e) {
}
}
if (!version)
{
try {
// version will be set for 4.x or 5.x player
axo = new activexobject("shockwaveflash.shockwaveflash.3");
version = axo.getvariable("$version");
} catch (e) {
}
}
if (!version)
{
try {
// version will be set for 3.x player
axo = new activexobject("shockwaveflash.shockwaveflash.3");
version = "win 3,0,18,0";
} catch (e) {
}
}
if (!version)
{
try {
// version will be set for 2.x player
axo = new activexobject("shockwaveflash.shockwaveflash");
version = "win 2,0,0,11";
} catch (e) {
version = -1;
}
}
return version;
}
// javascript helper required to detect flash player plugin version information
function getswfver(){
// ns/opera version >= 3 check for flash plugin in plugin array
var flashver = -1;
if (navigator.plugins != null && navigator.plugins.length > 0) {
if (navigator.plugins["shockwave flash 2.0"] || navigator.plugins["shockwave flash"]) {
var swver2 = navigator.plugins["shockwave flash 2.0"] ? " 2.0" : "";
var flashdescription = navigator.plugins["shockwave flash" + swver2].description;
var descarray = flashdescription.split(" ");
var temparraymajor = descarray[2].split(".");
var versionmajor = temparraymajor[0];
var versionminor = temparraymajor[1];
var versionrevision = descarray[3];
if (versionrevision == "") {
versionrevision = descarray[4];
}
if (versionrevision[0] == "d") {
versionrevision = versionrevision.substring(1);
} else if (versionrevision[0] == "r") {
versionrevision = versionrevision.substring(1);
if (versionrevision.indexof("d") > 0) {
versionrevision = versionrevision.substring(0, versionrevision.indexof("d"));
}
}
var flashver = versionmajor + "." + versionminor + "." + versionrevision;
}
}
// msn/webtv 2.6 supports flash 4
else if (navigator.useragent.tolowercase().indexof("webtv/2.6") != -1) flashver = 4;
// webtv 2.5 supports flash 3
else if (navigator.useragent.tolowercase().indexof("webtv/2.5") != -1) flashver = 3;
// older webtv supports flash 2
else if (navigator.useragent.tolowercase().indexof("webtv") != -1) flashver = 2;
else if ( isie && iswin && !isopera ) {
flashver = controlversion();
}
return flashver;
}
// when called with reqmajorver, reqminorver, reqrevision returns true if that version or greater is available
function detectflashver(reqmajorver, reqminorver, reqrevision)
{
versionstr = getswfver();
if (versionstr == -1 ) {
return false;
} else if (versionstr != 0) {
if(isie && iswin && !isopera) {
// given "win 2,0,0,11"
temparray = versionstr.split(" "); // ["win", "2,0,0,11"]
tempstring = temparray[1]; // "2,0,0,11"
versionarray = tempstring.split(","); // ['2', '0', '0', '11']
} else {
versionarray = versionstr.split(".");
}
var versionmajor = versionarray[0];
var versionminor = versionarray[1];
var versionrevision = versionarray[2];
// is the major.revision >= requested major.revision and the minor version >= requested minor
if (versionmajor > parsefloat(reqmajorver)) {
return true;
} else if (versionmajor == parsefloat(reqmajorver)) {
if (versionminor > parsefloat(reqminorver))
return true;
else if (versionminor == parsefloat(reqminorver)) {
if (versionrevision >= parsefloat(reqrevision))
return true;
}
}
return false;
}
}
function ac_addextension(src, ext)
{
if (src.indexof('?') != -1)
return src.replace(/\?/, ext+'?');
else
return src + ext;
}
function ac_generateobj(objattrs, params, embedattrs)
{
var str = '';
document.write(str);
}
function ac_fl_runcontent(){
var ret =
ac_getargs
( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
, "application/x-shockwave-flash"
);
ac_generateobj(ret.objattrs, ret.params, ret.embedattrs);
}
function ac_sw_runcontent(){
var ret =
ac_getargs
( arguments, ".dcr", "src", "clsid:166b1bca-3f9c-11cf-8075-444553540000"
, null
);
ac_generateobj(ret.objattrs, ret.params, ret.embedattrs);
}
function ac_getargs(args, ext, srcparamname, classid, mimetype){
var ret = new object();
ret.embedattrs = new object();
ret.params = new object();
ret.objattrs = new object();
for (var i=0; i < args.length; i=i+2){
var currarg = args[i].tolowercase();
switch (currarg){
case "classid":
break;
case "pluginspage":
ret.embedattrs[args[i]] = args[i+1];
break;
case "src":
case "movie":
args[i+1] = ac_addextension(args[i+1], ext);
ret.embedattrs["src"] = args[i+1];
ret.params[srcparamname] = args[i+1];
break;
case "onafterupdate":
case "onbeforeupdate":
case "onblur":
case "oncellchange":
case "onclick":
case "ondblclick":
case "ondrag":
case "ondragend":
case "ondragenter":
case "ondragleave":
case "ondragover":
case "ondrop":
case "onfinish":
case "onfocus":
case "onhelp":
case "onmousedown":
case "onmouseup":
case "onmouseover":
case "onmousemove":
case "onmouseout":
case "onkeypress":
case "onkeydown":
case "onkeyup":
case "onload":
case "onlosecapture":
case "onpropertychange":
case "onreadystatechange":
case "onrowsdelete":
case "onrowenter":
case "onrowexit":
case "onrowsinserted":
case "onstart":
case "onscroll":
case "onbeforeeditfocus":
case "onactivate":
case "onbeforedeactivate":
case "ondeactivate":
case "type":
case "codebase":
ret.objattrs[args[i]] = args[i+1];
break;
case "width":
case "height":
case "align":
case "vspace":
case "hspace":
case "class":
case "title":
case "accesskey":
case "name":
case "id":
case "tabindex":
ret.embedattrs[args[i]] = ret.objattrs[args[i]] = args[i+1];
break;
default:
ret.embedattrs[args[i]] = ret.params[args[i]] = args[i+1];
}
}
ret.objattrs["classid"] = classid;
if (mimetype) ret.embedattrs["type"] = mimetype;
return ret;
}
var beginmoving=false;
var sourceobj=null;
var objectobj=null;
var is_del=0;
var obj_v=null;
function mousedowntomove(obj,obj1){
obj.style.zindex=1;
obj.mousedowny=event.clienty;
obj.mousedownx=event.clientx;
beginmoving=true;
obj.setcapture();
obj.classname="remove";
sourceobj=obj;
objectobj=null;
obj_v=obj1;
}
function mousemovetomove(obj){
if(!beginmoving) return false;
obj.style.top = (event.clienty-obj.mousedowny);
obj.style.left = (event.clientx-obj.mousedownx);
}
function mouseuptomove(obj){
if(!beginmoving) return false;
obj.releasecapture();
obj.style.top=0;
obj.style.left=0;
obj.style.zindex=0;
beginmoving=false;
obj.classname="removableobj";
var top = (event.clienty-obj.mousedowny);//偏移量
var left = (event.clientx-obj.mousedownx); //偏移量
var k=$(obj).width()/2;
var m=$(obj).height()/2;
if(top>k||left>m){window.settimeout("swapfun()",10);}//偏移量超过div本身一半即对换位置
is_del=0;
}
function mouseoverfun(obj) {objectobj=obj; }
function swapfun() {
var k=$("#"+$(sourceobj).parent().attr("id")+" .removableobj").index($(sourceobj)[0]);
var m=$("#"+$(objectobj).parent().attr("id")+" .removableobj").index($(objectobj)[0]);
var objpic=array();
var str=$(obj_v).val().replace(/\/+/,"/")
if(str.substr(0,1)=="/"){str=str.substr(1);}
objpic=str.split("|");
str=""
var v=objpic[k];
objpic[k]=objpic[m];
objpic[m]=v;
for(var i=0;i0&&w>$(img).parent().width()){h=$(img).parent().width()*h/w;w=$(img).parent().width();}//不超出父级元素宽度
var flag=false;
var image=new image();
image.src=img.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= w/h){
if(image.width>w){
img.height=(image.height*w)/image.width;
img.width=w;
}
else{
img.width=image.width;
img.height=image.height;
}
img.alt= "";
}
else{
if(image.height>h){
img.width=(image.width*h)/image.height;
img.height=h;
}
else{
img.width=image.width;
img.height=image.height;
}
img.alt="";
}
}
$(img).css({'float':'left','padding-top':(h-img.height)/2+'px','padding-right':(w-img.width)/2+'px','padding-bottom': (h-img.height)/2+'px','padding-left': (w-img.width)/2+'px','_display':'inline'});
}
function check_validate1(value){
var reg = /^\d+$/;
if( value.constructor === string ){
var re = value.match( reg );
return true;
}
return false;
}
function check_validate2(value){
var reg = /^\w+$/;
if( value.constructor === string ){
var re = value.match( reg );
return true;
}
return false;
}
function check_validate(value){
var reg = /^(\d{3,4})-(\d{7,8})/;
if( value.constructor === string ){
var re = value.match( reg );
return true;
}
return false;
}
function request(paras){//ȡurl
var url = location.href;
var parastring = url.substring(url.indexof("?")+1,url.length).split("&");
var paraobj = {}
for (i=0; j=parastring[i]; i++){
paraobj[j.substring(0,j.indexof("=")).tolowercase()] = j.substring(j.indexof("=")+1,j.length);
}
var returnvalue = paraobj[paras.tolowercase()];
if(typeof(returnvalue)=="undefined"){
return "";
}else{
return returnvalue;
}
}
function lock_www(){//锁定带www的网址
var reg=/http\:\/\/(\d{1,3}\.){3}(\d{1,3})/;
var reg1=/http\:\/\/localhost\//;
if (!reg.test(location.href)&&!reg1.test(location.href)){
if(location.href.substr(0,7).tolowercase()=="http://"){
if(location.href.substr(7,4).tolowercase()!="www."){location.href="http://www."+location.href.substr(7);}
}else{
if(location.href.substr(0,4).tolowercase()!="www."){location.href="http://www."+location.href;}}
}}
//$(document).ready(function(){$("a[href^='http://']").attr("target","_blank");})//外部链接新窗口打开
function set_content_height(strng){//多个对象之间以|隔开,设置多个div高度相等,以最高高度为标准
var h=0;
var obj=strng.split("|");
if(obj.length<2){return ""}
for(var i=0;i<=obj.length-1;i++){
if($(obj[i])){
if(h<$(obj[i]).outerheight()){h=$(obj[i]).outerheight()}
}
}
for(var i=0;i<=obj.length;i++){if($(obj[i])){$(obj[i]).height(h)}}
}
function check(obj){
var k=1
$(obj).find("[err!='']").each(function(){if($.trim($(this).val())==""||(typeof($(this).attr("placeholder"))!="undefined"&&$(this).attr("placeholder")==$(this).val())){
if(typeof($(this).attr("err"))!="undefined"){
if($(this).is(":visible")){k=0;
alert($(this).attr("err"));$(this).focus();return false;
}
}}})
if(k){ return true}else{return false}
}
function swap(obj,attr1,attr2){//交换属性
if(typeof(obj.attr(attr2))!="undefined"){
var k=obj.attr(attr2);
obj.attr(attr2,$(obj).attr(attr1));
obj.attr(attr1,k);
}
}
function auto(tmp) {
//自适应触发函数
$(window).resize(function() {
return tmp();
});
return tmp();
}
function scroll(tmp){
$(window).scroll(function(){return tmp();})
return tmp();
}
function is_weixn(){
var ua = navigator.useragent.tolowercase();
if(ua.match(/micromessenger/i)=="micromessenger") {
return true;
} else {
return false;
}
}
function is_pho(){
if(navigator.platform.indexof('win32')!=-1){
return false;
}else{
return true}
}
/*html5*/
//设置本地存储
function setstorage(name, value) {
let data ={};
try{
data = json.parse(window.localstorage.getitem('data'));
} catch(err){
// console.log(err)
}
data=data==null?{}:data;
data[name]=value;
try{
window.localstorage.setitem('data', json.stringify(data));
} catch(err){
//alert(err)
}
}
// 获取本地存储内容
function getstorage(key) {
try {
let data = json.parse(window.localstorage.getitem('data'));
return 'undefined'!=typeof(data[key])?data[key]:'';
} catch(e) {
return '';
}
}
//删除本地存储函数
function removestorage(key) {
try {
let data = json.parse(window.localstorage.getitem('data'));
if('undefined'!=typeof(data[key])){ var d=data[key];delete data[key];}
window.localstorage.setitem('data', json.stringify(data));
if('undefined'!=typeof(d)){ return d;}
} catch(e) {
return '';
}
//let value = window.localstorage.removeitem(key);
//return value
}
//删除本地存储函数
function removestorageall(key) {
let value = window.localstorage.removeitem('data');
return value;
}
//缓存url内容
function get(type,url,data,obj){
switch(type){
case 'post':
$.post(url,data,function(res){obj(res);})
break;
case 'getjson':
$.getjson(url,data,function(res){obj(res);})
break;
default:
$.get(url,data,function(res){obj(res);})
break;
}
}
function c(options){
var option={type:'get',//获取url方式,get,post,getjson
iscache:true,//是否缓存
url:'',
data:{},
cachetype:'d'
}
option=$.extend(option,options);
var d=getstorage("c");//获取本地缓存
try {
d=json.parse(d);
} catch(e) {
option.iscache=false;
}
if('object'!=typeof(d)||d==''||d==null){option.iscache=false;d={}}
if('undefined'==typeof(d[option.cachetype])){option.iscache=false;}
if(option.iscache){
var res={};
res.code=1;
res.data=d[option.cachetype];
if('undefined'!=typeof(option.success)){option.success(res);}
return res.data;
}
get(option.type,option.url,option.data,function(res){
if(res.code==1){
d[option.cachetype]=res.data;
setstorage("c",d);
if('undefined'!=typeof(option.success)){option.success(res);}
return res.data;
}else{
if('undefined'!=typeof(option.success)){option.success(res);}
}
return false;
})
return false;
}
function formathtml_textarea(content){//textarea中空格与回车转化
return content.replace(/\r{0,}\n/g," ").replace(/\s/g," ");
}