



//open email
function openEmail(name)
{
	window.location = "mailto:" + name + "@qianlidao.com";
}

 
// Browser Detection
isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
NS4 = (document.layers) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IE4plus = (document.all) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
ver4 = (NS4 || IE4plus) ? true : false;
NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;

// Body onload utility (supports multiple onload functions)
var gSafeOnload = new Array();
function SafeAddOnload(f)
{
	if (IEmac && IE4)  // IE 4.5 blows out on testing window.onload
	{
		window.onload = SafeOnload;
		gSafeOnload[gSafeOnload.length] = f;
	}
	else if  (window.onload)
	{
		if (window.onload != SafeOnload)
		{
			gSafeOnload[0] = window.onload;
			window.onload = SafeOnload;
		}		
		gSafeOnload[gSafeOnload.length] = f;
	}
	else
		window.onload = f;
}

function SafeOnload()
{
	for (var i=0;i<gSafeOnload.length;i++)
		gSafeOnload[i]();
}

function validate(element, message)
{
	if(element.value == "")
	{
		__error(element, message);
		return false;
	}
	
	return true;
}

function validateHTMLArea(element, message)
{
	if(element.getHTML() == "")
	{
		__error(element, message);
		return false;
	}
	return true;
}

function validateEmail(element, message)
{
	if(!isValidEmail(element.value))
	{
		__error(element, message);
		return false;
	}
	
	return true;
}

function __error(element, message)
{
	window.alert(message);
	try
	{
		element.focus();
	}
	catch (e)
	{
		//do nothing
	}
}

function isValidEmail(emailAddress) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    return re.test(emailAddress);
}

function safeInitEditor()
{
	try
	{
		initEditor()
	}
	catch(exc)
	{
		var editor = null;
		window.setTimeout("safeInitEditor", 500);
	}
}
  