//电子邮件格式判断
function chk_email(email){
  invalid = "";
  if (!email){}
  //invalid = "请输入您的Email地址。";
  else {
    if ( (email.indexOf("@") == -1) || (email.indexOf(".") == -1) )
    invalid = "error";
    if (email.indexOf("your email here") > -1)
    invalid = "error";
    if (email.indexOf("\\") > -1)
    invalid = "error";
    if (email.indexOf("/") > -1)
    invalid = "error";
    if (email.indexOf("'") > -1)
    invalid = "error";
    if (email.indexOf("!") > -1)
    invalid = "error";
    if ( (email.indexOf(",") > -1) || (email.indexOf(";") > -1) )
    invalid = "error";
    if (email.indexOf("?subject") > -1)
    invalid = "error";
  }
  if (invalid == ""){
    return true;
  }else{
    return false;
  }
}

//是否日期判断
function isDateString(sDate)
{    var iaMonthDays = [31,28,31,30,31,30,31,31,30,31,30,31]
    var iaDate = new Array(3)
    var year, month, day

    if (arguments.length != 1) return false
    iaDate = sDate.toString().split("-")
    if (iaDate.length != 3) return false
    if (iaDate[1].length > 2 || iaDate[2].length > 2) return false

    year = parseFloat(iaDate[0])
    month = parseFloat(iaDate[1])
    day=parseFloat(iaDate[2])

    if (year < 1900 || year > 2100) return false
    if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) iaMonthDays[1]=29;
    if (month < 1 || month > 12) return false
    if (day < 1 || day > iaMonthDays[month - 1]) return false
    return true
} 

//文章内容字体大小变换
function Do_Article_Zoom(size){
	document.getElementById('content').style.fontSize=size+'px';
}

