var shoestyle = -1;
var shoecolor0 = "lilac";
var shoecolor1 = "lilac";
var fontcolor0= "black";
var fontstyle="english";
var design = "nodesign";
var ankletype = "regular";
var name = "";
var polar = 0;
var currentStep = 1;
var shoeprice = 15;
var designprice = 1;
var colorprice = 0;
var finalprice = 0;
var ankleprice = 0;
var polarprice = 0;
var nameprice = 0;
var shoesize = "06";
var sizeprice = 0;
var pricecorrection = 0;
var promocode = '';
var language = 'en';
var steps = [];
steps[0] = "Go Back";
steps[1] = "&#201;tape 1: choisissez vos chaussons ou bottes";
steps[2] = "&#201;tape 2: choisissez vos couleurs";
steps[3] = "&#201;tape 3: prenom de l'enfant";
steps[4] = "&#201;tape 4: choisissez un motif";
steps[5] = "&#201;tape 5: choisissez la taille";
steps[6] = "&#201;tape 6: recapitulatif";

function setLanguage(string)
{
	language = string;
}
function setSamples(shoetype)
{
	var samplebox = document.getElementById('samplelist')
	var samples = "samples";
	if(language == "fr"){samples = "echantillons";}
	switch(shoetype)
	{
		case 0:
			samplebox.innerHTML = "<br/>"+samples+"<br/><img src='images/samples/leather/sample1.jpg'><br/><br/><br/><br/><img src='images/samples/suede/sample2.jpg'><br/><br/><br/><br/><img src='images/samples/leatherboots/sample3.jpg'><br/><br/><br/><br/><img src='images/samples/suedeboots/sample4.jpg'><br/><br/><br/><br/><img src='images/samples/suede/sample4.jpg'>";
			return;		
		case 1:
			samplebox.innerHTML = "<br/>"+samples+"<br/><img src='images/samples/leather/sample1.jpg'><br/><br/><br/><br/><img src='images/samples/leather/sample2.jpg'><br/><br/><br/><br/><img src='images/samples/leather/sample3.jpg'><br/><br/><br/><br/><img src='images/samples/leather/sample4.jpg'>";
			return;
		case 2:
			samplebox.innerHTML = "<br/>"+samples+"<br/><img src='images/samples/suede/sample1.jpg'><br/><br/><br/><br/><img src='images/samples/suede/sample2.jpg'><br/><br/><br/><br/><img src='images/samples/suede/sample3.jpg'><br/><br/><br/><br/><img src='images/samples/suede/sample4.jpg'>";
			return;
		case 3:
			samplebox.innerHTML = "<br/>"+samples+"<br/><img src='images/samples/leatherboots/sample1.jpg'><br/><br/><br/><br/><img src='images/samples/leatherboots/sample2.jpg'><br/><br/><br/><br/><img src='images/samples/leatherboots/sample3.jpg'><br/><br/><br/><br/><img src='images/samples/leatherboots/sample4.jpg'>";
			return;
		case 4:
			samplebox.innerHTML = "<br/>"+samples+"<br/><img src='images/samples/suedeboots/sample1.jpg'><br/><br/><br/><br/><img src='images/samples/suedeboots/sample2.jpg'><br/><br/><br/><br/><img src='images/samples/suedeboots/sample3.jpg'><br/><br/><br/><br/><img src='images/samples/suedeboots/sample4.jpg'>";
			return;

	}	
}
function setPolarLining(polarLining)
{
	var addtopath = "";
	var imgcode = "<img src='images/polarlining.png' border=0'>";
	if(language == 'fr')
	{
		imgcode = "doublure polaire";
	}
	polar = polarLining;
	var layer4 = document.getElementById("shoelayer4");
	var selector = document.getElementById("polarliningselector");
	if(polarLining == 0)
	{
		polarprice = 0;
		layer4.innerHTML = "";
		selector.innerHTML = "<a href='javascript:setPolarLining(1)'><img src='images/redx.png' border=0>" + imgcode + "</a>";
	}
	else
	{
		selector.innerHTML = "<a href='javascript:setPolarLining(0)'><img src='images/greenv.png' border=0>" + imgcode + "</a>";
		if(ankletype == "regular")
		{
			polarprice = 2;
			layer4.innerHTML = "<img src='images/regularpolarlining.png'>";
		}
		else
		{
			polarprice = 2;
			layer4.innerHTML = "<img src='images/sheepskinwithpolarlining.png'>";
		}
	}
	updateprice();
}
function setSize(age)
{
	sizeprice = 0;
	document.getElementById("size" + shoesize).border = 0;
	document.getElementById("size" + age).border = 1;
	if(shoestyle > 2)
	{
	document.getElementById("bsize" + shoesize).border = 0;
	document.getElementById("bsize" + age).border = 1;
	}
	else
	{
		if(age == '34' || age == '45')
		{
			sizeprice = 2;
		}
		if(age == '56')
		{
			sizeprice = 4;
		}
	}
	shoesize = age;
	updateprice();
	return;
}
function setChart(age)
{
	var chart = document.getElementById("chart");
	if(shoestyle > 2) { chart = document.getElementById("bootchart");}
	if(age == "none")
	{
		chart.innerHTML = "";
		return;
	}
	chart.innerHTML = "<center><img src='images/chart" + age + ".png'></center><br>";
}
function setSheepSkin(ankleID)
{
	var addtopath = "";
	var imgcode = "<img src='images/sheepskinankle.png' border=0>"
	if(language == 'fr')
	{
		imgcode = "bordure en peau de mouton";
	}
	//for boots
	if(shoestyle > 2)
	{
		if(ankleID == 0) {return;}
		if(ankleID == 1)
		{
			document.getElementById("shoelayer2").innerHTML = "<img src='images/shoetemplate4.png' border=0 style='padding: 0px'>";
			shoecolor1 = 'cream';
		}
		if(ankleID == 2)
		{
			document.getElementById("shoelayer2").innerHTML = "<img src='images/shoetemplate4b.png' border=0 style='padding: 0px'>";
			shoecolor1 = 'brown';
		}
		return;
	}
	if(ankleID == 0)
	{
		ankletype = "regular";
		var ankle = document.getElementById("shoelayer3");
		ankle.innerHTML = "";
		ankleprice = 0;
		var selector = document.getElementById("sheepskinselector");
		selector.innerHTML = "<a href='javascript:setSheepSkin(1)'><img src='images/redx.png' border=0>" + imgcode + "</a>";
		var color2 = document.getElementById("colorbox2");
		var color4 = document.getElementById("colorbox4");
		color2.style.display = "block";
		color4.style.display = "none";
	}
	if(ankleID == 1)
	{
		ankletype = "sheepskin";
		var ankle = document.getElementById("shoelayer3");
		ankle.innerHTML = "<img src='images/sheepskinankle1.png'>";
		ankleprice = 2;
		var selector = document.getElementById("sheepskinselector");
		selector.innerHTML = "<a href='javascript:setSheepSkin(0)'><img src='images/greenv.png' border=0>"+imgcode+"</a>";		
		var color2 = document.getElementById("colorbox2");
		var color4 = document.getElementById("colorbox4");
		color2.style.display = "none";
		color4.style.display = "block";
		shoecolor1 = "cream";
		anklecolorname("cream");
	}
	if(ankleID == 2)
	{
		ankletype = "sheepskin";
		var ankle = document.getElementById("shoelayer3");
		ankle.innerHTML = "<img src='images/sheepskinankle2.png'>";
		ankleprice = 2;
		var selector = document.getElementById("sheepskinselector");
		selector.innerHTML = "<a href='javascript:setSheepSkin(0)'><img src='vgreenv.png' border=0>"+imgcode+"</a>";	
		shoecolor1 = "brown";	
		anklecolorname("brown");
	}
	setPolarLining(polar);
	updateprice();
}
function setshoestyle(styleID)
{
	shoestyle = styleID;
	setSamples(styleID);
	var shoelayer = document.getElementById('shoelayer2');
	shoelayer.innerHTML = '<img src="images/shoetemplate' + styleID + '.png"  border=0 style="padding: 0px">';
	if(styleID <= 2)
	{
		document.getElementById('name').style.top = '300px';
		document.getElementById('design').style.top = '340px';
		document.getElementById('design').style.left = '360px';
		if(ankletype == "regular")
		{
			document.getElementById('colorbox2').style.display = 'block';
			document.getElementById('colorbox4').style.display = 'none';
		}
		else
		{
			document.getElementById('colorbox4').style.display = 'block';
		}
		document.getElementById('shoelayer1').style.display = 'block';
		document.getElementById('shoelayer3').style.display = 'block';
		document.getElementById('modifiers').style.display = 'block';
		document.getElementById('shoelayer4').style.display = 'block';
		document.getElementById('sizechart').style.display = 'block';
		document.getElementById('bootsizechart').style.display = 'none';
		shoeprice = 15;
		if(shoecolor1 == "cream")
		{
			shoecolor1 = "lilac";
		}
	}
	else
	{
		document.getElementById('name').style.top = '245px';
		document.getElementById('design').style.top = '435px';
		document.getElementById('design').style.left = '410px';
		shoecolor1 = "cream";
		shoeprice = 25;
		colorprice = 0;
		document.getElementById('modifiers').style.display = 'none';
		document.getElementById('shoelayer1').style.display = 'none';
		document.getElementById('colorbox2').style.display = 'none';
		document.getElementById('colorbox4').style.display = 'block';
		document.getElementById('shoelayer3').style.display = 'none';
		document.getElementById('shoelayer4').style.display = 'none';
		document.getElementById('sizechart').style.display = 'none';
		document.getElementById('bootsizechart').style.display = 'block';
	}
	
	if(styleID == 2 || styleID == 4)
	{
		document.getElementById('colorbox1').style.display = 'none';
		document.getElementById('colorbox5').style.display = 'block';
		shoecolor('blue');
	}
	else
	{
		document.getElementById('colorbox1').style.display = 'block';
		document.getElementById('colorbox5').style.display = 'none';	
		shoecolor('lilac');
	}
	updateprice();
	nextStep();
	setDesign("nodesign");
}
function shoecolorname(string)
{
  var image = document.getElementById('shoecolorview');
  var image1 = document.getElementById('shoecolorview1');
  image.src =  "images/" + name2file(string.toLowerCase() );
  image1.src =  "images/" + name2file(string.toLowerCase() );
  document.getElementById("colorname1").innerHTML = string;
  document.getElementById("colorname5").innerHTML = string;
}
function fontcolorname(string)
{
  var image = document.getElementById('fontcolorview');
  image.src =  "images/" + name2file(string.toLowerCase(), 'font' );
  var namespace = document.getElementById("colorname2");
  namespace.innerHTML = string;
}

