<!--
// JavaScript Document

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function formCheck(){
var ok_to_send = true;
var my_form=document.feedback;
	if(my_form.firstname.value=="" || my_form.firstname.value==" ")
	{
		alert("Please enter your first name");
		my_form.firstname.focus();
		ok_to_send = false;
	}
	if((my_form.lastname.value=="" || my_form.lastname.value==" ") && ok_to_send)
	{
		alert("Please enter your last name");
		my_form.lastname.focus();
		ok_to_send = false;
	}
	if (my_form.event4.checked)
	{
		if((my_form.address.value=="" || my_form.address.value==" ") && ok_to_send)
		{
			alert("Please enter your address");
			my_form.address.focus();
			ok_to_send = false;
		}
		if((my_form.postcode.value=="" || my_form.postcode.value==" ") && ok_to_send)
		{
			alert("Please enter your postcode");
			my_form.postcode.focus();
			ok_to_send = false;
		}
	}
	if(notValidEmail(my_form.email.value) && ok_to_send)
	{
		alert("Please enter a valid e-mail address.");
		my_form.email.focus();
		ok_to_send = false;
	}
	if((notValidEmail(my_form.email.value) && ((my_form.address.value=="" || my_form.address.value==" " || my_form.postcode.value=="" || my_form.postcode.value==" "))) && ok_to_send)
	{
		alert("You must specify either an e-mail address or a home address and postcode.");
		ok_to_send = false;
	}
	if (ok_to_send)
	{
		my_form.submit();
	}
}

function formCheck3(my_form){
	if(trim(my_form.firstname.value)=="")
	{
		alert("Please enter your first name");
		my_form.firstname.focus();
		return false;
	}
	if(trim(my_form.lastname.value)=="")
	{
		alert("Please enter your last name");
		my_form.lastname.focus();
		return false;
	}
	if(trim(my_form.email.value)=="" && trim(my_form.phone.value)=="")
	{
		alert("Please enter either a phone number or an email address");
		my_form.email.focus();
		return false;
	}
	if(notValidEmail(my_form.email.value))
	{
		alert("Please enter a valid e-mail address.");
		my_form.email.focus();
		return false;
	}
	if(trim(my_form.venue.value)=="")
	{
		alert("Please enter the venue");
		my_form.venue.focus();
		return false;
	}
	
	if(trim(my_form.firstinput.value)=="")
	{
		alert("Please enter the date of the venue");
		my_form.firstinput.focus();
		return false;
	}
	if(trim(my_form.budget.value)=="" || trim(my_form.budget.value)=="£")
	{
		alert("Please enter the budget for the display");
		my_form.budget.focus();
		return false;
	}
	return true;
}

function formCheck4(my_form){
	if(trim(my_form.firstname.value)=="")
	{
		alert("Please enter your first name");
		my_form.firstname.focus();
		return false;
	}
	if(trim(my_form.lastname.value)=="")
	{
		alert("Please enter your last name");
		my_form.lastname.focus();
		return false;
	}
	if(trim(my_form.email.value)=="" && trim(my_form.phone.value)=="")
	{
		alert("Please enter either a phone number or an email address");
		my_form.email.focus();
		return false;
	}
	if(notValidEmail(my_form.email.value))
	{
		alert("Please enter a valid e-mail address.");
		my_form.email.focus();
		return false;
	}
	if(trim(my_form.venue.value)=="")
	{
		alert("Please enter the venue");
		my_form.venue.focus();
		return false;
	}
	return true;
}

function formCheck5(my_form){
	if(trim(my_form.firstname.value)=="")
	{
		alert("Please enter your first name");
		my_form.firstname.focus();
		return false;
	}
	if(trim(my_form.lastname.value)=="")
	{
		alert("Please enter your last name");
		my_form.lastname.focus();
		return false;
	}
	if(trim(my_form.email.value)=="" && trim(my_form.phone.value)=="")
	{
		alert("Please enter either a phone number or an email address");
		my_form.email.focus();
		return false;
	}
	if(notValidEmail(my_form.email.value))
	{
		alert("Please enter a valid e-mail address.");
		my_form.email.focus();
		return false;
	}
	return true;
}

