	document.domain = "chinatour360.com";
	CT={};
	
// 代码不支持 IE6
historyWatcher = function() {
    var timer, last;
    return {
        register: function(fn, thisObj) {
            if(typeof fn !== 'function') return;
            timer = window.setInterval(function() {
                if(location.hash !== last) {
                    last = location.hash;
                    fn.call(thisObj || window, last);
                }
            }, 100);
        },
        stop: function() {
            timer && window.clearInterval(timer);
        },
        set: function(newHash) {
            last = newHash;
            location.hash = newHash;
        }
    };
}();




	
	//初始化所有组件
	CT.Initial=function(){
		CT.Emails.show(); //show emails	//email替换 

		CT.Others.MsnSkype();
		CT.Others.FootLogo();
		CT.Others.TableInPic();
		CT.Others.HotelsAndTips();
		CT.Others.CopyTime();
		CT.Anchor.Run();
		CT.Anchor.replyDisplay();
		CT.Others.TableRule();
		CT.Zodiac.Run();
		CT.ClimateCharts.Run();
		CT.Others.GetMyWeather();
		CT.Others.ShareButton();
		CT.Others.Flikebox();
		//CT.Visa.NoBackground();
		
		//$("div.msnSkype").html('');
		

	};
	
	CT.Visa={
		NoBackground:function(){
			if(!$("#cityPicN")[0])
			{
				$("#main .left").css({'background':'none'});
			}
		}
	};
	
	//显示email
	CT.Emails={
		show:function(){
				var v,arrv;
				if (!$("span.clspost"))
				return false;
				$("span.clspost").each(function (index, domEle) {
					 arrv=$(this).html().split("|");
					 v=arrv[1]+"@"+arrv[0]+" ";
					 $(this).html(v);
				}); 
		}
	};
	
	//js控制锚点
	CT.Anchor={
		Run:function(){
			var myCommentID=(location.href.lastIndexOf('#qa')>-1?location.href.substring(location.href.lastIndexOf('#qa')+3):0);
			var $thisHashID=$("#qareply"+myCommentID).prev();
			//alert(myCommentID);
			//alert($thisHashID.html())
			//为了不重新生成页面，动态添加了ID
			$thisHashID.attr("id","qa"+myCommentID);
			if(myCommentID>0) 
			{
				location.hash='';
				
				historyWatcher.set('qa'+myCommentID);
				historyWatcher.register();
			}
		},
		replyDisplay:function(){
			if(location.href.lastIndexOf('#qa')>-1)
			{
				var myCommentID=(location.href.lastIndexOf('#qa')>-1?location.href.substring(location.href.lastIndexOf('#qa')+3):0);
				$.post('/com/js/qareplyajax/index.asp',{id:myCommentID},function(r){
					$("#qareply"+myCommentID).html(r).show();
			 
					  $(".close").click(function(){
						$(this).parent().hide();
					  });
					  $("#qaid").val(myCommentID);
					  var replyto=$("#qaid"+myCommentID).attr("replyto");
					  $("#replyto").val(replyto);

				});
				
			}
		}
	};
	
	CT.ClimateCharts={
		Run:function(){
			var $cc=$("#climateCharts");
			var $ccName='climateCharts';
			$cc.html('<iframe id="frame_'+$ccName+'" name="frame_'+$ccName+'" src="/cgi/ad_template/climateCharts.htm" width="720" height="1465" frameborder="0" scrolling="no" allowTransparency="true"></iframe>');
		}
	};
	
	CT.Zodiac={
		Run:function(){
			if ($("#zodiacID")[0])
			{
				$("#btnGetZoc").click(function(){
					$('#idzodiac').html('<div class=clsloading style=\"background:#f0f9fe;\">loading...<br/></div>');
					//zodiacNoDll.aspx datechange.asp
					$.post('/inc/zodiac/zodiacNoDll.aspx?rn='+escape(Math.random())+'&d='+$('#yr').val()+'-'+$('#mn').val()+'-'+$('#dy').val(),function(result){
						$('#idzodiac').html(result).show();
						$('#zodiacAnchor').click(function(){
							location.hash=$(this).attr('v');							  
						});
					})						   
				});
			}
		}
	};
	


	
	CT.Others={
		GetMyWeather:function(){
			var $cityWeather=$("#CityWeather");
			if(!$cityWeather[0])return false;
			$.getScript("/image/js/common/myWeatherCn/getWeather.min.js"); 
		},
		Flikebox:function(){
			  var $obj=$("#titleID");
			  if($("#titleID")[0])
			  {
//				  hrefValue = window.location.href; 
				  //alert(hrefValue);
//				  if(hrefValue.indexOf("yangqiong")<=0)
//				  return;
				  var flikeboxstr='<iframe src="/com/js/sharebutton/share.htm" frameborder="0" scrolling="no" width="260" height="22"></iframe>';
				 var $t=$obj.attr("t");
				 switch ($t)
				 {
					 case "0":
					 {
						 //only template city-index.htm and isdefault<>1  heidi special
						 if( typeof(faceBookSpecial)!="undefined" )
						 {
							 $obj.after("<div class=\"facebook\" style=\"float:none;width:700px;margin-top:1px;\" >"+flikeboxstr+"</div>").css({'margin-bottom':'2px'});
							 $(".content").css({'margin-top':'2px'});
							 break;
						 }
						 
						 //Photo-Index.htm
						 //photo-greatwall-index.htm
						 if ($("#span_back")[0])
						 {
							$obj.append("<span>"+flikeboxstr+"</span>")
						 }
						 else
						 {
							$obj.append("<span class=\"facebook\">"+flikeboxstr+"</span>")
						 }	
						break;
					 }
					 
					 case "1":
					 {
						//only /index.htm							
						$obj.append("<span class=\"facebook\">"+flikeboxstr+"</span>").css({'background':'none'});
					 	break;						 
					 }
					 
					 case "2":
					 {
						 
				 		$obj.before("<div class=\"facebook\">"+flikeboxstr+"</div>");		
						break;
					 }

					default:
				 	$obj.after("<div class=\"facebook\">"+flikeboxstr+"</div>");
				 }
			  }

		}
		,
		ShareButton:function(){
			  var $obj=$(".facebook");
			  if($obj){
			  	$obj.html('<iframe src="/com/js/sharebutton/share.htm" frameborder="0" scrolling="no" width="260" height="22"></iframe>');
			  }
		}
		,
			
		MsnSkype:function(){
			if ($("#msnSkype").attr("typeId")=="isIndex")
			$("#msnSkype").load("/com/js/msn/msn_Index.htm");
			else
			$("#msnSkype").load("/com/js/msn/msn.htm");
		}
		,
	//	ToolBar:function() {
    //	var po = document.createElement('script'); po.type = 'text/javascript'; 		
    //	po.async = true;
    //	po.src = 'http://cdn.wibiya.com/Toolbars/dir_0920/Toolbar_920020/Loader_920020.js';
    //	var s = document.getElementById('footer'); 
    //	s.parentNode.insertBefore(po, s);
 	 //	},
		FootLogo:function(){
			if( $("#footer")[0] )
			{

				
				var $imgAll=$("#footer img");
				var N=$imgAll.length-1;
				if($($imgAll.get(N)).attr("src")!="http://image.chinatour360.com/logo/cats.gif")
				return false;
				
				$($imgAll.get(N)).after('<img src="http://image.chinatour360.com/logo/asta.png" alt="">');
				
				
			}
		},
		CopyTime:function(){
			$("#copyTime").html('2012');
		},
		TableInPic:function(){
			$("table.tableInPic").each(function(){
				var $thisTd=$(this).find("td");	
				$thisTd.width($(this).find("img").width());								
			});

			
		},
		HotelsAndTips:function(){
			if ( $("div.left a.tip")[0] && $("div.left a.selHotel")[0] )
			{
				var $selHotel=$("div.left a.selHotel");
				$selHotel.parent().remove();
				$selHotel.clone().prependTo( $("div.left a.tip").parent() );
			}
		},
		TableRule:function(){
			$('div.content table').each(function(){

				if( $(this).attr('style')!=undefined && $(this).attr('border')!=undefined && $(this).attr('width')!=undefined)		
				{
					if( $(this).attr('style').toLowerCase()=='border-collapse: collapse' && $(this).attr('border')==1 && $(this).attr('width').toLowerCase()=='700' )
					{
						$(this).removeAttr('style').attr('cellspacing','0').attr('cellpadding','0');
						
					}
				}


			});
		}
	};

