You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

817 lines
22 KiB
JavaScript

function isIE(){
return document.all?true:false;
}
function editperson(){
$("#pf2").addClass("default-tab current");
$("#pf1").removeClass();
$("#persontab1").hide();
$("#persontab2").show();
}
function displaypro(){
$("#pf2").removeClass();
$("#pf1").addClass("default-tab current");
$("#persontab1").show();
$("#persontab2").hide();
}
function displayselect(o){
}
//profile
function onSel(o,p,pn){
$(".profliephoto li").removeClass();
$(o).addClass("active");
$("#profilephotoid").val(p);
$("#profilephotoname").val(pn);
}
function saveSelProfilePhoto(){
_ppn = $("#profilephotoid").val();
_rtxt = $.ajax({async:false,type:"GET", url:"/community/profile/updateprofile.asp?action=upicon&ppn="+_ppn}).responseText;
if (_rtxt.replace(/\s+/g,"").toLowerCase().substring(0,4)=="true"){
$("#customerpic").attr("src","/community/profile/profilephoto/"+$("#profilephotoname").val());
}
generalDivWinClose();
}
//remove user msg
function removeMsg(_n){
_rtxt = $.ajax({async:false,type:"GET", url:"/community/include/delmessages.asp?m="+_n}).responseText;
//alert(_rtxt);
location.reload();
//$("#msg"+_n).hide();
// generalDivWinClose();
}
function doWinLogin(_s){
_r = location.href;
ShowIFrame('','/community/login-win.asp?r='+_r+'&s='+_s,630,350,'bottom');
}
function Keydown(evt,me,pe,se)
{
var keycode = window.event ? evt.keyCode : evt.which;
if(keycode==13)doLogin(me,pe,se);
}
function doLogin(formsign){
var ec,cc,me,pe,se;//rc,
if(typeof formsign =="string")
{
me="loginmail"+formsign;
pe="loginpass"+formsign;
se="loginErrTips"+formsign;
}
else
{
me="loginmail";
pe="loginpass";
se="loginErrTips";
}
ec = RegCkElement(me,"The email or password you've entered is incorrect.","^(([\\u4E00-\\u9FA5]|[\\uFE30-\\uFEFF]|[\\d]|[a-zA-Z]|[\\_\\-\\.])+[\\@])(((([\\d]|[a-zA-Z]|[\\_\\-]|[\\[\\]\{\\}\>\\<])+[\\.])+)([\\d]|[a-zA-Z\\_\\-])+)$","Email",se,false);
if(!ec)return false;
cc = StrIsNullOrEmpty(pe,"The email or password you've entered is incorrect.","",se,false);
if(!cc)return false;
webLoginAuth($("#"+me).val(),$("#"+pe).val(),$("input[name='s']").val(),se,$("#rememberme").attr("checked")) ;
//showLoginErrMsg("Login,please wait.",se);
}
function doLoginHref(){
if (!doLogin()) return;
}
function doWinLoginHref(){
var ole,olp;
ole = document.loginForm.loginmail.value;
olp = document.loginForm.loginpass.value;
olr = $(":checkbox#rememberme:checked").val();
if (ole == "" || olp == "" || ole.length<6) {
showLoginErrMsg("The email or password you've entered is incorrect.","loginErrTips");
return false;
}
if (!webWinLoginAuth(ole,olp,olr)){
//showLoginErrMsg("The email or password you've entered is incorrect.","loginErrTips");
return false;
}
return true;
}
function getPass(){
}
function webLoginAuth(le,lp,ls,se,rm){
$.post("/community/logincheck.asp", {loginmail:le,loginpass:lp,rememberme:rm},function(_sf){
if (_sf == "true"){
if (typeof ls =="string"){
location.href=ls;
}else{
location.href="/community/customer-center/";
}
//return true;
}else{
showLoginErrMsg("The email or password you've entered is incorrect.",se);
}
});
}
//comments login
function basecommMain(_s){
parent.$("#personinfoComment").hide();
parent.$("#commentLogin").hide();
}
//qa right login
function qaRightBaseMain(le,lp){
parent.$("#personid").hide();
parent.$("#qaLogin").hide();
parent.$("#qabody").focus();
}
//qa-list login
function qawinreplyMain(_n){
nArray = _n.split("-");
nid = nArray[1];
parent.$("#replydivimg"+nid).hide();
parent.$("#div"+nid).slideDown(300);
}
//usercomments login
function commmentMain(_e)
{
parent.$("#notologin").show();
parent.$("#nologin").remove();
parent.$("#Email").val(_e);
parent.$("#NickName").val(_e).hide();
}
function webWinLoginAuth(le,lp,lr){
$.post("/community/logincheck.asp", {loginmail:le,loginpass:lp,rememberme:lr},function(_sf){
if (_sf == "true"){
sourcediv1 = sourcediv;
if (sourcediv.indexOf("-")){
sourcediv1 = sourcediv.split("-")[0];
}
switch (sourcediv1){
case "qarightbase":
qaRightBaseMain(le,lp);
break;
case "qawinreply":
qawinreplyMain(sourcediv);
break;
case "basecomm":
basecommMain(sourcediv);
break;
case "comments":
commmentMain(le);
break;
default:
}
try
{
parent.Check_Login('1');
//parent.$("#"+sourcediv).html();
}
catch(err)
{
for (i=0;i<parent.$(".boxy_bottom").size();i++) parent.Boxy.get(parent.$(".boxy_bottom").eq(i)).hide();
return true;
}
for (i=0;i<parent.$(".boxy_bottom").size();i++) parent.Boxy.get(parent.$(".boxy_bottom").eq(i)).hide();
return true;
}else{
showLoginErrMsg("The email or password you've entered is incorrect.","loginErrTips");
return false;
}
});
return false;
}
function showLoginErrMsg(_s,_d){
$("#"+_d).html(_s);
$("#"+_d).show();
}
function doWinLoginCheck(){
var ole,olp;
ole = document.winLoginForm.loginmail.value;
olp = document.winLoginForm.loginpass.value;
if (ole == "" || olp == "" || ole.length<6) {
showLoginErrMsg("The email or password you've entered is incorrect.");
return false;
}
if (!webLoginAuth(ole,olp)){
showLoginErrMsg("The email or password you've entered is incorrect.");
return false;
}
}
function doCreateAccountHref(){
if (!doCreateAccount()) return;
}
function doCreateAccount(){
var ole,olp;
ole = document.createAccountForm.cloginmail.value;
olp1 = document.createAccountForm.cloginpass1.value;
olp2 = document.createAccountForm.cloginpass2.value;
oln = document.createAccountForm.nickname.value;
vcode = document.createAccountForm.verifycode.value;
recommendEmail = document.createAccountForm.recommendEmail.value;
if (document.createAccountForm.termsFlag.checked != true){
showLoginErrMsg("I have read and accept the Terms and conditions?","createAccountErrTips");
return false;
}
if (vcode.length<4){
showLoginErrMsg("Please enter Verify Code?","createAccountErrTips");
return false;
}
ec = RegCkElement("cloginmail","The email you've entered is incorrect.","^(([\\u4E00-\\u9FA5]|[\\uFE30-\\uFEFF]|[\\d]|[a-zA-Z]|[\\_\\-\\.])+[\\@])(((([\\d]|[a-zA-Z]|[\\_\\-]|[\\[\\]\{\\}\>\\<])+[\\.])+)([\\d]|[a-zA-Z\\_\\-])+)$","","createAccountErrTips",false);
if(!ec)return false;
if (olp1 != olp2) {
showLoginErrMsg("Your password confirmation does not match.","createAccountErrTips");
return false;
}
if (olp1.length<6) {
showLoginErrMsg("Your Password must be more than 6 characters.","createAccountErrTips");
return false;
}
if(recommendEmail.length>0 && recommendEmail !="Did anyone refer you to us?"){
cc = RegCkElement("recommendEmail","The referrer's email you've entered is not valid. Please check format or change another email.","^(([\\u4E00-\\u9FA5]|[\\uFE30-\\uFEFF]|[\\d]|[a-zA-Z]|[\\_\\-\\.])+[\\@])(((([\\d]|[a-zA-Z]|[\\_\\-]|[\\[\\]\{\\}\>\\<])+[\\.])+)([\\d]|[a-zA-Z\\_\\-])+)$","","createAccountErrTips",false);
if(!cc){return false}
else{
if(recommendEmail.toLowerCase() == ole.toLowerCase()){showLoginErrMsg("You can't refer yourself.","createAccountErrTips");return false;}
}
}
rtxt = $.ajax({async:false,type:"POST", url:"/community/save-create-account.asp",data: "cemail="+ole+"&cpass="+olp1+"&cname="+oln+"&vc="+vcode+"&recommendEmail="+recommendEmail}).responseText;
if (rtxt.replace(/\s+/g,"").toLowerCase()=="true"){
loginFlag = true;
location.href="/community/customer-center/";
}
else if(rtxt.replace(/\s+/g,"").toLowerCase()=="000"){
showLoginErrMsg("Please enter the correct Verify Code","createAccountErrTips");
return false
}
else{
showLoginErrMsg("The email you've entered is not available.","createAccountErrTips");
return false;
}
}
function webCreateAccount(_u,_p,_n){
return false;
}
function isLogin(){
var loginFlag;
loginFlag = false;
rtxt = $.ajax({async:false,type:"GET", url:"/community/islogin.asp?"+Math.random()}).responseText;
if (rtxt.replace(/\s+/g,"").toLowerCase()=="true"){
loginFlag = true;
}
return loginFlag;
}
function qaReply(n){
if (!isLogin()){
$.facebox({ajax:"/community/usercp.asp?cp=sendfaq&SN="+n});
//doWinLogin("qawinreply-"+n);
return;
}
$("#replydivimg"+n).hide();
$("#div"+n).slideDown(300);
$("#reply"+n).focus();
}
function qaSave(_o,n){
$("#replydivimg"+n).show();
//$("#div"+n).slideUp(300);
writeQAtoA(_o,n);
}
function qaCancel(n){
$("#replydivimg"+n).show();
$("#div"+n).slideUp(300);
}
//save question
//_n name
//_e email
//_mf mailflag
//_wf isweb flag
//_b question body
function writeQAtoQ(_o,_n,_e,_mf,_wf,_b) {
_title = document.title;
_h1 = isIE()?document.getElementsByTagName("H1")[0].innerText:document.getElementsByTagName("H1")[0].textContent;
_url = location.href.replace("http://","");
_url = _url.substring(_url.indexOf("/"),_url.length);
if (!isLogin()){
if (_n==""){
alert("please input your name???");
return false;
}
if (_e==""){
alert("please input your email");
return false;
}
if (!isemail(_e)){
alert("Please check your email format!");
return false;
}
}
_wf = _wf?0:1;
_mf = _mf?1:0;
var o = {
name : _n,
email: _e,
mailflag: _mf,
webflag: _wf,
surl:_url,
stitle:_title,
body:_b
};
_o = $(_o);
_o.hide();
_o.after("<img src='/pic/loading.gif' class='sendStyle'/>");
//_o.src="/pic/loading.gif";
$.post("/community/include/saveQA.inc.asp?action=q",{qaname:o.name,qaemail:o.email,qamailflag:o.mailflag,qawebflag:o.webflag,qasourceurl:o.surl,qasourcetitle:o.stitle,qabody:o.body,h1:_h1},function(_sf){
if (parseInt(_sf)>0){
//alert("ok");
if (parseInt(_wf)!=1){
//location.href="/faq/";
location.href="/forms/thankyou-questions.asp";
}else{
location.href="http://answers.chinahighlights.com/question/"+parseInt(_sf)+"/";
}
}else{
alert("The question must be more than 20 characters long");
_o.show();
_o.next("img").remove();
}
});
}
//save question
//_n name
//_e email
//_mf mailflag
//_wf isweb flag
//_b question body
//i_d
//i_p
//i_t
//i_g
//i_n
function writeQAtoQ_static(_o,_n,_e,_mf,_wf,_b, _st, _pt, i_d, i_p, i_t, i_g, i_n) {
_title = document.title;
_h1 = isIE()?document.getElementsByTagName("H1")[0].innerText:document.getElementsByTagName("H1")[0].textContent;
_url = location.href.replace("http://","");
_url = _url.substring(_url.indexOf("/"),_url.length);
if (!isLogin()){
if (_n==""){
alert("please input your name???");
$("#qloading").removeAttr("style");
$("#qloading").hide();
$("#qloadingbg").remove();
$("#sendbutton").attr("disabled",false);
return false;
}
if (_e==""){
alert("please input your email");
$("#qloading").removeAttr("style");
$("#qloading").hide();
$("#qloadingbg").remove();
$("#sendbutton").attr("disabled",false);
return false;
}
if (!isemail(_e)){
alert("Please check your email format!");
$("#qloading").removeAttr("style");
$("#qloading").hide();
$("#qloadingbg").remove();
$("#sendbutton").attr("disabled",false);
return false;
}
}
_wf = _wf?0:1;
_mf = _mf?1:0;
var o = {
name : _n,
email: _e,
mailflag: _mf,
webflag: _wf,
surl:_url,
stitle:_title,
body:_b,
sources_type:_st,
product_type:_pt,
i_doBook: i_d,
i_PhoneNo: i_p,
i_TravelDate: i_t,
i_GroupType: i_g,
i_Nationality: i_n
};
oldsrc = _o.src;
_o.disabled="disabled";
_o.src="/pic/loading.gif";
var hide_lo = function(){
$("#qloading").removeAttr("style");
$("#qloading").hide();
$("#sendbutton").attr("disabled",false);
$("#qloadingbg").remove();
$("#qabody").val('');
};
$.post("/community/include/saveQA.inc.asp?action=q",{
qaname:o.name,
qaemail:o.email,
qamailflag:o.mailflag,
qawebflag:o.webflag,
sources_type:_st,
product_type:_pt,
qasourceurl:o.surl,
qasourcetitle:o.stitle,
qabody:o.body,
h1:_h1,
i_doBook: o.i_doBook,
i_PhoneNo: o.i_PhoneNo,
i_TravelDate: o.i_TravelDate,
i_GroupType: o.i_GroupType,
i_Nationality: o.i_Nationality
},function(_sf){
if (parseInt(_sf)>0){
//alert("ok");
location.hash=null;
location.hash="qatop";
$.get("/api/community/updatecache.asp");
$.ajax({
url: "/api/google-adwords/question-conversion-page.htm",
cache: false,
dataType:'script',
success: function(data){
}
});
alert("Thank You! Your Submission was Successful!");
if (parseInt(_sf)!=1){
//location.href="/faq/";
hide_lo();
}else{
hide_lo();
}
}else{
alert("The question must be more than 20 characters long.");
hide_lo();
_o.src = oldsrc;
_o.disabled="";
}
});
}
//save question on div form
function saveQAtoQonDiv(_n,_e,_mf,_wf,_b){
writeQAtoQ(_n,_e,_mf,_wf,_b);
generalDivWinClose();
}
//save answer
function writeQAtoA(_o,o) {
oldsrc = _o.src;
_o.disabled="disabled";
_o.src="/pic/loading.gif";
a_body = document.getElementById("reply"+o).value;
$.post("/community/include/saveQA.inc.asp?action=a", {qaqid:o,qaabody:a_body},function(_sf){
if (parseInt(_sf)>0){
location.href="http://answers.chinahighlights.com/question/"+o+"/";
}else{
alert("The answer must be more than 20 characters long");
_o.src = oldsrc;
_o.disabled="";
}
});
}
function faqindexTab(_n){
$(".qaNav ul li").eq(1).removeClass();
$(".qaNav ul li").eq(2).removeClass();
$("#lastquestion").hide();
$("#Unanswered").hide();
if (_n==1){
$(".qaNav ul li").eq(1).addClass("active");
$("#lastquestion").show();
}else{
$(".qaNav ul li").eq(2).addClass("active");
$("#Unanswered").show();
}
}
//update newsletter select
function updateNewsLetter(){
//alert($("#editNewsLetter_newslettertype").size());
var tmpt;
tmpt = "";
for (i=0;i<document.ul[1].newslettertype.length;i++){
if (document.ul[1].newslettertype[i].checked){
tmpt = tmpt + document.ul[1].newslettertype[i].value+",";
}
}
rtxt = $.ajax({async:false,type:"GET", url:"/community/customer-center/save-newsletter.asp?ntid="+tmpt}).responseText;
top.location.reload();
//location.href="/community/customer-center/index.asp";
generalDivWinClose();
}
//save comments
function saveComments(_c){
_url = location.href.replace("http://","");
_url = _url.substring(_url.indexOf("/"),_url.length);
_cmmid = document.writeComments.cmmid.value;
_cname = document.writeComments.fullname.value;
_cemail = document.writeComments.email.value;
_cmsg = document.writeComments.commentMsg.value;
_intype = document.writeComments.infoType.value;
if (!isLogin()){
if (_cname.length<2 || _cemail.length<6){
alert("Please input your name & email");
return false;
}
}
dt = new Date();
$.post("/community/include/save-comments.asp",{surl:_url,cname:_cname,cemail:_cemail,cmsg:_cmsg,cmmid:_cmmid,infoType:_intype},function(_sf){
// alert(_sf);
if (_sf.replace(/\s+/g,"").toLowerCase()=="true"){
commform = $(".addComment.roundCorner").clone(true);//hide();
$(".addComment.roundCorner").remove();
tmpHtmlStr = "<div class=\"publishInfo\"><div class=\"publisher\">"+_cname+"<br />on "+['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][dt.getMonth()]+"."+dt.getDate()+","+dt.getFullYear()+" said </div>";
tmpHtmlStr = tmpHtmlStr + "<div class=\"clear\"></div></div><div class=\"customerReview roundCorner\"><div class=\"say\"></div>";
tmpHtmlStr = tmpHtmlStr + _cmsg + "<div class=\"clear\"></div>";
tmpHtmlStr = tmpHtmlStr + "<div class=\"clear\"></div></div>"
$(".commentList.roundCorner").append(tmpHtmlStr);
commform.appendTo(".commentList.roundCorner");
$("#commentMsg").val("");
$("#CommCount").text(parseInt($("#CommCount").text())+1);
}else{
alert("System error!");
}
});
}
//close win(div)
function generalDivWinClose(){
$(document).trigger('close.facebox');
}
function stroyBack(){
generalDivWinClose();
location.href="index.asp";
}
//send messages
function smtu(n){
if (!isLogin()){
alert("Please first login");
return false;
}
_divid = "sendmessages";
_msg = document.getElementById(_divid+ "_msg").value;
if (_msg.length<10){
alert("please input Messages,the message must be more than 10 characters long.");
return false;
}
if (_msg.length>500){
alert("The message must be less than 500 characters long.");
return false;
}
// rt = $.get("/community/include/sendmessages.asp?u="+n+"&m="+_msg).responseText;
rt = $.ajax({async:false,type:"GET", url:"/community/include/sendmessages.asp?u="+n+"&m="+_msg}).responseText;
generalDivWinClose();
//alert(_msg);
//alert(rt);
//alert(n);
}
function hideNewsLetter(){
generalDivWinClose();
}
//delete travel story
function deleteTravelStory(n){
generalDivWinClose();
$.post("/community/travel-story/del-story.asp?sid="+n,function(_sf){
//alert(_sf);
});
$("#trid"+n).fadeOut(300);
}
//delete travel notes
function deleteTravelNotes(n){
generalDivWinClose();
$.post("/community/travel-story/save-story.asp?action=delcity&nid="+n,function(_sf){
//alert(_sf);
});
$("#trid"+n).fadeOut(300);
}
//save story new Itinerary
function saveStoryNewCity(_ac){
_divid = "newItinerary";
_cityname = document.getElementById(_divid+ "_newcityname").value;
if (_cityname.length<2){
alert("please input city name");
return;
}
_tourdate = document.getElementById(_divid+ "_newtourdate").value;
if (_tourdate.length<2){
alert("please input tour date");
return;
}
// _citynote = document.getElementById(_divid+ "_newnotesbody").value;
// if (_citynote.length<100){
// alert("please input Trip Journal,the story must be more than 100 characters long.");
// return ;
// }
_days = document.getElementById(_divid+ "_tourdays").value;
_sid = document.getElementById("sid").value;
$.post("/community/travel-story/save-story.asp?action="+_ac, {cityname:_cityname,tourdate:_tourdate,sid:_sid,days:_days},function(_sf){
if (parseInt(_sf)>0){
generalDivWinClose();
location.reload();
}else{
alert("The content cannot be null");
}
});
}
//add story submit Checkbox
function storycheck(){
st = document.getElementById("storytitle").value;
sb = document.getElementById("storybody").value;
sb = CKEDITOR.instances.storybody.getData();
if (st=="" || st.length>60){
document.getElementById("stitleErrTips").style.display='';
$("#stitleErrTips").css("opacity","100");
$("#stitleErrTips").focus();
return false;
}
if (sb=="" || sb.length<100){
$("#storyBodyErrTips").show();
$("#storyBodyErrTips").css("opacity","100");
$("#storyBodyErrTips").focus();
return false;
}
return true;
}
//update Story City notes
function updateStoryCity(_n){
_divid = "writeJournal"+_n;
_cityname = document.getElementById(_divid+ "_cityname").value;
_tourdate = document.getElementById(_divid+ "_tourdate").value;
_tourdays = document.getElementById(_divid+ "_tourdays").value;
$.post("/community/travel-story/save-story.asp?action=updatecity&nid="+_n,{cityname:_cityname,tourdate:_tourdate,tourdays:_tourdays},function(_sf){
generalDivWinClose();
location.reload();
});
}
//write story add city js function
function addPlace(){
tabObj = document.getElementById("placeTable");
nnn = tabObj.rows.length;
ggg=tabObj.insertRow(tabObj.rows.length);
ggg.id = "tr"+nnn.toString();
ggg.insertCell(0).innerHTML= "City "+(tabObj.rows.length - 1);
ggg.insertCell(1).innerHTML=tabObj.rows[1].cells[1].innerHTML;
newTmpHtml = tabObj.rows[1].cells[2].innerHTML.replace(new RegExp("tourdate1","gm"),"tourdate"+(tabObj.rows.length - 1));
newTmpHtml = newTmpHtml.replace(new RegExp("dateImage1","gm"),"dateImage1"+(tabObj.rows.length - 1));
ggg.insertCell(2).innerHTML=newTmpHtml;
ggg.insertCell(3).innerHTML=tabObj.rows[1].cells[3].innerHTML;
ggg.insertCell(4).innerHTML="<a href='javascript:delPlace("+nnn+")'>Delete This Place</a>";
if (tabObj.rows.length % 2==0) isIE()?ggg.setAttribute("className","alt-row"):ggg.setAttribute("class","alt-row");
}
function delPlace(o){
rn = document.getElementById("tr"+o).rowIndex;
// alert(n.parentNode);
tabObj = document.getElementById("placeTable");
tabObj.deleteRow(rn);
for (u=1;u<tabObj.rows.length;u++){
tabObj.rows[u].cells[0].innerHTML= "City "+ u.toString();
if (u % 2==0) {
isIE()?tabObj.rows[u].setAttribute("className",""):tabObj.rows[u].setAttribute("class","");
}
else{
isIE()?tabObj.rows[u].setAttribute("className","alt-row"):tabObj.rows[u].setAttribute("class","alt-row");
}
}
}
//other question.asp
function qatab(_s){
$(".viewOrderLab li").removeClass();
//$(".viewOrderLab li").eq(1).removeClass();
if (_s=="q"){
$(".viewOrderLab li").eq(0).addClass("current");
$("#questionList").show();
$("#answerList").hide();
}else{
$(".viewOrderLab li").eq(1).addClass("current");
$("#questionList").hide();
$("#answerList").show();
}
}
function favgo(s){
s = "//www.chinahighlights.com"+s;
if (isIE()){
window.external.addFavorite(s,'Chinahighlights Question & Answer');
}else{
window.sidebar.addPanel('Chinahighlights Question & Answer',s,'');
}
}
function dofav(n){
$("#fav"+n).show();
}
function outfav(n){
$("#fav"+n).hide();
}
function displayReply(n){
$("#replytxtid"+n).css("display")=="none"?$("#replytxtid"+n).slideDown(300):$("#replytxtid"+n).hide();
}
function isemail(str)
{
var result=str.match(/^[_a-z0-9-]+(\.[a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i);
if(result==null) return false;
return true;
}