function popmywindow(){
	Index = window.open('','pmw','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=270,height=235,top=0,left=0');
}
function ddsSI() {
	if (document.getElementById) {
		thesrc = document.getElementById("security_image").src;
		thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
		document.getElementById("security_image").src = thesrc+"?"+Math.round(Math.random()*100000);
	} else {
		alert("Sorry, cannot reload security image\nTry and email us directly.\nEmail address is in the footer.");
	}
}
function checkform(of) {
	if (!document.getElementById || !document.createTextNode) {return;}
	if (!document.getElementById('required')) {return;}
	var errorID		= 'errormsg';
	var errorClass	= 'error'
	var errorMsg	= 'Please enter or change the fields marked with a ';
	var errorImg	= 'images/alert.gif';
	var errorAlt	= 'Error';
	var errorTitle	= 'This field has an error!';
	var reqfields	= document.getElementById('required').value.split(',');
	if (document.getElementById(errorID)) {
		var em	= document.getElementById(errorID);
		em.parentNode.removeChild(em);
	}
	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	= '';
	}
	for (var i=0;i<reqfields.length;i++) {
		var f	= document.getElementById(reqfields[i]);
		if (!f) {continue;}
		switch (f.type.toLowerCase()) {
			case 'text':
				if (f.value=='' && f.id!='email') {
					cf_adderr(f);
				}
				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 !document.getElementById(errorID);
	function cf_adderr(o) {
		o.className				= errorClass;
		o.style.backgroundColor	= "#FCC";
		o.style.background		= "#FCC url('images/alert.gif') no-repeat top left";
		if (!document.getElementById(errorID)) {
			var errorIndicator		= document.createElement('img');
			errorIndicator.alt		= errorAlt;
			errorIndicator.src		= errorImg;
			errorIndicator.title	= errorTitle;
			var em	 = document.createElement('div');
			em.id	 = errorID;
			em.style.backgroundColor	= "#FCC";
			var newp = document.createElement('p');
			newp.appendChild(document.createTextNode(errorMsg));
			newp.appendChild(errorIndicator.cloneNode(true));
			em.appendChild(newp);
			for (var i=0;i<of.getElementsByTagName('input').length;i++) {
				if (/submit/i.test(of.getElementsByTagName('input')[i].type)) {
					var sb	= of.getElementsByTagName('input')[i];
					break;
				}
			}
			if (sb) {
				sb.parentNode.insertBefore(em,sb);
			}
		}
	}
	function cf_isEmailAddr(str) {
		return str.match(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/);
	}
}
function AjaxObject() {
	this.createRequestObject = function() {
		var ro;
		try {
			ro = new XMLHttpRequest();
		}
		catch (e) {
			ro = new ActiveXObject("Microsoft.XMLHTTP");
		}
		return ro;
	}
	this.sndReq = function(action, url, data) {
		if (action.toUpperCase() == "POST") {
			this.http.open(action,url,true);
			this.http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			this.http.onreadystatechange = this.handleResponse;
			this.http.send(data);
		}
		else {
			this.http.open(action,url + '?' + data,true);
			this.http.onreadystatechange = this.handleResponse;
			this.http.send(null);
		}	
	}
	this.handleResponse = function() {
		if ( me.http.readyState == 4) {
			var rawdata = me.http.responseText.split("|");
			for ( var i = 0; i < rawdata.length; i++ ) {
				var item = (rawdata[i]).split("=>");
				if (item[0] != "") {
					if (item[1].substr(0,3) == "%V%" ) { //	To change the .value rather than .innerHTML, preface with %V%
						document.getElementById(item[0]).value = item[1].substring(3);
					}
					else {
						document.getElementById(item[0]).innerHTML = item[1];
					}
				}
			}
			if (typeof me.funcDone == 'function') { me.funcDone();}
		}
		if ((me.http.readyState == 1) && (typeof me.funcWait == 'function')) {
			me.funcWait();
		}
	}
	var me			= this;
	this.http		= this.createRequestObject();
	var funcWait	= null;
	var funcDone	= null;
}
function Waiting() {
	document.getElementById('loading').style.visibility = 'visible';
	document.getElementById('loading').innerHTML = 'One moment, loading data...&nbsp;&nbsp;';
	document.getElementById('loading').className = 'on-query';
}
function DoneWaiting() {
	document.getElementById('loading').style.visibility = 'hidden';
	document.getElementById("loading").className = 'off-query';
	TJKpop();
	Lightview.updateViews();
}
function ddsAjax(myURL) {
	if (myURL!=0) {
		var ss  = myURL.split("?");
		var pt  = ss[0].split(".");
		if (pt.length>2) {
			var w = pt[(pt.length-2)];
			if (w.indexOf("/")>0) {
				var ww  = w.split("/");
				var w   = ww[1];
			}
		} else {
			var w = pt[0];
		}
		var ao		= new AjaxObject();
		ao.funcWait = Waiting;
		ao.funcDone = DoneWaiting;
		ao.sndReq('get','index.php', "p="+w+"&s=ajax");
	} else {
		DoneWaiting();
	}
}
function TJKpop(){ // v1.0 | www.TJKDesign.com
	var e = document.getElementById('menu');
	var s = document.getElementById('side');
	if (e){
		var a = e.getElementsByTagName('a');
		for (var i=0;i<a.length;i++){
			if (navigator.appName.indexOf("Explorer") >= 0){
				if (a[i].getAttribute('HREF') != null && a[i].getAttribute('HREF').indexOf("://") >= 0 && a[i].getAttribute('HREF').toUpperCase().indexOf(document.domain.toUpperCase()) == -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].getAttribute('className') != null && a[i].getAttribute('className').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].getAttribute('className') != null && a[i].getAttribute('className').indexOf("outside") >= 0){
					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;}
				}
			} else {
				if (a[i].getAttribute('href') != null && a[i].getAttribute('href').indexOf("://") >= 0 && a[i].getAttribute('href').toUpperCase().indexOf(document.domain.toUpperCase()) == -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].getAttribute('class') != null && a[i].getAttribute('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].getAttribute('class') != null && a[i].getAttribute('class').indexOf("outside") >= 0){
					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;}
				}
			}
			// end CODEX dds
		}
	}
	//	added by CODEX dds www.codex.co.za
	if (s) {
		var x = document.getElementsByTagName('a');
		for (var i=0;i<x.length;i++) {
			if (x[i].getAttribute('type') == 'ajax') {
			}
		}
	}
	// end CODEX dds
}
