function $( id ){return document.getElementById( id );}
function Trim(str) 
{ 
	return str.replace(/(^\s*)|(\s*$)/g,""); 
}
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 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 egrMobileCheck(in_mobile)
{
  reg=/^[0]?(13|15)\d{9}$/gi;
  if(!reg.test(in_mobile))
  {
  	return false;
  }
  return true;
}
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); 
} 