function anklecolorname(string)
{
  var image = document.getElementById('anklecolorview');
  var image2 = document.getElementById('anklecolorview2');
  image.src =  "images/" + name2file(string.toLowerCase(), 'ankle' );
  image2.src =  "images/" + name2file(string.toLowerCase(), 'ankle' );
  var namespace = document.getElementById("colorname3");
  var namespace2 = document.getElementById("colorname4");
  namespace.innerHTML = string;
  namespace2.innerHTML = string;
}

function nextStep()
{
	var addtopath = '';
	if(language == 'fr')
	{
		addtopath = '_fr';
	}
	var stepID = document.getElementById('steps');
	var stepX = parseInt(stepID.style.left + 0);
	var thisStep = ((stepX * -1) / 300) + 1;
	if (Math.floor(thisStep) > currentStep)
	{
		currentStep = Math.floor(thisStep);
		var stepname = document.getElementById('step');
		var debux = document.getElementById('debugbox');
		debux.innerHTML += 'current step: ' + currentStep + '<br/>';
		if(language == 'en')
		{
			stepname.innerHTML = "<center><img src='images/step" + currentStep + ".png'></center>";
		}
		else
		{
			stepname.innerHTML = "<center>" + steps[currentStep] + "</center>";
		}
		if(currentStep == 6)
		{
			document.getElementById('next').innerHTML='';
		}
		else
		{
			document.getElementById('next').innerHTML="<a href='javascript:nextStep()'><img src='images" + addtopath + "/next.png'></a>";
		}
		document.getElementById('previous').innerHTML="<a href='javascript:previousStep()'><img src='images" + addtopath + "/previous.png'></a>";
	}
	else
	{
		stepX -= 30;
		stepID.style.left = stepX + 'px';
		setTimeout("nextStep()", 100);
	}	
	updateprice();
}

