
$.ajaxSetup ({


cache: false //close AJAX cache


});

function playTran(Obj)
{
  if (document.all)
  Obj.filters.revealTrans.play();
}
//显示大图
function ShowBigPic(picture,destination,destinationname,picturetitle,ReViewTimes,Contributor,rownum)
{

   var Obj=document.getElementById("imgbigID");
    document.getElementById("imgbigID").picture=picture;
    document.getElementById("imgbigID").rownum=rownum;
     if (document.all)//ie not firefox
     {
        Obj.filters.revealTrans.Transition=100;
        Obj.filters.revealTrans.apply();
        playTran(Obj);
      }
  document.getElementById("imgbigID").src=RetPicUrl(picture,true);//show pic url
  document.getElementById("imgbigID").title=destinationname;
  //document.getElementById("picdesc").innerHTML=AboutPicture;
   document.getElementById("dtpicTitle").innerHTML=picturetitle.replace(/\|%/g,"'");//目的为的是'在页面中会出现异常
   
    document.getElementById("dtpicTitle").setAttribute('title',picturetitle.replace(/\|%/g,"'"));
    
    document.getElementById("emuploadPeople").innerHTML=Contributor;    
  
  if(destinationname=="")
  {
     document.getElementById("bigimgSearchTitle").innerHTML="All destinations";
  }
  else
  {
     document.getElementById("bigimgSearchTitle").innerHTML=destinationname;
  }

 document.getElementById("pichotelID").innerHTML=destinationname;
  document.getElementById("picattrID").innerHTML=destinationname;
   
 document.getElementById("hiddendestID").value=destination;
 //document.getElementById("ViewsNumID").innerHTML="Views:&nbsp;"+ReViewTimes;
 
 //add reviewtimes
 addReviewTimes(picture,ReViewTimes);
       

}
function addReviewTimes(picture,times)
{
   
    if(picture!="")
    {
        var Retimes=times;
         $.ajax({
            url:RetWebPath()+'Ajax/AddPicReviewTimes.ashx',
            type: 'GET',
            dataType:"text",
            data:"picture="+picture,
            timeout: 10000,
            error: function(data){     
                    document.getElementById("ViewsNumID").innerHTML="Views:&nbsp;"+times;
                },
            success: function(data){
                        var sAboutPic=data.split('|');
                        document.getElementById("ViewsNumID").innerHTML="Views:&nbsp;"+sAboutPic[0];
                        document.getElementById("picdesc").innerHTML=sAboutPic[1];
                        document.getElementById("picdesc").setAttribute('title',sAboutPic[1]);
                  }
              }
           );
    }
    else
    {
        document.getElementById("ViewsNumID").innerHTML="Views:&nbsp;";
        document.getElementById("picdesc").innerHTML="";
        document.getElementById("picdesc").setAttribute('title',""); 
    }
       
}
function PreviousPicture()
{
    if(document.getElementById("divalertinfo").style.display!="block")
   {
        if(document.getElementById("imgbigID").picture!="0")
        {
            ajaxNextPreviousPic("previous",document.getElementById("imgbigID").picture,document.getElementById("imgbigID").rownum);
        }
   }
}
function NextPicture()
{
   if(document.getElementById("divalertinfo").style.display!="block")
   {
        if(document.getElementById("imgbigID").picture!="0")
        {
            ajaxNextPreviousPic("next",document.getElementById("imgbigID").picture,document.getElementById("imgbigID").rownum);
        }
   }
}
function addOptionToSelect(objselectID,objID,objText)
{

   document.getElementById(objselectID).options.add(new Option(objText,objID)); 
 
}
function ClearSelect(objselectID)
{
  
    document.getElementById(objselectID).options.length = 0;
    
    if(objselectID=='selectattraction')
    {
        document.getElementById(objselectID).options.add(new Option("-China Travel Attractions-","0")); 
    }
    else
    {
        document.getElementById(objselectID).options.add(new Option("-China Travel Destinations-","0")); 
    }
    
}

function htmlEncode(value) {
    return value ? value.replace(/&/g, "&amp;")
        .replace(/</g, "&lt;").replace(/>/g, "&gt;") : "";
}


function clicksmallImg(objID)
{

  
    var  ImgObjID="smpic"+objID;
   // ShowBigPic(obj.getAttribute('picture'),obj.getAttribute('destination'),obj.getAttribute('destinationname'),obj.getAttribute('picturetitle'),obj.getAttribute('aboutpicture'),obj.getAttribute('reviewtimes'),obj.getAttribute('contributor'),obj.getAttribute('rownum'));
    ShowBigPic(document.getElementById(ImgObjID).getAttribute('picture'),document.getElementById(ImgObjID).getAttribute('destination'),document.getElementById(ImgObjID).getAttribute('destinationname'),htmlEncode(document.getElementById(ImgObjID).getAttribute('picturetitle')),document.getElementById(ImgObjID).getAttribute('reviewtimes'),document.getElementById(ImgObjID).getAttribute('contributor'),document.getElementById(ImgObjID).getAttribute('rownum'));
 
    ShowBegEndNumber(document.getElementById(ImgObjID).getAttribute('rownum'),allnum)
}
function ViewBigImg(obj)
{
    window.open(obj.src);
}
function showNoBigPic(bool)
{

    if(bool)
    {
        document.getElementById("divalertinfo").style.display="none";
       document.getElementById("divInfoimg").style.display="block";
    }
    else
    {
        ShowBigPic("","","","","","","","0");
    
       document.getElementById("divalertinfo").style.display="block";
       document.getElementById("divInfoimg").style.display="none";
   }
}

