/**
 * 去掉url前面的http://|https://
 */
removeHttp = function(url){
	return url.replace(/^[hH]{1}[tT]{2}[pP]{1}[sS]{0,1}:\/\//, '');
}

needSumbmitForm = function(value){
	return (value.indexOf("#")!=-1 || value.indexOf("?")!=-1 || value.indexOf("%")!=-1);	
}

mainDomain = function(url){
	if (needSumbmitForm(url))
		return document.location = "/ip?"+encodeURIComponent(url);
	document.location = "/ip/"+url;
}

mainWhois = function(url){
	if (needSumbmitForm(url))
		return document.location = "/whois?"+encodeURIComponent(url);
	document.location = "/whois/"+url;
}


mainAlexa = function(url){
	if (needSumbmitForm(url))
		return document.location = "/alexa?"+encodeURIComponent(url);
	document.location = "/alexa/"+url;
}

getDomain = function(url){
	if (needSumbmitForm(url))	return true;
		
	document.location = "/ip/"+url;
	return false;
	
}

whois = function(url){
	if (needSumbmitForm(url))	return true;
	
	document.location = "/whois/"+url;
	return false;
}

meta = function(url){
	if (needSumbmitForm(url))	return true;
	
	document.location = "/meta/"+url;
	return false;
}

alexa = function(url){
	if (needSumbmitForm(url))	return true;
	
	document.location = "/alexa/"+url;
	return false;
}

embody = function(url){
	if ($('loadmsg'))	$('loadmsg').setStyle('display', '');
	
	if (needSumbmitForm(url))	return true;
	
	document.location = "/embody/"+url;
	return false;
}

inlinks = function(url){
	if ($('loadmsg'))	$('loadmsg').setStyle('display', '');
	
	if (needSumbmitForm(url))	return true;
	
	document.location = "/links/"+url;
	return false;
}

ascii = function (str){
	var result = '请输入要转换为ascii码的字符！'
	if(str && str.length>0)
		result = '字符：'+str.charAt(0)+' 的ASCII码为：'+str.charCodeAt(0);
	
	alert(result);
} 

/**
 * 注册菜单效果
 */
navigationEffect = function(){
	var lis = $$('#nav02 ul li');
	lis.addEvent('mouseenter', function(){
		this.addClass('on');
	});
	lis.addEvent('mouseleave', function(){
		this.removeClass('on');
	});
}

window.addEvent('domready', function(){
	navigationEffect();
});
