// define buildUp Methods for StandAloneElements

	function createLine(){

		// setup Line Object and childNodes

		myLine = new clsObject("Line");

			myLine.addObject(new clsObject("Product"));

			myLine.addObject(new clsObject("Discount"));

			myLine.addObject(new clsObject("Weight"));

			myLine.addObject(new clsObject("QuantityOrdered"));

			myLine.addObject(new clsObject("Tax"));

			myLine.addObject(new clsObject("Price"));

			myLine.addObject(new clsObject("Variants"));

			myLine.addObject(new clsObject("Internal"));

		// setup Price childNodes

		myPrice = myLine.getFirstItem("Price");

			myPrice.addObject(new clsObject("Net"));

			myPrice.addObject(new clsObject("Gross"));

		// setup Net childNodes

		myNet = myPrice.getFirstItem("Net");

			myNet.addObject(new clsObject("SingleUnit"));

			myNet.addObject(new clsObject("LineTotal"));

		// setup Gross childNodes

		myGross = myPrice.getFirstItem("Gross");

			myGross.addObject(new clsObject("SingleUnit"));

			myGross.addObject(new clsObject("LineTotal"));

		// return Line-Object to Caller

		return myLine;

		};

// 

	function addToBag(anElement,Amount){

		with(this){

			var taxamount = taxarea[parseInt(XML.getFirstItem("Config").taxarea)][parseInt(anElement.Tax) + 1];

			var update = -1;

			myLines = XML.getFirstItem("Order").getFirstItem("OrderBody").getFirstItem("OrderLines").childNodes

			for(var i=0;i<myLines.length;i++){

				if(myLines[i].getFirstItem("Product").code==anElement.Prod_nr){

					update = i;

					break;

					};

				};

			// product already in shoppingcard

			if(update>-1){

				// detect position of prod_nr in shoppingcart

				myLines[i].getFirstItem("QuantityOrdered").amount = Amount;

				if(boolPriceTaxIncl){

					myLines[i].getFirstItem("Price").getFirstItem("Net").getFirstItem("LineTotal").putValue(anElement.Price * Amount * ( 1 - taxamount/( 100 + taxamount )));

					myLines[i].getFirstItem("Price").getFirstItem("Gross").getFirstItem("LineTotal").putValue(anElement.Price * Amount);

					}

				else{

					myLines[i].getFirstItem("Price").getFirstItem("Net").getFirstItem("LineTotal").putValue(anElement.Price * Amount);

					myLines[i].getFirstItem("Price").getFirstItem("Gross").getFirstItem("LineTotal").putValue(anElement.Price * Amount * ( 1 + taxamount/100 ));

					};

				}

			// add product to shoppingcart

			else{

				myLine = createLine();

				myProduct = myLine.getFirstItem("Product");

					myProduct.code = anElement.Prod_nr;

					myProduct.desc1 = anElement.Title;

					myProduct.desc2 = anElement.Subtitle;

				myQuantityOrdered = myLine.getFirstItem("QuantityOrdered");

					myQuantityOrdered.amount = Amount;

					myQuantityOrdered.unit = anElement.Unitdesc;

				myInternal = myLine.getFirstItem("Internal")

					myInternal.price = anElement.Price;

					myInternal.address = anElement.LnkAdress;

					myInternal.navIndex = anElement.NavIndex;

					myInternal.discount = anElement.Discount;

					myInternal.minOrder = anElement.Minorder;

					myInternal.variants = anElement.Variants;

				myWeight = myLine.getFirstItem("Weight");

					myWeight.unit = objWeight.charSymbol;

					myWeight.amount = parseFloat(anElement.Weight) * parseInt(Amount);

				myTax = myLine.getFirstItem("Tax");

					myTax.taxclass = anElement.Tax;

					myTax.rate = taxamount;

				myPrice = myLine.getFirstItem("Price");

					myPrice.unit = anElement.PriceUnit;

				myNet = myPrice.getFirstItem("Net");

				myGross = myPrice.getFirstItem("Gross");

					

				

				if(boolPriceTaxIncl){

					myNet.getFirstItem("SingleUnit").putValue(parseFloat(anElement.Price) * ( 1 - taxamount/( 100 + taxamount ) ));

					myNet.getFirstItem("LineTotal").putValue(parseFloat(anElement.Price) * parseInt(Amount) * ( 1 - taxamount/( 100 + taxamount ) ));

					myGross.getFirstItem("LineTotal").putValue(parseFloat(anElement.Price));

					myGross.getFirstItem("LineTotal").putValue(parseFloat(anElement.Price) * parseInt(Amount));

					}

				else{

					myNet.getFirstItem("SingleUnit").putValue(parseFloat(anElement.Price));

					myNet.getFirstItem("LineTotal").putValue(parseFloat(anElement.Price) * parseInt(Amount));

					myGross.getFirstItem("LineTotal").putValue(parseFloat(anElement.Price) * ( 1 + taxamount/100 ));

					myGross.getFirstItem("LineTotal").putValue(parseFloat(anElement.Price) * Amount * ( 1 + taxamount/100 ));

					};

				myLines[myLines.length] = myLine;

				};

			safeData();

			location.href="orderform.htm";

			};

		};