$(function(){
	$.extend({
		 csslzLoad: function(cssfileurl,styleobj){
			  var linkobj;
			  
			  if(  !!styleobj && $(styleobj).size()>0 && $(styleobj).attr("tagName")=='LINK' ){
			   linkobj=$(styleobj);
			   $(linkobj).attr("type","text/css");
			   $(linkobj).attr("rel","stylesheet");
			  }else{
			   linkobj=$('<link type="text/css" rel="stylesheet" />');
			   $("head").append(linkobj);
			  }
			  //替换/设置 样式
			  
			  
			  linkobj.attr('href',cssfileurl);
			  return styleobj;
		 }
	});	
	
	CT.Initial();
	if( $("#isPicName")[0] )
	{
		if( $.trim($("#isPicName").html())=="" )
		{
			$("dl.yellowBg").remove();
		}
	}
	
	$("img.clsphotogalleryimg").each(function(){
		if($(this).attr("align")!='')	
		{
			$(this).css({'float':$(this).attr("align")} );
		}
	});
});

//check skype is installed
msnSkypeIe=(function(){
	if(typeof(detected) == "undefined" && $.browser.msie) {
		document.write(
			['<script language="VBscript">',
			'Function isSkypeInstalled()',
			'on error resume next',
			'Set oSkype = CreateObject("Skype.Detection")',
			'isSkypeInstalled = IsObject(oSkype)',
			'Set oSkype = nothing',
			'End Function',
			'</script>'].join("\n")
		);
	}
})();

