 $(document).ready(function(){ 
		    var guidephotos = $('.guidenav li');
		    var current = 0;
		    var itemsNumber = guidephotos.length;
    		
		    guidephotos.each(function(index, el){
			    if (index !== current ){
				    $(el).hide();
			    }
		    });
    		
		    var interval = window.setInterval(function(){
			    var oldElement = guidephotos.eq(current);
    			
			    if (current + 1 === itemsNumber) {
				    current = 0;
			    } 
			    else {
				    current++;
			    }
    			
			    var newElement = guidephotos.eq(current);
			    oldElement.fadeOut(500,function(){
			        newElement.fadeIn(500);
			    });
		    }, 5000);
		;});
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
;
try {
var pageTracker = _gat._getTracker("UA-15619948-1");
pageTracker._setDomainName(".cnadventure.com");
pageTracker._trackPageview();
} catch(err) {};
function pageClose()
{
    if (event.clientX>document.body.clientWidth && event.clientY<0||event.altKey)
    {
        window.location = "/Default.aspx?act=clearsession";
    }
}

function showForgot(forgot_url, win_height, win_width)
{
    GB_hide();
    return GB_showCenter('Forgot Password', forgot_url, win_height, win_width);
}

function refreshSession()
{
    try
    {
        $.ajax({
            url: "/Noop.aspx",
            cache: false,
            success: function(msg){
            },
            error: function(msg) {
            }
        });        
    }
    catch(e){alert(e);}    
}

function siteSearch()
{
    var url_search = "/PageTwoColumnMainRight.aspx?tabid=22";
    var objKeywords = document.getElementById("ctl00_ctl00_txt_KeyWords");
    var keywords = objKeywords.value;
    if("" != keywords && "Search Site by Google" != keywords)
    {
        url_search += "&start=0&q=" + encodeURI(keywords);
        window.location = url_search;
    }
    else
    {
        alert("Please input keyword(s)!");
        objKeywords.focus();
    }
}

