//by yj 20090728
        var str_resume = "93,94,95,96";//简历，essay,奖学金
        var str_coverletter = "";//求职信
        var str_recommendation ="";//推荐信
        var str_interview = "";//面试
        var str_train = "";//求职辅导


		
var serializeForm = function(f){
	var oForm = $(f);
	
	var addParam = function(data, name, value){
		if(data!=""){
			data += "&";
		}
		data += name + "=" + value;
		return data;
	};
	
	var serializeInput = function(elems){
		var tag, type, data = "";
		for(var i = 0; i < elems.length; i++){
			var tag = elems[i].tagName.toLowerCase();
			var type = elems[i].type;
			if ((tag == "input" && (type == "text" || type == "hidden"))  ||tag == "textarea" || tag == "select"){
				data = addParam(data, elems[i].name, elems[i].value);
			}
		}
		return data;
	};
	
	var serializeMulti = function(elems){
		var data = "";
		var name = {};
		for (var i = 0; i < elems.length ; i++){
			if (elems[i].type == "checkbox"){
				if (!name[elems[i].name]&&elems[i].checked){
					name[elems[i].name] = elems[i].value;
				}
				else if (name[elems[i].name]&&elems[i].checked){
					name[elems[i].name] += "-"+elems[i].value;
				}
				else if (name[elems[i].name]&&name[elems[i].name] !=""){
					
				}
				else{
					name[elems[i].name] = "";
				}
			}
			else if (elems[i].type == "radio"){
				if (elems[i].checked){
					name[elems[i].name] = elems[i].value;
				}
				else{
					if (!name[elems[i].name]){
						name[elems[i].name] = "";
					}
				}
			}
			else if (elems[i].type == "text" ||elems[i].type == "hidden"){
				data = addParam(data, elems[i].name, elems[i].value);
			}
		}
		for(p in name){
			data = addParam(data, p, name[p]);
		}
		return data;
	};
	
	var bytag = function(tag, obj){
		var elem = obj||document;
		var oTag = elem.getElementsByTagName(tag);
		return oTag;
	};
	
	return (serializeInput(bytag("select", oForm))+"&"+serializeInput(bytag("textarea", oForm))+"&"+serializeMulti(bytag("input", oForm)));
};

function addtocard() {
	carts = $$(".wuza");

	    if( carts ) {
                var xmlHttp = false;
 try{
   xmlHttp=new ActiveXObject("msxml2.xmlhttp");
 }
 catch(error_0){
  try{
    xmlHttp=new ActiveXObject("microsoft.xmlhttp");
  }
  catch(error_1){
    xmlHttp=new XMLHttpRequest();
  }
 }

				for (var i=0; i<carts.length; i++){
					
					var pid = "che_" + carts[i].id.substr(11);
					var formid = "addtocart_" + carts[i].id.substr(11);
					var quid = "quantity_" + carts[i].id.substr(11);
					var price = "price_" + carts[i].id.substr(11);
					
					//alert(serializeForm($(formid)));

					if(document.getElementById(quid).value>0){
						
				
			            //document.getElementById(price).innerHTML = "123";
				        $url =  'index.php';
                        xmlHttp.open("post", $url, false);
						xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                        //xmlHttp.send($(formid).serialize());
						xmlHttp.send(serializeForm($(formid)));
						
					}
				}
				self.location="index.php?option=com_virtuemart&page=shop.cart";

		}
}

