// aa = "http://www.alliedappliance.com.au/";
//updated 16/07/2008
//located in /scripts and /global directories remove from scripts

abrand= new Array('Select one....','Admiral','AEG','Airwell','Americana','Amstrad','Aqua vac','Ariston','Armana','Asea','Asko','Beko','Bendix','Birko','Black & Decker','Blanco','Bosch','Braun','Breezair','Breville','Chef','Convair','Cucina','Daewoo','Davey','De Longhi','Decca','DeLonghi','Dimplex / EWT','Dirt Devil','Dishlex','Dux','Dyson','Electra','Electrolux','Emailair','Eurolec','Eurotech','Ezy Cook','Ferguson','Fisher','Fisher & Paykel','Fridigaire','Fujitsu General','General Electric (GE)','Glen','Goblin','Goldair','Goldstar','Goodmans','Gorenje Pacific','Grundig','Hardi','Hitachi','Hoover','Hotpoint','Ignis','Ilve','Inderset','ITT','JVC','Kambrook','Kelvinator','Kenwood','Kirby','Kleenmaid','Krups','LG Electrics','Linda','Logik','Lux','Malleys','Maytag','Meile','Merloni','Mistral','Mitsubishi','Moulinex','National','NEC','New World','Niagara Therapy','Nikkai','Norge','Omega','Onga','Orion','Oz Spares','Palsonic','Panasonic','Philips','Phillips','Pioneer','Pye','Qld Fridge Seals','Ray-O-Vac','Remington','Rheem','Ronson','Rowenta','Russell Hobbs','Samsung','Sansui','Sanyo','Seeley','Sharp','Sholzer','Simpson','Smeg','Speedqueen','St George','Stokes','Sunbeam','Tatung','Tefal','Thor','Tiffany','Toshiba','Tricity','Uniross','Vax','Volta','Vulcan','Wahl','Westinghouse','Whirlpool','White Night','Zanussi');
atype= new Array('Select one....','Air-conditioner','Automatic Bed','Bread Maker','Bug Zapper','Camper Oven - Gas','Can Opener','Chef / Major','Clothes Dryer','Coffee Maker','Convection Heater','Cooktop','Cooktop - Gas','Deep Fryer','Dishwasher','Electric Knife','Electric Shaver','Elevated Range','Elevated Range - Gas','Espresso Maker','Food Processor','Freezer','Frying Pan','Fuel Effect','Hair Clipper','Hair Curler','Hair Dryer','Hand Blender','Hand Mixer','Hot Water System','Kettle','Liquidiser','Massage Hand Unit','Microwave Oven','Mill','Mixer','Oil Heater','Panel Heater','Range','Range - Dual Fuel - Gas - Electric','Range - Gas','Rangehood','Recliner 2000 Series Chair','Refrigerator','Rice Cooker','Rolla-ssage Chair','Sandwich Maker','Sandwich Press','Sandwich Toaster','Slicer / Schredder','Slow Cooker','Steam Mop','Steam Station','Therapy Bed','Toaster','Toaster Oven','Towel Rail','Underbench Oven','Underbench Oven - Gas','Vacuum Cleaner','Wall Oven','Wall Oven - Gas','Washing Machine');

function range(appliance){
	document.write("We do not have a complete range of parts available on-line as yet and some appliances may not have any parts available on-line. So if you cant find what your looking for do not hesitate to email us about repairing or supplying spare parts to suit " + appliance + "s. Just type your email address and message in the box below and click on the send button.");
}