// ** 1105

	function TElementPrint(){

		var boolDisplArtId = "true";

		var addToBag = '<img src="assets/images/view_book.gif" width="74" height="21"> ';

		var rString = '<TR '

			+ ''

			+ ''

			+ ''

			+ ''

			+ '>'

			+ '<TD align="right" class="PROVIEWBODY" >';

		if(this.Image!=""){

			rString += "<a href=\"javascript:callpage('" + this.LnkAdress + "','" + this.Variants + "'," + this.NavIndex + ")\">"

			rString += "<img src='" + this.Image + "' border=0"

			if(this.Width!=0) rString += " width=" + this.Width;

			if(this.Height!=0) rString += " height=" + this.Height;

			rString += ">"

			rString += "</a>"

			};

		rString += '</TD><TD width="100%" class="PROVIEWBODY" ><TABLE border="0" cellpadding="1" cellspacing="0" width="100%">';

		if(boolDisplArtId) rString += '<TR><TD class="PROVIEWARTID">' + this.Prod_nr + "</TD></TR>";

		rString += "<TR><TD class=\"PROVIEWBEZ1\"><a href=\"javascript:callpage('" + this.LnkAdress + "','" + this.Variants + "'," + this.NavIndex + ")\">" + this.Title + "</a></TD></TR>"

			+ "<TR><TD class=\"PROVIEWBEZ2\">" + this.Subtitle + "</TD></TR>"

			+ "<TR><TD class=\"proviewprice\"><strong>" + TFormatCurrency(displPrice(this.Price,this.Tax) / this.PriceUnit, objPriCurrency);

		if(boolDisplSecCurr) rString += charSecCurrDelimiter + TFormatCurrency(displPrice(this.Price,this.Tax) / this.PriceUnit, objSecCurrency);

		rString += "</strong></TD></TR>"

			+ "<TR><TD>&nbsp;</TD></TR>"

			+ "<TR><TD>&nbsp;" + "<a border=\"0\" href=\"javascript:callpage('" + this.LnkAdress + "','" + this.Variants + "'," + this.NavIndex + ")\" >"  + addToBag + "</a></TD></TR>" 
			//'<a href="#" onClick="' + "window.open('https://www.paypal.com/cart/add=1&business=sales%40penmanship.ca&item_name=" + this.Title + "+<br>+" + this.Subtitle + "&item_number=" + this.Prod_nr + "&amount=" + TFormatCurrency(displPrice(this.Price,this.Tax) / this.PriceUnit, objSecCurrency) + "&image_url=https%3A//secure.fw2.com/zero-gravity/penmanship/assets/images/title-sm.gif','cartwin','width=600,height=400,scrollbars,location,resizable,status');" + '">'  + addToBag + "</a></TD></TR>" 

			+ "</TABLE>"

			+ "</td></tr>";

		return(rString);

		};

// ** 1106

	function Element(Index,Image,Width,Height,Prod_nr,Title,Subtitle,Manufac,Price,Weight,Tax,PriceUnit,Unitdesc,NavIndex,Options,LnkAdress,Discount,Minorder){

		this.Index = Index;

		this.Image = Image;this.Width = Width;

		this.Height = Height;this.Prod_nr = Prod_nr;

		this.Title = Title;this.Subtitle = Subtitle;

		this.Manufac = Manufac;this.Price = Price;

		this.Weight = Weight;this.Tax = Tax;

		this.PriceUnit = PriceUnit;this.Unitdesc = Unitdesc;

		this.NavIndex = NavIndex;

		this.Print = TElementPrint;this.Variants = Options;

		this.LnkAdress = LnkAdress;this.Discount = Discount;

		this.Minorder = Minorder;

		};