//检查内容有无单引号和双引号
function check_yh(str){
	str=str.replace(/(^\s*)|(\s*$)/g,"");
	if (str.indexOf("'")>=0 || str.indexOf('"')>=0 || str.indexOf('|')>=0 || str.indexOf('#')>=0)
	{
	alert("不能输入半角的单引号,双引号及一些特殊字符，系统将自动转换!");
	str=str.replace(/'/g,'’');
	str=str.replace(/"/g,'”');
	str=str.replace(/\|/g,'');
	str=str.replace(/#/g,'');
	}
	return str
}

//检查内容有无非法内容
function str_filter(str){
//InvaildWords为需要查找的字符串,以“|”隔开,英文为小写字母，true 为包含非法字符
	var my_friends ="广告|销售|产品|色情|fuck|脱衣|奶子|操你|免费电影|二手|商务|赚钱|管理员";
	var friend_array =my_friends.split("|");
	var have=false;
	str=str.replace(/\s+/g,"");
	for (loop=0; loop < friend_array.length;loop++)
	{
		if (str.indexOf(friend_array[loop]) >= 0)
		{
			have=true;
		}
	}
	if (have==true)
	{
		return true;
	}
	else
	{
		return false;
	}
}

//检查内容有无sql注入语句
function check_sqlin(str){
//InvaildWords为需要查找的字符串,以“|”隔开,英文为小写字母，true 为包含非法字符
	var my_friends ="url|http|script|object|applet|[|]|=|select|execute|exec|join|union|where|insert|delete|update|like |drop|create|rename|count|asc(|chr(|mid(|truncate|nchar|char(|alter|cast|exists|and |or |from|netlocalgroup|administrators|net user|.asp'";
	var friend_array =my_friends.split("|");
	var have=false;
	str=str.toLowerCase();
	for (loop=0; loop < friend_array.length;loop++)
	{
		if (str.indexOf(friend_array[loop]) >= 0)
		{
			have=true;
		}
	}
	if (have==true)
	{
		return true;
	}
	else
	{
		return false;
	}
}


//显示是否要删除对话框
function ConfirmDel()
{
   if(confirm("确定要删除吗？"))
     return true;
   else
     return false;
}

//禁止复制网页上的内容
function click() {
return false;}
function click1(){if (event.button==2) {return false; }}
function CtrlKeyDown(){
 if (event.keyCode==67&&event.ctrlKey)
 {
  clipboardData.setData('text','');
  return false; 
 }
}
//document.onkeydown=CtrlKeyDown;
//document.onselectstart=click;
//document.onmousedown=click1;

if (window.Event) 
document.captureEvents(Event.MOUSEUP); 
function nocontextmenu(){ 
 event.cancelBubble = true 
 event.returnValue = false; 
 return false; 
} 
function norightclick(e){ 
if (window.Event){
 if (e.which == 2 || e.which == 3)
 return false;
} 
else if (event.button == 2 || event.button == 3)
{
 event.cancelBubble = true;
 event.returnValue = false;return false;} 
} 
//document.oncontextmenu = nocontextmenu; // for IE5+ 
//document.onmousedown = norightclick; // for all others 

//拷贝字符串
function copyStr (str)
{
	clipboardData.setData('Text',str);
	alert ("“"+str+"”\n已经复制到您的剪贴板中\n您可以使用Ctrl+V快捷键粘贴到需要的地方");
}

//收藏网址
function addFavor(str1,str2)
{
window.external.addFavorite(str1,str2);
}

//打开隐藏窗口
function openhtml(thelocation)
{
window.open(thelocation,"","height=0,width=0,top=-100,left=-100,toolbar=no,menubar=no,scrollbars=no,resizable=on,location=no,status=no")
}  

//实现网页内锚点(Anchor)间平滑跳转
function intval(v)
{
v = parseInt(v);
return isNaN(v) ? 0 : v;
}
function getPos(e)// 获取元素信息
{
var l = 0;
var t  = 0;
var w = intval(e.style.width);
var h = intval(e.style.height);
var wb = e.offsetWidth;
var hb = e.offsetHeight;
while (e.offsetParent){
l += e.offsetLeft + (e.currentStyle?intval(e.currentStyle.borderLeftWidth):0);
t += e.offsetTop  + (e.currentStyle?intval(e.currentStyle.borderTopWidth):0);
e = e.offsetParent;
}
l += e.offsetLeft + (e.currentStyle?intval(e.currentStyle.borderLeftWidth):0);
t  += e.offsetTop  + (e.currentStyle?intval(e.currentStyle.borderTopWidth):0);
return {x:l, y:t, w:w, h:h, wb:wb, hb:hb};
}
function getScroll()// 获取滚动条信息
{
var t, l, w, h;
if (document.documentElement && document.documentElement.scrollTop) {
t = document.documentElement.scrollTop;
l = document.documentElement.scrollLeft;
w = document.documentElement.scrollWidth;
h = document.documentElement.scrollHeight;
} else if (document.body) {
t = document.body.scrollTop;
l = document.body.scrollLeft;
w = document.body.scrollWidth;
h = document.body.scrollHeight;
}
return { t: t, l: l, w: w, h: h };
}
function scroller(el, duration)// 锚点(Anchor)间平滑跳转
{
if(typeof el != 'object') { el = document.getElementById(el); }
if(!el) return;
var z = this;
z.el = el;
z.p = getPos(el);
z.s = getScroll();
z.clear = function(){window.clearInterval(z.timer);z.timer=null};
z.t=(new Date).getTime();
z.step = function(){
var t = (new Date).getTime();
var p = (t - z.t) / duration;
if (t >= duration + z.t) {
z.clear();
window.setTimeout(function(){z.scroll(z.p.y, z.p.x)},13);
} else {
st = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.y-z.s.t) + z.s.t;
sl = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.x-z.s.l) + z.s.l;
z.scroll(st, sl);
}
};
z.scroll = function (t, l){window.scrollTo(l, t)};
z.timer = window.setInterval(function(){z.step();},13);
}

//改变省市县选下拉列表择框中的市选择框
function changeShi(locationid,locationid1)
{ 
        document.form1.shi.length = 1;
        var locationid=locationid;
        var i,j;
		j=1;
        for(i=0; i < onecount; i++)
        {
                if(subcat[i][2] == locationid)
                {
					if (i==0 || (i>0 &&subcat[i][1] !=subcat[i-1][1]))
					{ 
						document.form1.shi.options[document.form1.shi.length] = new Option(subcat[i][4],subcat[i][1]);
						if (subcat[i][1] == locationid1)
						{
							document.form1.shi.selectedIndex = j;
						}
					j++;
					}
                }
        }
}

//改变省市县选下拉列表择框中的县选择框
function changeXian(locationid,locationid1)
{ 
        document.form1.xian.length = 1;
        var locationid=locationid;
        var i,j;
		j=1;
        for(i=0; i < onecount; i++)
        {
                if(subcat[i][1] == locationid)
                {
                        document.form1.xian.options[document.form1.xian.length] = new Option(subcat[i][3],subcat[i][0]);
						if (subcat[i][0] == locationid1)
						{
							document.form1.xian.selectedIndex = j;
						}
					j++;
                }
        }
}
