function formFocus()
{
	if(document.forms[0].elements[0])
	{
		if (document.forms[0].length > 0 && (document.forms[0].name == 'Login' || document.forms[0].name == 'Register'))
		{
			document.forms[0].elements[0].focus();
		}
	}
}
function switchImage(id,imgNewStatusLetter) {
	var image = document.getElementById(id);
	image.src = '/photogallery/images/icons/small/' + id + imgNewStatusLetter + '.gif';
}
function loginCheck()
{
uidlen  = document.Login.uidform.value;
passlen = document.Login.password.value;

		if (document.Login.uidform.value == "")
		{
			alert('Please enter a username');
			document.Login.uidform.focus();
			return false;
		}
		if (uidlen.length < 3)
		{
			alert('username must be atleast 4 char long')
			document.Login.uidform.focus()
			return false
		}
		if (document.Login.password.value == "")
		{
			alert('Please enter a password')
			document.Login.password.focus()
			return false
		}
		if (passlen.length < 6)
		{
			alert('password must be atleast 6 char long')
			document.Login.password.focus()
			return false
		}
}

function Popup(url, window_name, window_width, window_height)
{
	var WinWd, WinHt;

	showindow = "toolbar=no,location=no,directories=no,"+ "status=no,menubar=no,scrollbars=yes,"+ "resizable=yes,width="+window_width+",height="+window_height;

	WinWd = screen.width/2 - window_width/2;
	WinHt = screen.height/2 - window_height/2;

	NewWindow=window.open(url,window_name,showindow);
	NewWindow.moveTo(WinWd,WinHt);
}

function PopupForm(window_name, window_width, window_height, maximise)
{
	var WinWd, WinHt;

	showindow = "toolbar=no,location=no,directories=no,"+ "status=no,menubar=no,scrollbars=yes,maximise="+maximise+",resizable="+maximise+","+"width="+window_width+",height="+window_height;

	WinWd = screen.width/2 - window_width/2;
	WinHt = screen.height/2 - window_height/2;

	NewWindow=window.open('',window_name,showindow);
	NewWindow.moveTo(WinWd,WinHt);
}

function smilie(thesmilie, fieldname)
{
	fieldname.value += thesmilie+" ";
	fieldname.focus();
}

function fieldHighlight( fieldname, depth )
{
	if(fieldname.checked)
	{
		val = 1;
	}
	else
	{
		val = 0;
	}

	E = fieldname;
	var j = 0;

	while (E.tagName!="TR" && j < depth)
	{
		if(document.all)
		E=E.parentElement
		else
		E=E.parentNode

		j++;
	}

	if(E.tagName=="TR")
	{
		if(val == "1")
		E.className = 'alterRowHighlight';
		else
		E.className = 'alterRowDeHighlight';
	}

	return( true );
}

function SetChecked(dml, depth)
{
	len = dml.elements.length;
	var i = 0;

	if(depth < 0)
	{
		depth = 3;
	}

	if(dml.allbox.checked)
	{
		val = 1;
	}
	else
	{
		val = 0;
	}

	for( i=0 ; i<len ; i++)
	{
		dml.elements[i].checked=val

		E = dml.elements[i];
		var j = 0;

		while (E.tagName!="TR" && j < depth)
		{
			if(document.all)
			E=E.parentElement
			else
			E=E.parentNode

			j++;
		}

		if(E.tagName=="TR")
		{
			if(val == "1")
			E.className = 'alterRowHighlight';
			else
			E.className = 'alterRowDeHighlight';
		}
	}
}

function RotateCheck()
{
var angle;
angle = eval(document.rotate.param_a.value);

if(!angle)
{ alert('You must specify an angle value');
  document.rotate.param_a.focus();
  return false; }
}

function GammaCheck()
{
var red, green, blue;

red = eval(document.gamma.param_a.value);
green = eval(document.gamma.param_b.value);
blue = eval(document.gamma.param_c.value);

if(red > 5)
{ alert('Red color must be < 5');
  document.gamma.param_a.focus()
  return false }

if(red < 0)
{ alert('Red color must be > 0');
  document.gamma.param_a.focus()
  return false }

if(green > 5)
{ alert('Green color must < 5');
  document.gamma.param_b.focus()
  return false }

if(green < 0)
{ alert('Green color must be > 0');
  document.gamma.param_b.focus()
  return false }

if(blue > 5)
{ alert('Blue color must < 5');
  document.gamma.param_c.focus()
  return false }

if(blue < 0)
{ alert('Blue color must be > 0');
  document.gamma.param_c.focus()
  return false }
}

function BrightCheck()
{
var brt, sat, hue;

brt = eval(document.bright.param_a.value);
sat = eval(document.bright.param_b.value);
hue = eval(document.bright.param_c.value);

if(brt < -100 || brt > 100)
{ alert('<?php echo($_Lang_Errors[81]); ?>');
  document.bright.param_a.focus()
  return false }

if(sat < -100 || sat > 100)
{ alert('<?php echo($_Lang_Errors[82]); ?>');
  document.bright.param_b.focus()
  return false }

if(hue < -100 || hue > 100)
{ alert('<?php echo($_Lang_Errors[83]); ?>');
  document.bright.param_c.focus()
  return false }
}

