rlm@0: #!/usr/bin/perl
rlm@0: 
rlm@0: 
rlm@0: use List::Util qw(first max maxstr min minstr reduce shuffle sum);
rlm@0: use Storable;
rlm@0: use CGI::Ajax;
rlm@0: use CGI;
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: my $q = new CGI;
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: my %hash = ( 
rlm@0: 'template_material'	=> \&template_material, 
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: 'materials_template' => \&materials_template,
rlm@0: 'display'	=> \&display,
rlm@0: 'inputbox_template'	=> \&inputbox_template,
rlm@0: 
rlm@0: 
rlm@0:  'change_rules' => \&change_rules);
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: my $pjx = CGI::Ajax->new(%hash);
rlm@0: #$pjx->JSDEBUG(1);
rlm@0: #$pjx->DEBUG(1);
rlm@0: 
rlm@0: print $pjx->build_html($q,\&gen); # this outputs the html for the page
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: sub template_material
rlm@0: {
rlm@0: 	
rlm@0: $all = shift;
rlm@0: $all =~ m/_(.*)/;
rlm@0: 
rlm@0: $materialcolor = $1;
rlm@0: 
rlm@0: 	
rlm@0: $r = "$materialcolor	
rlm@0:    <input TYPE=\"image\" src = \"./templates/thumbnails/classic_$materialcolor.jpg\" 	onclick=\"display([\'template1\'], [\'display\']); inputbox_template([\'template1\'], [\'inputbox\']);materials_template([\'template1\'], [\'materials\']);\" ID=\"template1\" NAME=\"template1\" VALUE=\"classic_$materialcolor\">
rlm@0:    <input TYPE=\"image\" src = \"./templates/thumbnails/big_$materialcolor.jpg\" 		onclick=\"display([\'template2\'], [\'display\']); inputbox_template([\'template2\'], [\'inputbox\']);materials_template([\'template2\'], [\'materials\']);\" ID=\"template2\" NAME=\"template2\" VALUE=\"big_$materialcolor\">
rlm@0:    <input TYPE=\"image\" src = \"./templates/thumbnails/basic_$materialcolor.jpg\" 	onclick=\"display([\'template3\'], [\'display\']); inputbox_template([\'template3\'], [\'inputbox\']);materials_template([\'template3\'], [\'materials\']);\" ID=\"template3\" NAME=\"template3\" VALUE=\"basic_$materialcolor\"> 
rlm@0:    <input TYPE=\"image\" src = \"./templates/thumbnails/lines_$materialcolor.jpg\" 	onclick=\"display([\'template4\'], [\'display\']); inputbox_template([\'template4\'], [\'inputbox\']);materials_template([\'template4\'], [\'materials\']);\" ID=\"template4\" NAME=\"template4\" VALUE=\"lines_$materialcolor\"> 
rlm@0:  
rlm@0: 
rlm@0: ";
rlm@0: 
rlm@0: return $r;
rlm@0: }
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: sub display
rlm@0: {
rlm@0: 	$all = shift;
rlm@0: 	
rlm@0: 	
rlm@0: 	
rlm@0: 	$t ="$all
rlm@0: 	<input TYPE=\"image\" src = \"./templates/display/$all.jpg\" onclick=\"template_material([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); \" ID=\"temp1\" NAME=\"temp1\" VALUE=\"\">
rlm@0: 	";
rlm@0: 	return $t;
rlm@0: 	
rlm@0: }
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: sub materials_template{
rlm@0: 	
rlm@0: 	$newvar = shift;
rlm@0: 	
rlm@0: 	my $t = $newvar;
rlm@0: 	
rlm@0: 	$newvar =~ m/([^_]*)_/;
rlm@0: 	$newvar = $1;
rlm@0: 	
rlm@0: 	#return (($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked');
rlm@0: 	
rlm@0: 	$y = "$t<br>".(($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked')."
rlm@0: 	<form id=\"radiobuttons\">
rlm@0: 		<h3>PICK your Materials?:&nbsp;</h3>
rlm@0: 		
rlm@0: 		<div class = \"Acrylic\">
rlm@0: 		Acrylic:
rlm@0: 		<input TYPE=\"radio\" onclick=\"template_material([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']);  \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_acrylic_clear\"".(($t =~ m/_acrylic_clear/) ? 'CHECKED' : '')."><a href=\"\#\">Clear</a>
rlm@0: 		<input TYPE=\"radio\" onclick=\"template_material([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']);  \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_acrylic_blue\"".(($t =~ m/_acrylic_blue/) ? 'CHECKED' : '')."><a href=\"\#\">Blue</a>
rlm@0: 		<input TYPE=\"radio\" onclick=\"template_material([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']);  \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_acrylic_green\"".(($t =~ m/_acrylic_green/) ? 'CHECKED' : '')."><a href=\"\#\">Green</a>
rlm@0: 		</div>
rlm@0: 		
rlm@0: 		<div class = \"Aluminum\">
rlm@0: 		Aluminum:
rlm@0: 		<input TYPE=\"radio\" onclick=\"template_material([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_aluminum_red\"".(($t =~ m/_aluminum_red/) ? 'CHECKED' : '')."><a href=\"\#\">Red</a>
rlm@0: 		<input TYPE=\"radio\" onclick=\"template_material([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_aluminum_blue\"".(($t =~ m/_aluminum_blue/) ? 'CHECKED' : '')."><a href=\"\#\">Blue</a>
rlm@0: 		<input TYPE=\"radio\" onclick=\"template_material([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_aluminum_green\"".(($t =~ m/_aluminum_green/) ? 'CHECKED' : '')."><a href=\"\#\">Green</a>
rlm@0: 		<input TYPE=\"radio\" onclick=\"template_material([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_aluminum_black\"".(($t =~ m/_aluminum_black/) ? 'CHECKED' : '')."><a href=\"\#\">Black</a>
rlm@0: 		</div>
rlm@0: 		
rlm@0: 	
rlm@0: 		</form>
rlm@0: 	";
rlm@0: 	
rlm@0: 	
rlm@0: 		
rlm@0: 	
rlm@0: }
rlm@0: 
rlm@0: sub inputbox_template
rlm@0: {
rlm@0: 	$all = shift;
rlm@0: 	return $all;
rlm@0: }
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: 
rlm@0: sub gen
rlm@0: {
rlm@0: open FILE, "<./buy2.html";
rlm@0: return do { local $/; <FILE> };
rlm@0: 
rlm@0: };
rlm@0: 
rlm@0: