function highLight()

{

	for (var i = 1; i <= document.anchors.length; i ++)

	{

		if (document.anchors[i] == location.href)

		{	

			var id = document.anchors[i].name;

			

			if (id == '')

			{

				continue;

			}

			else

			{

				document.getElementById(id).className = "locationcell";

			}

		

		}

	}


}				


function cellchange(cell, colour)

{

	document.getElementById(cell).style.background = colour;

}


function one2two() {

var m1 = document.theForm.menu1;

var m2 = document.theForm.elements["menu2[]"];


    m1len = m1.length ;

    for ( i=0; i<m1len ; i++){

        if (m1.options[i].selected == true ) {

            m2len = m2.length;

            

			m2.options[m2len]= new Option(m1.options[i].text);

			m2.options[m2len].value= m1.options[i].value;

        }

    }


    for ( i = (m1len -1); i>=0; i--){

        if (m1.options[i].selected == true ) {

            m1.options[i] = null;

        }

    }

		for (i=0; i<m2.length; i++) { 

		m2.options[i].selected = true; 

		} 


}


function two2one() {

var m1 = document.theForm.menu1;

var m2 = document.theForm.elements["menu2[]"];


    m2len = m2.length ;

        for ( i=0; i<m2len ; i++){

            if (m2.options[i].selected == true ) {

                m1len = m1.length;

                m1.options[m1len]= new Option(m2.options[i].text);

            }

        }

        for ( i=(m2len-1); i>=0; i--) {

            if (m2.options[i].selected == true ) {

                m2.options[i] = null;

            }

        }




}



function quickJump()

{	if (document.forms['jump'].url.value == 0)

	{

		return false;

	}

	parent.location = document.forms['jump'].url.value;

}


function calculateQuote(loop, tasterPrice, packPrice, setUpfee)

{


	var packs_required   = 0;

	var tasterGrandTotal = 0;

		

	var totalRounds = document.forms['quote'].elements['rounds'].value;

	

	for (i = 1; i <= loop; i ++)

	{	

		tasterTotal = parseInt(document.forms['quote'].elements[i].value);

		pack = tasterTotal%10;

		

		if (pack != 0)

		{

			pack = 10 - pack;

		}

		

		packs_required   += (pack + tasterTotal)/10;

		tasterGrandTotal += tasterTotal;

	}

	

	tasterPrice = tasterPrice * tasterGrandTotal * totalRounds;

	

	var grand_total = packs_required * packPrice * totalRounds + tasterPrice + setUpfee;

	var total_ongoing = grand_total - setUpfee;

	

	document.forms['quote'].total.value = grand_total;

	document.forms['quote'].total_ongoing.value = total_ongoing;

	

}


function quoteLoop(lang)

{

	location.href="beer.php?lang="+lang+"&loop="+document.forms['quote'].no_brewery.value+"&page=tasterValQuote";

}


function quoteSystem(tasters, loop, lang)

{

	document.write("<select name='no_brewery' class='formtextselect' onchange='quoteLoop(\""+lang+"\")'>");

	

	for (i = 2; i <= 200; i ++)

	{

		if (i == loop)

		{

			document.write("<option value='"+i+"' selected>"+i+"</option>");

			continue;

		}

		document.write("<option value='"+i+"'>"+i+"</option>");

	}

		

		document.write("</select></td></tr>");

		

	for (i = 1; i <= loop; i ++)

	{	

		

		document.write("<tr><td class='tdwhite' style='background-color:#e8e8e8'>"+tasters+" "+i+"</td>");

		document.write("<td class='tdwhite' style='background-color:#e8e8e8'><select class='formtextselect' name='no_tasters"+i+"'>");

		

		for (j = 6; j <= 100; j ++)

		{

			document.write("<option value='"+j+"'>"+j+"</option>");

		}

		

		document.write("</select></td></tr>");

	}

}


function quizScore(w,c)