function ListenWindow()
{
	ListenMusic=window.open( document.ecard.music.value ,"ListenMusic","status=no,resize=no,toolbar=no,scrollbars=no,width=200,height=100,maximize=no");

	var WinWd, WinHt;
	WinWd = screen.width/2 - 100;
	WinHt = screen.height/2 - 50;
	ListenMusic.moveTo(WinWd,WinHt);

	return false;
}

function AlbumThemeWindow( url, closewin, athemeid )
{
	if(closewin == 1)
	{
		if(GetCookie('albinatoratheme'))
		{
			DeleteCookie ("albinatoratheme")
			AlbumTheme=window.open("","AlbumTheme","status=no,resize=no,toolbar=no,scrollbars=no,width=200,height=100,maximize=no");
			AlbumTheme.close();
		}
	}
	else
	{
		if(!GetCookie('albinatoratheme') || GetCookie('albinatoratheme') != athemeid )
		{
			SetCookie("albinatoratheme", athemeid);
			AlbumTheme=window.open(url,"AlbumTheme","status=no,resize=no,toolbar=no,scrollbars=no,width=200,height=100,maximize=no");

			var WinWd, WinHt;
			WinWd = screen.width/2 - 100;
			WinHt = screen.height/2 - 50;
			AlbumTheme.moveTo(WinWd,WinHt);
		}
	}
	self.focus();
}

function relaxUpload()
{
	relaxUpload=window.open("relax.php","relaxUpload","status=no,resize=no,toolbar=no,scrollbars=no,width=350,height=200,maximize=no");

	var WinWd, WinHt;
	WinWd = screen.width/2 - 175;
	WinHt = screen.height/2 - 100;
	relaxUpload.moveTo(WinWd,WinHt);
}

//"Accept terms" form submission- By Dynamic Drive
//For full source code and more DHTML scripts, visit www dot dynamicdrive dot com
//This credit MUST stay intact for use

var checkobj

function agreesubmit(el)
{
	checkobj=el
	if (document.all||document.getElementById)
	{
		for (i=0;i<checkobj.form.length;i++)
		{
			var tempobj=checkobj.form.elements[i]

			if(tempobj.type.toLowerCase()=="submit")
			tempobj.disabled=!checkobj.checked
		}
	}
}


<!--- Cookie JavaScript (c) Amit Arora <amit dot arora _at_ bigfoot dot com> --->

    function SetCookie (name, value) {
        var argv = SetCookie.arguments;
        var argc = SetCookie.arguments.length;
        var expires = new Date();
        var path = (argc > 3) ? argv[3] : null;
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
	  expires.setYear(expires.getYear()+1);
        document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString()+1800)) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
    }

    function getCookieVal (offset) {
        var endstr = document.cookie.indexOf (";", offset);
        if (endstr == -1)
        endstr = document.cookie.length;
        return unescape(document.cookie.substring(offset, endstr));
    }

    function GetCookie (name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen)
        	{
        	var j = i + alen;
        	if (document.cookie.substring(i, j) == arg)
        	return getCookieVal (j);
        	i = document.cookie.indexOf(" ", i) + 1;
        	if (i == 0) break;
        	}
        return null;
    }

    function DeleteCookie (name) {
        var exp = new Date();
        exp.setTime (exp.getTime() - 1);
        var cval = GetCookie (name);
        document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
    }
    function popupUserName() {
		var alertText = 'The user name you choose will be used to create the web address that you will send to your friends and family to view your travel website, blogs and photos.  For example if you chose the user name "Travelbug" your web address would be www.bugbitten.com/Travelbug\n\n';
		alertText += 'So please think carefully about your user name as it cannot be changed later and make it easy for your mates to remember.  Can\'t think of one?  Why not use the same user name as your email address.  So if your email is travelbug@hotmail.com you would use "travelbug".';
		alert(alertText);
	}

	function popupUserEmail() {
		var alertText = 'We recommend that you use the email address you most frequently use to email your friends and family ie Hotmail, Yahoo or GMail.  Work email address are also acceptable but if you frequently change jobs don\'t forget to update your email address.   If we are unable to contact you, your account can be deleted';
		alert(alertText);
	}

	function popupUserRealName() {
		var alertText = 'Your real name is used by your friends to find your website.  If you only enter part of your real name it is unlikely they will be able to find you so you will need to ensure they know your web address is.';
		alert(alertText);
	}

	function popupUserAllowPC() {
		var alertText = 'If you choose "Yes" this means your friends and family are able to use your photos to send real paper postcards.  How cool is that!  If you don\'t then they will be unable to do so.';
		alert(alertText);
	}

	function popupUserAllowLocation() {
		var alertText = '"Please enter the name of the city you are currently in.  This city is changeable whenever you sign in so your friends and family know where in the world you are!';
		alert(alertText);
	}