function email(ABRAND,ATYPE,APARTNAME,APARTNUM){
	
	if (!ABRAND)	 ABRAND="";
	if (!ATYPE)		 ATYPE="";
	if (!APARTNAME) APARTNAME="";
	if (!APARTNUM)  APARTNUM="";
	if ( APARTNUM > '' && APARTNAME > '' ) APARTNUM = APARTNUM + " " + APARTNAME;

	sj  = '<tr><td class="hdg1">Appliance</td>';
	sj += '<td><select name="a_brand" style="width:140px;">';
	for (i in abrand){
		sj += '<option ';
		if ( ABRAND == abrand[i] ) sj += 'SELECTED ';
		sj += 'value="' + abrand[i] + '">' + abrand[i];
	}
	sj += '</select>';
	sj += '<select name="a_type" style="width:140px;">';
	for (i in atype){
		sj += '<option ';
		if ( ATYPE == atype[i] ) sj += 'SELECTED ';
		sj += 'value="' + atype[i] + '">' + atype[i];
	}
	sj += '</select>';
	sj += '<input type="hidden" name="subject" value=""></td></tr>';

	t="<table cellpadding='0' border='0'>";
	t +="<form name='mailer' method='post' action='"+aa+"global/email.php' onSubmit='return checkIt(this);'>";
	t +="<tr><td class=hdg1 valign=top width=120>Your Email Address</td><td><input name='email' maxlength='100'></td></tr>";
	t +="<tr><td>&nbsp;</td></tr>";
	t +="<tr><td class=hdg1 valign=top>Origin</td><td><select name=country><option value='15'>Australia<option value='149'>New Zealand</select></td></tr>";
	t +="<tr><td>&nbsp;</td></tr>";
	t +=sj;
	t +="<tr><td>&nbsp;</td></tr>";
	t +="<tr><td class=hdg1 valign=top>Name</td><td><input name='name' maxlength='100'><td></tr>";
	t +="<tr><td class=normal valign=top colspan=2>Your full name is required for an order enquiry.</td></tr>";
	t +="<tr><td class=hdg1 valign=top>Phone</td><td><input name='phone' maxlength=16 size=16><td></tr>";
	t +="<tr><td class=normal valign=top colspan=2>Your day time phone number is required for an order enquiry in case we have to contact you for more information about the part you require.</td></tr>";
	
	t +="<tr><td class=hdg1 valign=top>Postcode</td><td><input name='post' maxlength=4 size=4><td></tr>";
	t +="<tr><td class=normal valign=top colspan=2>Postcode is required for delivery pricing.</td></tr>";

	t +="<tr><td class=hdg1 valign=top>Model Number</td><td><input name='model'></td></tr>";
	t +="<tr><td class=normal valign=top colspan=2>Required for order enquiry. A full model number is required. Model is found on the appliance nameplate.</td></tr>";
	t +="<tr><td class=hdg1 valign=top>Part Type</td><td><input name='part' value='"+APARTNAME+"'></td></tr>";
	t +="<tr><td class=normal valign=top colspan=2>Required for order enquiry. Be concise, dont use 'a clothes dryer fan belt' use 'belt fan' - we know its a clothes dryer if you selected the right subject!</td></tr>";
	t +="<tr><td>&nbsp;</td></tr>";
	t +="<tr><td class=hdg1 valign=top>Message or<br>Additional Info</td><td><textarea name='message' rows='5' cols='40'>";
	t +=APARTNUM+"</textarea></td></tr>";

	t +="<tr><td></td><td><input type='submit' value='Email Allied Appliance'></td></tr></form></table>";
	document.write(t); 
}

function checkIt(which) {
	
	error = new Array('Sorry, but some fields are not filled out correctly.');
	e=1;
	
	if ( which.email.value.search(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/i) == -1 )
		error[e++] = 'The email address you typed is not supported.';
	
	if (document.forms['mailer'].a_brand.selectedIndex == 0 )
		error[e++] = 'Please select a brand of appliance.';
	
	if (document.forms['mailer'].a_type.selectedIndex == 0 )
		error[e++] = 'Please select a type of appliance.';
	
	if (which.name.value.search(/[^a-z ]/i) != -1 || which.name.value=="" || which.name.value.length<4 || which.name.value.indexOf(" ",1) == -1)
		error[e++] = 'The Name you have typed is not supported. Your full name is required.';

	if (which.phone.value.search(/^[0-9 \(\)]{10,}$/) == -1 )
		error[e++] = 'The phone number you have typed is not supported. Must be 10 digits, no spaces or brackets please. Either mobile or land line with area code.';

	if (which.post.value.search(/^[0-9]{4,5}$/) == -1 )
		error[e++] = 'The postcode must be 4 digits.';

	if (which.model.value.search(/^[\w\*\- ]{3,}$/i) == -1)
		error[e++] = 'The Model you have typed is not supported. a-z0-9_*- can be used';

	if (which.part.value.search(/^[\w\*\- ]{3,}$/i) == -1)
		error[e++] = 'The Part you have typed is not supported. a-z0-9_*- can be used';
		
	if ( which.message.value.search(/^[\w \,\.\?\"\(\)\{\}\[\]\!\@\#\$\%\^\&\*\-\=\+\|\/]*$/i) == -1 )
		error[e++] = 'The Message you have typed is not supported. a-z0-9,.?"(){}[]!@#$%^&*-_=+|/ can only be used';
		
	if ( e > 1 ){
		alert ( error.join("\n") );
		return false;
	}
	
	subject  = document.forms['mailer'].a_brand[document.forms['mailer'].a_brand.selectedIndex].value;
	subject += ' ' + document.forms['mailer'].a_type[document.forms['mailer'].a_type.selectedIndex].value;
	subject  = subject.replace ( '%20' , ' ' );
	document.forms['mailer'].subject.value = subject;
	document.forms['mailer'].action = aa + 'global/email.php#' + subject.replace ( ' ' , '+' );

	return true;

}

