| 17 |
rsolanki |
1 |
//Custom JavaScript Functions by Shawn Olson
|
|
|
2 |
//Copyright 2004
|
|
|
3 |
//http://www.shawnolson.net
|
|
|
4 |
//If you copy any functions from this page into your scripts, you must provide credit to Shawn Olson & http://www.shawnolson.net
|
|
|
5 |
//*******************************************
|
|
|
6 |
|
|
|
7 |
function stripCharacter(words,character) {
|
|
|
8 |
//documentation for this script at http://www.shawnolson.net/a/499/
|
|
|
9 |
var spaces = words.length;
|
|
|
10 |
for(var x = 1; x<spaces; ++x){
|
|
|
11 |
words = words.replace(character, "");
|
|
|
12 |
}
|
|
|
13 |
return words;
|
|
|
14 |
}
|
|
|
15 |
|
|
|
16 |
function changecss(theClass,element,value) {
|
|
|
17 |
//documentation for this script at http://www.shawnolson.net/a/503/
|
|
|
18 |
var cssRules;
|
|
|
19 |
if (document.all) {
|
|
|
20 |
cssRules = 'rules';
|
|
|
21 |
}
|
|
|
22 |
else if (document.getElementById) {
|
|
|
23 |
cssRules = 'cssRules';
|
|
|
24 |
}
|
|
|
25 |
for (var S = 0; S < document.styleSheets.length; S++){
|
|
|
26 |
for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
|
|
|
27 |
if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
|
|
|
28 |
document.styleSheets[S][cssRules][R].style[element] = value;
|
|
|
29 |
}
|
|
|
30 |
}
|
|
|
31 |
}
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
function checkUncheckAll(theElement) {
|
|
|
35 |
//documentation for this script at http://www.shawnolson.net/a/693/
|
|
|
36 |
var theForm = theElement.form, z = 0;
|
|
|
37 |
while (theForm[z].type == 'checkbox' && theForm[z].name != 'checkall') {
|
|
|
38 |
theForm[z].checked = theElement.checked;
|
|
|
39 |
z++;
|
|
|
40 |
}
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
function changeImgSize(objectId,newWidth,newHeight) {
|
|
|
44 |
imgString = 'theImg = document.getElementById("'+objectId+'")';
|
|
|
45 |
eval(imgString);
|
|
|
46 |
oldWidth = theImg.width;
|
|
|
47 |
oldHeight = theImg.height;
|
|
|
48 |
if(newWidth>0){
|
|
|
49 |
theImg.width = newWidth;
|
|
|
50 |
}
|
|
|
51 |
if(newHeight>0){
|
|
|
52 |
theImg.height = newHeight;
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
function changeColor(theObj,newColor){
|
|
|
58 |
eval('var theObject = document.getElementById("'+theObj+'")');
|
|
|
59 |
if(theObject.style.backgroundColor==null){theBG='white';}else{theBG=theObject.style.backgroundColor;}
|
|
|
60 |
if(theObject.style.color==null){theColor='black';}else{theColor=theObject.style.color;}
|
|
|
61 |
//alert(theObject.style.color+' '+theObject.style.backgroundColor);
|
|
|
62 |
switch(theColor){
|
|
|
63 |
case newColor:
|
|
|
64 |
switch(theBG){
|
|
|
65 |
case 'white':
|
|
|
66 |
theObject.style.color = 'black';
|
|
|
67 |
break;
|
|
|
68 |
case 'black':
|
|
|
69 |
theObject.style.color = 'white';
|
|
|
70 |
break;
|
|
|
71 |
default:
|
|
|
72 |
theObject.style.color = 'black';
|
|
|
73 |
break;
|
|
|
74 |
}
|
|
|
75 |
break;
|
|
|
76 |
default:
|
|
|
77 |
theObject.style.color = newColor;
|
|
|
78 |
break;
|
|
|
79 |
}
|
|
|
80 |
}
|