function previousStep()
{
	var addtopath = '';
	if(language == 'fr')
	{
		addtopath = '_fr';
	}
	var stepID = document.getElementById('steps');
	var stepX = parseInt(stepID.style.left + 0);
	var thisStep = ((stepX * -1) / 300) + 1;
	if (Math.ceil(thisStep) < currentStep)
	{
		currentStep = Math.ceil(thisStep);
		var debux = document.getElementById('debugbox');
		var stepname = document.getElementById('step');
		debux.innerHTML += 'current step: ' + currentStep + '<br/>';
		if(language == 'en')
		{
			stepname.innerHTML = "<center><img src='images/step" + currentStep + ".png'></center>";
		}
		else
		{
			stepname.innerHTML = "<center>" + steps[currentStep] + "</center>";
		}
		if(currentStep == 1)
		{
			document.getElementById('previous').innerHTML='';
		}
		else
		{
			document.getElementById('previous').innerHTML="<a href='javascript:previousStep()'><img src='images" + addtopath + "/previous.png'></a>";
		}
		document.getElementById('next').innerHTML="<a href='javascript:nextStep()'><img src='images" + addtopath + "/next.png'></a>";

		}
	else
	{
		stepX += 30;
		stepID.style.left = stepX + 'px';
		setTimeout("previousStep()", 100);
	}
	updateprice();
}