function price(product_id) {

                    var formid = "addtocart_" + product_id;
					var quid = "quantity_" + product_id;
					var price = "price_" + product_id;
					var priceold = "priceold_" + product_id;
					var total = document.getElementById(priceold).value;
					//alert(total);
					
					var zs_price = "字数/分钟_field_" + product_id;
					

					
					//01.简历  推荐信 求职信
					//if(str_resume.indexOf(product_id)!=-1||str_recommendation.indexOf(product_id)!=-1||str_coverletter.indexOf(product_id)!=-1){
					if(str_resume.indexOf(product_id)!=-1||str_recommendation.indexOf(product_id)!=-1||str_coverletter.indexOf(product_id)!=-1){
					for(i=0;i<document.getElementById(zs_price).length;i++){
                        if(document.getElementById(zs_price)[i].selected==true){
						    var zs_price_1 = document.getElementById(zs_price)[i].innerHTML;
							var zs_price_2 = zs_price_1.split("&nbsp;");
							//alert(zs_price_t);
							//alert((zs_price_2[2]+zs_price_2[3].substr(1)));
							//alert(parseInt(zs_price_2[2]+zs_price_2[3].substr(1)));
							//alert((zs_price_2[2]+zs_price_2[3].substr(1)).replace(/\s/g,""));

							var zs_price_t = (zs_price_2[2]+zs_price_2[3].substr(1)).replace(/\s/g,"");							
							total = parseInt(total)+parseInt(zs_price_t);
							
							
                        }
                    }
					}
					
					var gw_price = "您的工作经验_field_" + product_id;
					//推荐信 模拟面试 求职信 简历
					//if(str_recommendation.indexOf(product_id)!=-1||str_interview.indexOf(product_id)!=-1||str_coverletter.indexOf(product_id)!=-1||str_resume.indexOf(product_id)!=-1){
					if(str_recommendation.indexOf(product_id)!=-1||str_interview.indexOf(product_id)!=-1||str_coverletter.indexOf(product_id)!=-1||str_resume.indexOf(product_id)!=-1){
					for(i=0;i<document.getElementById(gw_price).length;i++){
                        if(document.getElementById(gw_price)[i].selected==true){
						    var gw_price_1 = document.getElementById(gw_price)[i].innerHTML;
							var gw_price_2 = gw_price_1.split("&nbsp;");
							//alert(gw_price_2[2]+gw_price_2[3].substr(1));
							//total = parseInt(total)+parseInt(gw_price_2[2]+gw_price_2[3].substr(1));
							var gw_price_t = (gw_price_2[2]+gw_price_2[3].substr(1)).replace(/\s/g,"");							
							total = parseInt(total)+parseInt(gw_price_t);
                        }
                    }
					}
					
					var jh_price = "顾问级别_field_" + product_id;
					//简历 职业规划辅导
					//if(str_resume.indexOf(product_id)!=-1||str_train.indexOf(product_id)!=-1){
					if(str_resume.indexOf(product_id)!=-1 ||str_train.indexOf(product_id)!=-1){
					for(i=0;i<document.getElementById(jh_price).length;i++){
                        if(document.getElementById(jh_price)[i].selected==true){
						    var jh_price_1 = document.getElementById(jh_price)[i].innerHTML;
							var jh_price_2 = jh_price_1.split("&nbsp;");
							//alert(jh_price_2[2]+jh_price_2[3].substr(1));
							//total = parseInt(total)+parseInt(jh_price_2[2]+jh_price_2[3].substr(1));
							var jh_price_t = (jh_price_2[2]+jh_price_2[3].substr(1)).replace(/\s/g,"");							
							total = parseInt(total)+parseInt(jh_price_t);
                        }
                    }
					}
					
					//alert(total);
					
					wuza1 = $$('.wuza1_' + product_id);
					for (var i=0; i<wuza1.length; i++){
					    if(wuza1[i].checked){
					        //alert(wuza1[i].alt);
							total = parseInt(total)+parseInt(wuza1[i].alt);
						}
					}
					
					wuza2 = $$('.wuza2_' + product_id);
					for (var i=0; i<wuza2.length; i++){
					    if(wuza2[i].checked){
					        //alert(wuza2[i].alt);
							total = parseInt(total)+parseInt(wuza2[i].alt);
						}
					}
					
					wuza3 = $$('.wuza3_' + product_id);
					for (var i=0; i<wuza3.length; i++){
					    if(wuza3[i].checked){
					        //alert(wuza3[i].alt);
							total = parseInt(total)+parseInt(wuza3[i].alt);
						}
					}
					

					total = parseInt(total)*parseInt(document.getElementById(quid).value);
					//alert(parseInt(total));
					//alert(parseInt(document.getElementById(quid).value));
					//var totla = 
			        document.getElementById(price).innerHTML = "合计: ￥<b>" + total + "</b>";
					
				    carts = $$(".wuza");
                    var total_3 = parseInt("0");
				    for (var i=0; i<carts.length; i++){
					    var product_id_1 = carts[i].id.substr(11);
					    var total_1 = document.getElementById("price_" + product_id_1).innerHTML;
						var total_2 = total_1.split("</B>")[0].substr(8);
						if(total_2){
						    total_3 +=parseInt(total_2);
						}
					}
					//alert(total_3);
					
					document.getElementById("price_total").innerHTML = "您所购商品价格总计: ￥<b>" + total_3 + "</b>";


}

