// JavaScript Document

function generate_address(username) {
        var domain = "rhapsodybridal.co.uk";
        var atsign = "&#64;";
        var addr = username + atsign + domain;
        document.write( 
          "<" + "a" + " " + "href=" + "mail" + "to:" + addr + ">" +
          addr +
          "<\/a>");
      }
	  
function AddToBasket(description, opt, optname, opt2, optname2, opt3, optname3, qty, price) {

	var price;
	var itemDesc;
	var nextURL;

			
	<!-- validate qty  -->
	if (qty < 1) {
		alert ("No quantity entered");
		return;
	}
	
	<!-- validate price  -->
	if (price < 1) {
		alert ("No price entered");
		return;
	}

	<!-- build description  -->
	if (optname == "") {
		itemDesc = description;
	} else {
		if (opt == "Please select one") {
			alert("Please select "+optname);
			return;
		} else {
			itemDesc = description + " " + optname + ": " + opt;
		}
	}
	
	if (optname2 != "") {
		if (opt2 == "Please select one") {
			alert("Please select "+optname2);
			return;
		} else {
			itemDesc = itemDesc + " " + optname2 + ": " + opt2;
		}
	}
	
	if (optname3 != "") {
		if (opt3 == "Please select one") {
			alert("Please select "+optname3);
			return;
		} else {
			itemDesc = itemDesc + " " + optname3 + ": " + opt3;
		}
	}

	<!-- Replace all spaces with a + -->
	itemDesc=itemDesc.replace(/ /g,"+");
	itemDesc=itemDesc.replace(/&/g,"and");
	
	<!-- Set return page -->
	nextURL=window.location.href;
			
	<!-- Add to and display basket -->
	window.location.href = "http://www.romancart.com/cart.asp?itemname="+itemDesc+"&storeid=45599&quantity="+qty+"&price="+price+"&returnurl="+nextURL;
	
}	


function showField(data) {

	if (data != "" && data !="£") {
		data=data.replace(/"/g,"\'\'");
		document.write(data)
	}
	
}
function tidyField(data) {

	data=data.replace(/"/g,"\'\'");
	alert (data);
	return data;	
	
}

function homesearch(s) {

	var srch = "/listman/exec/search.cgi?search=1&";

	srch=srch+"lfield4_keyword="+s;
		
	srch=srch+"&sort_order=1&perpage=10&template=_search_results.html";
		
	window.location.href = srch;

}

function MakeOptions(frmname,opts,selname) {

	var opt_string = opts;
	var opt_array = opt_string.split(",");
	var s = document.forms[frmname].elements[selname];

	 if (s.options.length == 1) {
		  for (var i = 0; i < opt_array.length; i++) {
			   s.options.add(new Option(opt_array[i], opt_array[i]), s.options.length);
		  }
	 }
	
}

function hideElement(opts,optno) {
	
	if (opts == "") {
		var s;
		if (optno == 1)
			s = document.form1.choices;
		if (optno == 2)
			s = document.form1.choices2;
		if (optno == 3)
			s = document.form1.choices3;

		s.style.visibility='hidden';
	}
	
}