function formCheckFAQ(){
var ok_to_send = true;
var my_form=document.faqForm;
	if(my_form.firstname.value=="" || my_form.firstname.value==" ")
	{
		alert("Please enter your first name");
		my_form.firstname.focus();
		ok_to_send = false;
	}
	if((my_form.lastname.value=="" || my_form.lastname.value==" ") && ok_to_send)
	{
		alert("Please enter your last name");
		my_form.lastname.focus();
		ok_to_send = false;
	}
	if((notValidEmail(my_form.contactemail.value) || my_form.contactemail.value=="") && ok_to_send)
	{
		alert("Please enter a valid e-mail address.");
		my_form.contactemail.focus();
		ok_to_send = false;
	}
	if((my_form.faqQuestion.value=="" || my_form.faqQuestion.value==" ") && ok_to_send)
	{
		alert("Please enter your question you would like to ask 1st Galaxy Fireworks");
		my_form.faqQuestion.focus();
		ok_to_send = false;
	}
	if (ok_to_send)
	{
		my_form.submit();
	}
}

function formExpertAdvice(my_form)
{
	var validateChkbox = false;
	if(my_form.datamethod.value=='Discard' || my_form.datamethod.value=='Delete') 
	{
		return true;
		
	}
	else if(my_form.datamethod.value=='Reply')
	{
		validateChkbox = true;
	}
	if(my_form.faqQuestion.value=="" || my_form.faqQuestion.value==" ")
	{
		alert("You need to specify a question.");
		my_form.faqQuestion.focus();
		return false;
	}
	if(my_form.faqAnswer.value=="" || my_form.faqAnswer.value==" ")
	{
		alert("You need to specify an answer.");
		my_form.faqAnswer.focus();
		return false;
	}
	if(validateChkbox)
	{
		if(my_form.listFAQ.checked)
		{
			if(my_form.faqCategory.value=="empty")
			{
				alert("You need to specify an FAQ category for this question.");
				my_form.faqCategory.focus();
				return false;
			}
		}
	}
	if(my_form.datamethod.value=='Edit' || my_form.datamethod.value=='Add')
	{
		if(my_form.faqCategory.value=="empty")
		{
			alert("You need to specify an FAQ category for this question.");
			my_form.faqCategory.focus();
			return false;
		}
	}
	if(validateChkbox)
	{
		if(!my_form.listFAQ.checked)
		{
			if(!confirm("If you would like to add this question to the FAQ database please click 'Cancel' and tick the checkbox.\nIf you just want to send an email message with the answer on it click 'OK'"))
			{
				return false;
			}
		}
	}
	//passed all tests return true
	return true;
}

function formMetatag(){
var ok_to_send = true;
var my_form=document.metaEditor;
	if(my_form.titleEditor.value=="" || my_form.titleEditor.value==" ")
	{
		alert("You need to specify a title for this page.");
		my_form.titleEditor.focus();
		ok_to_send = false;
	}
	if((my_form.descriptionEditor.value=="" || my_form.descriptionEditor.value==" ") && ok_to_send)
	{
		alert("You need to specify a description for this page.");
		my_form.descriptionEditor.focus();
		ok_to_send = false;
	}
	if((my_form.keywordsEditor.value=="" || my_form.keywordsEditor.value==" ") && ok_to_send)
	{
		alert("You need to specify keywords for this page.");
		my_form.keywordsEditor.focus();
		ok_to_send = false;
	}
	if (ok_to_send)
	{
		my_form.submit();
	}
}

function formEvent(){
var ok_to_send = true;
var my_form=document.sampleform;
	if(my_form.eventName.value=="" || my_form.eventName.value==" ")
	{
		alert("You need to specify a title for this event.");
		my_form.eventName.focus();
		ok_to_send = false;
	}
	if((my_form.eventDescription.value=="" || my_form.eventDescription.value==" ") && ok_to_send)
	{
		alert("You need to specify a description for this event.");
		my_form.eventDescription.focus();
		ok_to_send = false;
	}
	if((my_form.firstinput.value=="" || my_form.firstinput.value==" ") && ok_to_send)
	{
		alert("You need to specify a date for this event.");
		my_form.keywordsEditor.focus();
		ok_to_send = false;
	}
	if((my_form.eventCategory.value=="" || my_form.eventCategory.value==" ") && ok_to_send)
	{
		alert("You need to specify what type of event this event is (public / organised).");
		my_form.eventCategory.focus();
		ok_to_send = false;
	}
	if (ok_to_send)
	{
		my_form.submit();
	}
}

