

var windowbrow=navigator.appName;
  var windowtype;
  if (windowbrow.indexOf("Netscape")!=-1)
  {
     windowtype=1;
     //alert("you are using Netscape(Mozilla) family browser,good!");
     }   
  if (windowbrow.indexOf("Microsoft")!=-1)
  {
     //isIE=1;
     windowtype=0;
     //alert("You are using Microsoft's Internet Explorer browser,Opps,shit!");
  }   

// retrieve XML document (reusable generic function);
// parameter is URL string (relative or complete) to
// an .xml file whose Content-Type is a valid XML
// type, such as text/xml; XML source must be from
// same domain as HTML file
function loadXMLDoc(url,tfunc,ffunc) {
	var req;

    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        //req.OnReadyStateChange = processReqChange(req);//,tfunc,ffunc);
        req.open("GET", url, false);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            //req.OnReadyStateChange = processReqChange(req);//,tfunc,ffunc);
            req.open("GET", url, false);
            req.send();
        }
    }
	return req;
}

// handle onreadystatechange event of req object
function processReqChange(req) { //,tfunc,ffunc) {
	// only if req shows "loaded"
	if (req.readyState == 4) {
		// only if "OK"
		if (req.status == 200) {
		//execScript(tfunc, "javascript")
		} else {
		// execScript(ffunc, "javascript")
		}
	}
}

function decode_utf8(utftext) {
    var plaintext = ""; var i=0; var c=c1=c2=0;
    while(i<utftext.length)
        {
        c = utftext.charCodeAt(i);
        if (c<128) {
            plaintext += String.fromCharCode(c);
            i++;}
        else if((c>191) && (c<224)) {
            c2 = utftext.charCodeAt(i+1);
            plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
            i+=2;}
        else {
            c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
            plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
            i+=3;}
        }
    return plaintext;
}
function setCookie(name,value,expiry,path,domain,secure){
	var nameString = name + '=' + escape(value);
	var expiryString = (expiry == null) ? '' : ' ;expires = '+ expiry.toGMTString();
	var pathString = (path == null) ? '' : ' ;path = '+ path;
	var domainString = (domain == null) ? '' : ' ;domain = '+ domain;
	var secureString = (secure) ?';secure':'';
	document.cookie = nameString + expiryString + pathString + domainString + secureString;
}
function getCookie() {
	if (arguments.length==2){

		var CookieFound = false;
		var CookieString = getCookie(arguments[0]);

		var aCookieString=CookieString.split('&');
		for (var i=0;i<aCookieString.length;i++){
			j=aCookieString[i].indexOf('=');
			if (arguments[1]==aCookieString[i].substring(0,j))
				return unescape(aCookieString[i].substr(j+1));
		}
	} else {
		var CookieFound = false;
		var CookieString = document.cookie;

		var aCookieString=CookieString.split('; ');
		for (var i=0;i<aCookieString.length;i++){
			j=aCookieString[i].indexOf('=');
			if (arguments[0]==aCookieString[i].substring(0,j))
				return unescape(aCookieString[i].substr(j+1));
		}
	}
	return '';
}
function deleteCookie(name){
	var expires = new Date();
	expires.setTime (expires.getTime() - 1);
	setCookie( name , "Delete Cookie", expires,null,null,false);
}
function urlencode_gb2utf8(rawtext) {
    rawtext = rawtext.replace(/\r\n/g,"\n");
    var utftext = "";
    for(var n=0; n<rawtext.length; n++)
        {
        //
        var c=rawtext.charCodeAt(n);
        // 0-127 => 1byte
        if (c<128)
            utftext += escape(String.fromCharCode(c));    
        // 127 - 2047 => 2byte
        else if((c>127) && (c<2048)) {
            utftext += escape(String.fromCharCode((c>>6)|192));
            utftext += escape(String.fromCharCode((c&63)|128));}
        // 2048 - 66536 => 3byte
        else {
            utftext += escape(String.fromCharCode((c>>12)|224));
            utftext += escape(String.fromCharCode(((c>>6)&63)|128));
            utftext += escape(String.fromCharCode((c&63)|128));}
        }
    return utftext;
}
//复制标题地址
function copyurl()      
{      
	   var clipBoardContent=document.title+"\r\n"+location.href;      
	   if (window.clipboardData){      
		  if(window.clipboardData.setData("Text",clipBoardContent)){      
			  document.getElementById('copyshow').innerHTML = ' <font color="green">复制成功</font>';
		  }      
	   }      
	   else{      
		  document.getElementById('copyshow').innerHTML = ' <font color="red">您使用的浏览器不支持此功能，请到地址栏复制链接</font>';      
	   }      

} 
//添加文章收藏
function bookmarkit(){
	window.external.addFavorite(location.href,document.title);
}
//文章挎贝时
document.body.oncopy = function () { 
  strWebUrl = new String("http://www.mmhao.com");
  var strMmhao = new String("www.mmhao.com");  
  var str2 = new String(location.href);
  rExp  = /<BR>/i;
  str1 = new String("\r\n本文来自: 美眉好减肥方法("+strMmhao.link(strWebUrl)+")");
  setTimeout( function () { 
  var text = getClipboard();
	if (text) { 
	  text = text + str1 + " \r\n详细出处参考："+str2; 
	  setClipboard(text);
	  
	} 
	}, 100 ) 
}


