function carorder(id)
{
	var time =new Date();
	window.showModalDialog("order.asp?d="+time.getTime()+"&id="+id,"baoming","dialogWidth=480px;dialogHeight=300px");
}
function reserve(n)
{
	var time =new Date();
	window.showModalDialog("/reserve_"+n+".asp?d="+time.getTime(),"baoming","dialogWidth=700px;dialogHeight=600px");
}
function checkLogin(theform)
{
	if (theform.username.value=="")
	{		
		alert("请输入您的用户名");
		theform.username.focus();
		return false;
	}
	if (theform.password.value=="")
	{
		alert("请输入您的密码");
		theform.password.focus();
		return false;
	}
	return true;
}
function showFlash(name, width, height) {
	str =	'<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="'+width+'" height="'+height+'">' +
			'<param name="movie" value="'+name+'">' +
			'<param name="quality" value="high">' +
			'<param name="wmode" value="transparent">' +
			'<embed src="'+name+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>' +	'</object>';
	document.write(str);
}

function $(o){
	var o=document.getElementById(o)?document.getElementById(o):o;
	return o;
}
//根据id获取dom对象
function $ID(id){
	if(document.getElementById(id)){
		return document.getElementById(id);
	}else{
		return false;
	}
}
//根据id获取值
function $F(id){
	if(document.getElementById(id)){
		return document.getElementById(id).value;
	}else{
		return "";
	}
}
//根据id获取select框被选择的值
function $S(id){
	if($ID(id).length > 0){
		return $ID(id).options[$ID(id).selectedIndex].value;
	}else{
		return null;
	}
}
//根据id设置select框被选择的值
function $SS(id,value,text){
	$ID(id).options[$ID(id).selectedIndex].value = value;
	$ID(id).options[$ID(id).selectedIndex].text = text;
}
//根据id设置select是否禁用
function $SSF(id,flag){
	if(flag){
		$ID(id).disabled=true;
	}else{
		$ID(id).disabled=false;
	}

}

//根据name获取复选框的被选择的值
function $C(name){
	var cbl = $A(name).length;
	var temp = new Array();
	var m =0;
	for(var i =0;i<cbl;i++){
		if($A(name)[i].checked == true){

			temp[m] = $A(name)[i].value;
			m++;
		}
	}
	return temp.join(',');
}
//根据给定的值设置复选框的选项被选中
function $SETC(name,value){
	if(value.constructor = Object) var arr = value.split(',');
	var chkbox = document.getElementsByName(name);
	for(var m=0; m<arr.length;m++){
		for(var i = 0; i < chkbox.length; i++){
			if(chkbox[i].value == arr[m]){
				chkbox[i].checked = true;
				break;
			}
		}
	}

}
//根据给定的值设置select的选项被选中
function $SET(id,value){
	for(var i = 0; i < $ID(id).options.length; i++){
		if($ID(id).options[i].value == value){
			$ID(id).options[i].selected = true;
			break;
		}
	}
}
//随机关键字生成方法(AS和JS里都可以使用)
function getRandomKeyID( len ){
	if (len == undefined) {
		len = 6;
	}
	var keyID = "";
	var char_arr = new Array();
	char_arr.push(function () {
		return String.fromCharCode(48+Math.floor(Math.random()*10));
	});
	char_arr.push(function () {
		return String.fromCharCode(97+Math.floor(Math.random()*26));
	});
	char_arr.push(function () {
		return String.fromCharCode(65+Math.floor(Math.random()*26));
	});
	for (var i = 0; i<len; i++) {
		keyID += char_arr[Math.floor(Math.random()*char_arr.length)]();
	}
	return keyID;
}
//计算字符串长度
function strLength( sTargetStr ) {
	var sTmpStr, sTmpChar;
	var nOriginLen = 0;
	var nStrLength = 0;

	sTmpStr = new String(sTargetStr);
	nOriginLen = sTmpStr.length;

	for ( var i=0 ; i < nOriginLen ; i++ ) {
		sTmpChar = sTmpStr.charAt(i);

		if (escape(sTmpChar).length > 4) {
			nStrLength += 2;
		} else if (sTmpChar!='\r') {
			nStrLength ++;
		}
	}

	return nStrLength;

}
//删除前后空格的函数
String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
//检查电子邮件格式
function checkEmailFormat(id){
	var str = $F(id);
	var reg = /(\S)+[@]{1}(\S)+[.]{1}(\w)+/;
	return reg.test(str);
}
//检查手机号码格式
function checkMobileFormat(id){
	var str = $F(id);
	var reg=/^0{0,1}[0-9]{11}$/;
	return reg.test(str);
}
//检查用户名格式,用户名为英文、中文字符、数字、下划线组成，长度为5-16个字符
function checkStrFormat(id){
	var str = $F(id);
	if(checkStrLength(str)>16 || checkStrLength(str)<5){
		return false;
	}
	var reg = /^[\u4E00-\u9FA50-9a-zA-Z_]*$/g;

	return reg.test(str);


}
//检查格式英文、中文字符
function checkNameFormat(id){
	var str = $F(id);

	var reg = /^[\u4E00-\u9FA5a-zA-Z_]*$/g;
	return reg.test(str);


}
//检查20位内的数字
function chk_math(str){
	var reg=/^[0-9]{1,20}$/;
	return reg.test(str);
}
//获取字符长度,一个汉字是2个字符
function checkStrLength(strTemp){
	var i,sum;
	sum=0;
	for(i=0;i<strTemp.length;i++){
		if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255))
		sum=sum+1;
		else
		sum=sum+2;
	}
	return sum;
}
//刷新验证码
function refreshCode(el){
	el.src = randCodeUrl+getRandomKeyID(10);
}
//ajax的响应动作
function doing(){}

//获取url参数
function getUrlPar(name){
	var value = window.location.href;
	var murl = value.split("?");
	if(murl[1])
	var purl = murl[1].split("&");
	else
	return false;
	var su = "";

	for(var i =0; i < purl.length;i++){

		su = purl[i].split("=");
		if(su[0] == name) {
			return su[1];

		}

	}
	return false;
}


// utility function to retrieve an expiration data in proper format;
function getExpDate(days, hours, minutes){
	var expDate = new Date();
	if(typeof(days) == "number" && typeof(hours) == "number" && typeof(hours) == "number"){
		expDate.setDate(expDate.getDate() + parseInt(days));
		expDate.setHours(expDate.getHours() + parseInt(hours));
		expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
		return expDate.toGMTString();
	}
}

//utility function called by getCookie()
function getCookieVal(offset){
	var endstr = document.cookie.indexOf(";", offset);
	if(endstr == -1){
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}

// primary function to retrieve cookie by name
function getCookie(name){
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while(i < clen){
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg){
			return getCookieVal(j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if(i == 0) break;
	}
	return "";
}

// store cookie value with optional details as needed
function setCookie(name, value, expires, path, domain, secure){
	document.cookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}

//删除cookie
function deleteCookie(name,path,domain){
	if(getCookie(name)){
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