function name2file(string, where)
{
  if(string == "")
  {
    if(where == 'ankle')
    {
      string = shoecolor1;
    }
    else
    {
		if(where == 'font')
		{
			string = fontcolor0;
		}
		else
		{
			string = shoecolor0;
		}
    }
  }
  switch(string)
  {
	case 'cream': return 'CL_Beige.jpg';
	case 'blue': return 'CLs_Blue.jpg';
	case 'rust': return 'CLs_Rust.jpg';
	case 'red': return 'CL_Red.jpg';
	case 'babyblue': return 'CL_BabyBlue.jpg';
    case 'beige': return 'CL_Beige.jpg';
    case 'black': return 'CL_Black.jpg';
    case 'white': return 'CL_white.jpg';
    case 'brown': return 'CL_brown.jpg';
    case 'bubblegum': return 'CL_Bubblegum.jpg';
    case 'butterscotch': return 'CL_Butterscotch.jpg';
    case 'champagne': return 'CL_Champagne.jpg';
    case 'deeppink': return 'CL_DeepPink.jpg';
    case 'dustyrose': return 'CL_dustyrose.jpg';
    case 'navy': return 'CL_Navy.jpg';
    case 'lilac': return 'CL_Pacific.jpg';
    case 'pastelyellow': return 'CL_PastelYellow.jpg';
    case 'pink': return 'CL_Pink.jpg';
    case 'pistachio': return 'CL_Pistachio.jpg';
    case 'tan': return 'CL_Beige.jpg';
    case 'wheat': return 'CL_Wheat.jpg';
    case 'charcoal': return 'CL_Charcoal.jpg';
    case 'eggplant': return 'CL_EggPlant.jpg';
    case 'green': return 'CLs_Green.jpg';
    default: return 'CL_white.jpg';
  }
}
function friendlyage(age)
{
	if(language == 'en')
	{
		switch(age)
		{
			case "06" : return "a baby up to six months old.";
			case "612" : return "a six to twelve months old baby.";
			case "1218" : return "a twelve to eightteen months old toddler.";
			case "1824" : return "an eightteen to twentyfour months old toddler.";
			case "23" : return "a two to three years old child.";
			case "34" : return "a three to four years old child.";
			case "45" : return "a four to five years old child.";
			case "56" : return "a five to six years old child.";
			case "610" : return "a six to ten years old child.";
		}
		return "zero to six months";
	}
	else
	{
		switch(age)
		{
			case "06" : return "un enfant de 0 a 6 mois.";
			case "612" : return "un enfant de 6 a 12 mois";
			case "1218" : return "un enfant de 12 a 18 mois.";
			case "1824" : return "un enfant de 18 a 24 mois.";
			case "23" : return "un enfant de 2 a 3 ans.";
			case "34" : return "un enfant de 3 a 4 ans";
			case "45" : return "un enfant de 4 a 5 ans.";
			case "56" : return "un enfant de 5 a 6 ans.";
			case "610" : return "un enfant de 6 a 10 ans.";
		}
		return "0 a 6 mois";
	}
}

function friendlyage2(age)
{
	switch(age)
	{
		case "06" : return "0-6 months";
		case "612" : return "6-12 months";
		case "1218" : return "12-18 months";
		case "1824" : return "18-24 months";
		case "23" : return "2-3 years";
		case "34" : return "3-4 years";
		case "45" : return "4-5 years";
		case "56" : return "5-6 years";
		case "610" : return "6-10 years";
	}
	return "0-6 months";
}

