1
2function formatDoc(sCmd, sValue) {
3  document.execCommand(sCmd, false, sValue);
4}
5function cleanUp(obj)
6{
7  hp = document.getElementById(obj);
8  hp.innerHTML = hp.innerHTML.replace(/(<([^>]+)>)/ig,"");
9}
10
11function makeCite()
12{
13    var html = "";
14    var sel, range;
15    if (typeof window.getSelection != "undefined") {
16        var sel = window.getSelection();
17        if (sel.rangeCount) {
18            var container = document.createElement("blockquote");
19            for (var i = 0, len = sel.rangeCount; i < len; ++i) {
20                container.appendChild(sel.getRangeAt(i).cloneContents());
21            }
22            html = container.innerHTML;
23
24        }
25    } else if (typeof document.selection != "undefined") {
26        if (document.selection.type == "Text") {
27            html = document.selection.createRange().htmlText;
28        }
29    }
30
31    range = sel.getRangeAt(0);
32    range.deleteContents();
33    var post_p = document.createElement("p")
34    range.insertNode(post_p);
35    var post_br = document.createElement("br")
36    range.insertNode(post_br);
37    range.insertNode(container);
38
39}
40
41function makeCode()
42{
43    var html = "";
44    var sel, range;
45    if (typeof window.getSelection != "undefined") {
46        var sel = window.getSelection();
47        if (sel.rangeCount) {
48            var container = document.createElement("code");
49            for (var i = 0, len = sel.rangeCount; i < len; ++i) {
50                container.appendChild(sel.getRangeAt(i).cloneContents());
51            }
52            html = "<p>"+container.innerHTML+"</p>";
53
54        }
55    } else if (typeof document.selection != "undefined") {
56        if (document.selection.type == "Text") {
57            html = document.selection.createRange().htmlText;
58        }
59    }
60
61    range = sel.getRangeAt(0);
62    range.deleteContents();
63    var post_p = document.createElement("p")
64    range.insertNode(post_p);
65    var post_br = document.createElement("br")
66    range.insertNode(post_br);
67    var p_container = document.createElement("p");
68    p_container.appendChild(container);
69    range.insertNode(p_container);
70}
71
72function getfColor(block)
73{
74	hp = document.getElementById("hoverpopup1");
75	hp.style.visibility = "Hidden";
76  var s_url=block.href;
77  var pColor=s_url.substr(s_url.indexOf("#"));
78  document.execCommand('forecolor',         false, pColor);
79}
80
81function getbColor(block)
82{
83	hp = document.getElementById("hoverpopup2");
84	hp.style.visibility = "Hidden";
85  var s_url=block.href;
86  var pColor=s_url.substr(s_url.indexOf("#"));
87  document.execCommand('backcolor',         false, pColor);
88
89}
90
91function ShowPopup(hoveritem, hoverpopup)
92{ var posArray = findPos(document.getElementById(hoveritem));
93  HidePopup("hoverpopup1", "hoverpopup2");
94  hp = document.getElementById(hoverpopup);
95	// Set position of hover popup
96	hp.style.top  = (posArray[1]-250) + 'px';
97	hp.style.left = (posArray[0]-200 ) + 'px';
98	// Set popup to visible
99	hp.style.visibility = "Visible";
100}
101
102function HidePopup(hoverpopup1, hoverpopup2)
103{
104  document.getElementById("hoverpopup1").style.visibility = "Hidden";
105  document.getElementById("hoverpopup2").style.visibility = "Hidden";
106}
107
108function resizeBoxId(obj,size) {
109    var arows = document.getElementById(obj).height;
110    document.getElementById(obj).height = parseInt(arows)+size * 10;
111}
112
113function findPos(obj){
114    var posX = obj.offsetLeft;var posY = obj.offsetTop;
115    while(obj.offsetParent){
116        if(obj==document.getElementsByTagName('body')[0]){break}
117        else{
118            posX=posX+obj.offsetParent.offsetLeft;
119            posY=posY+obj.offsetParent.offsetTop;
120            obj=obj.offsetParent;
121        }
122    }
123    var posArray=[posX,posY];
124    return posArray;
125}