// ** 1107

	var Entry = new Array();

// ** 1108

	

		Entry[0] = new Element(

		0,

		"assets/thumb/CreativeAlphabet_CoverThumb.jpg",

		126,

		155,

		"MP01",

		"Book A Creative Alphabet For Preschool and Kindergarten",

		"ISBN# 0-9688493-0-X",

		"",

		"11.85",

		"0.5",

		"1",

		1,

		"",

		0,

		"",

		"pd980443116.htm",

		"",

		1)

	

		Entry[1] = new Element(

		1,

		"assets/thumb/CreativeAlphabet_CoverThumb.jpg",

		126,

		155,

		"MPC01",

		"Book A, Creative alphabet",

		"ISBN 0-9688493-0-X",

		"",

		"11.85",

		"0",

		"1",

		1,

		"Pieces",

		1,

		"",

		"pd-808681489.htm",

		"",

		1)

	

		Entry[2] = new Element(

		2,

		"assets/thumb/BookB_CoverTh.gif",

		155,

		108,

		"MP02",

		"Book B, Manuscript practice",

		"ISBN 0-9688493-1-8",

		"",

		"4.26",

		"0",

		"1",

		1,

		"Pieces",

		2,

		"",

		"pd982307016.htm",

		"",

		1)

	

		Entry[3] = new Element(

		3,

		"assets/thumb/Book1_CoverTh.gif",

		155,

		117,

		"MP03",

		"Book 1, Introducing printing and handwriting ",

		"ISBN 0-9688493-2-6",

		"",

		"11.85",

		"0",

		"1",

		1,

		"Pieces",

		3,

		"",

		"pd408183593.htm",

		"",

		1)

	

		Entry[4] = new Element(

		4,

		"assets/thumb/Book2_CoverTh.gif",

		155,

		117,

		"MP04",

		"Book 2, Beginning handwriting",

		"ISBN 0-9688493-3-4",

		"",

		"18.63",

		"0",

		"1",

		1,

		"Pieces",

		4,

		"",

		"pd-718519242.htm",

		"",

		1)

	

		Entry[5] = new Element(

		5,

		"assets/thumb/Book3_CoverS1.gif",

		155,

		116,

		"MP05",

		"Book 3, Handwriting practice",

		"ISBN 0-9688493-4-2",

		"",

		"11.85",

		"0",

		"1",

		1,

		"Pieces",

		5,

		"",

		"pd-1114603137.htm",

		"",

		1)

	

		Entry[6] = new Element(

		6,

		"assets/thumb/Book4_CoverTh.gif",

		125,

		155,

		"MP06",

		"Book 4, Calligraphy",

		"ISBN 0-9688493-5-0",

		"",

		"11.85",

		"0.5",

		"1",

		1,

		"Pieces",

		6,

		"",

		"pd1266605396.htm",

		"",

		1)

	

		Entry[7] = new Element(

		7,

		"assets/thumb/Book5_CoverTh.gif",

		116,

		155,

		"MP07",

		"Book 5, Spiritual crib handwriting",

		"ISBN 0-9688493-6-9",

		"",

		"8.45",

		"0",

		"1",

		1,

		"Pieces",

		7,

		"",

		"pd-249143355.htm",

		"",

		1)

	

		Entry[8] = new Element(

		9,

		"assets/thumb/Book6_CoverTh.gif",

		125,

		155,

		"MP08",

		"Book 6, Handwriting exercise",

		"ISBN 0-9688493-7-7",

		"",

		"11.85",

		"0",

		"1",

		1,

		"Books",

		8,

		"",

		"pd-1240869982.htm",

		"",

		1)

	

		Entry[9] = new Element(

		10,

		"assets/thumb/Book7_CoverTh.gif",

		125,

		155,

		"MP09",

		"Book 7, Penmanship skills",

		"ISBN 0-9688493-8-5",

		"",

		"13.57",

		"0",

		"1",

		1,

		"Pieces",

		10,

		"",

		"pd308133755.htm",

		"",

		1)

	

		Entry[10] = new Element(

		11,

		"assets/thumb/Book8_CoverTh.gif",

		125,

		155,

		"MP10",

		"Book 8, Mastering penmanship",

		"ISBN 0-9688493-9-3",

		"",

		"15.24",

		"0",

		"1",

		1,

		"Pieces",

		11,

		"",

		"pd742599328.htm",

		"",

		1)

	Entry[11] = new Element(

		8,

		"assets/thumb/Book5B_CoverTh.gif",

		125,

		155,

		"MP7B",

		"Book 5B, Scripture Handwriting",

		"ISBN 0-9731112-0-8",

		"",

		"8.45",

		"0",

		"1",

		1,

		"Pieces",

		8,

		"",

		"pd-249943355.htm",

		"",

		1)