function validatePromotion()
{
	var promo = document.getElementById('promobox').value;
	if(promo == "6690")
	{
		promocode = promo;
		pricecorrection = 3;
	}
	updateprice();
}
function friendlycolor(color)
{
	if(language == 'en')
	{
		  switch(color)
		  {
			case 'cream': return 'cream colored';
			case 'blue': return 'blue';
			case 'rust': return 'rust colored';
			case 'red': return 'red';
			case 'babyblue': return 'baby blue';
		    case 'beige': return 'beige';
		    case 'black': return 'black';
		    case 'white': return 'white';
		    case 'brown': return 'brown';
		    case 'bubblegum': return 'bubblegum colored';
		    case 'butterscotch': return 'butterscotch colored';
		    case 'champagne': return 'champagne colored';
		    case 'deeppink': return 'deep pink';
		    case 'dustyrose': return 'dusty rose colored';
		    case 'navy': return 'navy blue';
			case 'lilac': return 'lilac';
		    case 'pastelyellow': return 'pastel yellow';
		    case 'pink': return 'pink';
		    case 'pistachio': return 'pistachio green';
		    case 'tan': return 'tan colored';
		    case 'wheat': return 'wheat colored';
		    case 'charcoal': return 'charcoal colored';
		    case 'eggplant': return 'eggplant colored';
		    default: return 'white';
		  }
	}
	else
	{
	  	switch(color)
	  	{
			case 'cream': return 'creme';
			case 'blue': return 'bleu';
			case 'rust': return 'rouille';
			case 'red': return 'rouge';
			case 'babyblue': return 'bleu ciel';
			case 'beige': return 'ecru';
			case 'black': return 'noir';
			case 'white': return 'blanc';
			case 'brown': return 'brun';
			case 'bubblegum': return 'gomme balloune';
			case 'butterscotch': return 'caramel';
			case 'champagne': return 'champagne';
			case 'deeppink': return 'rose foncer';
			case 'dustyrose': return 'saumon';
			case 'navy': return 'bleu foncer';
			case 'lilac': return 'lilas';
			case 'pastelyellow': return 'jaune';
			case 'pink': return 'rose';
			case 'pistachio': return 'vert pistache';
			case 'tan': return 'bronze';
			case 'wheat': return 'de ble';
			case 'charcoal': return 'antracite';
			case 'eggplant': return 'aubergine';
			case 'green': return 'vert foncer';
			default: return 'blanc';
	  	}	
	}
}	
function updateprice()
{
	if(shoestyle== -1) return;
	var secondcolor = '';
	var designspec = '';
	var anklespec = '';
	var polarspec = '';
	var namespec = '';
	var promospec = '';
	var sizespec = '';
	if(language == 'en')
	{
		var shoename = 'leather shoe';
		if (shoestyle == 2){ shoename = 'suede shoe'; }
		if (shoestyle == 3){ shoename = 'leather boot'; }
		if (shoestyle == 4){ shoename = 'suede boot'; }
	}
	else
	{
		var shoename = 'chaussons en cuir';
		if (shoestyle == 2){ shoename = 'chaussons en suede daim'; }
		if (shoestyle == 3){ shoename = 'bottes en cuir'; }
		if (shoestyle == 4){ shoename = 'bottes en suede daim'; }
	}
	finalprice = shoeprice + designprice + colorprice + nameprice + sizeprice - pricecorrection;
	if(shoestyle <= 2) { finalprice += ankleprice + polarprice; }
	document.getElementById('pricebox').innerHTML = "$" + finalprice;
	if(language == 'en')
	{
		if(nameprice != 0)
		{
			namespec = '<br>name: $' + nameprice;
	 	}
		if(designprice != 0)
		{
			designspec = '<br>design: $' + designprice;
		}
		if(shoestyle <= 2)
		{
			if(ankleprice != 0)
			{
				anklespec = '<br>sheepskin: $' + ankleprice;
			}
			if(polarprice != 0)
			{
				polarspec = '<br>polar lining: $' + polarprice;
			}
		}
		if(pricecorrection != 0)
		{
			promospec = '<br>promotion: -$' + pricecorrection;
		}
		if(sizeprice != 0)
		{
			sizespec = '<br>large size: $' + sizeprice;
		}
	}
	else
	{
		if(nameprice != 0)
		{
			namespec = '<br>prenom: $' + nameprice;
	 	}
		if(designprice != 0)
		{
			designspec = '<br>motif: $' + designprice;
		}
		if(shoestyle <= 2)
		{
			if(ankleprice != 0)
			{
				anklespec = '<br>bordure en peau de mouton: $' + ankleprice;
			}
			if(polarprice != 0)
			{
				polarspec = '<br>doublure polaire: $' + polarprice;
			}
		}
		if(pricecorrection != 0)
		{
			promospec = '<br>promotion: -$' + pricecorrection;
		}
		if(sizeprice != 0)
		{
			sizespec = '<br>grande taille: $' + sizeprice;
		}

	}
	document.getElementById('pricespecification').innerHTML = shoename + ' $' + shoeprice + namespec + designspec + anklespec + polarspec + sizespec + promospec; 
	var buttonText = ""
	if(language == 'en')
	{
		document.getElementById('checkout').innerHTML = "<h2>You are ordering: </h2>" + getHumanShoe();
		document.getElementById('checkout').innerHTML +='<br><hl>If you have a promotion code, enter it here: <input type = "text" value = "promo" onChange="validatePromotion()" id="promobox">';
		buttonText = "check out using PayPal";
	}
	else
	{
		document.getElementById('checkout').innerHTML = "<h2>Vous commandez: </h2>" + getHumanShoeFR();
		document.getElementById('checkout').innerHTML +='<br><hl>Si vous avez un code promotionnel, entrez le ici: <input type = "text" value = "promo" onChange="validatePromotion()" id="promobox">';
		buttonText = "payez avec PayPal";
	} 
	var fontname = font2name(fontstyle);
	var fontcolor = fontcolor0;
	if(name.length == 0)
	{
		fontname = "";
		fontcolor = "";
	}
	document.getElementById('checkout').innerHTML +='<form name="paypalform" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" style="margin: 0px">\
	<p align="left">\
	<input type="hidden" name="cmd" value="_cart">\
	<input type="hidden" name="business" value="softsoulshoes@hotmail.com">\
	<input type="hidden" name="return" value="">\
	<input type="hidden" name="no_shipping" value="2">\
	<input type="hidden" name="shipping" value="3.00">\
	<input type="hidden" name="shipping2" value="3.00">\
	<input type="hidden" name="no_note" value="1">\
	<input type="hidden" name="currency_code" value="USD">\
	<input type="hidden" name="bn" value="PP ShopCartBF">\
	<input type="hidden" name="quantity" value="1">\
	<input type="hidden" name="add" value="1">\
	<input type="hidden" name="amount" value="' + finalprice + '.00">\
	<input type="hidden" name="item_name" value="' + getShoeStyle() + '">\
	<input type="hidden" name="on0" value="shoecolor">\
	<input type="hidden" name="on1" value="anklestyle">\
	<input type="hidden" name="on2" value="anklecolor">\
	<input type="hidden" name="on3" value="font">\
	<input type="hidden" name="on4" value="fontcolor">\
	<input type="hidden" name="on5" value="name">\
	<input type="hidden" name="on6" value="design">\
	<input type="hidden" name="on7" value="polarlining">\
	<input type="hidden" name="on8" value="size">\
	<input type="hidden" name="on9" value="promocode">\
	<input type="hidden" name="os0" value="' + shoecolor0 + '">\
	<input type="hidden" name="os1" value="' + ankletype + '">\
	<input type="hidden" name="os2" value="' + shoecolor1 + '">\
	<input type="hidden" name="os3" value="' + fontname + '">\
	<input type="hidden" name="os4" value="' + fontcolor + '">\
	<input type="hidden" name="os5" value="' + name + '">\
	<input type="hidden" name="os6" value="' + design + '">\
	<input type="hidden" name="os7" value="' + int2yesno(polar) + '">\
	<input type="hidden" name="os8" value="' + friendlyage2(shoesize) + '">\
	<input type="hidden" name="os9" value="' + promocode + '">\
	</form><img src="images/paypal.gif" onclick="document.paypalform.submit();"/></form>';
	//if(promocode != '')
	//{
//		document.getElementById('checkout').innerHTML += '<input type="hidden" name="on9" value="promocode"><input type="hidden" name="os9" value="' + promocode + '">';
//	}
//	document.getElementById('checkout').innerHTML += '<input type="submit" value="check out using paypal"></form></p>';
}
function int2yesno(number)
{
	if(number == 0) { return "no"; }
	return "yes";
}

