function popup_image(image_url, title) {
	var winl = (screen.width - 200)/2;
	var wint = (screen.height - 300)/2;
	var settings ='top='+wint+',';
	settings +='left='+winl+',';
	settings +='width=200, ';
	settings +='height=300, ';
	settings +='scrollbars=no,';
	settings +='resizable=yes';

	title = title.replace(/\s/g, '%20');

	win=window.open('/image_popup.php?image_url='+image_url+'&title='+title, 'image',settings);

	if(parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}

	function popup_gallery(g, i) {
		if (screen.width > 800) {
			w = 800;
			h = 600;
			s = 1;
		} else {
			w = 400;
			h = 400;
			s = 0;
		}

		var winl = (screen.width - 700)/2;
		var wint = (screen.height - 500)/2;
		var settings ='top='+wint+',';
			settings +='left='+winl+',';
			settings +='width=700, ';
			settings +='height=500, ';
			settings +='scrollbars=no,';
			settings +='resizable=yes';

		win=window.open('/gallery_popup.php?g='+g+'&i='+i+'&w='+w+'&h='+h+'&s='+s, 'image',settings);

		if(parseInt(navigator.appVersion) >= 4) {
		   win.window.focus();
		}
	}

/* preload images */
if (document.images) {
	var spacerOn = new Image();
	spacerOn.src = "images/spacer.gif";
}

function Popup(w, h, page, resize) {
        var winl = (screen.width-w)/2;
        var wint = (screen.height-h)/2;
        var settings  ='height='+h+',';
        settings +='width='+w+',';
        settings +='top='+wint+',';
        settings +='left='+winl+',';
        settings +='scrollbars=yes,';
        settings +='resizable='+resize+'';

        win=window.open(page,'editor',settings);

        if(parseInt(navigator.appVersion) >= 4) {
                win.window.focus();
        }

}

function validateSearchForm() {
	if (document.forms.search.searchstr.value.length < 3) {
			alert('You search must be more than three characters long.');
			document.forms.search.searchstr.focus();
			return(false);
	}
	return(true);
}

function subscribeForm()
{
	var email = document.forms.subscribe.sub_email.value;
	var name   = document.forms.subscribe.sub_name.value;

        var regex  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        if (name == '')
        {
                alert('Please enter your full name');
                document.forms.subscribe.sub_name.focus();
                return(false);
        }
        else if (email == '') {
        	      alert('Please enter your email address');
                document.forms.subscribe.sub_email.focus();
                return(false);
        }
        else {
                if (regex.test(email))
                {
                       return(true);
                }
                else
                {
                        alert('Please enter a VALID email address to subscribe with, e.g (someone@somewhere.com)');
                        document.forms.subscribe.sub_email.focus();
                        return(false);

                }
        }
   return(false);
}
