/**
 * 106云盘自动发卡平台网盘系统
 * ============================================================================
 * 版权所有 2016-2028 扎兰屯市姝妍计算机服务有限公司，并保留所有权利。
 * 网站地址: http://www.106ym.com
 * ----------------------------------------------------------------------------
 * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
 * ============================================================================
 */
window.onerror=function(){return true;}
if(typeof(root)=='undefined'){
	root='http://static.523w.cn';
}
if(typeof(host)=='undefined'){
	host = window.location.protocol+'//'+window.location.host;
}

/**
 * 数组扩展,返回数组下标
 * @param {string} val 数组值
 * @return {int} 返回数组下标
 */
Array.prototype.indexOf = function(val) {
	for (var i = 0; i < this.length; i++) {
		if (this[i] == val) {
			return i;
		}
	}
	return -1;
};
/**
 * 数组随机排序
 */
Array.prototype.shuffle = function() {
	var input = this;
	for (var i = input.length-1; i >=0; i--) {
		var randomIndex = Math.floor(Math.random()*(i+1)); 
		var itemAtIndex = input[randomIndex]; 
		input[randomIndex] = input[i]; 
		input[i] = itemAtIndex;
	}
	return input;
}
/**
 * 删除指定数组元素
 * @param {array} arr 需要操作的数组
 * @param {string} val 需要删除的元素的值
 */
try{
	function array_remove(arr, val) {
		var index = arr.indexOf(val);
		arr.splice(index, 1);
		return arr;
	}
}catch(e){
	//TODO handle the exception
}
/**
 * 判断值是否包含在数组之内
 * @param {array} arr 待查询的数组
 * @param {string} search 查询的值
 * @return {boolean} 布尔值
 */
try{
	function in_array(search,arr) {
		for (var i = 0; i < arr.length; i++) {
			if (arr[i].toString() == search) {
				return true;
			}
		}
		return false;
	}
}catch(e){
	//TODO handle the exception
}

/**
 * angular 初始化
 */
try {
	//创建moudle1
	myAngular = angular.module('app', []);
	//创建控制器
	myAngular.controller("myController", function($scope, $http) {});
	//页面加载完成后,再加载模块
	angular.element(document).ready(function() {
		jQuery(".ng_hide").removeClass('ng_hide');
		angular.bootstrap(jQuery('html'), ["app"]);
		scope = angular.element(jQuery("body")).scope();
	});
	//解析html
	myAngular.filter('html', function($sce) {
		return function(text) {
			return $sce.trustAsHtml(text);
		}
	})
	//价格过滤器(保留两位小数)
	myAngular.filter('price', function() {
		return function(x) {
			if (!x) {
				return '';
			}
			var f_x = parseFloat(x);
			var f_x = Math.round(x * 100) / 100;
			var s_x = f_x.toString();
			var pos_decimal = s_x.indexOf('.');
			if (pos_decimal < 0) {
				pos_decimal = s_x.length;
				s_x += '.';
			}
			while (s_x.length <= pos_decimal + 2) {
				s_x += '0';
			}
			return s_x;
		}
	});
	//日期过滤器
	myAngular.filter('date', function() {
		return function(x) {
			if (!x) {
				return '';
			}
			if (x.length==10) {
				x = x * 1000;
			}else{
				x=x-0;
			}
			var myDate = new Date(x);
			var Y = myDate.getFullYear();
			var m = (myDate.getMonth() + 1)<10?'0'+(myDate.getMonth() + 1):myDate.getMonth() + 1;
			var d = myDate.getDate()<10?'0'+myDate.getDate():myDate.getDate();
			var H = myDate.getHours()<10?'0'+myDate.getHours():myDate.getHours();
			var i = myDate.getMinutes()<10?'0'+myDate.getMinutes():myDate.getMinutes();
			var s = myDate.getSeconds()<10?'0'+myDate.getSeconds():myDate.getSeconds();
			return arguments[1].replace('Y', Y).replace('m', m).replace('d', d).replace('H', H).replace('i', i).replace('s', s);
		}
	});
} catch (e) {}

/************************************************
 * 插件
************************************************/

/**
 * 引入cookie
 */
if(jQuery('[data-cookie]').length>0){	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.cookie.js"%3E%3C/script%3E'));
}

/**
 * 引入base64
 */
if(jQuery('[data-base64]').length>0){	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/base64.js"%3E%3C/script%3E'));
}


/**
 * 日期选择
 */
