
/**
 * 
 * @return {}
 */
function getURL() {
	return location.protocol + "//" + location.host + "/";
	// + window.location.pathname.split("/")[1] + "/";
}

// 验证是否为数字方法－－－－－－－－－－－－－－－－－－
function checknumber(String) {
	var Letters = "1234567890.";
	var i;
	var c;
	for (i = 0; i < String.length; i++) {
		c = String.charAt(i);
		if (Letters.indexOf(c) == -1) {
			return true;
		}
	}
	return false;
}
/*
 * 日期格式化
 * */function getNowFormatDate(next) {
	var day = new Date();
	var Year = 0;
	var Month = 0;
	var Day = 0;
	var CurrentDate = "";
	// 初始化时间
	// Year= day.getYear();//有火狐下2008年显示108的bug
	Year = day.getFullYear();// IE火狐下都可以
	Month = day.getMonth() + 1;
	Day = day.getDate();
	// Hour = day.getHours();
	// Minute = day.getMinutes();
	// Second = day.getSeconds();
	CurrentDate += Year + "-";
	if (Month >= 10) {
		CurrentDate += Month + "-";
	} else {
		CurrentDate += "0" + Month + "-";
	}

	if (Day >= 10) {
		if (next) {
			var   d   =   new   Date(new   Date().getTime()+1000*60*60*24); 
			CurrentDate= d.getFullYear()+ "-"+   (d.getMonth()+1)   + "-"+ d.getDate();
		} else {
			CurrentDate += Day;

		}
	} else {
		if (next=="next") {
			var   d   =   new   Date(new   Date().getTime()+1000*60*60*24); 
			CurrentDate= d.getFullYear()+ "-"+   (d.getMonth()+1)   + "-0"+ d.getDate();
		} else {
			CurrentDate += "0" + Day;
		}
	}

	return CurrentDate;
}
/**
 * 设置cookie
 * 
 * @param {}
 *            name
 * @param {}
 *            value
 * @param {}
 *            options
 * @return {}
 */