function checkd(){
	var la = document.tt.f.length;
	var ff ="";
	for(var i=0;i<la;i++){
		if(document.tt.f[i].checked)ff=ff+document.tt.f[i].value+", ";
	}
	document.tt.d.value=ff+document.tt.c.value;
	document.tt.dd.value=ff+document.tt.c.value;
}

(function($) {
	$.fn.Slider=function(options) {
        var settings = {
            width: 320, height: 275, picHeight:226, timeout: 3000, overlay: 500, effect: 'fadeOut'		
        };

		//extending options
		options = options || {};
        $.extend(settings, options);

		return this.each(function(){
			var timer;
			var index=0;
			var done=true;
			var a = $(this);
			var aImg = a.find('ul');
			var aCount = $("li",aImg).length;
			
			a.css({width:settings.width,height:settings.height});
			aImg.find('img').css({width:settings.width,height:settings.picHeight});
					
			sliderStart($('ul li',this[0])[0]);
			$('.num span').bind('mouseover',function() {
				if(done && !$(this).is('.theNum')) {
					sliderPlay(a.find('span').index(this));
				}
			});

			function sliderPlay(ix) {
				if(ix>=0) index=ix; 
				else index++;

				if(index>aCount-1) index=0;
				
				sliderStop();
				done=false;
				var imgList=$(a).find('ul');
				var imgNum=$(a).find('.num');
				var old=$('>.selected',imgList);
				if(old.length>0){
					old.css('z-index',10);
					$('>:eq('+index+')',imgList).addClass('selected').show();

					eval("old."+settings.effect+"(settings.overlay,function() {$(this).css('z-index',1).removeClass('selected');done=true;sliderStart();});");

					imgNum.find('.theNum').removeClass('theNum');
					$('>:eq('+index+')',imgNum).addClass('theNum');
				}
			}
			// 停止自动
			function sliderStop(){clearTimeout(timer);}
			
			// 开始自动
			function sliderStart(){timer=setTimeout(function(){sliderPlay(-1)},settings.timeout);}
			
		});
	};
})(jQuery);