if(jQuery("[data-datetimepicker]").length>0){	
	var the=jQuery(this);
	var opts=the.attr("data-datetimepicker")?the.attr("data-datetimepicker"):"{}";
	opts=eval("(" +opts+ ")");
	
	if(typeof(opts.version)!="undefined"){
		document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/jquery.datetimepicker/'+opts.version+'/jquery.datetimepicker.css" /%3E'));
		document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.datetimepicker/'+opts.version+'/jquery.datetimepicker.full.js"%3E%3C/script%3E'));
	} else{
		document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/jquery.datetimepicker/1.3.3/jquery.datetimepicker.css" /%3E'));
		document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.datetimepicker/1.3.3/jquery.datetimepicker.full.js?v=11"%3E%3C/script%3E'));
	}
}

/**
 * 多级联动选项cxselect
 */
if(jQuery('[data-cxselect]').length>0){	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/cxSelect/1.3.11/js/jquery.cxselect.min.js"%3E%3C/script%3E'));
}

/**
 * 密码安全等级提示
 */
if(jQuery("[data-passwordStrength]").length>0){	
	document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/passwordStrength/css/password_strength.css" /%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.passwordStrength.js"%3E%3C/script%3E'));
}

/**
 * 颜色值选择输入
 */
if(jQuery('[data-bigcolorpicker]').length>0){	
	document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/bigcolorpicker/jquery.bigcolorpicker.css" /%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/bigcolorpicker/jquery.bigcolorpicker.js"%3E%3C/script%3E'));
}

/**
 * 图片延迟加载
 */
if(jQuery('[data-src]').length>0 || jQuery('[data-lazyload]').length>0){	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/lazyload/1.9.3/jquery.lazyload.min.js"%3E%3C/script%3E'));
}

/*
 * 连续滚动
 */
if(jQuery("[data-marquee]").length>0){	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery_marquee.js"%3E%3C/script%3E'));
}

/*
 * 返回顶部
 */
if(jQuery('[data-scrollup]').length>0){	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.easing.1.3.js"%3E%3C/script%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.scrollUp.min.js"%3E%3C/script%3E'));
}

/*
 * 引入bootstrap.js
 */
if(jQuery('[data-bootstrap]').length>0){	
	var the=jQuery('[data-bootstrap]');
	var opts=the.attr("data-bootstrap")?the.attr("data-bootstrap"):"{}";
	opts=eval("(" +opts+ ")");
	if(typeof(opts.version)!="undefined"){
		document.write(unescape('%3Cscript type="text/javascript" src="http://static.523w.cn/css/bootstrap/'+opts.version+'/js/bootstrap.min.js"%3E%3C/script%3E'));
	} else{
		document.write(unescape('%3Cscript type="text/javascript" src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"%3E%3C/script%3E'));
	}
	
	// bootstrap 模态框垂直居中
	try{
		$('.modal').on('show.bs.modal', function (e) {
			$(this).css({"visibility":"hidden","display":"block"});
			var top=($(window).height()-$(this).find('.modal-dialog').height()) / 2;
			$(this).css({"visibility":"visible"});
			if(top>0){
				top+="px";	
				$(this).find(".modal-dialog").css({"margin-top":top});
			}
		})
	}catch(e){}
}

/*
 * 进入amazeui.js
 */
if(jQuery('[data-amazeui]').length>0){	
	var the=jQuery('[data-amazeui]');
	var opts=the.attr("data-amazeui")?the.attr("data-amazeui"):"{}";
	opts=eval("(" +opts+ ")");
	if(typeof(opts.version)=="undefined"){
		document.write(unescape('%3Cscript type="text/javascript" src="http://cdn.amazeui.org/amazeui/2.3.0/js/amazeui.min.js"%3E%3C/script%3E'));
	}else{
		document.write(unescape('%3Cscript type="text/javascript" src="http://cdn.amazeui.org/amazeui/'+opts.version+'/js/amazeui.min.js"%3E%3C/script%3E'));
	}
}

if(jQuery("[data-zoom]").length>0){
	document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/jqzoom/jquery.jqzoom.css" /%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jqzoom/jquery.jqzoom.min.js"%3E%3C/script%3E'));
}
if(jQuery("[data-fancybox],[data-fancybox-buttons],[data-fancybox-thumbs],[data-fancybox-group]").length>0){
	document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/fancybox/jquery.fancybox.css" /%3E'));
	document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/fancybox/helpers/jquery.fancybox-buttons.css" /%3E'));
	document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/fancybox/helpers/jquery.fancybox-thumbs.css" /%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.mousewheel.min.js"%3E%3C/script%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/fancybox/jquery.fancybox.min.js"%3E%3C/script%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/fancybox/helpers/jquery.fancybox-buttons.js"%3E%3C/script%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/fancybox/helpers/jquery.fancybox-thumbs.js"%3E%3C/script%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/fancybox/helpers/jquery.fancybox-media.js"%3E%3C/script%3E'));

}


