// JavaScript Document
//计算价格
function getPrice(num, type){
	var danjia;
	var price;
	if(type == '3'){
		danjia = 88;
		price =  num * 88;
	}else if(type == '4'){
		danjia = 286;
		price = num * 286;
	}else if(type == '5'){
		danjia = 286;
		price = num * 286;
	}else{
		/*if(num == 1){*/
			danjia = 198;
			price =  num * 198;
		/*}else{
			danjia = 198;
			price =  num * 198 - (num) * 50;
		}*/
	}
	
	document.order.price.value = price;
	document.order.theprice.value = price;
	//alert(type);
	
}

function setDanjia(type){
	if(type == "3"){
		document.order.price.value = 88;
		document.order.theprice.value = 88;	
		document.order.p_num.value = 1;
	}else if(type == "4"){
		document.order.price.value = 286;
		document.order.theprice.value = 286;	
		document.order.p_num.value = 1;
	}else if(type == "5"){
		document.order.price.value = 286;
		document.order.theprice.value = 286;	
		document.order.p_num.value = 1;
	}else{
		document.order.price.value = 198;
		document.order.theprice.value = 198;
		document.order.p_num.value = 1;
	}
}

String.prototype.trim = function() {return this.replace(/(^\s*)|(\s*$)/g, "");}

//检查订单表单数据










function check(){
	
	var form = document.order;
	
	var emailPat='^[a-zA-Z0-9]{1}[\.a-zA-Z0-9_-]*[a-zA-Z0-9]{1}@[a-zA-Z0-9]+[-]{0,1}[a-zA-Z0-9]+[\.]{1}[a-zA-Z]+[\.]{0,1}[a-zA-Z]+$'; 
	var matchArray=form.mail.value.match(emailPat); 	
	
	if(form.thename.value.trim() == ""){
		alert("姓名不能为空！");
		form.thename.focus();
		return false;
	}
	
	if((form.thenumber.value.trim() == "") && (form.thephone.value.trim() == "")){
		alert("为方便与您取得联系，电话与手机至少填写一项！");
		form.thenumber.focus();
		return false;
	}
	
	if(form.theaddress.value.trim() == ""){
		alert("您的收货地址为空或地址有误！");
		form.theaddress.focus();
		return false;
	}
	
	if((form.code.value.trim() == "") || (form.code.value.trim().length < 6)){
		alert("邮政编码不正确！");
		form.code.focus();
		return false;
	}
	
	if (matchArray == null) {
		alert("您的邮箱地址填写有误！"); 
		form.mail.focus();
		return false;
	}
	
}
// JavaScript Document
function createXMLHttp() {
	var xmlHttp = null;
		var ex;
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
		}
		catch (ex)
		{
			try
			{
				xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
			}
			catch (ex)
			{
				try
				{
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (ex)
				{
	                
	                try
	                {
	                 xmlHttp = new XMLHttpRequest();
				    }
				    catch(ex)
				    {
				      throw new Error("XMLHttp object could be created.");
				    }
				}
			}
		}
	return xmlHttp;
}

//问卷调查
function vote(type,div){
	
	var xmlhttp = createXMLHttp();
	var voteid;
	if(type == "vote"){
		
		var e = document.getElementsByName("votenum");
       
        for(var i=0;i<e.length;i++){ 
        if(e[i].checked) 
              voteid=e[i].value; 
        }
	}else{
	   voteid = "" ;	
	}
	
	
	xmlhttp.open("post", "vote.php", true);

	xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');

	xmlhttp.send("type="+type+"&id="+voteid);
	
	xmlhttp.onreadystatechange=function(){
		if (4==xmlhttp.readyState){
			if (200==xmlhttp.status){
				document.getElementById(""+div+"").innerHTML = xmlhttp.responseText;	
			}
		}
	}
}

//=================使用JQuery框架的Ajax函数==============================================

//Ajax 的Get方法//注意参数不支持中文











//返回值直接写入AVessel代表的ID
function JQueryAjaxVesselGet(AUrl, AVessel)
{
	$.get(AUrl, 
 		function(AResponseText)
 		{
 			$('#' + AVessel).html(AResponseText);
 		}
 	);
}	

//Ajax 的 Post方法,表单内容支持中文
//返回值直接写入AVessel代表的ID
function JQueryAjaxVesselPost(AUrl, AFormID, AVessel)
{
	var FormValue = $("#" + AFormID).formSerialize();
	$.post(AUrl, FormValue, 
		function(AResponseText)
 		{
 			$('#' + AVessel).html(AResponseText);
 		}	
	);
}

//=========================JQuery框架 Ajax函数结束===================================


//新窗口打开在线客服系统
function open_online_kefu(){
	var url = "http://www.shihui.tv/on_chat/dialog_1.htm?arg=kabaosun&style=1" + 
	         "&charset=utf-8&lytype=0&referer=http%3A%2F%2Fwww.shihui.tv%2F" + 
			  "&keyword=&tpl=crystal_blue";
	
	window.open(url,"_blank","height=473,width=703");	
	//alert("客服正忙，请稍后再试！谢谢！");
	
	//return false;
	
}

//QQ在线状态








function qq_online(qq){
	
	alert("客服正忙，请稍后再试！谢谢！");
	
	return false;
	
	//document.writeln("<a target=blank href=tencent:\/\/message\/?uin="+qq+"&Site=http:\/\/www.shihui.tv&Menu=yes><img border=\"0\" SRC=http:\/\/wpa.qq.com\/pa?p=1:"+qq+":7 alt=\"\"  align=\"absmiddle\">");	
}

//淘宝在线状态




function taobao_online(taobao){
	//
	alert("客服正忙，请稍后再试！谢谢！");
	
	return false;
	//document.write("<a href='http://amos1.taobao.com/msg.ww?v=2&uid='+encodeURIComponent('"+taobao+"')+'&s=2' target='_blank'><img src='http://amos1.taobao.com/online.ww?v=2&uid='+encodeURIComponent('"+taobao+"')+'&s=2' border='0' alt='' /></a>");	
}

//