jQuery.cookie = function(name, value, options) {
	if (typeof value != 'undefined') {
		// name and value given, set cookie
		options = options || {};
		if (value === null) {
			value = '';
			// clone object since it's
			options = $.extend({}, options);
			options.expires = -1;
		}
		var expires = '';
		if (options.expires
				&& (typeof options.expires == 'number' || options.expires.toUTCString)) {
			var date;
			if (typeof options.expires == 'number') {
				date = new Date();
				date.setTime(date.getTime()
						+ (options.expires * 24 * 60 * 60 * 1000));
			} else {
				date = options.expires;
			}
			expires = '; expires=' + date.toUTCString();
		}
		var path = options.path ? '; path=' + (options.path) : '';
		var domain = options.domain ? '; domain=' + (options.domain) : '';
		var secure = options.secure ? '; secure' : '';
		document.cookie = [name, '=', encodeURIComponent(value), expires, path,
				domain, secure].join('');
	} else {
		var cookieValue = null;
		if (document.cookie && document.cookie != '') {
			var cookies = document.cookie.split(';');
			for (var i = 0; i < cookies.length; i++) {
				var cookie = jQuery.trim(cookies[i]);
				// Does this cookie string begin with the name we want?
				if (cookie.substring(0, name.length + 1) == (name + '=')) {
					cookieValue = decodeURIComponent(cookie
							.substring(name.length + 1));
					break;
				}
			}
		}
		return cookieValue;
	}
};
// 新订单弹出插件
function startips(title, content, width, height) {
	$("body").autotips({
				title : title,
				content : content,
				width : width,
				height : height
			});
}
$.fn.autotips = function(content) {
	clearTimeout(MTimeout);
	if ($("#musicDIV").length == 0) {
		var objectHTML = '<div id="musicDIV" style="width:100px;height:100px; overflow:hidden;display:none;"><object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" height=0 id="ye" width=0 border="0" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0">'
				+ '<param name="URL" value="http://www.midifan.com/midi/music.asp?id=4354" />'
				+ ' <param name="rate" value="1" />'
				+ '<param name="balance" value="0" />'
				+ '<param name="currentPosition" value="0" />'
				+ ' <param name="defaultFrame" value="" />'
				+ ' <param name="playCount" value="1" />'
				+ '<param name="autoStart" value="1">'
				+ '<param name="currentMarker" value="0" />'
				+ '<param name="invokeURLs" value="-1" />'
				+ '<param name="baseURL" value="" />'
				+ '<param name="volume" value="200" />'
				+ '<param name="mute" value="0" />'
				+ '<param name="uiMode" value="full" />'
				+ '<param name="enabled" value="-1">'
				+ '<param name="enableContextMenu" value="0" />'
				+ '<param name="fullScreen" value="0" />'
				+ '<param name="SAMIStyle" value="" />'
				+ '<param name="SAMILang" value="" />'
				+ '<param name="SAMIFilename" value="" />'
				+ '<param name="captioningID" value="" />'
				+ '<param name="enableErrorDialogs" value="0" />'
				+ '<param name="stretchToFit" value="0" />'
				+ '<param name="windowlessVideo" value="0" />'
				+ '<param name="_cx" value="9340" />'
				+ '<param name="_cy" value="6694" />' + '</object></div>';
		$("body").append(objectHTML);
	}
	var $this = $(this);// 当前对象
	var $win = $(window);
	var contentT = content.title;
	var contentC = content.content;
	var thisW = content.width;
	var thisH = content.height;
	var $div = '<div class="autotipsBox" style="width:'
			+ thisW
			+ 'px"><dl class="autotips"><dt><a class="closeTips"></a><span>'
			+ contentT
			+ '</span></dt><dd style="height:'
			+ thisH
			+ 'px">'
			+ contentC
			+ '</dd><div class="hideTips"><input type="button" value="" class="hideTipsButton"/></div></dl><div class="popButton"></div></div>';
	$this.append($div);
	$(".autotipsBox").show().find("dt").find("a").click(function() {
				$(".autotipsBox").fadeOut(500, function() {
							$(this).remove()
						});
				removeYe();
			});
	$(".hideTipsButton").click(function() {
		$(this).closest("dl").fadeOut(500).next("div").show().css("margin-top",
				thisH * 1 + 30);
	})
	$(".popButton").click(function() {
				$(this).fadeOut("500").prev("dl").fadeIn("500");
			})
	autotips();
	playmusic();
	$(window).scroll(function() {
				setTimeout(function() {
							autotips();
						}, 500);
			})
	$(window).resize(function() {
				setTimeout(function() {
							autotips();
						}, 500);
			})
	// parent.document.getElementById("mainFrame").contentWindow.startipss();
	function autotips() {
		var winT = $win.scrollTop();
		var winL = $win.scrollLeft();
		var winH = $win.height();
		var winW = $win.width();
		var top = winT + winH - thisH - 65;
		var left = winL + winW - thisW;
		$(".autotipsBox").css({
					top : top,
					left : left
				});
	}

}
var musicNo = 1;
var MTimeout;
function playmusic() {
	clearTimeout(MTimeout);
	ye.URL = "";
	ye.URL = getBasePath() + 'common/music/music.mp3';
	// musicInt = setTimeout("playmusic()", 10000);
	// setTimeout("removeYe()",5000)
	if (musicNo == 10) {
		musicNo = 1;
		clearTimeout(MTimeout);
	} else {
		musicNo++;
		MTimeout = setTimeout("playmusic()", 10000);
	}
}
function removeYe() {
	clearTimeout(MTimeout);
	$("#musicDIV").remove();
	musicNo = 1;
}

Date.prototype.format = function(format) {
	var o = {
		"M+" : this.getMonth() + 1, // month
		"d+" : this.getDate(), // day
		"h+" : this.getHours(), // hour
		"m+" : this.getMinutes(), // minute
		"s+" : this.getSeconds(), // second
		"q+" : Math.floor((this.getMonth() + 3) / 3), // quarter
		"S" : this.getMilliseconds()
		// millisecond
	}
	if (/(y+)/.test(format))
		format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4
						- RegExp.$1.length));
	for (var k in o)
		if (new RegExp("(" + k + ")").test(format))
			format = format.replace(RegExp.$1, RegExp.$1.length == 1
							? o[k]
							: ("00" + o[k]).substr(("" + o[k]).length));
	return format;
}

