<!--


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_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

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_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 findbedrooms(numberofbeds,pathname){
	var stopat = eval(numberofbeds) + 1;
	//alert('this is number of beds - '+numberofbeds+'\n ..and this is pathname - '+pathname+'');
	for (k=1; k<stopat ; k++){
 //alert ('this is it - '+);
	//MM_changeProp('bedroom'+k,'','style','babyon' ,'div');
	MM_changeProp(pathname+k,'','className','babyon','DIV')
}

		for (l=11; l>eval(numberofbeds) ; l--){
 //alert ('this is it - '+);
	//MM_changeProp('bedroom'+k,'','style','babyon' ,'div');
	MM_changeProp(pathname+l,'','className','baby','DIV')
}
}

function round_decimals(original_number, decimals) {
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}

function pad_with_zeros(rounded_value, decimal_places) {

    // Convert the number to a string
    var value_string = rounded_value.toString()
    
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")

    // Is there a decimal point?
    if (decimal_location == -1) {
        
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0
        
        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }
    
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length
    
    if (pad_total > 0) {
        
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++) 
            value_string += "0"
        }
    return value_string
}

function add_it_baby(howmany,howmuch,whereto){

	//alert(howmany+","+howmuch+","+whereto);

	var myvalue = 0;

	if(whereto == "guest_tickets"){

	myvalue = ( eval(window.document.adform.exhibitor_ticket.value) + eval(window.document.adform.guest_tickets.value) ) * howmuch;
	
	}else{
	
	myvalue = howmany * howmuch;
	
	}
	
	//alert(myvalue);
	
	MM_changeProp(whereto+'_value','','innerHTML',myvalue,'SPAN');
	
	
	
	normal_subtotal = ((eval(document.adform.qp_bw.options[document.adform.qp_bw.selectedIndex].value))*110)+((eval(document.adform.hp_bw.options[document.adform.hp_bw.selectedIndex].value))*165)+((eval(document.adform.hp_bw.options[document.adform.wp_bw.selectedIndex].value))*225)+((eval(document.adform.hp_bw.options[document.adform.wpb_bw.selectedIndex].value))*245)+((eval(document.adform.qp_fc.options[document.adform.qp_fc.selectedIndex].value))*220)+((eval(document.adform.hp_fc.options[document.adform.hp_fc.selectedIndex].value))*300)+((eval(document.adform.hp_fc.options[document.adform.wp_fc.selectedIndex].value))*410)+((eval(document.adform.hp_fc.options[document.adform.wpb_fc.selectedIndex].value))*435)
	
	premium_subtotal = ((eval(document.adform.ifc.options[document.adform.ifc.selectedIndex].value))*625)+((eval(document.adform.ibc.options[document.adform.ibc.selectedIndex].value))*490)+((eval(document.adform.oifc.options[document.adform.oifc.selectedIndex].value))*625)+((eval(document.adform.opr.options[document.adform.opr.selectedIndex].value))*625)+((eval(document.adform.ocp.options[document.adform.ocp.selectedIndex].value))*760)+((eval(document.adform.bp.options[document.adform.bp.selectedIndex].value))*1225)


	if (document.adform.cat_entry.checked == true){
		check_total = 75;
	}
	if (document.adform.cat_entry.checked == false){
		check_total = 0;
	}
	
	
	
	MM_changeProp('normal_total','','innerHTML',normal_subtotal,'SPAN');
	
	MM_changeProp('premium_total','','innerHTML',premium_subtotal,'SPAN');
	
	grand_total_is = normal_subtotal+premium_subtotal+check_total;
	
	MM_changeProp('grand_total','','innerHTML',grand_total_is,'SPAN');
	
	// alert('howmany = '+howmany+'\n\n howmuch = '+howmuch+'\n\n whereto = '+whereto+'\n\n premium_subtotal = '+premium_subtotal+'\n\n normal_subtotal = '+normal_subtotal+'\n\n check_total = '+check_total+'');

}

function CountWords(this_field, show_word_count, show_char_count) {
if (show_word_count === undefined) {show_word_count = true;} // show is default
if (show_char_count === undefined) {show_char_count = false;} //noshow is deft
var char_count = this_field.value.length;               // very crude measure
var fullStr = this_field.value + " ";   // add space delimiter to end of text
var initial_whitespace_rExp= /^[^A-Za-z0-9]+/gi; //use for complex whitespace
var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
var non_alphanumerics_rExp = /[^A-Za-z0-9]+/gi;         // and for delimiters
var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
var splitString = cleanedStr.split(" ");
var word_count = splitString.length -1;



if (fullStr.length <2) {word_count = 0;}
if (word_count == 1) {wordOrWords = " word";}
   else {wordOrWords = " words";}
if (char_count == 1) {charOrChars = " character";}
   else {charOrChars = " characters";}
if (show_word_count && show_char_count) {
   var msg = "Word Count:\n" + "" + word_count + wordOrWords + "\n";
   msg += "" + char_count + charOrChars;
   window.alert(msg);
   } else {
		if (word_count > 50) {
			var preresult = (word_count-50)*.2;
			var newcharge = round_decimals(preresult, 2);
			var wcstatus = window.confirm("The Catalogue Entry is a maximum of 50 words.\n\n You have written " + word_count + wordOrWords+'\n\n Additional words are charged at 20p each making the charge for this entry £'+newcharge+'\n\n To continue and pay the exta click OK \n To amend your text to 50 words click Cancel') ;
			if (wcstatus){
				document.submit();
			}
		}
   		else {
      		document.submit();
      	}
   }
return word_count; }


function calculate_tickets(ticketsleft, ticketsbought){

//get no exhibitor tickets selected
var sel = document.getElementById("ex_tickets");
var num_ex_tickets_buying = eval(sel.options[sel.selectedIndex].value);

//if none are selected, set var to 0
if(!num_ex_tickets_buying) 
	num_ex_tickets_buying = 0;

//get no guest tickets selected
var num_gu_tickets_buying = eval(document.getElementById("gu_tickets").value);

//if none are selected, set var to 0
if(!num_gu_tickets_buying) 
	num_gu_tickets_buying = 0;

//total tickets
var total_tix = num_ex_tickets_buying + num_gu_tickets_buying;

//total extra, or less tickets than already selected
var total_extra_tix = total_tix - ticketsbought;

//if extra tickets is more than tickets left, display error

if(total_extra_tix > ticketsleft){
if(ticketsbought!=0){

	alert("You have selected " + total_extra_tix + " extra tickets, but there are only " +ticketsleft+ " tickets left. \n\nPlease change your ticket numbers and try again");

}else{

	alert("You have selected " + total_extra_tix + " tickets, but there are only " +ticketsleft+ " tickets left. \n\nPlease change your ticket numbers and try again");

}

}else{

	window.document.adform.submit();

}



}


function addmoreguests(guesttype, companynum){

	if(guesttype=="guest"){
	
	//add a guest to the company selected
	document.getElementById("additional_"+companynum).value = 5;
	
	}
	
	if(guesttype=="company"){

	//add another company
	document.getElementById("additionalcompanies").value = 5;
	
	}

document.addform.submit();

}

function guestsdone(){

document.addform.action = "exhibitor_process.html"
document.addform.submit();

}

//-->