//显示导航数字
function ShowBegEndNumber(begNum,endNum)
{
   document.getElementById("sbegNum").innerHTML=begNum;
    document.getElementById("sendNum").innerHTML=endNum;
}

function ShowSmallPic(obj,spic_ID)
{   
   
  obj.src=RetPicUrl(spic_ID,false);
 
}
 //2009-8-10 add by hcdu taskID:62142
   function KeyClick(clickname,e)
   {     
	
       if(e == 13)
       {	   
        
         if(clickname=="SearchPicture")
         {
             SearchPicture();
         }    	    
       } 
		  
   }
function ChageList(obj)
{
    var destinationID=obj.options[obj.selectedIndex].value;
  
   $.ajax({
        url:RetWebPath()+'Ajax/ShowAttractionList.ashx',
        type: 'GET',
        dataType:"json",
        data:"destination="+destinationID,
        timeout: 10000,
        error: function(data){     
                ClearSelect("selectattraction");
            },
        success: function(data){
                    var dataTemp = data.list1;    
                   
                      document.getElementById("selectattraction").options.length = 0;
                    document.getElementById("selectattraction").options.add(new Option("-China Travel Attractions-","0")); 
                    $.each(dataTemp,function(i,n)
                       {     
                   
                         addOptionToSelect("selectattraction",n.site,n.sitename);
                     
                        }
                      );                  
              }
          }
       );
}


function ajaxNextPreviousPic(type,NowImgPicID,NowRowNum)
{

  
    $.ajax({
        url:RetWebPath()+'Ajax/ReturnNextPreviousPic.ashx',
        type: 'GET',
        dataType:"json",
        data:"DestinationID="+strSelectDestinationID+"&SearchName="+strTxtsearch+"&Contributor="+strTxtContributor+"&AttrID="+strSelectattractionID+"&picID="+NowImgPicID+"&type="+type+"&top="+rTopType,
        timeout: 10000,
        error: function(data){
        alert('You are either at the beginning or end of this slideshow.');     
          
            },
        success: function(data){
                    var dataTemp = data.list1;
                  
                    $.each(dataTemp,function(i,n)
                       {     
                           
                           if(type=="next")
                           {
                                ShowBigPic(n.picture,n.destination,n.destinationname,n.picturetitle,n.reviewtimes,n.contributor,Number(NowRowNum)+1);
                                ShowBegEndNumber(Number(NowRowNum)+1,allnum);//显示导航数字
                           }
                           else
                           {
                                ShowBigPic(n.picture,n.destination,n.destinationname,n.picturetitle,n.reviewtimes,n.contributor,Number(NowRowNum)-1);
                                ShowBegEndNumber(Number(NowRowNum)-1,allnum);//显示导航数字
                          }
                          
                        }
                     
                      );                       
              }
          }
       );
       
    
}


function SearchPicture()
{
        rTopType="";//
      strSelectDestinationID="";
      strTxtContributor="";
      strSelectattractionID="";//attactionID
      strTxtsearch="";
      JsfirstID="0";
    if(document.getElementById("txtsearchname").value=="China Travel photos"&&document.getElementById("selectdestination").value=="0" && document.getElementById("txtContributor").value=="")
    {
        alert("Looking for something? Enter your search terms and try again.");
    }
    else
    {
        var itemName="";
        if(document.getElementById("txtsearchname").value!="China Travel photos")
        {
            strTxtsearch=document.getElementById("txtsearchname").value;
            itemName=strTxtsearch;
        }
        if(document.getElementById("selectdestination").value!="0")
        {
             strSelectDestinationID=document.getElementById("selectdestination").value;             
                   
              document.getElementById("SpanMenuID").innerHTML=document.getElementById("selectdestination").options[document.getElementById("selectdestination").selectedIndex].text;
             if(itemName=="")
             {
                itemName=document.getElementById("selectdestination").options[document.getElementById("selectdestination").selectedIndex].text;
             }
             else
             {
                itemName+="/"+document.getElementById("selectdestination").options[document.getElementById("selectdestination").selectedIndex].text;
             }
        }
        if(document.getElementById("selectattraction").value!="0")
        {
             strSelectattractionID=document.getElementById("selectattraction").value;
             if(itemName=="")
             {
                itemName=document.getElementById("selectattraction").options[document.getElementById("selectattraction").selectedIndex].text;
             }
             else
             {
                itemName+="/"+document.getElementById("selectattraction").options[document.getElementById("selectattraction").selectedIndex].text;
             }
        }
         strTxtContributor=document.getElementById("txtContributor").value;
         if(strTxtContributor!="")
         {
            if(itemName=="")
             {
                itemName=strTxtContributor;
             }
             else
             {
                itemName+="/"+strTxtContributor;
             }
         }
          if(itemName=="")
          {
             document.getElementById("itemphototitle").innerHTML="All destinations";
          }
          else
          {
             document.getElementById("itemphototitle").innerHTML=itemName;
          }
     
        showNoBigPic(true);
         InitShowPic("1");
    }    
    
}

function ClickHotel(objvalue)
{
    if(objvalue!="")
    {
        var href="../chinatravelnet/hotels/searchresult.aspx?destination="+objvalue;
        window.open(href);
    }
    else
    {
         var href="../chinatravelnet/hotels/searchresult.aspx";
        window.open(href);
    }
}
function ClickAtt(objvalue,objtext)
{
    if(objvalue!="")
    {
        var href="../china-attractions/"+Jtrim(objtext);
        href+="/searchresult-"+objvalue+".html";
        window.open(href);
    }
    else
    {
       
        window.open("../china-attractions/");
    }
}
function Jtrim(str){ 
      var p=/\s/g;
      str=str.replace(p,"");   
      return str;
}