function notValidEmail(pString){
var dotpos=pString.indexOf('.');
var atpos=pString.indexOf('@');
	if(atpos == -1 || (pString=="") || (pString==" ") || (pString.length < 6)){
		return true;
	}
	else if(dotpos + 1 == atpos){
		return true;
	}
	else{
		var emailterm=pString.substring(atpos, (pString.length));
		if(emailterm.indexOf('.')==-1 || emailterm.length < 2){
			return true;}
		else return false;
	}

}

function bName() {
  // return 1 for Internet Explorer
  if (navigator.appName == "Microsoft Internet Explorer")
    return 1;

  // return 2 for Navigator
  if (navigator.appName == "Netscape")
    return 2;

  // return 0 for other browsers
  return 0;
}

function bVer() {
  // return version number (e.g., 4.03)
  return parseFloat(navigator.appVersion)
}

var nameCode = bName();
var versionCode = bVer();

function resizeBoxes(){
if(nameCode==1){
document.feedback.firstname.size=30;
document.feedback.lastname.size=30;
document.feedback.company.size=30;
document.feedback.address.cols=29;
document.feedback.postcode.size=30;
document.feedback.phone.size=30;
document.feedback.fax.size=30;
document.feedback.mobile.size=30;
document.feedback.email.size=30;
document.feedback.comments.cols=29;}
else if(versionCode>=5){
document.feedback.firstname.size=30;
document.feedback.lastname.size=30;
document.feedback.company.size=30;
document.feedback.address.cols=27;
document.feedback.postcode.size=30;
document.feedback.phone.size=30;
document.feedback.fax.size=30;
document.feedback.mobile.size=30;
document.feedback.email.size=30;
document.feedback.comments.cols=27;}
}

function resizeBoxes2(){
if(nameCode==1){
document.faqForm.firstname.size=30;
document.faqForm.lastname.size=30;
document.faqForm.contactemail.size=30;
document.faqForm.faqQuestion.cols=29;}
else if(versionCode>=5){
document.faqForm.firstname.size=30;
document.faqForm.lastname.size=30;
document.faqForm.contactemail.size=30;
document.faqForm.faqQuestion.cols=27;}
}

function resizeBoxes3()
{
	if(nameCode==1)
	{//IE
		document.sampleform.firstname.size=30;
		document.sampleform.lastname.size=30;
		document.sampleform.address.cols=29;
		document.sampleform.postcode.size=30;
		document.sampleform.phone.size=30;
		document.sampleform.email.size=30;
		document.sampleform.venue.size=30;
		document.sampleform.venue_contact.size=30;
		document.sampleform.venue_contact_no.size=30;
		document.sampleform.venue_address.cols=29;
		document.sampleform.firing_time.size=30;
		document.sampleform.budget.size=30;
	}
	else if(versionCode>=5)
	{//netscape 6+
		document.sampleform.firstname.size=30;
		document.sampleform.lastname.size=30;
		document.sampleform.address.cols=27;
		document.sampleform.postcode.size=30;
		document.sampleform.phone.size=30;
		document.sampleform.email.size=30;
		document.sampleform.venue.size=30;
		document.sampleform.venue_contact.size=30;
		document.sampleform.venue_contact_no.size=30;
		document.sampleform.venue_address.cols=27;
		document.sampleform.firing_time.size=30;
		document.sampleform.budget.size=30;
	}
}

function resizeBoxes4()
{
	if(nameCode==1)
	{//IE
		document.feedback.firstname.size=30;
		document.feedback.lastname.size=30;
		document.feedback.address.cols=29;
		document.feedback.postcode.size=30;
		document.feedback.phone.size=30;
		document.feedback.email.size=30;
		document.feedback.venue.size=30;
		document.feedback.venue_contact.size=30;
		document.feedback.venue_contact_no.size=30;
		document.feedback.venue_address.cols=29;
	}
	else if(versionCode>=5)
	{//netscape 6+
		document.feedback.firstname.size=30;
		document.feedback.lastname.size=30;
		document.feedback.address.cols=27;
		document.feedback.postcode.size=30;
		document.feedback.phone.size=30;
		document.feedback.email.size=30;
		document.feedback.venue.size=30;
		document.feedback.venue_contact.size=30;
		document.feedback.venue_contact_no.size=30;
		document.feedback.venue_address.cols=27;
	}
}