function getShoeStyle()
{
	var style = "shoe";
	var material = "leather";
	if(shoestyle > 2) { style = "boot"; }
	if(shoestyle == 2 || shoestyle == 4){ material = "suede"; }
	return material + " " + style;
}

function getHumanShoeFR()
{
	var material = "cuir";
	var style = "chaussons";
	if(shoestyle > 2) { style = "bottes"; }
	if(shoestyle == 2 || shoestyle == 4) { material = "suede daim"; }
	var humanstring =  "Une paire de " + style + " en " + material + " de couleur " + friendlycolor(shoecolor0) + " avec ";
	if(shoestyle > 2)
	{
		humanstring += "bordure en " + friendlycolor(shoecolor1);
	}
	else
	{
		if(ankletype == "regular")
		{
			humanstring += "bordure en " + friendlycolor(shoecolor1);
		}
		else
		{
			humanstring += "bordure en peau de mouton en " + friendlycolor(shoecolor1);
		}
	}

	if(polarprice > 0)
	{
		humanstring += " et doublure polaire";
	}

	if(designprice > 0)
	{
		humanstring += ", decore avec le design ";

		humanstring += " '" + translateDesign(design) + "'";
		if(nameprice > 0){humanstring += ", et le ";}
		
	}
	if(nameprice > 0)
	{
		humanstring += "  nom '" + name + "' en couleur " + friendlycolor(fontcolor0) + ", cousu avec le style '" +  font2name(fontstyle) + "'";
	}
	
	humanstring += " pour " + friendlyage(shoesize);
	return humanstring;
}

function getHumanShoe()
{
	if(language == 'fr')
	{
		return getHumanShoeFR();
	}
	var material = "leather";
	var style = "shoe";
	if(shoestyle > 2) { style = "boot"; }
	if(shoestyle == 2 || shoestyle == 4) { material = "suede"; }
	var humanstring =  "A " + friendlycolor(shoecolor0) + " " + material + " " + style + " with ";
	if(shoestyle > 2)
	{
		humanstring += friendlycolor(shoecolor1) + " fur";
	}
	else
	{
		if(ankletype == "regular")
		{
			humanstring += "a " + friendlycolor(shoecolor1) + " ankle";
		}
		else
		{
			humanstring += "a " + friendlycolor(shoecolor1) + " sheepskin ankle";
		}
	}
	if(polarprice > 0)
	{
		humanstring += " and polar lining";
	}
	if(designprice > 0 || nameprice > 0)
	{
		humanstring += ", decorated with the ";
		if(designprice > 0)
		{
			humanstring += " '" + design + "' design";
			if(nameprice > 0){humanstring += ", and the ";}
		}
		if(nameprice > 0)
		{
			humanstring += friendlycolor(fontcolor0) + " name '" + name + "' stiched on with the '" +  font2name(fontstyle) + "' font";
		}
	}
	humanstring += " for " + friendlyage(shoesize);
	return humanstring;
}

function name2color(string)
{
  switch(string)
  {
	case 'blue': return '#7a8ec1';
	case 'rust': return '#db7d1b';
    case 'red': return '#ff3334';
	case 'babyblue': return '#32ccfe';
    case 'beige': return '#e8d9c2';
    case 'black': return '#000000';
    case 'white': return '#ffffff';
    case 'brown': return '#5d360b';
    case 'bubblegum': return '#ffaeba';
    case 'butterscotch': return '#e3bc95';
    case 'champagne': return '#f4c597';
    case 'deeppink': return '#e8258e';
    case 'dustyrose': return '#ffa291';
    case 'navy': return '#251a78';
    case 'lilac': return '#d8c8f7';
    case 'pastelyellow': return '#fff57c';
    case 'pink': return '#ffc6bd';
    case 'pistachio': return '#dfeba3';
    case 'tan': return '#d1b48c';
    case 'wheat': return '#f5deb4';
    case 'charcoal': return '#505050';
    case 'eggplant': return '#410074';
    case 'green': return '#1e772d';
    default: return '#ffffff';
  }
}

