﻿	//document.domain = "Tibettours.com";
	Tibet={};
	

	//cookie设置 调用：$.Cookie.Set('abc');
	$.Cookie={
		// write cookies 
		Set:function(name, value, hours){
			var expire = "";
			if(hours != null)
			{
				expire = new Date((new Date()).getTime() + hours * 3600000);
				expire = "; expires=" + expire.toGMTString();
			}
			document.cookie = name + "=" + escape(value) + expire+";path=/";
		},
		// read cookies
		Get:function(name){
			var cookieValue = "";
			var search = name + "=";
			if(document.cookie.length > 0)
			{
				offset = document.cookie.indexOf(search);
				if (offset != -1)
				{
				  offset += search.length;
				  end = document.cookie.indexOf(";", offset);
				  if (end == -1) end = document.cookie.length;
				  cookieValue = unescape(document.cookie.substring(offset, end));
				}
			}
			return cookieValue;
		}
	};
	
	//初始化所有组件
	Tibet.Initial=function(){
		Tibet.Emails.show();
		Tibet.Others.fixTibetIco();
		Tibet.Others.Flikebox();
		Tibet.Others.MsnSkype();
		Tibet.Others.FootLogo();
		//$("div.msnSkype").html('');
	};
	
	//显示email
	Tibet.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);
				}); 
		}
	};
	Tibet.Fun={
		CheckEmail:function (alertTxt,obj)
		{
			var temp = $('#'+obj);
			//var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
			//var myreg = /^[-_A-Za-z0-9\.]+@([_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/;
			var myreg = /^[^.]+@([^.]+\.)+[^.]{2,3}$/;
			if(temp.val()!="")	
			{	
				var str=temp.val();
				if(! ( str.indexOf("@")!=-1 && str.indexOf(".")!=-1 ) )
				{
					alert(alertTxt);
					temp.focus();
					return false;
				}
				else
					return true;
			}
			else
			{
					alert(alertTxt);
					temp.focus();
					return false;	
			}
		}	
	};
	
	Tibet.Others={
		//内容区的小图标去掉margin
		fixTibetIco:function(){
			$("#content img").each(function(){
				if ($(this).width()<50)
				{
					$(this).css({"margin":"0px"});
				}
			});
		}
		,
		Flikebox:function(){
		}
		,
		MsnSkype:function(){
			
			$("#msnSkype").load("/com/js/msn/msn.htm");
			
			
		},
		FootLogo:function(){
			if( $("div.footer")[0] )
				
			{	

				var $imgAll=$("div.footer img");
				var N=$imgAll.length-1;
				if($($imgAll.get(N)).attr("src")!="/images/logo/cats.gif")
				return false;
				
				$($imgAll.get(N)).after('<img src="/images/logo/asta.png" alt="">');
			}
		}
	};
	
	
	$(function(){
		Tibet.Initial();  
	});

//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")
		);
	}
})();

