function $( id ){return document.getElementById( id );}

/* 去前后空格 */
function Trim(str) 
{ 
	return str.replace(/(^\s*)|(\s*$)/g,""); 
}

/* 手机校验 */
function egrMobileCheck(in_mobile)
{
  reg=/^[0]?(13|15|18)\d{9}$/gi;
  if(!reg.test(in_mobile))
  {
  	return false;
  }
  return true;
}

//邮件校验
function checkMail(in_email)
{
	reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

  if(!(reg.test(in_email))){
     
   return false;
  }
  return true;
}


var tempObj;
function fEvent(sType,oInput){
	switch (sType){
		case "focus" :
			oInput.isfocus = true;
		case "mouseover" :
			oInput.style.borderColor = '#9ecc00';
			break;
		case "select":
			oInput.select();
			oInput.isfocus = true;
			break;
		case "blur" :
			oInput.isfocus = false;
		case "mouseout" :
			if(!oInput.isfocus){
				oInput.style.borderColor='#C2C2C2';
			}
		break;
	}
}


function SetAllInput(){
	var temp,tempValue=null;
    tempObj = document.getElementsByTagName("INPUT");
	for(var i=0; i<tempObj.length; i++)
	{
		if(tempObj[i].type=="text")
		{
			if(tempObj[i].onfocus == null)
			{	
				tempValue = tempObj[i].value;
				tempObj[i].onfocus = new Function("fEvent('focus',tempObj["+i+"])");
			}
				
			if(tempObj[i].onblur == null)
				tempObj[i].onblur = new Function("fEvent('blur',tempObj["+i+"])");				

				
			if(tempObj[i].onmouseover == null)
				tempObj[i].onmouseover = new Function("fEvent('mouseover',tempObj["+i+"])");
			if(tempObj[i].onmouseout == null)
				tempObj[i].onmouseout = new Function("fEvent('mouseout',tempObj["+i+"])");
			if(tempObj[i].onclick == null)
				tempObj[i].onclick = new Function("tempObj["+i+"].select();");
			
			if(tempObj[i].onchange == null){
				if(tempValue != null)
					tempObj[i].onchange = new Function("if(tempObj["+i+"].value!='"+tempValue+"') {tempObj["+i+"].style.color='#333333';}else{tempObj["+i+"].style.color='#666666';}");		
			}
				

		} 
		
	}
	

}

function SetUserInput(){
	var temp,tempValue=null;
    tempObj = document.getElementsByTagName("INPUT");
	for(var i=0; i<tempObj.length; i++)
	{
		if(tempObj[i].type=="text")
		{
			if(tempObj[i].onfocus == null)
			{	
				tempValue = tempObj[i].value;
				tempObj[i].onfocus = new Function("fEvent('focus',tempObj["+i+"])");
			}
				
			if(tempObj[i].onblur == null)
				tempObj[i].onblur = new Function("fEvent('blur',tempObj["+i+"])");				

				
			if(tempObj[i].onmouseover == null)
				tempObj[i].onmouseover = new Function("fEvent('mouseover',tempObj["+i+"])");
			if(tempObj[i].onmouseout == null)
				tempObj[i].onmouseout = new Function("fEvent('mouseout',tempObj["+i+"])");
			if(tempObj[i].onclick == null)
				tempObj[i].onclick = new Function("tempObj["+i+"].focus();");
			
			if(tempObj[i].onchange == null){
				if(tempValue != null)
					tempObj[i].onchange = new Function("if(tempObj["+i+"].value!='"+tempValue+"') {tempObj["+i+"].style.color='#333333';}else{tempObj["+i+"].style.color='#666666';}");		
			}
				

		} 
		
	}
	

}

function CheckInputSearchForaddform(){
//请输入想查询的关键字
	if(Trim(document.addform.keyword.value)=="" || Trim(document.addform.keyword.value)=="请输入关键字" || Trim(document.addform.keyword.value)=="请输入想查询的关键字")
	{
		alert("请输入想查询的关键字");
		document.addform.keyword.select();
		return false;
	}
	document.addform.submit();
	return false;
}

function CheckInputSearchAddFormFoot(){
//请输入想查询的关键字
	if(Trim(document.addformFoot.keyword.value)=="" || Trim(document.addformFoot.keyword.value)=="请输入想查询的关键字")
	{
		alert("请输入想查询的关键字");
		document.addformFoot.keyword.select();
		return false;
	}
	document.addformFoot.submit();
	return false;
}



function CheckInputSearchForTimeForm(){
	if(Trim(document.complexform.dest.value)=="" || Trim(document.complexform.dest.value)=="中文/拼音")
	{
		alert("请输入想查询的目的地");
		document.complexform.dest.select();
		return false;
	}
	document.complexform.submit();
	return false;

}

function DisplayDate()
{
    var now = new Date();          //当前时间

	function getThisMonth()        //这个月日期
	{
	    return now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate();
	}

	function getNextMonth()       //下个月日期
    {  
        var d=new Date(now.getFullYear(),now.getMonth()+1,now.getDate());
		return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
    }
	document.getElementById('dateA').value=getThisMonth();
	document.getElementById('dateB').value=getNextMonth();
}