jQuery(document).on('click','.parent_fancybox_close',function(){
	parent.jQuery.fancybox.close();		
});
if(jQuery("[data-tabs]").length>0){
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery_featureList.js"%3E%3C/script%3E'));
}
if(jQuery("[data-scrollfollow]").length>0){	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.scrollfollow.min.js"%3E%3C/script%3E'));
}
if(jQuery("[data-jCarouselLite]").length>0){	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jcarousellite_1.0.1.min.js"%3E%3C/script%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.easing.1.3.js"%3E%3C/script%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.mousewheel-3.0.4.pack.js"%3E%3C/script%3E'));
}
if(jQuery("[data-validate]").length>0){	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.validate.min.js"%3E%3C/script%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.metadata.js"%3E%3C/script%3E'));
}
if(jQuery("[data-cycle]").length>0){	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.cycle.all.min.js"%3E%3C/script%3E'));
}


if(jQuery("[data-colorbox]").length>0){
	var options=jQuery("[data-colorbox]").attr("data-colorbox");
	options=eval("(" +options+ ")");
	if(typeof(options.style)=="undefined"){
		document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/sys_css/colorbox/style3/colorbox.css" /%3E'));
	}else{
		document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+options.style+'" /%3E'));	
	}
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.colorbox-min.js"%3E%3C/script%3E'));
}


if(jQuery("[data-uploadify]").length>0){	
	document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/uploadify/uploadify.css" /%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.uploadify.js"%3E%3C/script%3E'));
}

if(jQuery('[data-wd_affix]').length>0){	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.wd_affix.js"%3E%3C/script%3E'));
}

if(jQuery('[data-powerFloat]').length>0){	
	document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/powerFloat/css/powerFloat.css" /%3E'));
	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/powerFloat/jquery.powerFloat.js"%3E%3C/script%3E'));
}
if(jQuery('[data-quickmod]').length>0){	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jquery.wd.quickmod.js"%3E%3C/script%3E'));
}
if(jQuery('[data-jcrop]').length>0){	
	document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/jcrop/jquery.Jcrop.min.css" /%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/jcrop/jquery.Jcrop.min.js"%3E%3C/script%3E'));
}


if(jQuery('[data-idealforms]').length>0){	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/idealforms/1.02/js/jquery.idealforms.min.js"%3E%3C/script%3E'));
}
if(jQuery('[data-waterfall]').length>0){	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/waterfall/js/jquery.waterfall.min.js"%3E%3C/script%3E'));
}
if(jQuery('[data-swiper]').length>0){	
	document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/swiper/swiper.min.css" /%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/swiper/swiper.jquery.min.js"%3E%3C/script%3E'));
}

if(jQuery('[data-angular]').length>0){	
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/angular/1.2.16/angular.min.js"%3E%3C/script%3E'));
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/angular/angular.js"%3E%3C/script%3E'));
}

//data-webuploader-pic下一版本废弃
if(jQuery('[data-webuploader-pic]').length>0){	
	var the=jQuery('[data-webuploader-pic]');
	var opts=the.attr("data-webuploader-pic")?the.attr("data-webuploader-pic"):"{}";
	opts=eval("(" +opts+ ")");
	if(typeof(opts.version)!="undefined"){
		document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/webuploader/webuploader-'+opts.version+'.css" /%3E'));
		document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/webuploader/webuploader-'+opts.version+'.min.js"%3E%3C/script%3E'));
	}else{
		document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/webuploader/webuploader-1.css" /%3E'));
		document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/webuploader/webuploader-0.1.5.min.js"%3E%3C/script%3E'));
	}
	
}

if(jQuery('[data-webuploader-one]').length>0){	
	var the=jQuery('[data-webuploader-one]');
	var opts=the.attr("data-webuploader-one")?the.attr("data-webuploader-one"):"{}";
	opts=eval("(" +opts+ ")");
	var css=typeof(opts.css)!="undefined"?opts.css:'webuploader_one_pc.css';
	var js=typeof(opts.js)!="undefined"?opts.js:'webuploader_one_pc.js';
	document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/webuploader/'+css+'" /%3E'));
	if(typeof(opts.version)!="undefined"){
		document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/webuploader/webuploader-'+opts.version+'.min.js"%3E%3C/script%3E'));
	}else{
		document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/webuploader/webuploader-0.1.5.min.js"%3E%3C/script%3E'));
	}
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/webuploader/'+js+'"%3E%3C/script%3E'));
	
}