var refer=document.referrer;

if ((refer!='')&&((refer.indexOf('yoka.com')<0)||(refer.indexOf('yoka.com')>15))){
	for (var i=0;i<NeedPhotoUrl.length;i++)
	{
		if (window.location.href==NeedPhotoUrl[i])
		{
			window.open(OpenPhotoUrl[Math.round(Math.random()*(OpenPhotoUrl.length-1))],'YOKA','resizable=1,menubar=1,scrollbars=1,menubar＝1,width=1024,height=768,screenX=0,screenY=0');
			window.focus();
		}
	}
}
<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> -->
/**********************************************************
复制maintext到贴切板
***********************************************************/
function setClipboard(maintext) 
{
    if (window.clipboardData) 
    {
        return (window.clipboardData.setData("Text", maintext));
    } 
    else 
    {
        if (window.netscape) 
        {
            try{
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            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 = maintext;
            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);
            return true;
            }
            catch(e)
            {
                alert("您的firefox安全限制限制您进行剪贴板操作，请打开'about:config'将 signed.applets.codebase_principal_support'设置为true'之后重试，相对路径为firefox根目录 /greprefs/all.js");
                return false;
            }
        }
    }
    return false;
}
/**********************************************************
粘贴剪切板的内容
***********************************************************/
function getClipboard() 
{
    if (window.clipboardData) 
    {
        return (window.clipboardData.getData('text'));
    } 
    else 
    {
        if (window.netscape) 
        {
            try 
            {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                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");
                clip.getData(trans, clip.kGlobalClipboard);
                var str = new Object();
                var len = new Object();
                trans.getTransferData("text/unicode", str, len);
            }
            catch (e) 
            {
                alert("您的firefox安全限制限制您进行剪贴板操作，请打开'about:config'将 signed.applets.codebase_principal_support'设置为true'之后重试，相对路径为firefox根目录 /greprefs/all.js");
                return null;
            }
            if (str) 
            {
                if (Components.interfaces.nsISupportsWString) 
                {
                    str = str.value.QueryInterface(Components.interfaces.nsISupportsWString);
                } 
                else 
                {
                    if (Components.interfaces.nsISupportsString) 
                    {
                        str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
                    } 
                    else 
                    {
                        str = null;
                    }
                }
            }
            if (str) 
            {
                return (str.data.substring(0, len.value / 2));
            }
        }
    }
    return null;
}