{	

	var msg     = "";

	var score   = 0;

	var correct = new Array(1, 8, 11, 15, 20, 28, 31, 36, 40, 48, 51, 58, 60, 66, 72, 76, 82, 86, 91, 93);

	

		

	for (i = 0, j = 1; i < correct.length; i ++, j ++)

	{

		if (document.forms['quiz'].elements[correct[i]].checked == true)

		{

			score += 1;

			msg   += j + ")\t= " + c + "\n";

		}

		else

		{

			msg   += j + ")\t= " + w + "\n";

		}

	}

	

	msg += "_______________\n";

	msg += Math.ceil(score * 100 / (correct.length)) + " %" + " " + c + "\n";

	msg += "_______________\n";

	

	alert(msg);

}




	/* globals */

	counter = 2;

	function duplicate(copyRef)

	{	

		var formName = 'courseReg';

		var pasteRef = copyRef+1;

		var status   = 'sameAs[' +copyRef+  ']';

		var pasteRef =       '[' +pasteRef+ ']';

		var copyRef  =       '[' +copyRef+  ']';

		

					

		var copy     = new Array();

		copy[0]      = 'nameCompany'  + copyRef;

		copy[1]      = 'address1' 	+ copyRef;

		copy[2]      = 'address2'     + copyRef;

		copy[3]      = 'city'         + copyRef;

		copy[4]      = 'stateCounty'  + copyRef;

		copy[5]      = 'zipPost'      + copyRef;

		copy[6]      = 'country'      + copyRef;

		copy[7]      = 'phone'        + copyRef;

		copy[8]      = 'fax'          + copyRef;

				

		var paste    = new Array();

		paste[0]     = 'nameCompany'  + pasteRef;

		paste[1]     = 'address1'     + pasteRef;

		paste[2]     = 'address2'     + pasteRef;

		paste[3]     = 'city'         + pasteRef;

		paste[4]     = 'stateCounty'  + pasteRef;

		paste[5]     = 'zipPost'      + pasteRef;

		paste[6]     = 'country'      + pasteRef;

		paste[7]     = 'phone'        + pasteRef;

		paste[8]     = 'fax'          + pasteRef;

	

		if (document.forms[formName].elements[status].checked)

		{

			for (i = 0; i < copy.length; i ++)

			{

				document.forms[formName].elements[paste[i]].value = document.forms[formName].elements[copy[i]].value;

			}

		}

		else

		{	

			for (i = 0; i < copy.length; i ++)

			{	

				document.forms[formName].elements[paste[i]].value = '';

			}	

		}

		

		

	}


function cellColour(cell,style,colour)

{

/* table cell */

	document.getElementById(cell).className = style;

	

	

/* text within cell */

	document.getElementById(cell+'T').className = colour;

}


function cellLink(path)

{

	parent.location = path;

}


function formValidator(form)

{

/*methods*/

this.emailCheck   		= emailCheck;

this.numericCheck   	= numericCheck;

this.emptyCheck			= emptyCheck;

this.stringLengthCheck  = stringLengthCheck;

this.selectedCheck  	= selectedCheck;

this.checkBoxCheck		= checkBoxCheck;

this.errors				= errors;

/*form path*/

this.form     			= form;

 

/*error messages*/

this.errorList = '';


this.msgEmail   		= "Your email address is invalid.\n";

this.msgNameFirst  	= "Your first name is invalid.\n";

this.msgNameLast  	= "Your last name is invalid.\n";

this.msgPostCode  	= "Your post code is invalid.\n";

this.msgPassword  	= "Your password is invalid.\n";

this.msgRePassword  	= "Your password and re-entered password are not the same.\n";

this.msgComments  	= "The message field cannot be left blank.\n";

this.msgPhoneNumber  	= "Your phone number is invalid.\n";

this.msgNumber   		= "This field has to be numeric.\n";

this.msgLength   		= "This field has to be x charachters long.\n";

this.msgSelect   		= "Please make a selection.\n";

this.msgDate   		= "You must select a date.\n";


/*form element highlight colour*/

this.colour    		= '#e8e8e8';

 

}


function checkBoxCheck(message)

{

	var flag = 0;

	

	for (i = 0; i < this.form.elements.length; i ++ )

	{

		if (this.form.elements[i].checked)

		{

			var flag = 1;

		}

	}


	if (flag == 0)

	{

		this.errorList += message;

		

		return false;

	}

	else

	{

		return true;

	}

}


