﻿if (top.location != location)
top.location.href = self.location;

window.onerror = function(){   
 return true;   
}

//document
function $(o){
 var o=document.getElementById(o)?document.getElementById(o):o;
 return o;
}

//去空格Trim
function   
String.prototype.Trim()   
{return   this.replace(/(^\s*)|(\s*$)/g,"");}    
 function   String.prototype.Ltrim()
{return   this.replace(/(^\s*)/g,   "");}     
function   String.prototype.Rtrim()
{return   this.replace(/(\s*$)/g,   "");}


//层拖动
//在div中加入  onselectstart="return false" onmousedown="move_obj=this" onmouseup="move_obj=null"
var move_obj = null;
document.onmousemove = function(){
 if(move_obj==null)return;
 move_obj.style.top=event.y-move_obj.offsetHeight/2;
 move_obj.style.left=event.x-move_obj.offsetWidth/2;
}

//判断输入数字
function IsNumeric(port){
  var pattern=/^\d+$/;
  if(!pattern.test(port))
  return false;
  return true;
}

//全选脚本
function unselectall()
{
    if(document.myform.chkAll.checked){
	document.myform.chkAll.checked = document.myform.chkAll.checked&0;
    } 	
}

function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.Name != "chkAll"&&e.disabled==false)
       e.checked = form.chkAll.checked;
    }
  }

//左邊高度自適應
window.onload=function(){
l=le_height.offsetHeight-160;
re_height.height=l;
}

function showmenu(divname,divstatus){  
if(divstatus==1){
divname.style.display="block";
}else{
divname.style.display="none";
}
}

//项目策划
function showpr(id){
if($("pr_"+id).className=="closed"){
$("pr_"+id).className="opend";
$("prImg_"+id).src="images/up.gif";
$("prImg_"+id).alt="查看缩略";
$("prText_"+id).innerText="查看缩略";
}else{
$("pr_"+id).className="closed";
$("prImg_"+id).src="images/down.gif";
$("prImg_"+id).alt="查看详细";
$("prText_"+id).innerText="查看详细";
}
}

//客户登录
function checklogin(){
    alert("客户管理系统即将上线！\n通过本系统，随时随地对您的项目信息进行监控，并随时提出修改意见和信息反馈！");
	return false;
} 

function CheckIfEnglish( String )
{ 
    var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-";
    var i;
    var c;
    if(String.charAt( 0 )=='-')
	  return false;
    if( String.charAt( String.length - 1 ) == '-' )
      return false;
    for( i = 0; i < String.length; i ++ )
    {
        c = String.charAt( i );
	    if (Letters.indexOf( c ) < 0)  return false;
    }
    return true;
}

function CheckIfChinese( String )
{ 
     var Letters = "`=~!@#$%^&*()_+[]{}\\|/?.>,<;:'\"";
     var i;
     var c;
     for( i = 0; i < String.length; i ++ )
     {
         c = String.charAt( i );
	     if (Letters.indexOf( c ) >= 0)
	       return false;
     }
     return true;
}

function CheckIfSpace(String)
{
	 var i;
     for( i = 0; i < String.length; i ++ )
     {
	 	  if(String.charAt(i) == ' ')
		   	 return true;
     }
     return false;
}

//通用网址合法检测
function checkcnadd(theform) 
{

	if (theform.domain.value == "") 
	{
		alert("请输入您要查询中文域名！");
		theform.domain.focus();
		return false;
	}

	if (! CheckIfChinese(theform.domain.value)) 
	{
		alert("中文域名不能包含特殊字符！");
		theform.domain.focus();
		return false;
	}

	if (CheckIfSpace(theform.domain.value)) 
	{
		alert("中文域名不能包含空格！");
		theform.domain.focus();
		return false;
	}
	return true;
}


//英文域名合法检测
function checken(theform)
{	
     if (document.checkdomain.domain.value.length==0) 
	 {
		alert("请输入您要查询的英文域名！");
		document.checkdomain.domain.focus();
     	return false;
     }	
	     ii=0;
     bString="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-";
    
	 while (ii<document.checkdomain.domain.value.length) 
	 {
		if (bString.indexOf(document.checkdomain.domain.value.substring(ii,ii+1))==-1) 
		{
			alert("英文域名不能包含特殊字符！");
			document.checkdomain.domain.focus();
			return false;
		}
		ii=ii+1;
     }
	
     return true;
}


//中文域名合法检测
function checkcn(theform) 
{

	if (theform.domain.value == "") 
	{
		alert("请输入您要查询的中文域名！");
		theform.domain.focus();
		return false;
	}

	if (! CheckIfChinese(theform.domain.value)) 
	{
		alert("中文域名不能包含特殊字符！");
		theform.domain.focus();
		return false;
	}

	if (CheckIfSpace(theform.domain.value)) 
	{
		alert("中文域名不能包含空格！");
		theform.domain.focus();
		return false;
	}
	
	if (CheckIfEnglish(theform.domain.value)) 
	{
		alert("中文域名不能全为英文！");
		theform.domain.focus();
		return false;
	}
	
	return true;
}