function hideblackbg(div, remove) {
	$("#" + div).hide();
	if (remove == "remove") {
		$("#" + div).html("");
	}
	$("#blackBg , #loadingDiv").remove();
	$(".blackbg").remove();
}
/*半透明背景
 * $(obj).transition();
 *  $(obj).transition("loading");
 */
$.fn.transition = function(load) {
	var $this = $(this);
	var thisW = $this.width();
	var thisH = $this.height();
	var win = $(window);
	var bathpath = getURL(); //获取路径
	var winW;//当前对象的宽度
	var winH;//当前对象的高度
	var sL;//滚动条左侧距离
	var sT;//滚动条上面距离
	var imgL;//loading图片左侧距离
	var imgT;//loading图片右侧距离
	var thisL;//当前对象左侧距离
	var thisT;//当前对象右侧距离
	if (load && typeof load == "string") {
		var loadImg = $(
				"<img src='"
						+ getURL()
						+ "company/common/images/page/0504314.gif' id='loadingDiv'/>")
				.css( {
					position : "absolute",
					width : "100px",
					height : "100px",
					"z-index" : "10000"
				});
		loadImg.appendTo("body");
	}
	var divBg = $("<div />", {
		id : "blackBg",
		css : {
			background : "#000",
			position : "absolute",
			"z-index" : "10"
		}
	}).addClass("blackbg");
	position();
	divMove();

	$(window).resize(function() {
		position();
		divMove();
	})
	win.scroll(function() {
		position();
		divMove();
	})
	if ($("#blackBg").length < 1) {
		divBg.fadeTo("fast", 0.35, function() {
			$(this).appendTo("body");
		})
	}
	$this.css( {
		position : "absolute",
		"z-index" : "1000"
	}).show();
	//div位置计算
	function position() {
		winW = win.width();
		winH = win.height();
		sL = win.scrollLeft();
		sT = win.scrollTop();
		imgL = winW / 2 + sL - 50;
		imgT = winH / 2 + sT - 50;
		thisL = (winW - thisW) / 2 + sL;
		thisT = (winH - thisH) / 2 + sT;
	}
	//移动DIV
	function divMove() {
		if (loadImg) {
			loadImg.css( {
				left : imgL,
				top : imgT
			});
		}
		divBg.css( {
			left : sL,
			top : sT,
			width : winW,
			height : winH
		}).bgiframe();
		$this.css( {
			left : thisL,
			top : thisT
		});
	}
	return this;
}
//IE6背景
$.fn.bgiframe = function(s) {
	if ($.browser.msie && /6.0/.test(navigator.userAgent)) {
		s = $.extend( {
			top : 'auto',
			left : 'auto',
			width : 'auto',
			height : 'auto',
			opacity : true,
			src : 'javascript:false;'
		}, s || {});
		var prop = function(n) {
			return n && n.constructor == Number ? n + 'px' : n;
		}, html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'
				+ s.src
				+ '"'
				+ 'style="display:block;position:absolute;z-index:-1;'
				+ (s.opacity !== false ? 'filter:Alpha(Opacity=\'0\');' : '')
				+ 'top:'
				+ (s.top == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')'
						: prop(s.top))
				+ ';'
				+ 'left:'
				+ (s.left == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')'
						: prop(s.left))
				+ ';'
				+ 'width:'
				+ (s.width == 'auto' ? 'expression(this.parentNode.offsetWidth+\'px\')'
						: prop(s.width))
				+ ';'
				+ 'height:'
				+ (s.height == 'auto' ? 'expression(this.parentNode.offsetHeight+\'px\')'
						: prop(s.height)) + ';' + '"/>';
		return this.each(function() {
			if ($('> iframe.bgiframe', this).length == 0)
				this
						.insertBefore(document.createElement(html),
								this.firstChild);
		});
	}
	return this;
};
