function GenerateRandomString()
{
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 5;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	
	document.getElementById('SecCode').value=randomstring;
}

function CheckEmail(strEmail)
			{
				var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
				if (!filter.test(strEmail)) return false; else return true;
			}

function CheckSecString()
{
	if (document.getElementById('SecCode').value!=document.getElementById('SecCodeMatch').value) return false;
	else return true;
}

function DisableFlashElements()
{
	try {document.getElementById('MainAnimation').style.visibility='hidden';} catch(err){};
	try {document.getElementById('Cube_1').style.visibility='hidden';} catch(err){};
	try {document.getElementById('Cube_2').style.visibility='hidden';} catch(err){};
	try {document.getElementById('Cube_3').style.visibility='hidden';} catch(err){};
	try {document.getElementById('Cube_4').style.visibility='hidden';} catch(err){};
	try {document.getElementById('Cube_5').style.visibility='hidden';} catch(err){};
	try {document.getElementById('GalleryFlash').style.visibility='hidden';} catch(err){};	
		
}

function EnableFlashElements()
{
	try {document.getElementById('MainAnimation').style.visibility='visible';} catch(err){};
	try {document.getElementById('Cube_1').style.visibility='visible';} catch(err){};
	try {document.getElementById('Cube_2').style.visibility='visible';} catch(err){};
	try {document.getElementById('Cube_3').style.visibility='visible';} catch(err){};
	try {document.getElementById('Cube_4').style.visibility='visible';} catch(err){};
	try {document.getElementById('Cube_5').style.visibility='visible';} catch(err){};
	try {document.getElementById('GalleryFlash').style.visibility='visible';} catch(err){};
}

function BrochurePopup()
{
	DisableFlashElements();
	GenerateRandomString();
	document.getElementById('BrochureRequestBopupBCG').style.display='';
	document.getElementById('BrochureRequestPopup').style.display='';	
}

function CloseBrochureRequestPopup()
{
	EnableFlashElements();
	document.getElementById('BrochureRequestBopupBCG').style.display='none';
	document.getElementById('BrochureRequestPopup').style.display='none';	
}

function SendBrochureRequest()
{
	if (CheckSecString()!=true)
	{
		document.getElementById('BrochureRequestMessages').innerHTML='Please retype security code properly';
	}
	
	if ((document.getElementById('Address').value=='') | (document.getElementById('Postcode').value==''))
	{
		document.getElementById('BrochureRequestMessages').innerHTML='Please enter address and postcode';
	}
	else if ((document.getElementById('Email').value=='') & (document.getElementById('SubscribeToEmailer').value==1))
	{
		document.getElementById('BrochureRequestMessages').innerHTML='Please enter your email address';
	}
	else if (CheckEmail(document.getElementById('Email').value)==false)
	{
		 document.getElementById('BrochureRequestMessages').innerHTML='Please type in a valid email address';
	}
	else
	document.BrochureRequestForm.submit();
}

function SetCheckboxValue(strNameOfCheckBox,strValue)
		{
			if (document.getElementById(strNameOfCheckBox).checked==true) document.getElementById(strNameOfCheckBox).value=strValue;
			else
			document.getElementById(strNameOfCheckBox).value="";
		}