function fontcolor(string)
{
  fontcolor0 = string;
  var namediv = document.getElementById('name');
  namediv.style.color = name2color(string);
  var image = document.getElementById('fontcolorview');
  image.src = "images/" + name2file(string);
  updateName();
}

function shoecolor(string)
{
  shoecolor0 = string;
  var layer0 = document.getElementById('shoelayer0');
  var image = document.getElementById('shoecolorview');
  layer0.style.backgroundColor = name2color(string);
  image.src = "images/" + name2file(string);
  if(shoestyle == 1)
  {
	  if(shoecolor0 == shoecolor1)
	  {
		colorprice = 0;
	  }
	  else
	  {
		colorprice = 0;
	  }
  }
  updateprice();
}

function anklecolor(string)
{
  shoecolor1 = string;
  var layer1 = document.getElementById('shoelayer1');
  layer1.style.backgroundImage = 'url(images/ankle/' + string + '.gif' + ')';
  if(shoestyle == 1)
  {
	  if(shoecolor0 == shoecolor1)
	  {
		colorprice = 0;
	  }
	  else
	  {
		colorprice = 0;
	  }
  }
  updateprice();
}

function translateDesign(string)
{
	switch(string)
	{
		default: return string;
		case 'zebra': return 'zebre';
		case 'cat': return 'tete de tigre';
		case 'cat2': return 'tete de chat';
		case 'bluebunny': return 'lapin bleu';
		case 'bee2': return 'abeille';
		case 'turtle': return 'tortue';
		case 'butterfly': return 'papillion jaune';
		case 'butterfly2': return 'papillion vert';
		case 'frog': return 'grenouille';
		case 'fish': return 'poisson';
		case 'ladybug': return 'coccinelle';
		case 'tractor': return 'tracteur';
		case 'schoolbus': return 'autobus d\'ecole';
		case 'firetruck': return 'camion de pompier';
		case 'bluecar': return 'bolide';
		case 'strawberry': return 'fraise';
		case 'football': return 'ballon de foot';
		case 'americanfootball': return 'rugby';
		case 'flower': return 'fleur';
		case 'flower2': return 'margerite';
	}
}	

function setDesignCategory(string)
{
	switch(string)
	{
		case 'none': 
			document.getElementById('designselectorview').innerHTML = '';
			return;
		case 'animals':
			document.getElementById('designselectorview').innerHTML = "\
			<a href='javascript:setDesign(\"lion\")'><img src='designs/lion.png' width=80 height=70  onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"zebra\")')><img src='designs/zebra.png' width=80 height=70  onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"cat\")'><img src='designs/cat.png' width=80 height=70  onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"cat2\")'><img src='designs/cat2.png' width=80 height=70  onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"bluebunny\")'><img src='designs/bluebunny.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"bee2\")'><img src='designs/bee2.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"turtle\")'><img src='designs/turtle.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"butterfly\")'><img src='designs/butterfly.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"butterfly2\")'><img src='designs/butterfly2.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"frog\")'><img src='designs/frog.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"fish\")'><img src='designs/fish.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"ladybug\")'><img src='designs/ladybug.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			";
			return;
		case 'vehicles':
			document.getElementById('designselectorview').innerHTML = "\
			<a href='javascript:setDesign(\"tractor\")'><img src='designs/tractor.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"schoolbus\")'><img src='designs/schoolbus.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"truck\")'><img src='designs/truck.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"firetruck\")'><img src='designs/firetruck.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"bluecar\")'><img src='designs/bluecar.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			";
			return;
		case 'others':
			document.getElementById('designselectorview').innerHTML = "\
			<a href='javascript:setDesign(\"strawberry\")'><img src='designs/strawberry.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"football\")'><img src='designs/football.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"americanfootball\")'><img src='designs/americanfootball.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"flower\")'><img src='designs/flower.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			<a href='javascript:setDesign(\"flower2\")'><img src='designs/flower2.png' width=80 height=70 onmouseover='this.style.borderColor=\"grey\"' onmouseout='this.style.borderColor=\"white\"'></a>\
			";
			return;
		default:
			document.getElementById('designselectorview').innerHTML = '';
			return;
	}
}

function setDesign(string)
{
	design = string;
	if(string == 'nodesign')
	{
		setDesignCategory('none');
		document.getElementById('design').innerHTML = '';
		designprice = 0;
		updateprice();
	}
	else
	{
		var scale = 90;
		if(shoestyle > 2)
		{
			scale = 45;
		}
		document.getElementById('design').innerHTML = '<img src=designs/'+string+'.png width='+scale+'>';
		designprice = 5;
		updateprice();
	}
}

function font2name(string)
{
	switch(string)
	{
		case "egypt" : return "Dean";
		case "oldlondon" : return "Anna";
		case "arial" : return "Tyler";
		case "english" : return "Sarah";
	}
}
function setfont(string)
{
	fontstyle = string;
	updateName();
}

