/* 	 
	Author: Aaron White - http://www.aaronmwhite.co.uk/
	28/08/2011
*/

function newImage(arg) 
{
	if (document.images) 
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() 
{
	if (document.images && (preloadFlag == true)) 
	{
		for (var i=0; i<changeImages.arguments.length; i+=2) 
		{
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function activate(field) 
{
            field.disabled=false;
            if(document.styleSheets)field.style.visibility  = 'visible';
            field.focus();
}

function last_choice(selection) 
{
            return selection.selectedIndex==selection.length - 1;
}

function process_choice(selection,textfield) 
{
            if(last_choice(selection)) 
			{
               activate(textfield);
            } 
			else 
			{
               textfield.disabled = true;    
               if(document.styleSheets)textfield.style.visibility  = 'hidden';
               textfield.value = '';
            }
}

function selectedMethod(form) 
{
            if(form.method.value.length > 0) 
			{
               return true;
            }
            return false;
}

function selectedSource(form) 
{
            if(form2.source.value.length > 0) 
			{
               if(last_choice(document.form2.source) && form2.othertext.value.length==0) 
			   {
                  return false
               } 
			   else 
			   {
                  return true;
               }
            }
            return false;
}

function permissionChecked(form) 
{
            if ( form.mailinglist.value.length > 0 ) 
			{
               return true;
            }
            return false;
}
		 
function enteredEmail(form) 
{
           if ( form.email_int.value.length > 0 ) 
		   {
                  return true;
           }
            return false;
}

function validateForm(form) 
{
            if (  selectedSource(form) && permissionChecked(form) ) 
			{
               return true
            } 
			else 
			{
               alert("Please complete all the compulsory fields (those marked with a *)");
               return false;
            }
}

function MM_openBrWindow(theURL,winName,features) 
{ 
  window.open(theURL,winName,features);
} 

// Search box focus and blur functions

function searchOnFocus()
{
	if(document.getElementById("searchTerm").value=='Enter keywords')
	{
		document.getElementById("searchTerm").value='';
	}
}
function searchOnBlur()
{
	if(document.getElementById("searchTerm").value=='') 
	{
		document.getElementById("searchTerm").value='Enter keywords';
	}
}

/* 	 
	Author: Aaron White - http://www.aaronmwhite.co.uk/
	28/08/2011
*/