// ** 1109

	function SetupSearchEngineForm(){

		myConfig = XML.getFirstItem("Config");

		mySearchEngine = myConfig.getFirstItem("SearchEngine");

		if(mySearchEngine.term!="null") document.SearchEngine.Term.value = mySearchEngine.term;

		for(var i=0;i<document.SearchEngine.Mode.length;i++){

			if(i==mySearchEngine.mode) document.SearchEngine.Mode[i].selected = true;

			};

		if(mySearchEngine.maxPrice>0) document.SearchEngine.Maxprice.value = mySearchEngine.maxPrice;

		else{

			document.SearchEngine.Maxprice.value="";

			mySearchEngine.maxPrice = -1;

			};

		};

// ** 1111

	function SearchFor(Term,Mode){

		myConfig = XML.getFirstItem("Config");

		mySearchEngine = myConfig.getFirstItem("SearchEngine");

		if(Term!=""){

			if(Mode=="") Mode=0;

			Term = Term.toLowerCase();

			var counter = 0;

			var result = "<form name=\"ProductIndex\" onSubmit=\"return false;\">"; 

			for(var i=0;i<Entry.length;i++){

				var foundDesc1 = Entry[i].Title.toLowerCase().indexOf(Term)!=-1;

				var foundDesc2 = Entry[i].Subtitle.toLowerCase().indexOf(Term)!=-1;

				var foundProdId = Entry[i].Prod_nr.toLowerCase().indexOf(Term)!=-1;

				var foundManufac = Entry[i].Manufac.toLowerCase().indexOf(Term)!=-1;

				// SearchFor All

				if(Mode==0){

					if((foundDesc1 || foundDesc2 || foundProdId || foundManufac)&&chkMaxprice(Entry[i].Price,mySearchEngine.maxPrice)){

						counter++;result += Entry[i].Print();

						};

					};

				// SearchFor Description

				if(Mode==1){

					if((foundDesc1 || foundDesc2)&&chkMaxprice(Entry[i].Price,mySearchEngine.maxPrice)){

						counter++;result += Entry[i].Print();

						};

					};

				// SearchFor ProdId

				if(Mode==2){

					if(foundProdId&&chkMaxprice(Entry[i].Price,mySearchEngine.maxPrice)){

						counter++;result += Entry[i].Print();

						};

					};

				// SearchFor Manufac

				if(Mode==3){

					if(foundManufac&&chkMaxprice(Entry[i].Price,mySearchEngine.maxPrice)){

						counter++;result += Entry[i].Print();

						};

					};

				};

			result += "</form>";

			if(counter>0){

				mySearchEngine.init="false";

				return result;

				}

			else{

				if(mySearchEngine.init=="false")	return "Sorry, no matching product was found. Please try again..."

				else return("");

				};

			};

		if(mySearchEngine.init=="false") return "You did not enter any search criteria. Please enter your search term."

		else return("");

		};

// ** 11112

	function chkMaxprice(aPrice,aMaxPrice){

		aMaxPrice = replace(aMaxPrice.toString(),",",".");

		if(parseFloat(aMaxPrice)>0){

			if(parseFloat(aPrice)<=parseFloat(aMaxPrice)) return(true)

			else return(false);

			}

		else return(true);

		};

// ** 1111b

	function displPrice(aPrice,aTaxindex){

		var taxamount = taxarea[XML.getFirstItem("Config").taxarea][parseInt(aTaxindex) + 1];

		if(boolDisplTaxIncl){

			if(boolPriceTaxIncl) return(aPrice)

			else return(aPrice * ( 1 + taxamount/100 ) );

			}

		else{

			if(boolPriceTaxIncl) return(aPrice * ( 1 - taxamount/( 100 + taxamount ) ) )

			else return(aPrice);

			};

		};

// ** 1113

	function callpage(address, defValues, NavIndex){

		myConfig = XML.getFirstItem("Config");

		myConfig.getFirstItem("QueryStringData").putValue(defValues);

		myConfig.getFirstItem("NavigationIndex").putValue(NavIndex.toString());

		safeData();

		location.href = address;

		};