function englishCharCorrectionLeft(character)
{
	switch(character)
	{
		case 'f': return 10;
		case 'g': return 6;
		case 'h': return 5;
		case 'j': return 10;
		case 'k': return 5;
		case 'm': return 2;
		case 'n': return 3;
		case 'p': return 10;
		case 'q': 
		case 'r':
		case 's': return 2;
		case 'y': return 8;
		default: return 0;
	}
}
function englishCharCorrectionRight(character)
{
	if(character == ' ') return -8;
	if(character == 'b') return 2;
	if(character == 'c') return 4;
	if(character == 'e') return 5;
	if(character == 'f') return -1;
	if(character == 'g') return -6;
	if(character == 'h') return -1;
	if(character == 'i') return 8;
	if(character == 'j') return -4;
	if(character == 'l') return 8;
	if(character == 'm') return -8;
	if(character == 'o') return 1;
	if(character == 'p') return -10;
	if(character == 'r') return 2;
	if(character == 's') return 6;
	if(character == 't') return 8;
	if(character == 'v') return 3;
	if(character == 'w') return -5;
	if(character == 'y') return -6;
	if(character == 'A') return -10;
	if(character == 'C') return -6;
	if(character == 'E') return -6;
	if(character == 'F') return -6;
	if(character == 'G') return -6;
	if(character == 'H') return -6;
	if(character == 'I') return -6;
	if(character == 'J') return -6;
	if(character == 'N') return -8;
	if(character == 'O') return -6;
	if(character == 'Q') return -6;
	if(character == 'S') return -12;
	if(character == 'T') return -6;
	if(character == 'U') return -4;
	if(character == 'V') return -4;
	if(character == 'W') return -10;
	if(character == 'X') return -6;
	if(character == 'Y') return -6;
	if(character == 'Z') return -10;
	if(character < 'a') return -14;
	return 0;
}
function updateName()
{
	var newname = document.nameform.childname.value;
	name = newname;
	if(newname.length == 0)
	{
		nameprice = 0;
	}
	else
	{
		nameprice = 10;
	}
	if(fontstyle == 'arial')
	{
		if(newname.length > 7)
		{
			document.getElementById('name').style.fontSize = '30px';
		}
		else
		{
			document.getElementById('name').style.fontSize = '40px';
		}
		document.getElementById('name').innerHTML = '<center>' + newname + '</center>';
	}
	else
	{
		document.getElementById('name').innerHTML = "";
		var namelen = newname.length;
		var i=0;
		var nameHTML='<center>';
		var fontpath = '/fonts/' + fontstyle + '/' + fontcolor0 + '/';
		var scale = "30";
		if(fontstyle == 'english')
		{
			var inlinebox = document.createElement('div');
			inlinebox.style.position = 'relative';
			inlinebox.style.margin = 'auto';
			inlinebox.style.display = 'block';
			inlinebox.style.width = '100px';
			inlinebox.style.height = '41px';
			var leftof = 0;
			for (i=0; i<namelen;i++)
			{

				if(i > 0)
				{
					var correction = 16;
					correction -= englishCharCorrectionLeft(newname.charAt(i));
					correction -= englishCharCorrectionRight(newname.charAt(i-1));
					leftof += correction; //englishCharSize(newname.charAt(i-1));
				}
				var thisChar = document.createElement('div');
				thisChar.style.width = '30px';
				thisChar.style.height = '30px';
				thisChar.style.position = 'absolute';
				thisChar.style.top = '0px';
				thisChar.style.left= leftof + 'px';
				thisChar.style.display = 'block';
				
				if(newname.charAt(i) == ' ')
				{
					//nameHTML += '&nbsp;';
				}
				else
				{
					if(newname.charAt(i) < 'a')
					{
						fontpath = 'fonts/' + fontstyle + '/' + fontcolor0 + '/_';
					}
					else
					{
						fontpath = 'fonts/' + fontstyle + '/' + fontcolor0 + '/';
					}
					thisChar.innerHTML += '<img src="' + fontpath +newname.charAt(i)+'.png">';
				}
				inlinebox.appendChild(thisChar);
			}
			var boxsize = leftof + 18;
			inlinebox.style.width = boxsize + 'px';
			document.getElementById('name').appendChild(inlinebox);		

		}
		else
		{
			if(namelen > 6 && fontstyle == "egypt"){scale = "20";}
			if(namelen > 12 && fontstyle == "oldlondon"){scale = "20";}
			for (i=0; i<namelen;i++)
			{
				if(newname.charAt(i) == ' ')
				{
					nameHTML += '&nbsp;';
				}
				else
				{
					if(newname.charAt(i) < 'a')
					{
						fontpath = 'fonts/' + fontstyle + '/' + fontcolor0 + '/_';
					}
					else
					{
						fontpath = 'fonts/' + fontstyle + '/' + fontcolor0 + '/';
					}
					nameHTML += '<img src="' + fontpath +newname.charAt(i)+'.png" height="'+scale+'">';
				}
			}
			nameHTML += '</center>';
			document.getElementById('debugbox').innerHTML += newname + '<br>';
			document.getElementById('name').innerHTML = nameHTML;//'<center>' + newname + '</center>';
		}

	}
	updateprice();
}
