/** * create:2009-5-15 * @requires jQuery v1.3+ * *  */$(function(){var url="http://forum.ellechina.com/viewthread.php?tid=243103";var requestUrl="service/post_svote.php";$("#c3 .item").each(function(){$(this).find(".forum").attr("href",url);});var options={max:23,file:"beautywhite_090610",ctime:0};$(".poll span").addClass("loading");$.post(requestUrl,options,function(data){var votes=data.split(",");setTimeout(function(){$(".poll span").each(function(i){var vote=votes[i]?votes[i]:0;$(this).removeClass("loading").text("("+vote+")");});},500);});$(".poll .btn").bind("click",function(){$(".poll .btn").attr("disabled","disabled");var btn=$(this),text=$(btn).next("span").text();$(btn).next("span").text("").addClass("loading");var index=$(".poll .btn").index(btn);options.o=index;$.post(requestUrl,options,function(data){if(data=="voted"){$(btn).next("span").removeClass("loading").text(text);alert("您已经送过小红花了！");return;}var votes=data.split(",");setTimeout(function(){$(btn).next("span").removeClass("loading").text("("+votes[index]+")");$(".poll .btn").removeAttr("disabled");},500);});});$(".to-testing").click(function(){$.cookie("index",0);});var questions=["1.脸上隐约还有去年晒过的痕迹","2.果酸保养品对你很有效","3.很想美白,但同时也很在意脸上的细纹","4.定期有户外的运动","5.总是觉得美白保养品无法达到效果","6.太阳穴的周围出现了斑点","7.有时候忘了做防晒保养","8.只是偶尔会用美白产品","9.经常被人说脸色不好","10.服色属于较深的类型","11.以前的肌肤比现在要明亮","12.雀斑边的更为明显","13.觉得自己有必要采取防老化对策","14.经常在紫外线指数较高的时候外出","15.生活不是很规律"];var results=["初期美白：你很白了！泡沫洁面+每周1-2次的去角质+美白美容液能让你肌肤更剔透！","中期美白：初期美白外，还要使用按摩霜进行面部按摩+每周1-2次的去角质。","彻底美白：中期美白外，无论属于哪类肌肤都要坚持整年的持续美白再辅助使用淡斑精华液。"];var index=parseInt($.cookie("index")),len=questions.length,score=0;if(!index){$.cookie("index",0);}if(index>=0&&index<len){$(".content","#testing #contents").html(getQuestionHtml(index,questions[index]));if(index==0){$(".prev","#testing").addClass("disabled");}if(index==len-1){$(".next","#testing").text("查看结果");}}if(index>len-1){for(var i=0;i<len;i++){score=score+parseInt($.cookie("answer"+i));}if(score>=0&&score<=30){$(".content","#testing #contents").html(getResultHtml(results[0]));}if(score>30&&score<=55){$(".content","#testing #contents").html(getResultHtml(results[1]));}if(score>55&&score<=75){$(".content","#testing #contents").html(getResultHtml(results[2]));}$(".bottom-btn","#testing").hide();}$(".prev","#testing").bind("click",function(){if(!$(this).hasClass("disabled")){if(index>0){$.cookie("index",index-1);}$.cookie("answer"+index,null);$(this).parent().empty().text("请稍候...");window.location.href="testing.htm";}});$(".next","#testing").bind("click",function(){var val=$("input:checked","#testing").val();if(!val){alert("您还没有选择答案！");return;}$.cookie("index",index+1);$.cookie("answer"+index,val);$(this).parent().empty().text("请稍候...");window.location.href="testing.htm";});$(".finished","#testing").click(function(){window.opener=null;window.open('','_self');window.close();});$(".again","#testing").click(function(){$.cookie("index",0);window.location.href="testing.htm";});});function getQuestionHtml(i,n){return"<dl><dt>"+n+"</dt><dd><label for=\"answer"+i+"_yes\"><input type=\"radio\" id=\"answer"+i+"_yes\" name=\"answer"+i+"\" value=\"5\" />是</label><label for=\"answer"+i+"_no\"><input type=\"radio\" id=\"answer"+i+"_no\" name=\"answer"+i+"\" value=\"3\" />不完全是</label></dd></dl>";}function getResultHtml(n){n=n.split("：");return"<p class=\"result\"><span>"+n[0]+"：</span>"+n[1]+"</p>"+"<p class=\"btn-section\">"+"<input type=\"button\" class=\"finished\" value=\"结束测试\" title=\"结束测试\" />"+"<input type=\"button\" class=\"again\" value=\"再测一次\" title=\"再测一次\" /></p>";}