function emptyCheck(elNum, message)

{

	if (this.form.elements[elNum].value == '' || this.form.elements[elNum].value == 0)

	{

		this.errorList += message;

		

		this.form.elements[elNum].style.background = this.colour;

		

		return false;

	}

	else

	{

		return true;

	}

	

}


function emailCheck(elNum, message)

{

emailValue = this.form.elements[elNum].value;

 

	if ((emailValue.indexOf('@') < 0) || ((emailValue.charAt(emailValue.length-4) != '.') && (emailValue.charAt(emailValue.length-3) != '.')))

 	{

 	this.errorList += message;

 

 	//this.form.elements[elNum].focus();

 	this.form.elements[elNum].style.background = this.colour;

 

 	return false;

 	}

	else

	{

	return true;

	}

}

 

function numericCheck(elNum, message)

{

	var oldstring = this.form.elements[elNum].value;

	var newstring = parseFloat(oldstring).toString();

 

 	if (oldstring.length != newstring.length && newstring == 'NaN') 

 	{

 	//alert(this.msgNumber);

 	this.errorList += message;

 

 	this.form.elements[elNum].focus();

 	this.form.elements[elNum].style.background = this.colour;

 

 	return false;

 }

 

 	else

 	{

 	return true;

 	}

}

 

function stringLengthCheck(elNum, amount, message)

{

 	if(this.form.elements[elNum].value.length < amount)

 	{

 	this.errorList += message;

  

 	//this.form.elements[elNum].focus();

 	this.form.elements[elNum].style.background = this.colour;

 

 	return false;

 	}

 

 	else

 	{

 	return true;

 	}

}

 

function selectedCheck(elNum, message)

{

 	if(this.form.elements[elNum].value == 'none')

 	{

  	this.errorList += message;

 

 

 	this.form.elements[elNum].focus();

 	this.form.elements[elNum].style.background = this.colour;

 

 	return false;

 	}

 

 	else

 	{

 	return true;

 	}

}


function errors()

{

	if(this.errorList)

	{

	alert(this.errorList);

	

	return false;

	}

	

	else

	{

	return true;

	}


}



/* globals */

pack_20_total	= 0;

pack_5_total 	= 0;

TIB_total		= 0;

TTT_total 		= 0;

total 		= 0;


function numItem(element, action, type)

{	

	var path 		= document.forms['order'].elements[element].value;

		

	if (action == 'add')

	{

		path = document.forms['order'].elements[element].value = parseInt(path) + 1;

	

		if (type == 5)

		{

			pack_5_total ++;

		}

		else if (type == 20)

		{

			pack_20_total ++;

		}

		else if (type == 'TTT')

		{

			TTT_total ++;

		}

		else if (type == 'TIB')

		{

			TIB_total ++;

		}

		

	}

	if (action == 'minus')

	{

		if (path == 0)

	 	{

	 		return false;

	 	}

		else

		{

			document.forms['order'].elements[element].value --;

		}

		if (type == 5)

		{

			pack_5_total --;

		}

		else if (type == 20)

		{

			pack_20_total --;

		}

		else if (type == 'TTT')

		{

			TTT_total --;

		}

		else if (type == 'TIB')

		{

			TIB_total --;

		}

	}

	/* flavour stands running total */

	if (type == 20 || type == 5)

	{		

		var pack_20_price	= document.forms['order'].price_20.value;

		var pack_5_price	= document.forms['order'].price_5.value;

		

		document.forms['order'].elements['total'].value = pack_20_price * pack_20_total + pack_5_price * pack_5_total;

	}

	

	/* flavour stands running total */

	else if (type == 'TTT')

	{

		var TTT_price	= document.forms['order'].priceTTT.value;

		

		document.forms['order'].elements['total'].value = TTT_price * TTT_total;

	}

	

	else if (type == 'TIB')

	{

		var TIB_price	= document.forms['order'].priceTIB.value;

		

		document.forms['order'].elements['total'].value = TIB_price * TIB_total;

	}

}


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.0

  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 && document.getElementById) x=document.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 GetScreenSize() 

{ 

	var swidth = screen.width; 

	var sheight = screen.height; 

} 