function resizeBoxes5()
{
	if(nameCode==1)
	{//IE
		document.feedback.firstname.size=30;
		document.feedback.lastname.size=30;
		document.feedback.address.cols=29;
		document.feedback.postcode.size=30;
		document.feedback.phone.size=30;
		document.feedback.email.size=30;
	}
	else if(versionCode>=5)
	{//netscape 6+
		document.feedback.firstname.size=30;
		document.feedback.lastname.size=30;
		document.feedback.address.cols=27;
		document.feedback.postcode.size=30;
		document.feedback.phone.size=30;
		document.feedback.email.size=30;
	}
}

function resizeSearchBox(){
if(nameCode==1){
document.searchform.productQuery.size=13;}
else if(versionCode>=5){
document.searchform.productQuery.size=13;}
}


function restrictLength(pElem,pInt){
if(pElem.value.length > pInt){
 alert("Sorry, you've reached the maximum number of characters allowed for this text box.");
 pElem.value = pElem.value.substring(0,pInt);}
}

function calcCharLeft(target) {
    var maxLength = 255;
    if (target.value.length > maxLength) {
      target.value = target.value.substring(0,maxLength);
      charleft = 0;
    }
    else {
      charleft = maxLength - target.value.length;
    } document.sampleform.charCount.value = charleft;
}
  
function moveSelectedOptions(from,to) {
 for (var i=(from.options.length-1); i>=0; i--) {
  var o = from.options[i];
  if (o.selected) {
   to.options[to.options.length] = new Option( o.text, o.value, false, false);
   from.options[i] = null;
   }
  }
 from.selectedIndex = -1;
 to.selectedIndex = -1;
 sortSelect(from);
 sortSelect(to);
 }

function moveAllOptions(from,to) {
 for (var i=(from.options.length-1); i>=0; i--) {
  var o = from.options[i];
  to.options[to.options.length] = new Option( o.text, o.value, false, false);
  from.options[i] = null;
  }
 sortSelect(from);
 sortSelect(to);
 from.selectedIndex = -1;
 to.selectedIndex = -1;
 }
 
 function sortSelect(obj) {
	var o = new Array();
	if (obj.options==null) { return; }
	for (var i=0; i<obj.options.length; i++) {
		o[o.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected) ;
		}
	if (o.length==0) { return; }
	o = o.sort( 
		function(a,b) { 
			if ((a.text+"") < (b.text+"")) { return -1; }
			if ((a.text+"") > (b.text+"")) { return 1; }
			return 0;
			} 
		);

	for (var i=0; i<o.length; i++) {
		obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
		}
	}

function selectAllOptions(obj) {
	var selBox = eval("document.cep3."+obj);
 for (var i=0; i<selBox.options.length; i++) {
  selBox.options[i].selected = true;
  }
 }
 
 function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
}

function windowOpener(pUrl,pWidth,pHeight)
{
	var winFeat='scrollbars=yes,resizable=yes,width='+pWidth+',height='+pHeight;
	var popwin = window.open(pUrl,'popwin',winFeat);
	popwin.focus();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



function pdfBrochure(pUrl)
{
	var midScreenWidth = (screen.availWidth)/2; // find the mid width
	var midScreenHeight = (screen.availHeight)/2; // find the mid height
	var l = midScreenWidth - 208; // position left
	var t = midScreenHeight - 210; // position top
	var winFeatures = ("width=416,height=420,left="+l+",top="+t+",scrollbars=1,resizeable=1");
	var popWin;	

	if(!popWin || popWin.closed)
	{
  		popWin = window.open(pUrl, 'popWin', winFeatures);
 	}
 	else
	{
  		popWin.location = pUrl;
  		popWin.focus();
 	}
	//window.opener.location.reload();
}

//-->
