﻿/*判断输入是否为合法的电话号码*/
function isphone(instr)
{
	if('' == instr)
		return false;
    chars="0123456789( )-,;";
    tf= true;
    for (i=0;i<instr.length;i++)
    {
        ch = instr.charAt(i);
        if (chars.indexOf(ch)==-1)
        {
            tf=false;
            break;
        }
    }
    return tf;
}


// 通用函数

// $id() 通过对象id来得到对象句柄
// 不直接用 $ 作为函数名的原因是不想与 jQuery 冲突。
function $id(n)
{
	var obj;
	if(document.all)
		obj = document.all[n];
	else
		obj = document.getElementById(n);

	return obj;
}


// 附加事件回调函数到一个对象上
// 例如 AttachEvent('load', window, OnPageLoaded)
function AttachEvent(type, target, handler)
{
	if(window.document.all)
	{
		target.attachEvent("on" + type, handler );//ie
	}
	else
	{
		target.addEventListener(type, handler, false);//firefox
	}
}

function DetachEvent(type, target, handler)
{
	if(window.document.all)
	{
		target.detachEvent("on" + type, handler );//ie
	}
	else
	{
		target.removeEventListener(type, handler, false);//firefox
	}
}

function redirect(url)
{
var phpcms_path = './';
	if(url.indexOf('://') == -1 && url.substr(0, 1) != '/' && url.substr(0, 1) != '?') url = phpcms_path+url;
	location.href = url;
}