summaryrefslogtreecommitdiff
path: root/js/standard.js
blob: 253971628bb1f77a30c0eeda44c02cb95d6eee5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**
 * Copyright (c) 2007 Nathan Kinkade
 * 
 * This code is offered under an MIT (X11) license.  For more information
 * about the terms of this license see the file LICENSE included with this
 * software or visit: http://www.opensource.org/licenses/mit-license.php
 */

function empty(field) {

	field = trim(field);
	if ( field ) {
		return false;
	} else {
		return true;
	}

}

function trim(string) {
	string = string.replace(/^\s+/, '');
	string = string.replace(/\s+$/, '');
	return string;
}

function getElement(elemid) {

		/* the former for Firefox and crew, the latter for IE */
        return (document.getElementById) ? document.getElementById(elemid) : document.all[elemid];

}

function submitForm(formid) {

	var myForm = getElement(formid);

	myForm.submit();

	return true;

}

function checkAll(fieldname) {

	var myCheckBoxes = document.getElementsByName(fieldname);

	for ( idx = 0; idx < myCheckBoxes.length; idx++ ) {
		if ( myCheckBoxes[idx].checked == false ) {
			myCheckBoxes[idx].checked = true;
		}
	}
}

function uncheckAll(fieldname) {

	var myCheckBoxes = document.getElementsByName(fieldname);

	for ( idx = 0; idx < myCheckBoxes.length; idx++ ) {
		if ( myCheckBoxes[idx].checked == true ) {
			myCheckBoxes[idx].checked = false;
		}
	}
}

function switchToStylesheet(title) {

	var idx, linkElement;

	for ( idx = 0; (linkElement = document.getElementsByTagName("link")[idx]); idx++ ) {
		if ( (linkElement.getAttribute("rel").indexOf("style") != -1) && (linkElement.getAttribute("title")) ) {
			linkElement.disabled = true;
			if ( linkElement.getAttribute("title") == title ) {
				linkElement.disabled = false;
			}
		}
	}

}

// this is only here because XHTML 1.0 strict has deprected the target attribute
function openInNewWindow(url) {
	window.open(url, "_blank", "resizable=yes ,scrollbars=yes,toolbar=no,menubar=yes,width=640,height=480");
}