if(jQuery('[data-webuploader-more]').length>0){	
	var the=jQuery('[data-webuploader-more]');
	var opts=the.attr("data-webuploader-more")?the.attr("data-webuploader-more"):"{}";
	opts=eval("(" +opts+ ")");
	var css=typeof(opts.css)!="undefined"?opts.css:'webuploader_more_pc.css';
	var js=typeof(opts.js)!="undefined"?opts.js:'webuploader_more_pc.js';
	document.write(unescape('%3Clink rel="stylesheet" type="text/css" href="'+root+'/js/webuploader/'+css+'" /%3E'));
	if(typeof(opts.version)!="undefined"){
		document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/webuploader/webuploader-'+opts.version+'.min.js"%3E%3C/script%3E'));
	}else{
		document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/webuploader/webuploader-0.1.5.min.js"%3E%3C/script%3E'));
	}
	document.write(unescape('%3Cscript type="text/javascript" src="'+root+'/js/webuploader/'+js+'"%3E%3C/script%3E'));
	
}





jQuery(document).ready(function(){ 

	//浮动广告
	try{
		
		jQuery(".scrollfollow").each(function(){
			var the=jQuery(this);
			var options=the.attr("data-options")?the.attr("data-options"):"{}";
			options=eval("(" +options+ ")");
			the.scrollFollow({
				speed:options.speed?options.speed:1000,
				offset:options.offset?options.offset:60					   
			});
		});
		
		//在线服务
		jQuery("#service_online .close").click(function(){
			jQuery(".service_online_big").hide();
			jQuery(".service_online_small").show();
		});	
		jQuery(".service_online_small").mouseover(function(){
			jQuery(".service_online_big").show();
			jQuery(".service_online_small").hide();
		});
		if(jQuery(window).width()>1024){
			jQuery(".service_online_big").show();
			jQuery(".service_online_small").hide();
		}else{
			jQuery(".service_online_big").hide();
			jQuery(".service_online_small").show();	
		}
    }catch(e){}
});




/************************************************
 * 函数
************************************************/

/*
 * 提示
 * @example wd_alert();
 */
function wd_alert(){
	var param=typeof(arguments[0])=="undefined"?{}:arguments[0];
	param.msg=typeof(param.msg)=="undefined"?"数据处理中，请稍候...":param.msg;
	param.width=typeof(param.width)=="undefined"?"200px":param.width;
	param.height=typeof(param.height)=="undefined"?"30px":param.height;
	param.lineheight=typeof(param.lineheight)=="undefined"?param.height:param.lineheight;
	param.background=typeof(param.background)=="undefined"?"#45B54A":param.background;
	param.timeout=typeof(param.timeout)=="undefined"?1000:param.timeout;
	param.color=typeof(param.color)=="undefined"?'#fff':param.color;
	jQuery("body").find(".wd_alert").remove();
	jQuery('body').prepend('<div class="wd_alert">'+param.msg+'</dov>').find(".wd_alert").css({width:param.width,height:param.height,"line-height":param.lineheight,"text-align":"center",background:param.background,color:param.color,position:"fixed",margin:"auto",left:0,right:0,top:0,"font-size":"14px","z-index":99999999});
	if(param.timeout>0){
		setTimeout(function(){
			wd_alert_del();
		},param.timeout);
	}	
}
function wd_alert_del(){
	var param=typeof(arguments[0])=="undefined"?{}:arguments[0];
	param.timeout=typeof(param.timeout)=="undefined"?300:param.timeout;
	jQuery("body").find(".wd_alert").fadeOut(param.timeout,function(){
		jQuery(this).remove();	
	});	
}

/**
 * 模仿PHP的strtotime()函数
 * strtotime('2012-07-27 12:43:43') OR strtotime('2012-07-27')
 * @return 时间戳
 */
function strtotime(str){
    var _arr = str.split(' ');
    var _day = _arr[0].split('-');
    _arr[1] = (_arr[1] == null) ? '0:0:0' :_arr[1];
    var _time = _arr[1].split(':');
    for (var i = _day.length - 1; i >= 0; i--) {
        _day[i] = isNaN(parseInt(_day[i])) ? 0 :parseInt(_day[i]);
    };
    for (var i = _time.length - 1; i >= 0; i--) {
        _time[i] = isNaN(parseInt(_time[i])) ? 0 :parseInt(_time[i]);
    };
    var _temp = new Date(_day[0],_day[1]-1,_day[2],_time[0],_time[1],_time[2]);
    return _temp.getTime() / 1000;
}