function switchLanguage(lang)
{
    var loc =  window.location.href;
    var idx = loc.indexOf("?");
    if(-1 == idx)
        loc += "?language=" + lang;
    else
    {
        var new_s = "";
        var languageExisted = false;
        
        var s = window.location.search;
        var a = s.split("?");
        var b = a[1].split("&"); 
        for(var i=0; i<b.length; i++) 
        { 
            if("" != new_s)
                new_s += "&";
                
            var c = b[i].split("=");
            if(c[0] == "language")
            {
                new_s += "language="+lang;
                languageExisted = true;
            }
            else
                new_s += b[i];
        }
        
        loc = loc.substring(0, idx+1) + new_s;
        if(!languageExisted)
            loc += "&language=" + lang;
    }   
        
    window.location = loc;
}
;
    var point_radius = 5;/*radius of the sight point in the overall photo*/
    var sights = new Array("185#131#5#/pub/aspx/View.aspx?type=Picture&field=Name&id=247&linktype=3#Huanghuacheng Great Wall","289#107#11#/pub/aspx/View.aspx?type=Picture&field=Name&id=290&linktype=3#The Simatai Great Wall","276#107#9#/pub/aspx/View.aspx?type=Picture&field=Name&id=273&linktype=3#The Jinshanling Great Wall in Beijing","210#127#7#/pub/aspx/View.aspx?type=Picture&field=Name&id=259&linktype=3#Jiankou Great Wall","218#135#8#/pub/aspx/View.aspx?type=Picture&field=Name&id=285&linktype=3#The Mutianyu Great Wall in Beijing","156#134#4#/pub/aspx/View.aspx?type=Picture&field=Name&id=384&linktype=3#Badaling Great Wall and Juyongguan Pass","144#150#4#/pub/aspx/View.aspx?type=Picture&field=Name&id=384&linktype=3#Badaling Great Wall and Juyongguan Pass","37#246#13#/pub/aspx/View.aspx?type=Picture&field=Name&id=297&linktype=3#Wulonggou-Meiyao-Tangzigou Great Wall","56#247#14#/pub/aspx/View.aspx?type=Picture&field=Name&id=306&linktype=3#Zijingguan Pass of the Great Wall","297#159#12#/pub/aspx/View.aspx?type=Picture&field=Name&id=251&linktype=3#The Great Wall at Huangyaguan","544#182#2#/pub/aspx/View.aspx?type=Picture&field=Name&id=288&linktype=3#Laolongtou Great Wall & Shanhaiguan Pass","539#177#2#/pub/aspx/View.aspx?type=Picture&field=Name&id=288&linktype=3#Laolongtou Great Wall & Shanhaiguan Pass","541#169#15#/pub/aspx/View.aspx?type=Picture&field=Name&id=266&linktype=3#The Great Wall at Jiaoshan","538#163#16#/pub/aspx/View.aspx?type=Picture&field=Name&id=277&linktype=3#The Great Wall at Jiumenkou","527#160#17#/pub/aspx/View.aspx?type=Picture&field=Name&id=232&linktype=3#The Great Wall at Dongjiakou","263#105#6#/pub/aspx/View.aspx?type=Picture&field=Name&id=241&linktype=3#Gubeikou Great Wall");
    
    function getPos(el,sProp)
	{
		var iPos = 0;
		while (el!=null)
		{
			iPos+=el["offset" + sProp];
			el = el.offsetParent;
		}
		return sProp=="Left"?iPos+4:iPos+2;
	}
			
    function showSight(o, e)
    {
        var debug = false;
		if(e)
		{
		    var x_in_img = document.body.scrollLeft + e.clientX - getPos(o, "Left");
			var y_in_img = document.body.scrollTop + e.clientY - getPos(o, "Top");
			if (debug) alert("xy: " + x_in_img + " x " + y_in_img);
			
			if(!isInHotPoint(o, x_in_img, y_in_img))
			    hideSight();
		}
    }
    
    function isInHotPoint(o, coor_x, coor_y)
    {
        for(var i=0; i<sights.length; i++)
        {
            /*format of sights[i]: coordinate_x#coordinate_y#sight id#photo url of the sight#sight title*/
            var parts = sights[i].split("#");
            if(Math.sqrt(Math.pow(coor_x-parts[0],2)+Math.pow(coor_y-parts[1],2)) <= point_radius)
            {
                divSightHint.style.left = getPos(o, "Left") + parseInt(parts[0]) - 2;
                divSightHint.style.top = getPos(o, "Top") + parseInt(parts[1]) - 2;
                divSightHint.innerHTML = formatHintContent(parts);
                
                tooltip.show(divSightHint);
                return true;
            }
        }
        
        return false;
    }
    
    
    function formatHintContent(parts)
    {
        var content = "<a href='/PageTwoColumnMainRight.aspx?tabid=20&sightid="+parts[2]+"' target=_blank>";
        if("" != parts[3])
            content += "<img src='" + parts[3] + "' class=imgWithBorder /><br>";
        content += "<img src='/img/icon/arrow.gif' hspace='4' border='0'/>"+parts[4]+"</a>";
        
        return content;
    }
    
    function hideSight()
    {
        tooltip.hide();
    }
   
;
        function GoSubmitInquiry(thisid,posturl)
        {
            var fullname = $('#'+thisid +'txt_FullName');
            if(fullname.val().length < 3)
            {
                alert("Please input your full name");
                fullname.focus();
                return false;
            }
            var email = $('#' + thisid + 'txt_Email');
            if(email.val().length < 5 || email.val().indexOf('@') < 1 || email.val().indexOf('.') < 2)
            {
                alert("Please input your email in correct format, such as: myname@email.com");
                email.focus();
                return false;
            }
            var content = $('#' + thisid + 'txt_Content');
            if (content.val().length < 2)
            {
                alert("Please input your question");
                content.focus();
                return false;
            }
            var data = {'fullname':escape(fullname.val()),'email': escape(email.val()),'content': escape(content.val())};
            $.post(
	            posturl,
	            data,
	            function() {
                    alert("Thank you for your inquiry. We will get back to you in 24 hours!");
                    fullname.val("");
	                email.val("");
	                content.val("");
	                
	                $("#btnSubmit").show();
                    $("#img_subscribe_loading").hide();
	            }
            );
            
            $("#btnSubmit").hide();
            $("#img_subscribe_loading").show();
            return true;  
        }
   ;