
function $(id) {
	if(document.getElementById(id)) return document.getElementById(id);
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=640,height=480,left = 50,top = 50');");
}

function popUp2(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=360,height=480,left = 50,top = 50');");
}

function display(id) {
	$(id).style.display	=	'block';
}

function changeLgImg(imgName) {
	$('lgImage').style.display	=	'block';
	$('lgImage').innerHTML	=	'<img src="'+baseurl+'images/gallery/Lg/'+imgName+'.jpg" />';//src=baseurl+'images/gallery/Lg/'+imgName+'.jpg';
}
function ajaxObject(url, callbackFunction) {
	var that=this;      
	this.updating = false;
	this.abort = function() {
		if (that.updating) {
			that.updating=false;
			that.AJAX.abort();
			that.AJAX=null;
		}
	}
	this.update = function(passData,postMethod) { 
		if (that.updating) { return false; }
		that.AJAX = null;                          
		if (window.XMLHttpRequest) {              
			that.AJAX=new XMLHttpRequest();
		} else {
			try {
				that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				that.AJAX=new IFrameXMLHttpRequest();
			}
		}                                             
		if (that.AJAX==null) {                             
			return false;                               
		} else {
			that.AJAX.onreadystatechange = function() {  
				if (that.AJAX.readyState==4) {             
					that.updating=false;
					that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
					that.AJAX=null;                                         
				}                                                      
			}                                                        
			that.updating = new Date();        

			if ($('ajaxcall')) $('ajaxcall').innerHTML=new Date();
			if (/post/i.test(postMethod)) {
				var uri=urlCall+'?'+that.updating.getTime();
				that.AJAX.open("POST", uri, true);
				that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				that.AJAX.send(passData);
			} else {
				var uri=urlCall+'?'+passData+'&stamp='+(that.updating.getTime()); 
				that.AJAX.open("GET", uri, true);                             
				that.AJAX.send(null);                                         
			}              
			return true;                                             
		}
	}
	var urlCall = url;
	this.callback = callbackFunction || function () { };
}
function reloadCaptcha(imgId,folderLoc,prevIds) {
	var f=function(newImg) {
		if (document.getElementById(imgId)) {
			document.getElementById(imgId).src=folderLoc+newImg+'.gif?r='+Math.random();
		} else {
			for(var i=1; document.getElementById(imgId+'_'+i); i++) {
				document.getElementById(imgId+'_'+i).src=folderLoc+newImg+'.gif?r='+Math.random();
			}
		}
	}
	var ajax=new ajaxObject('/captcha-refresh.htm',f);
	ajax.update('?prevIds='+prevIds,'POST');
}
