/**
 * Equal Heights Plugin
 * Equalize the heights of elements. Great for columns or any elements
 * that need to be the same size (floats, etc).
 * 
 * Version 1.0
 * Updated 12/10/2008
 *
 * Copyright (c) 2008 Rob Glazebrook (cssnewbie.com) 
 *
 * Usage: $(object).equalHeights([minHeight], [maxHeight]);
 * 
 * Example 1: $(".cols").equalHeights(); Sets all columns to the same height.
 * Example 2: $(".cols").equalHeights(400); Sets all cols to at least 400px tall.
 * Example 3: $(".cols").equalHeights(100,300); Cols are at least 100 but no more
 * than 300 pixels tall. Elements with too much content will gain a scrollbar.
 * 
 */

(function($) {
	$.fn.equalHeights = function(minHeight, maxHeight) {
		tallest = (minHeight) ? minHeight : 0;
		this.each(function() {
			if($(this).height() > tallest) {
				tallest = $(this).height();
			}
		});
		if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
		return this.each(function() {
			$(this).height(tallest).css("overflow","auto");
		});
	}
})(jQuery);

function shippingPrice(formname){
	if(formname=='wbcrn'){
		var costs = document.wbcrn.Postage.value.split(",");
		document.wbcrn.shipping.value = costs[0];
		document.wbcrn.shipping2.value = costs[1];
	}else if(formname=='wbc'){
		var costs = document.wbc.Postage.value.split(",");
		document.wbc.shipping.value = costs[0];
		document.wbc.shipping2.value = costs[1];
	}else if(formname=='lab'){
		var costs = document.lab.Postage.value.split(",");
		document.lab.shipping.value = costs[0];
		document.lab.shipping2.value = costs[1];
	}
}









function getRadios(what){
	var amount="";
	// get the color value
	j=what.amount.length; //alert(j)
	for (i=0; i<j; i++){
		if(what.amount[i].checked) var amount = what.amount[i].value
	}
// show selections

	if(amount=="28.75"){
		updatecities(0)
	}else if(amount=="10.00"){
		updatecities(1)
	}
}
	// End -->
	
	
	
function updatecities(selectedcitygroup){
	var countrieslist=document.wbcrn.countries;
	var citieslist=document.wbcrn.item_name;
	
	var cities=new Array()
	cities[0]=["Euro Pres by Sally Goddard Blythe and Dr Peter Blythe|Euro Pres by Sally Goddard Blythe and Dr Peter Blythe", "Euro Pres by Dr Ursula Anderson|Euro Pres by Dr Ursula Anderson", "Euro Pres by Dr Harry Schneider|Euro Pres by Dr Harry Schneider", "Euro Pres by Dr Luis Gomez|Euro Pres by Dr Luis Gomez", "Euro Pres by Dr Lawrence J. Beuret|Euro Pres by Dr Lawrence J. Beuret", "Euro Pres by Beverly Steffert|Euro Pres by Beverly Steffert", "Euro Pres by Dr Richard T. Halvorsen|Euro Pres by Dr Richard T. Halvorsen", "Euro Pres by Dr Curtis Cripe|Euro Pres by Dr Curtis Cripe", "Euro Pres by Pat Charlton and Alison Hore|Euro Pres by Pat Charlton and Alison Hore"]
	cities[1]=["Euro Pres by Dr Harry Schneider|Euro Pres by Dr Harry Schneider", "Euro Pres by Dr Lawrence J. Beuret|Euro Pres by Dr Lawrence J. Beuret", "Euro Pres by Dr Richard T. Halvorsen|Euro Pres by Dr Richard T. Halvorsen"]
	citieslist.options.length=0
	for (i=0; i<cities[selectedcitygroup].length; i++)
		citieslist.options[citieslist.options.length]=new Option(cities[selectedcitygroup][i].split("|")[0], cities[selectedcitygroup][i].split("|")[1])
}



function validateonsubmit(formname,buttonmsg){
	var myForm=document.getElementById(formname);
	var SS= Spry.Widget.Form.validate(myForm);
	if(SS==true){
	document.getElementById('form-submit').href='javascript:;';
	document.getElementById('form-submit').innerHTML=buttonmsg;
	myForm.submit();
	}
}

function copyaddress(form,checkbox){
	var theform = form ;
	var thecheckbox = checkbox ;
	if(document.getElementById(thecheckbox).checked == true){
		document.getElementById('inv_address_line_1').value = document.getElementById('address_line_1').value;
		document.getElementById('inv_address_line_2').value = document.getElementById('address_line_2').value;
		document.getElementById('inv_address_town').value = document.getElementById('address_town').value;
		document.getElementById('inv_address_county').value = document.getElementById('address_county').value;
		document.getElementById('inv_address_postcode').value = document.getElementById('address_postcode').value;
	}else{
		document.getElementById('inv_address_line_1').value = "";
		document.getElementById('inv_address_line_2').value = "";
		document.getElementById('inv_address_town').value = "";
		document.getElementById('inv_address_county').value = "";
		document.getElementById('inv_address_postcode').value = "";
	}
}

function navOver(state,id){
	if(state == "show"){
		$(document.getElementById(id)).removeClass("rounded-corners");
		$(document.getElementById(id)).addClass("top-rounded-corners");
	}else{
		$(document.getElementById(id)).removeClass("top-rounded-corners");
		$(document.getElementById(id)).addClass("rounded-corners");
	}
}
