function popPic() {
    popWin = window.open('', 'popPic', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=640,height=480,left=0,top=0');
}
// this function is needed to work around 
// a bug in IE related to element attributes
function hasClass(obj) {
    var result = false;
    if (obj.getAttributeNode("class") != null) {
        result = obj.getAttributeNode("class").value;
    }
    return result;
}
function checkform(of) {
	// Test if DOM is available and there is an element called required
	if (!document.getElementById || !document.createTextNode) {
		return;
	}
	if (!$('required')) {
		return;
	}
	// Define error messages and split the required fields
	var errorID		= 'errormsg';
	var errorClass	= 'error'
	var errorMsg	= 'Please enter or change the fields marked ';
	var errorImg	= '/images/exclamation.gif';
	var errorAlt	= 'Error';
	var errorTitle	= 'This field has an error!';
	var reqfields	= $('required').value.split(',');
	// Cleanup old mess
	// if there is an old errormessage field, delete it
	if ($(errorID)) {
		$(errorID).parentNode.removeChild(em);
	}
	// remove old images and classes from the required fields
	for (var i=0;i<reqfields.length;i++) {
		var f	= document.getElementById(reqfields[i]);
		if (!f) {
			continue;
		}
		if (f.previousSibling && /img/i.test(f.previousSibling.nodeName)) {
			f.parentNode.removeChild(f.previousSibling);
		}
		f.className	= '';
	}
	// loop over required fields
	for (var i=0;i<reqfields.length;i++) {
		// check if required field is there
		var f	= $(reqfields[i]);
		if (!f) {
			continue;
		}
		// test if the required field has an error, according to its type
		switch (f.type.toLowerCase()) {
			case 'text':
				if (f.value=='' && f.id!='email') {
					cf_adderr(f)
				}
				// email is a special field and needs checking
				if (f.id=='email' && !cf_isEmailAddr(f.value)) {
					cf_adderr(f)
				}
			break;
			case 'textarea':
				if (f.value=='') {
					cf_adderr(f)
				}
			break;
			case 'checkbox':
				if (!f.checked) {
					cf_adderr(f)
				}
			break;
			case 'select-one':
				if (!f.selectedIndex && f.selectedIndex==0) {
					cf_adderr(f)
				}
			break;
		}
	}
	return !$(errorID);
	/* Tool methods */
	function cf_adderr(o) {
		// create image, add to and colourise the error fields
		var errorIndicator		= new Element('img', {alt: errorAlt, src: errorImg, title: errorTitle});
		o.addClassName(errorClass);
		o.parentNode.insertBefore(errorIndicator,o);
		if (!$(errorID)) {
			// create errormessage and insert before submit button
			var newp = new Element('p').update(errorMsg).insert(errorIndicator.cloneNode(true));
			var em	 = new Element('div', {id: errorID}).update(newp);
			// find the submit button
			var sb = $('submit');
			if (sb) {
				sb.insert({before: em});
			}
		}
	}
	function cf_isEmailAddr(str) {
		return str.match(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/);
	}
}
function TJKpop(){ // v1.0 | www.TJKDesign.com
	var e = $('main-content');
	var s = $('side');
	if (e){
		var a = e.select('a');
		for (var i=0;i<a.length;i++){
			if (a[i].readAttribute('href') != null && a[i].readAttribute('href').indexOf("://") >= 0 && a[i].readAttribute('href').toUpperCase().indexOf(document.domain.toUpperCase()) == -1) {
				if (a[i].readAttribute('class') == null || (a[i].readAttribute('class') != null && a[i].readAttribute('class').indexOf("lyteframe") == -1)) {
					a[i].className+=a[i].className?' external':'external';
					a[i].title+=' (opens in new window)';
					a[i].onclick=function(){newWin=window.open(this.href,'TJKWin');if(window.focus){newWin.focus()} return false;}
				}
			//	added by CODEX dds www.codex.co.za
			} else if (a[i].readAttribute('class') != null && a[i].readAttribute('class').indexOf("ajax") >= 0 && a[i].title.indexOf("ajax") == -1) {
				a[i].onclick = function () {ddsAjax(this.href); return false;}
				a[i].title += ' (ajax)';
			} else if (a[i].readAttribute('class') != null && a[i].readAttribute('class').indexOf("external") >= 0 && a[i].title.indexOf("external") == -1) {
				a[i].title+=' (opens in new window/tab)';
				a[i].onclick=function(){newWin=window.open(this.href,'TJKWin');if(window.focus){newWin.focus()} return false;}
			}
			// end CODEX dds
		}
	}
	//	added by CODEX dds www.codex.co.za
	if (s) {
		var x = s.getElementsBySelector('a');
		for (var i=0;i<x.length;i++) {
			if (x[i].getAttribute('type') == 'ajax') {
			}
		}
	}
	// end CODEX dds
}
function swapClass(obj,col) {
	if ($(obj)) {
		obj = $(obj);
	}
	obj.className = col;
}
/*
function TABdiv() {
    $('showBlah').observe('click',function() {
        if (!$('blah').visible()) {
            new Effect.BlindDown($('blah'));
        }
    });
    $('hideBlah').observe('click',function() {
        if ($('blah').visible()) {
            new Effect.BlindUp($('blah'));
        }
    });
}
*/
Event.observe(window, 'load', function() {
	new Lightbox();
		TJKpop();
/*		TABdiv();*/
});