/*
var newSS=document.createElement('link');
newSS.rel='icon';
newSS.type='image/x-icon';
newSS.href=escape("/images/favicon.ico");
newSS.href=escape("http://www.google.cn/favicon.ico");
document.getElementsByTagName("head")[0].appendChild(newSS);
newSS.rel='shortcut icon';
document.getElementsByTagName("head")[0].appendChild(newSS);
newSS.rel='Bookmark';
document.getElementsByTagName("head")[0].appendChild(newSS);
*/

/* 加入收藏夹 */

function setHome(title, url) {   
    if(!title) {   
        var title = window.document.title;   
    }   
    if(!url) {   
        var url = window.document.location;   
    }   
    try{   
        if (document.all){    
            window.external.addFavorite(url,title);    
        } else if (window.sidebar) {    
            window.sidebar.addPanel(title, url,"");    
        }    
    }catch(e){};   
}


/*
function setHome(title, url) {
	var title="蓝途旅游网";
	var url= "http://www.landtu.com";
	if (window.sidebar) window.sidebar.addPanel(title, url,"");
	else if( window.opera && window.print ){
		var mbm = document.createElement('a');
		mbm.setAttribute('rel','sidebar');
		mbm.setAttribute('href',url);
		mbm.setAttribute('title',title);
		mbm.click();
	}
	else if( document.all ) window.external.addFavorite(url,title);
} 
*/



var lastScrollY=0; 
function heartBeat(){  
var diffY; 
if (document.documentElement && document.documentElement.scrollTop) 
    diffY = document.documentElement.scrollTop; 
else if (document.body) 
    diffY = document.body.scrollTop 
else 
    {/*Netscape stuff*/} 
     
//alert(diffY); 
percent=.1*(diffY-lastScrollY);  
if(percent>0)percent=Math.ceil(percent);  
else percent=Math.floor(percent);  
document.getElementById("lovexin12").style.top=parseInt(document.getElementById ("lovexin12").style.top)+percent+"px"; 
document.getElementById("lovexin14").style.top=parseInt(document.getElementById ("lovexin12").style.top)+percent+"px"; 
lastScrollY=lastScrollY+percent;  
//alert(lastScrollY); 
} 
function ShowOnlineQQ(){
	suspendcode12="<DIV id=\"lovexin12\" style='z-index:999;right:5px;POSITION:absolute;TOP:280px;'><a href=tencent://message/?uin=706287008&Site=蓝途旅游网&Menu=yes target=blank title='点击与蓝途旅游网客服人员交谈'><img border=0 src=/images/qq.gif ></a></div>" 
	suspendcode14="<DIV id=\"lovexin14\" style='right:5px;POSITION:absolute;TOP:120px;'></div>" 
	document.write(suspendcode12);  
	document.write(suspendcode14);  
	window.setInterval("heartBeat()",1); 
}


var abroad = 1;
var around = 3;
var domestic = 2;
var vacation = 6;
var hongkong = 4;
var visa = 5;
var company = 6;
var destination = 7;
var vacation = -1;


/*
	使用的ajxa方法统一， 可重复使用
		_url  传递的url地址
		_method 使用方法 post or get 暂时支持 get
		_send 发送的内容 如 a=1&b=2 urlencode
		returnfuc 完成后调用的方法， 一个参数 返回的字符串
	
*/


function axajObj(){
	this.xmlHttpObj = null;
	this.returnFuc = function(val){};
}


axjaReturnFuc = function(value){}
axajSend = function( _url, _method, _send, returnFuc ){
	if(!returnFuc)
		returnFuc = axjaReturnFuc;
	var xmlHttpObj;
    if(window.ActiveXObject){
        xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
    }else if(window.XMLHttpRequest){
        xmlHttpObj = new XMLHttpRequest();
    }
    try{
        xmlHttpObj.onreadystatechange = function(){
			if(xmlHttpObj.readyState == 4)
			{            
				if (xmlHttpObj.status == 200 )
				{
					returnFuc( xmlHttpObj.responseText );
				}
			}	
		};
       	xmlHttpObj.open(_method, _url, true);
       	xmlHttpObj.send(_send);
    }catch(exception){
        alert("xmlHttp Fail");
    }
	return;	
}



locationSetting = function(){
	var url = escape(window.location.href.toString());
	var referrer = escape(document.referrer);
	if(referrer==""){
		return;
	}

	var patrn1=/\.(baidu|google)\./gi; 
	if ( patrn1.test(referrer) ){
		var urlString = "referrer="+referrer+"&url="+url;
		//axajSend( "/PageStatistics/record.php?"+urlString, "GET", "" );
		var div = null;
		div = document.createElement("div");
		div.style.display = "none";
		div.innerHTML = '<iframe MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no src=/PageStatistics/record.php?'+urlString+' height=0 width=0></iframe>';
		document.body.appendChild(div);
	}
	return;
}


function HtmlInitFuc(fuc){
	if(window.document.all){
		window.attachEvent("onload" ,
			function(e){
				fuc();
			}
		);
	}else{
		window.addEventListener("load",
			function(e){
				fuc();
			},
			false
		);
	}	
	return;
}

HtmlInitFuc(locationSetting);
