﻿//that support for Mozilla innerText
try{
	HTMLElement.prototype.__defineGetter__
	(
	"innerText",
	function ()
	{
		var anyString = "";

		var childS = this.childNodes;
			for(var i=0; i<childS.length; i++)
			{
				if(childS[i].nodeType==1)
				anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText;
				else if(childS[i].nodeType==3)
				anyString += childS[i].nodeValue;
			}
			return anyString;
	}
	); 
}
catch(e){}

//IE is to determine whether
function isIE(){
	if (navigator.appName!="Microsoft Internet Explorer") {return false}
	return true
}
//Open a new window
function popnew(url,title,width,height){
    var w = 1024;
    var h = 768;

    if (document.all || document.layers){
        w = screen.availWidth;
        h = screen.availHeight;
    }

    var leftPos = (w/2-width/2);
    var topPos = (h/2.3-height/2.3);

    window.open(url,title,"width="+width+",height="+height+",top="+topPos+",left="+leftPos+",scrollbars=no,resizable=no,status=no")
}

function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} //End While
	return strTemp;

} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";
	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
			}
			else{
				strTemp = VALUE.substring(iTemp,v_length);
				break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function


function CheckPost(){
  try{
	if (Trim(document.forms[0].title.value)=="") {
		 alert("Title can not be empty, please write the title of the log!")
		 document.forms[0].title.focus()
		 return false
		}
	}
  catch(e){}

  try{
    if (document.getElementById("P2").checked) {
    	if (!CheckDate(document.forms[0].PubTime.value)){
    	   alert("Date format is not correct! \n format:yyyy-mm-dd hh:mm:ss")	
		   return false
    	}
    	else
    	{
	    	document.forms[0].PubTime.value=CheckDate(document.forms[0].PubTime.value)
    	}
    }
  }
  catch(e){}

  try{
	var oEditor = FCKeditorAPI.GetInstance('Message') ;
	var iLength = oEditor.GetXHTML( true ).length;
	if (iLength==0){
		 alert("The content can not be empty!")
		 oEditor.Focus();
		 return false
	}
	if (iLength<20){
		 alert("Not the number of content!")
		 oEditor.Focus();
		 return false
	}
  }
  catch(e){}
  
   try{document.forms[0].SaveArticle.disabled=true}catch(e){}
   try{document.forms[0].SaveDraft.disabled=true}catch(e){}
   try{document.forms[0].ReturnButton.disabled=true}catch(e){}
   try{document.forms[0].CancelEdit.disabled=true}catch(e){e}
   try{document.forms[0].DelArticle.disabled=true}catch(e){}
return true
}

   function CheckDate(str){
        var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/; 
        var r = str.match(reg); 
        if(r==null)return false; 
        var d= new Date(r[1],r[3]-1,r[4],r[5],r[6],r[7]); 
        return (d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds());
   }

//Quote
function addQuote(usr,content){
	try{
	//if (document.getElementById("editorbody").style.display=="none") showUBB("Message");
    document.forms["ajax_post"].Message.value="[quote="+usr+"]"+document.getElementById(content).innerText+"[/quote]"
	document.forms["ajax_post"].Message.focus();
	}catch(e){}
}

//Insert the annex to upload
function addUploadItem(type,path){
    var Uppath=path//Check the relative path
	try{
	  var oEditor = window.parent.FCKeditorAPI.GetInstance('Message')
	  var hrefLen=location.href.lastIndexOf("/")
      var Fhref=location.href.substr(0,hrefLen+1)
	  path=Fhref+path //Coupled with an absolute path
	}
	catch(e){}
	type=type.toLowerCase()
 	 switch(type){
 	  case 'gif':
		oEditor.InsertHtml('<img src="'+path+'" />')
 	  	break;
 	  case 'jpg':
		oEditor.InsertHtml('<img src="'+path+'" />')
 	  	break;
 	  case 'png':
        oEditor.InsertHtml('<img src="'+path+'" />')
 	  	break;
 	  case 'bmp':
        oEditor.InsertHtml('<img src="'+path+'" />')
 	  	break;
 	  case 'jpeg':
        oEditor.InsertHtml('<img src="'+path+'" />')
 	  	break;
 	  default :
        oEditor.InsertHtml('<a href="'+path+'"><img border="0" src="../../images/download.gif" style="margin:0px 2px -4px 0px"/>Click to download this file</a>')
        break;
     }
	 parent.parent.AddItem(Uppath);
}
//Included in the picture
function showbigimage(img,url){ 
document.getElementById(img).src=url; 
return 1; 
}
//Copy the text
function copyToClipboard(txt) {
     if(window.clipboardData) {
             window.clipboardData.clearData();
             window.clipboardData.setData("Text", txt);
     } else if(navigator.userAgent.indexOf("Opera") != -1) {
          window.location = txt;
     } else if (window.netscape) {
          try {
               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
          } catch (e) {
               alert("You use the FF browser, copy the function of the browser refused to be! \n in the browser address bar the importation of'about:config'And enter \n and then'signed.applets.codebase_principal_support'Set to'true'");
          }
          var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
          if (!clip)
               return;
          var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
          if (!trans)
               return;
          trans.addDataFlavor('text/unicode');
          var str = new Object();
          var len = new Object();
          var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
          var copytext = txt;
          str.data = copytext;
          trans.setTransferData("text/unicode",str,copytext.length*2);
          var clipid = Components.interfaces.nsIClipboard;
          if (!clip)
               return false;
          clip.setData(trans,null,clipid.kGlobalClipboard);
     }
	 document.getElementById("copy_ok").innerHTML='The page address of the picture phone has been copied!'
}
//Add to Favorites
function addfavorite()
{
   if (document.all)
   {
      window.external.addFavorite('http://www.memobilepark.com/','Mobile phone wallpaper memobilepark.com');
   }
   else if (window.sidebar)
   {
      window.sidebar.addPanel('Mobile phone wallpaper memobilepark.com','http://www.memobilepark.com/',"");
   }
} 

//---------------------------------------------------------------------------
function G(obj){
	return document.getElementById(obj);
}
//读取流览数
function views(id,viewpage){
var xmlhttp;
try{
	xmlhttp=new XMLHttpRequest();
	}
catch(e){
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4){
	if (xmlhttp.status==200){
		var data=xmlhttp.responseText.split("||");
		view_result(id,data[0]);
		}
	else{
		G("view"+id).innerHTML="";//Validation error return values
		}
	}
else{
	G("view"+id).innerHTML='<img src="/images/loading16.gif" />';//Loading ...
	}
}
xmlhttp.open("post", "/view.asp", true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.send("id="+escape(id)+"&viewpage="+escape(viewpage)+"&action=view");
}
function view_result(id,data1){
	G("view"+id).innerHTML=data1;
}

//Dig Operation content
function dig(id){
var digs=G("digs"+id).innerHTML
var xmlhttp;
try{
	xmlhttp=new XMLHttpRequest();
	}
catch(e){
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4){
	if (xmlhttp.status==200){
		var data=xmlhttp.responseText;
		G("digs"+id).innerHTML=data;
		}
	else{
		G("digs"+id).innerHTML=digs;//The verification process is a mistake to return to the original data
		}
	}
else{
	G("digs"+id).innerHTML='<img src="/images/loading16.gif" />';//Loading ...
	}
}
xmlhttp.open("post", "/view.asp", true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.send("id="+escape(id)+"&action=dig");
}

//Read the user
function user(id){
var xmlhttp;
try{
	xmlhttp=new XMLHttpRequest();
	}
catch(e){
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4){
	if (xmlhttp.status==200){
		var data=xmlhttp.responseText;
		user_result(id,data);
		}
	else{
		G("login").innerHTML="";//Validation error return values
		}
	}
else{
	G("login").innerHTML='<img src="/images/loading24.gif" />';//Loading ...
	}
}
xmlhttp.open("post", "/checklogin.asp", true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.send("id="+escape(id));
}
function user_result(id,data){
	G("login").innerHTML=data;
}