function price1(product_id) {
                    var formid = "addtocart_" + product_id;
					var quid = "quantity_" + product_id;
					var price = "price_" + product_id;
					var priceold = "priceold_" + product_id;
					var total = document.getElementById(priceold).value;
					
					
					var zs_price = "字数/分钟_field_" + product_id;
					//alert(document.getElementById(zs_price).length);
					//alert(str_resume.indexOf(product_id));
					//简历 推荐信 求职信
					if(str_resume.indexOf(product_id)!=-1||str_recommendation.indexOf(product_id)!=-1||str_coverletter.indexOf(product_id)!=-1){
					for(i=0;i<document.getElementById(zs_price).length;i++){
                        if(document.getElementById(zs_price)[i].selected==true){
						    var zs_price_1 = document.getElementById(zs_price)[i].innerHTML;
							var zs_price_2 = zs_price_1.split("&nbsp;");
							//alert(zs_price_2[2]+zs_price_2[3].substr(1));
							//total = parseInt(total)+parseInt(zs_price_2[2]+zs_price_2[3].substr(1));
							var zs_price_t = (zs_price_2[2]+zs_price_2[3].substr(1)).replace(/\s/g,"");							
							total = parseInt(total)+parseInt(zs_price_t);
                        }
                    }
					}
					
					var gw_price = "您的工作经验_field_" + product_id;
					//推荐信 模拟面试 求职信 简历
					if(str_recommendation.indexOf(product_id)!=-1||str_interview.indexOf(product_id)!=-1||str_coverletter.indexOf(product_id)!=-1||str_resume.indexOf(product_id)!=-1){
					for(i=0;i<document.getElementById(gw_price).length;i++){
                        if(document.getElementById(gw_price)[i].selected==true){
						    var gw_price_1 = document.getElementById(gw_price)[i].innerHTML;
							var gw_price_2 = gw_price_1.split("&nbsp;");
							//alert(gw_price_2[2]+gw_price_2[3].substr(1));
							//total = parseInt(total)+parseInt(gw_price_2[2]+gw_price_2[3].substr(1));
							var gw_price_t = (gw_price_2[2]+gw_price_2[3].substr(1)).replace(/\s/g,"");							
							total = parseInt(total)+parseInt(gw_price_t);
                        }
                    }
					}
					
					var jh_price = "顾问级别_field_" + product_id;
					//简历 职业规划辅导
					if(str_resume.indexOf(product_id)!=-1||str_train.indexOf(product_id)!=-1){
					for(i=0;i<document.getElementById(jh_price).length;i++){
                        if(document.getElementById(jh_price)[i].selected==true){
						    var jh_price_1 = document.getElementById(jh_price)[i].innerHTML;
							var jh_price_2 = jh_price_1.split("&nbsp;");
							//alert(jh_price_2[2]+jh_price_2[3].substr(1));
							//total = parseInt(total)+parseInt(jh_price_2[2]+jh_price_2[3].substr(1));
							var jh_price_t = (jh_price_2[2]+jh_price_2[3].substr(1)).replace(/\s/g,"");							
							total = parseInt(total)+parseInt(jh_price_t);
                        }
                    }
					}
					
					var yy_price = "语言-文档或面试语种_field_" + product_id;
					for(i=0;i<document.getElementById(yy_price).length;i++){
                        if(document.getElementById(yy_price)[i].selected==true){
						    var yy_price_1 = document.getElementById(yy_price)[i].innerHTML;
							var yy_price_2 = yy_price_1.split("&nbsp;");
							//alert(jh_price_2[2]+jh_price_2[3].substr(1));
							//total = parseInt(total)+parseInt(yy_price_2[2]+yy_price_2[3].substr(1));
							var yy_price_t = (yy_price_2[2]+yy_price_2[3].substr(1)).replace(/\s/g,"");							
							total = parseInt(total)+parseInt(yy_price_t);
							//alert(123);
                        }
                    }
					
					var jf_price = "交付周期-加速交付升级服务_field_" + product_id;
					//职业规划辅导
					//notice:源代码为不等于 职业规划（不知道什么意思）：if(product_id != "74"){
					if(str_train.indexOf(product_id)==-1){
					for(i=0;i<document.getElementById(jf_price).length;i++){
                        if(document.getElementById(jf_price)[i].selected==true){
						    var jf_price_1 = document.getElementById(jf_price)[i].innerHTML;
							var jf_price_2 = jf_price_1.split("&nbsp;");
							//alert(jh_price_2[2]+jh_price_2[3].substr(1));
							//total = parseInt(total)+parseInt(jf_price_2[2]+jf_price_2[3].substr(1));
							var jf_price_t = (jf_price_2[2]+jf_price_2[3].substr(1)).replace(/\s/g,"");							
							total = parseInt(total)+parseInt(jf_price_t);
							//alert(123);
                        }
                    }
					}
					
					/*
					var qzjy_price = "求职建议附加服务_field_" + product_id;
					//简历
					if(str_resume.indexOf(product_id)!=-1){
					for(i=0;i<document.getElementById(qzjy_price).length;i++){
                        if(document.getElementById(qzjy_price)[i].selected==true){
						    var qzjy_price_1 = document.getElementById(qzjy_price)[i].innerHTML;
							var qzjy_price_2 = qzjy_price_1.split("&nbsp;");
							//alert(jh_price_2[2]+jh_price_2[3].substr(1));
							//total = parseInt(total)+parseInt(qzjy_price_2[2]+qzjy_price_2[3].substr(1));
							var qzjy_price_t = (qzjy_price_2[2]+qzjy_price_2[3].substr(1)).replace(/\s/g,"");							
							total = parseInt(total)+parseInt(qzjy_price_t);
							//alert(123);
                        }
                    }
					}*/
					
					
					if(isNaN(parseInt(document.getElementById(quid).value))) {
					  total = 0;;
					}else{
					  total = parseInt(total)*parseInt(document.getElementById(quid).value);
					}
					//alert(Number(parseInt(document.getElementById(quid).value)));
					//var totla = 
			        document.getElementById(price).innerHTML = "合计: ￥<b>" + total + "</b>";


}
