﻿var StrTitle = "http://blue.fhuang.com\n---------------------------------------------\n\n";
var IsIE=document.all&&document.getElementById;
var IsNS=document.getElementById&&!document.all;
var MusicBoxWin=0;
if(document.URL.indexOf("xable")>0)location.href="/x/";

var SkinMenuObj='<a href="/blue/Cookie.asp?Skin=Default">Skin: Default</a><a href="/blue/Cookie.asp?Skin=pureblue">Skin: pureblue</a><a href="/blue/Cookie.asp?Skin=newyear">Skin: newyear</a>\
                <div class="Separator"></div>\
                <a href="javascript:SwitchSidebar()">Show/Hide SideBar</a>\
                <div class="Separator"></div>';
var LineMenuObj='<div class="Separator"></div>';


function Confirm(Str){  if(!confirm(StrTitle + Str)) return false;  }
function Alert(Str){    window.alert(StrTitle + Str);   }
function IsNumber(){  return ((event.keyCode >= 48) && (event.keyCode <= 57));  }
function GetFileName(url, opt){ document.write(url.substr(url.lastIndexOf(opt)+1)); }
function ReplaceSpace(Str){ return Str.replace(/ /g,"%20"); }
function CopyText(objID){   window.clipboardData.setData("Text",""+objID+"");   }
function AddFav(StrURL,StrTitle){   window.external.AddFavorite(StrURL,StrTitle);   }

function CheckNull(ObjID,Str) {
    var Obj=document.getElementById(ObjID);
    if(Obj.value == "" ) {
        if(Str&&Str!="") Alert(Str);
        Obj.focus();
        return false;
    }
}

// New Central Windows
function OpenWin(winU,winN,winW,winH){
  return window.open(winU,winN,'status=no,resizable=no,width='+winW+',height='+winH+',left='+(screen.width-winW)/2+',top='+(screen.height-winH)/2+'');
}

function ShowHide(objID){
    var obj=document.getElementById(objID);
    if(obj.style.display!='none'){
        obj.style.display='none';
    }
    else{
        obj.style.display='block';
    }
}

function RunCode(ObjID) {
    var Obj=document.getElementById(ObjID);
    if (Obj&&Obj.value!=""){
        var newwin=window.open('','','');  
        newwin.opener = null 
        newwin.document.write(Obj.value);  
        newwin.document.close();
    }
}

function CopyTextArea(ObjID){
    var Obj=document.getElementById(ObjID);
    if (Obj) { 
        Obj.select();
        js=Obj.createTextRange();
        js.execCommand("Copy");
    }
}

function GetLength(ObjID){
    var Obj=document.getElementById(ObjID);
    alert("Current Text: "+Obj.value.length+" Byte\t\n");
    Obj.focus();
}

function SelectAll(ObjID) {
    var Obj=document.getElementsByName(ObjID);
    for (var i=0; i<Obj.length; i++) {
        var CheckList=Obj[i];
        CheckList.checked=!CheckList.checked;
    }
}


function SwitchSidebar(){
    try{
    var ObjSidebar=document.getElementById("BlogSidebar");
    var ObjBody=document.getElementById("InnerBody");
    if(ObjBody.className!="FullInnerBody"){
        ObjSidebar.style.display="none";
        ObjBody.className="FullInnerBody";
    }else{
        ObjSidebar.style.display="block";
        ObjBody.className="InnerBody";
    }
    }catch(e){}
}

function ImgResize(s){
    var MaxWidth = 500;
    var MaxHeight = 350;
    var img=new Image();
    s.style.cursor="pointer";
    img.src=s.src;
    if(img.width/img.height>5/4){
        if(img.width>MaxWidth){
            s.width=MaxWidth;
            s.height=img.height*MaxWidth/img.width;
        }
    }
    else{
        if (img.height>MaxHeight){
            s.height=MaxHeight;
            s.width=img.width*MaxHeight/img.height;
        }
    }
}