//DESIGN 1 JS
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } 
  else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
addLoadEvent(function() {
  document.getElementById('fogDiv').style.visibility = "hidden";
}); 
//LAYOUT MODULES JS
YAHOO.util.Event.onDOMReady(function() {
	var prodConfigLoad = MSB.$('prodConfigLoad').value;
	var root = loadMyXML('./includes/shop-defaults.xml');
	MSB.$('shopemail').value = root.getElementsByTagName('shopEmail')[0].childNodes[0].nodeValue;
	MSB.$('shopdomain').value = root.getElementsByTagName('shopDomain')[0].childNodes[0].nodeValue;
	MSB.$('moneySymbol').value = root.getElementsByTagName('moneySymbol')[0].childNodes[0].nodeValue;
	var XoffA = root.getElementsByTagName('Offset');
	var YoffA = root.getElementsByTagName('Offset');
/*	if (XoffA.length > 0) {
		var Xoff = parseInt(root.getElementsByTagName('Xoffset')[0].childNodes[0].nodeValue);
	}
	else {
		var Xoff = 0;
	}
	if (YoffA.length > 0) { 
		var Yoff = parseInt(root.getElementsByTagName('Yoffset')[0].childNodes[0].nodeValue);
	}
	else {
		var Yoff = 0;
	}*/
	var Xoff = MSB.$('designtool').offsetTop;
	var Yoff = MSB.$('designtool').offsetLeft;
//	alert(Xoff+'  '+Yoff);
	var root;
	if (MSB.$('prodConfigLoad').value == 'default') {
		root = loadMyXML('./includes/wep-tool-config.xml');
	}
	else {
		root = loadMyXML('./configs/'+MSB.$('prodConfigLoad').value+'/includes/wep-tool-config.xml');
	}
	var showDprice = root.getElementsByTagName('dynamicPricing')[0].childNodes[0].nodeValue;
	var showQcart = root.getElementsByTagName('showQuickCart')[0].childNodes[0].nodeValue;
	var showCKbutton = root.getElementsByTagName('showCheckoutButton')[0].childNodes[0].nodeValue;
	var showQsubmit = root.getElementsByTagName('showQuoteSubmission')[0].childNodes[0].nodeValue;
	var showAddCart = root.getElementsByTagName('showAddtoCart')[0].childNodes[0].nodeValue;
	var showPriceSheet = root.getElementsByTagName('showPriceSheet')[0].childNodes[0].nodeValue;
	var showOurDesigns = root.getElementsByTagName('showOurDesigns')[0].childNodes[0].nodeValue;
	var instantQuote = root.getElementsByTagName('instantQuote')[0].childNodes[0].nodeValue;
	var x,y; 
	if (showQcart.toLowerCase() != 'yes') {
		MSB.$('boxCart').style.visibility = 'hidden';
	}
	if (showDprice.toLowerCase() != 'yes') {
		MSB.$('priceDiv').style.visibility = 'hidden';
	}
	if (showOurDesigns.toLowerCase() != 'yes') {
		MSB.$('SDtoolbarDiv').style.display = 'none';
	}
	if (showOurDesigns.toLowerCase() == 'yes') {
		loadourdesigns();
	}
	YAHOO.namespace("example.container");
//	var Xoff = 0;
//	var Yoff = 0;
	/* savedesignoverlay panel8 */
	YAHOO.example.container.savedesignoverlay = new YAHOO.widget.Panel("savedesignoverlay", {/* xy:[325+Xoff,-120+Yoff],*/ /*width:"300px",*/ visible: false, zIndex: 2500, close: true } );
	YAHOO.example.container.savedesignoverlay.render();
	/* opendesignoverlay panel9 */
	YAHOO.example.container.opendesignoverlay = new YAHOO.widget.Panel("opendesignoverlay", { /* xy:[0+Xoff,0+Yoff], width:"250px",*/ visible: false, zIndex: 6000, close: false } );
	YAHOO.util.Event.addListener("opendesignbox", "click", YAHOO.example.container.opendesignoverlay.show, YAHOO.example.container.opendesignoverlay, true);
	YAHOO.example.container.opendesignoverlay.render();

	/* PRODUCT SELECTOR panel4 */
	YAHOO.example.container.productsoverlay = new YAHOO.widget.Panel("productsoverlay", {/* panel4 xy:[90+Xoff,-80+Yoff],*/ /*width:"135px",*/ /*height:"309px",*/ visible: true, zIndex: 690, draggable: true, close: false } );

	YAHOO.util.Event.addListener("showProductsbox", "click", showProducts);
		function showProducts() {
			MSB.$('showProductsbox').style.opacity = "1";
			MSB.$('showProductsbox').style.filter = "alpha(opacity= 100)"; //IE
			MSB.$('showProductsbox').style.backgroundColor = "#A5CBFF";
			MSB.$('showProductColorsbox').style.opacity = "0.5";
			MSB.$('showProductColorsbox').style.filter = "alpha(opacity= 50)"; //IE
			MSB.$('showProductColorsbox').style.backgroundColor = "transparent";
			MSB.$('imagegalleryoverlay').style.visibility = "hidden";
			YAHOO.example.container.fontboxoverlay.hide();
			YAHOO.example.container.productsoverlay.show();
			YAHOO.example.container.productcolorsoverlay.hide();
			YAHOO.example.container.textboxoverlay.hide(); /* textboxoverlay */
			//YAHOO.example.container.imagegalleryoverlay.hide(); /* imagegalleryoverlay */
			MSB.$('textEditorDiv').style.backgroundColor = "transparent";
			YAHOO.example.container.archoverlay.hide(); /* archoverlay */
			MSB.$('showtextbox').style.backgroundColor = "transparent";
			MSB.$('launchIGbox').style.backgroundColor = "transparent";

			YAHOO.example.container.savedesignoverlay.hide();
			MSB.$('sizeChart').style.visibility = "hidden";

			MSB.$('pickedHint').innerHTML ="Selected style: " + MSB.$('actprod').value;

			MSB.$('textboxoverlay').style.visibility = "hidden";
			MSB.$('textHint').style.visibility = "hidden";
			MSB.$('TCpicker_bd').style.visibility = "hidden";
			MSB.$('symoverlay').style.visibility = "hidden";

			MSB.$('sel-F').style.visibility = 'hidden';
			MSB.$('sel-B').style.visibility = 'hidden';
			MSB.$('deleteimageBox').style.visibility = 'hidden';

		}

	YAHOO.example.container.productsoverlay.render();

	//PRODUCT COLOR PICKER panel5
	YAHOO.example.container.productcolorsoverlay = new YAHOO.widget.Panel("productcolorsoverlay", {/* xy:[230+Xoff,-80+Yoff],*/ /*width:"112px",*/ visible: false, zIndex: 689, close: false} );
	//YAHOO.util.Event.addListener("showProductColorsbox", "click", YAHOO.example.container.panel5.show, YAHOO.example.container.panel5, true);
	//YAHOO.example.container.panel5.render();

	YAHOO.util.Event.addListener("showProductColorsbox", "click", showProductColoursEtc, highlightinsizechart);
		function showProductColoursEtc() {
			MSB.$('showProductsbox').style.opacity = "0.5";
			MSB.$('showProductsbox').style.filter = "alpha(opacity= 50)"; //IE
			MSB.$('showProductsbox').style.backgroundColor = "transparent";
			MSB.$('showProductColorsbox').style.backgroundColor = "#A5CBFF";
			MSB.$('showProductColorsbox').style.opacity = "1";
			MSB.$('showProductColorsbox').style.filter = "alpha(opacity= 100)"; //IE
			MSB.$('textEditorDiv').style.backgroundColor = "transparent";
			//MSB.$('textEditorDiv').style.opacity = "0.5";
			//MSB.$('textEditorDiv').style.filter = "alpha(opacity= 50)"; //IE
			MSB.$('fontsmenubox').style.visibility = "hidden"; /* font menu BUTTON */
			MSB.$('imagegalleryoverlay').style.visibility = "hidden"; /* font menu BUTTON */
			YAHOO.example.container.productsoverlay.hide();
			YAHOO.example.container.productcolorsoverlay.show();
			YAHOO.example.container.textboxoverlay.hide(); /* textboxoverlay */
			YAHOO.example.container.imagegalleryoverlay.hide(); /* imagegalleryoverlay */
			YAHOO.example.container.fontboxoverlay.hide();
			YAHOO.example.container.archoverlay.hide(); /* archoverlay */

			MSB.$('showtextbox').style.backgroundColor = "transparent";
				MSB.$('showtextbox').style.opacity = "0.5";
				MSB.$('showtextbox').style.filter = "alpha(opacity= 50)"; //IE

			MSB.$('launchIGbox').style.backgroundColor = "transparent";
				MSB.$('launchIGbox').style.opacity = "0.5";
				MSB.$('launchIGbox').style.filter = "alpha(opacity= 50)"; //IE

			YAHOO.example.container.savedesignoverlay.hide();
			
			//Garment Size Chart - click here
			MSB.$('sizeChart').src = 'products/'+MSB.$("actprod").value+'_SIZECHART.html';

			//MSB.$('pickedHint').innerHTML ="The Style on the right is " + MSB.$('actprod').value;

			MSB.$('textboxoverlay').style.visibility = 'hidden';
			MSB.$('textHint').style.visibility = 'hidden';
			MSB.$('TCpicker_bd').style.visibility = 'hidden';
			MSB.$('symoverlay').style.visibility = 'hidden';

			MSB.$('sel-F').style.visibility = 'hidden';
			MSB.$('sel-B').style.visibility = 'hidden';
			MSB.$('deleteimageBox').style.visibility = 'hidden';

		}
		
	YAHOO.util.Event.on("sizeChartLinkSpan", "click", showSizeChart, highlightinsizechart);
		function showSizeChart() {
			MSB.$('sizeChart').style.visibility = "visible";
		}

	YAHOO.util.Event.on("sizeChart", "mouseout", hideSizeChart);
	YAHOO.util.Event.on("sizeChart", "click", hideSizeChart);
		function hideSizeChart() {
			MSB.$('sizeChart').style.visibility = "hidden";

		}
		
	//YAHOO.example.container.productcolorsoverlay.render();
	
	/* TEXT COLOR PICKER panel2 textcoloroverlay */
	YAHOO.example.container.textcoloroverlay = new YAHOO.widget.Panel("textcoloroverlay", {/* xy:[610+Xoff,190+Yoff],*/ /*width:"125px",*/ /*height:"140px",*/ visible: false, zIndex: 1000, close: false } );
	YAHOO.util.Event.addListener("showCPbox", "click", YAHOO.example.container.textcoloroverlay.show, YAHOO.example.container.textcoloroverlay, true);
	YAHOO.example.container.textcoloroverlay.render();
	/* TEXT COLOR PICKER TCpicker */
	YAHOO.example.container.panelTCP = new YAHOO.widget.Panel("TCpicker", {/* xy:[610+Xoff,190+Yoff],*/ /*width:"125px",*/ /*height:"140px",*/ visible: false, zIndex: 1000, close: false } );
	YAHOO.util.Event.addListener("newtextButton", "click", YAHOO.example.container.panelTCP.show, YAHOO.example.container.panelTCP, true);
	YAHOO.example.container.panelTCP.render();
	/* STROKE COLOR panel2a */
	YAHOO.example.container.strokecoloroverlay = new YAHOO.widget.Panel("strokecoloroverlay", { xy:[180+Xoff,215+Yoff], width:"200px", visible: false, zIndex: 600, close: false } );
	YAHOO.util.Event.addListener("strokeBox", "click", YAHOO.example.container.strokecoloroverlay.show, YAHOO.example.container.strokecoloroverlay, true);
	YAHOO.example.container.strokecoloroverlay.render();
	/* FONTS LIST fontboxoverlay panel3 */
	YAHOO.example.container.fontboxoverlay = new YAHOO.widget.Panel("fontboxoverlay", {/* xy:[610+Xoff,40+Yoff],*/ /*width:"170px",*/ /*height:"120px",*/ visible: false, zIndex: 1000, close: false } );
	YAHOO.util.Event.addListener("fontsmenubox", "click", YAHOO.example.container.fontboxoverlay.show, YAHOO.example.container.fontboxoverlay, true);
	YAHOO.example.container.fontboxoverlay.render();

	/* OPEN SYMBOLS GALLERY panel6 symoverlay */
	YAHOO.example.container.symoverlay = new YAHOO.widget.Panel("symoverlay", {/* xy:[140+Xoff,375+Yoff], width:"240px",*/ visible: false, zIndex: 600, close: false } );
	YAHOO.util.Event.addListener("launchsymbox", "click", YAHOO.example.container.symoverlay.show, YAHOO.example.container.symoverlay, true);
	YAHOO.example.container.symoverlay.render();

	/* CUSTOM IMAGE GALLERY OVERLAY panel7 imagegalleryoverlay */
	YAHOO.example.container.imagegalleryoverlay = new YAHOO.widget.Panel("imagegalleryoverlay", {/* xy:[360+Xoff,140+Yoff],*/ /*width:"230px",*/ /*height:"242px",*/ visible: false, zIndex: 700, close: false } );
	YAHOO.util.Event.addListener("launchIGbox", "click", showImgOpts/*YAHOO.example.container.imagegalleryoverlay.show, YAHOO.example.container.imagegalleryoverlay, true*/);
	function showImgOpts(){
	YAHOO.example.container.imagegalleryoverlay.render();
	
		MSB.$('symoverlay').style.visibility = "visible";
		MSB.$('textHint').style.visibility = "visible";
		MSB.$('textHint').style.position = "absolute";
		MSB.$('textHint').style.top = "393px";
		MSB.$('TCpicker_bd').style.visibility = "visible";
		MSB.$('TCpicker_bd').style.position = "absolute";
		MSB.$('TCpicker_bd').style.top = "438px";
		MSB.$('TCpicker_c').style.visibility = "inherit"; /* text colour picker */

		MSB.$('sel-F').style.visibility = 'visible';
		MSB.$('sel-B').style.visibility = 'visible';
		MSB.$('deleteimageBox').style.visibility = 'visible';

			// pre-emptivly load specific SYMBOLS (02March2011)	
			var root = loadMyXML("./symbols/SavageSYMBOLS.xml");
			var mysymbol;
			var mysyms = root.getElementsByTagName('symbol');
			var parent = MSB.$('symscrollgallery');
			parent.innerHTML = "";
			var newChild;
			for (var i=0;i<mysyms.length;i++) {
				mysymbol = mysyms[i].childNodes[0].nodeValue;
				newChild = document.createElement('IMG');
				newChild.setAttribute('id','selsym-'+mysymbol);
				newChild.setAttribute('name','selsym-'+mysymbol);
				newChild.setAttribute('src','./symbols/symimages/'+mysymbol+'-thumb.png');
				parent.appendChild(newChild);
				YAHOO.util.Event.on('selsym-'+mysymbol,'click', symbolselect);
			}
	}

	/* SAVED DESIGN COMPLETE OVERLAY panel10 savecompleteoverlay */
	YAHOO.example.container.savecompleteoverlay = new YAHOO.widget.Panel("savecompleteoverlay", {/* xy:[335+Xoff,-120+Yoff],*/ /*width:"270px",*/ visible: false, zIndex: 2600, close: false} ); /* was TRUE */
	YAHOO.example.container.savecompleteoverlay.render();
	if (showAddCart.toLowerCase() == 'yes') {
		/* panel20 addtocartoverlay */
		YAHOO.example.container.addtocartoverlay = new YAHOO.widget.Panel("addtocartoverlay", {/* xy:[270+Xoff,-120+Yoff],*/ /*width:"440px",*/ visible: false, zIndex: 2700, close: false} );/* was TRUE */
		YAHOO.example.container.addtocartoverlay.render();
	}
	else {
		MSB.$('addtocartoverlay').style.display = 'none';
		MSB.$('SbuydesignBox').style.display = 'none';
		MSB.$('WbuydesignBox').style.display = 'none';
	}
/*	if (showQsubmit.toLowerCase() == 'yes') {
		YAHOO.example.container.panel28 = new YAHOO.widget.Panel("quoteformoverlay", { xy:[250+Xoff,100+Yoff], width:"400px", visible: false, zIndex: 902, close: true} );
		YAHOO.example.container.panel28.render();
		var oButton = new YAHOO.widget.Button("SandQButton", {label: "Get My Quote"});
		YAHOO.example.container.panel29 = new YAHOO.widget.Panel("quoteintrooverlay", { xy:[250+Xoff,100+Yoff], width:"500px", visible: false, zIndex: 902, close: true} );
		YAHOO.util.Event.addListener("SandQDiv", "click", YAHOO.example.container.panel29.show, YAHOO.example.container.panel29, true);
		YAHOO.example.container.panel29.render();
	}
	else { */
	//	MSB.$('quoteintrooverlay').style.display = 'none';
	//	MSB.$('quoteformoverlay').style.display = 'none';
	//	MSB.$('SquotedesignBox').style.display = 'none';
	//	MSB.$('WquotedesignBox').style.display = 'none';
	//	MSB.$('SandQDiv').style.display = 'none';
//	}
	//DEBUG OVERLAY
/*	if (MSB.$('debugmode').value.toLowerCase() == 'yes') {
		YAHOO.example.container.panel12 = new YAHOO.widget.Panel("debugoverlay", { xy:[100+Xoff,125+Yoff], width:"200px", visible: true, zIndex: 600, close: true } );
		YAHOO.example.container.panel12.render();
	}
	else {
		YAHOO.example.container.panel12 = new YAHOO.widget.Panel("debugoverlay", { xy:[100+Xoff,125+Yoff], width:"200px", visible: false, zIndex: 600, close: true } );
		YAHOO.example.container.panel12.render();
	} */
	//savewaitoverlay panel13
	YAHOO.example.container.savewaitoverlay = new YAHOO.widget.Panel("savewaitoverlay", { xy:[610+Xoff,325+Yoff], width:"240px", visible: false, zIndex: 3000, close: true} );
	YAHOO.example.container.savewaitoverlay.render();
	//ALERT - open design panel14
	YAHOO.example.container.opendesignAlert = new YAHOO.widget.Panel("opendesignAlert", {/* xy:[120+Xoff,0+Yoff], */ /* width:"249px", height:"150px",*/ visible: false, zIndex: 2001, close: false} );
	YAHOO.example.container.opendesignAlert.render();
	//opendesignAlert2 panel132
	YAHOO.example.container.opendesignAlert2 = new YAHOO.widget.Panel("opendesignAlert2", {/* xy:[100+Xoff,225+Yoff], width:"450px", height:"150px",*/ visible: false, zIndex: 2001, close: false} );
	YAHOO.example.container.opendesignAlert2.render();
	//SEARCH DESIGNS OVERLAY panel15
	YAHOO.example.container.searchdesignsoverlay = new YAHOO.widget.Panel("searchdesignsoverlay", { xy:[165+Xoff,275+Yoff], width:"480px", visible: false, zIndex: 600, close: false} );
	YAHOO.util.Event.addListener("searchdesignbox", "click", YAHOO.example.container.searchdesignsoverlay.show, YAHOO.example.container.searchdesignsoverlay, true);
	YAHOO.example.container.searchdesignsoverlay.render();
	/* productdescoverlay panel18 */
	YAHOO.example.container.productdescoverlay = new YAHOO.widget.Panel("productdescoverlay", {/* productdescoverlay xy:[351+Xoff,190+Yoff],*/ width:"246px", visible: false, zIndex: 100, close: false} );
	YAHOO.example.container.productdescoverlay.render();
	/* welcomeoverlay panel21 */
	YAHOO.example.container.welcomeoverlay = new YAHOO.widget.Panel("welcomeoverlay", { xy:[160+Xoff,5+Yoff], width:"285px", visible: false, zIndex: 901, close: false} );
	YAHOO.example.container.welcomeoverlay.render();
	/* designreviewoverlay panel22 */
	YAHOO.example.container.designreviewoverlay = new YAHOO.widget.Panel("designreviewoverlay", { /* xy:[250+Xoff,0+Yoff], width:"430px", */ visible: false, zIndex: 6902, close: false} );
	YAHOO.example.container.designreviewoverlay.render();
	/* */
	YAHOO.example.container.panel23 = new YAHOO.widget.Panel("rotateoverlay", { xy:[60+Xoff,220+Yoff], width:"200px", visible: false, zIndex: 630, close: false} );
	YAHOO.util.Event.addListener("rotateBox", "click", YAHOO.example.container.panel23.show, YAHOO.example.container.panel23, true);
	YAHOO.example.container.panel23.render();
	/* archoverlay panel24 */
	YAHOO.example.container.archoverlay = new YAHOO.widget.Panel("archoverlay", {/* panel24 xy:[740+Xoff,190+Yoff],*/ /*width:"120px",*/ /*height:"140px",*/ visible: false, zIndex: 2000, close: false} );
	YAHOO.util.Event.addListener("launchTpathbox", "click", YAHOO.example.container.archoverlay.show, YAHOO.example.container.archoverlay, true);
	YAHOO.example.container.archoverlay.render();
	/* helpoverlay panel25 */
	YAHOO.example.container.helpoverlay = new YAHOO.widget.Panel("helpoverlay", {/* xy:[0+Xoff,0+Yoff],*/ /*width:"275px",*/ visible: false, zIndex: 2000, close: true} );
	YAHOO.util.Event.addListener("helpiconbox", "click", YAHOO.example.container.helpoverlay.show, YAHOO.example.container.helpoverlay, true);
	YAHOO.example.container.helpoverlay.render();
	/* */
	YAHOO.example.container.panel26 = new YAHOO.widget.Panel("contactusoverlay", { xy:[200+Xoff,100+Yoff], width:"400px", visible: false, zIndex: 800, close: true} );
	YAHOO.util.Event.addListener("emailiconbox", "click", YAHOO.example.container.panel26.show, YAHOO.example.container.panel26, true);
	YAHOO.example.container.panel26.render();
/*	if (showPriceSheet.toLowerCase() == 'yes') {
		YAHOO.example.container.panel27 = new YAHOO.widget.Panel("pricesheetoverlay", { xy:[100+Xoff,100+Yoff], width:"500px", visible: false, zIndex: 800, close: true} );
		YAHOO.util.Event.addListener("showpriceshDiv", "click", YAHOO.example.container.panel27.show, YAHOO.example.container.panel27, true);
		YAHOO.example.container.panel27.render();
	}
	else { */
	
	//	MSB.$('pricesheetoverlay').style.display = 'none';
	//	MSB.$('showpriceshDiv').style.display = 'none';
//	}

	YAHOO.example.container.panel30 = new YAHOO.widget.Panel("stockoverlay", { xy:[100+Xoff,60+Yoff], width:"400px", visible: false, zIndex: 801, close: false} );
	YAHOO.util.Event.addListener("launchSIGbox", "click", YAHOO.example.container.panel30.show, YAHOO.example.container.panel30, true);
	YAHOO.example.container.panel30.render();
	YAHOO.example.container.panel31 = new YAHOO.widget.Panel("shopdesignsoverlay", { xy:[100+Xoff,60+Yoff], width:"400px", visible: false, zIndex: 802, close: false} );
	YAHOO.util.Event.addListener("launchSDbox", "click", YAHOO.example.container.panel31.show, YAHOO.example.container.panel31, true);
	YAHOO.example.container.panel31.render();
	/* TEXT INPUT OVERLAY panel1 textboxoverlay */
	YAHOO.example.container.textboxoverlay = new YAHOO.widget.Panel("textboxoverlay", {/* xy:[351+Xoff,190+Yoff],*/ /*width:"245px",*/ visible: false, zIndex: 699,  close: false} );
	YAHOO.example.container.textboxoverlay.render(); 
	YAHOO.example.container.panel34 = new YAHOO.widget.Panel("TB2Div", { xy:[110+Xoff,235], width:"125px", /*height:"155px",*/ visible: false, zIndex: 4000, close: true} ); /* vis false until Text button hit */
	YAHOO.example.container.panel34.render();


	YAHOO.util.Event.addListener("showtextbox", "click", showTextOpts
	/*YAHOO.example.container.textboxoverlay.show, YAHOO.example.container.textboxoverlay, true*/);
	function showTextOpts(){
		YAHOO.example.container.textboxoverlay.show, YAHOO.example.container.textboxoverlay, true;
		MSB.$('textboxoverlay').style.visibility = "visible";
		MSB.$('textHint').style.position = "absolute";
		MSB.$('textHint').style.visibility = "visible";
		MSB.$('textHint').style.top = "102px";
		MSB.$('TCpicker_bd').style.visibility = "visible";
		MSB.$('TCpicker_bd').style.position = "absolute";
		MSB.$('TCpicker_bd').style.top = "145px";
		MSB.$('TCpicker_c').style.visibility = "inherit"; /* text colour picker */
	}



	YAHOO.util.Event.addListener("showtextboxNext", "click", YAHOO.example.container.textboxoverlay.show, YAHOO.example.container.textboxoverlay, true);

	/* New NEXT button for showing TEXT entry panel */
	YAHOO.util.Event.addListener("showtextboxNext", "click", showTextNext);
			function showTextNext() {
				MSB.$('textboxoverlay').style.visibility = "visible";

				MSB.$('sel-F').style.visibility = 'visible';
				MSB.$('sel-B').style.visibility = 'visible';

				YAHOO.example.container.productsoverlay.hide();
				YAHOO.example.container.productcolorsoverlay.hide();
				YAHOO.example.container.productdescoverlay.hide();
				YAHOO.example.container.imagegalleryoverlay.hide();
				MSB.$('showtextbox').style.visibility = "inherit";
				MSB.$('launchIGbox').style.visibility = "visible";
				
				MSB.$('showProductColorsbox').style.opacity = "0.5";
				MSB.$('showProductColorsbox').style.filter = "alpha(opacity= 50)"; //IE
				MSB.$('showProductColorsbox').style.backgroundColor = "transparent";
				
				MSB.$('textEditorDiv').style.visibility = "visible";
				MSB.$('textEditorDiv').style.backgroundColor = "#A5CBFF";

			MSB.$('showtextbox').style.backgroundColor = "#A5CBFF";
				MSB.$('showtextbox').style.opacity = "1";
				MSB.$('showtextbox').style.filter = "alpha(opacity= 100)"; //IE

			MSB.$('launchIGbox').style.backgroundColor = "transparent";
				MSB.$('launchIGbox').style.opacity = "1";
				MSB.$('launchIGbox').style.filter = "alpha(opacity= 100)"; /* IE */


				/*MSB.$('andOr').style.visibility = "visible";*/
			}

	/* New TEXT button for showing ALL TEXT options */
	YAHOO.util.Event.addListener("showtextbox", "click", textOptionsAll);
		function textOptionsAll() {
			MSB.$('sel-F').style.visibility = 'visible';
			MSB.$('sel-B').style.visibility = 'visible';

			YAHOO.example.container.productsoverlay.hide();
			YAHOO.example.container.productcolorsoverlay.hide();
			YAHOO.example.container.productdescoverlay.hide(); 
			YAHOO.example.container.fontboxoverlay.show(); 
			YAHOO.example.container.archoverlay.show();

			MSB.$('showProductsbox').style.backgroundColor = "transparent";
				MSB.$('showProductsbox').style.opacity = "0.5";
				MSB.$('showProductsbox').style.filter = "alpha(opacity= 50)"; /* IE */

			MSB.$('showProductColorsbox').style.backgroundColor = "transparent";
				MSB.$('showProductColorsbox').style.opacity = "0.5";
				MSB.$('showProductColorsbox').style.filter = "alpha(opacity= 50)"; /* IE */
				//MSB.$('archoverlay').style.visibility = "visible";

				MSB.$('imagegalleryoverlay').style.visibility = "hidden";

			MSB.$('textEditorDiv').style.backgroundColor = "transparent";

			MSB.$('showtextbox').style.backgroundColor = "#A5CBFF";
				MSB.$('showtextbox').style.opacity = "1";
				MSB.$('showtextbox').style.filter = "alpha(opacity= 100)"; //IE

			MSB.$('launchIGbox').style.backgroundColor = "transparent";
				MSB.$('launchIGbox').style.opacity = "0.5";
				MSB.$('launchIGbox').style.filter = "alpha(opacity= 50)"; /* IE */

			YAHOO.example.container.savedesignoverlay.hide(); 
			MSB.$('sizeChart').style.visibility = "hidden";
		}

	
	/* NEW LINES and Function for displaying TB2Div (align and delete dialog), fontboxoverlay, textcoloroverlay, and blanking text input line */
	YAHOO.util.Event.addListener("newtextButtonDiv", "click", newText);
			function newText() {
				YAHOO.example.container.fontboxoverlay.show();
				MSB.$('fontsizeDiv').style.visibility = "inherit"; /* text size dropdown menu */
				MSB.$('fontsmenubox').style.visibility = "visible"; /* font menu button */
				MSB.$('textHint').style.visibility = "inherit"; /* text colour picker */
				MSB.$('TCpicker_c').style.visibility = "visible"; /* text colour picker */
				MSB.$('TCpicker_bd').style.top = "145px";
				MSB.$('deleteimageBox').style.visibility = 'visible';
				YAHOO.example.container.archoverlay.show(); /* archoverlay */
			}
			
	YAHOO.util.Event.addListener("newtextButtonDiv", "mousedown", ghostline);
		function ghostline() {
			var ghostThis = MSB.$('edittextboxGhost').value;
			MSB.$('edittextbox').value = ghostThis;
		}
	YAHOO.util.Event.addListener("newtextButtonDiv", "mouseup", ghostempty);
		function ghostempty() {
			MSB.$('edittextboxGhost').value = "";
		}
			
	
	/* NEW LINE works for displaying TB2Div (align and delete dialog) */
	YAHOO.util.Event.addListener("replacetextButtonDiv", "click", YAHOO.example.container.panel34.show, YAHOO.example.container.panel34, true);
	/* NEW LINE and Function -- Add Your Text */
	YAHOO.util.Event.addListener("launchIGbox", "click",show3bTools);
		function show3bTools() {
			MSB.$('fontsmenubox').style.visibility = "hidden";
			YAHOO.example.container.productsoverlay.hide();
			YAHOO.example.container.productcolorsoverlay.hide();
			YAHOO.example.container.productdescoverlay.hide();
			YAHOO.example.container.fontboxoverlay.hide();
			YAHOO.example.container.archoverlay.hide();
			MSB.$('imagegalleryoverlay').style.visibility = 'visible';

			MSB.$('showProductsbox').style.backgroundColor = 'transparent';
			MSB.$('showProductColorsbox').style.backgroundColor = 'transparent';

			MSB.$('showProductsbox').style.backgroundColor = 'transparent';
				MSB.$('showProductsbox').style.opacity = '0.5';
				MSB.$('showProductsbox').style.filter = 'alpha(opacity= 50)'; //IE

			MSB.$('showProductColorsbox').style.backgroundColor = 'transparent';
				MSB.$('showProductColorsbox').style.opacity = '0.5';
				MSB.$('showProductColorsbox').style.filter = 'alpha(opacity= 50)'; //IE

			MSB.$('textEditorDiv').style.backgroundColor = 'transparent';
			
			MSB.$('showtextbox').style.backgroundColor = 'transparent';
				MSB.$('showtextbox').style.opacity = '0.5';
				MSB.$('showtextbox').style.filter = 'alpha(opacity= 50)'; //IE

			MSB.$('launchIGbox').style.backgroundColor = '#A5CBFF';
				MSB.$('launchIGbox').style.opacity = '1';
				MSB.$('launchIGbox').style.filter = 'alpha(opacity= 100)'; /* IE */

			YAHOO.example.container.savedesignoverlay.hide();
		}


	YAHOO.util.Event.addListener("designfileDiv", "click",showTextEditorDiv);
		function showTextEditorDiv() {
			MSB.$('textEditorDiv').hidden = "visible";/* TESTING */
		}


	YAHOO.util.Event.on("savedesignbox", "click", designerrorcheck);
	YAHOO.util.Event.on("fontUp", "click", fsIncrease);
	YAHOO.util.Event.on("fontDown", "click", fsDecrease);
//	YAHOO.util.Event.on("stkUp", "click", stkIncrease);
//	YAHOO.util.Event.on("stkDown", "click", stkDecrease);
	YAHOO.util.Event.on("archUp", "click", function () {archadjust('up')});
	YAHOO.util.Event.on("archUpOne", "click", function () {archadjust('upOne')});
	YAHOO.util.Event.on("archUpTwo", "click", function () {archadjust('upTwo')});
	YAHOO.util.Event.on("archUpThree", "click", function () {archadjust('upThree')});
	YAHOO.util.Event.on("archDown", "click", function () {archadjust('down')});
	YAHOO.util.Event.on("archDownOne", "click", function () {archadjust('downOne')});
	YAHOO.util.Event.on("archDownTwo", "click", function () {archadjust('downTwo')});
	YAHOO.util.Event.on("archDownThree", "click", function () {archadjust('downThree')});
	YAHOO.util.Event.on("sel-F", "click", function () {changeproductloc('F')});
	YAHOO.util.Event.on("sel-B", "click", function () {changeproductloc('B')});
	YAHOO.util.Event.on("savedesignBox2", "click", savedesign);
	YAHOO.util.Event.on("opendesignBox2", "click", openwarn);
	YAHOO.util.Event.on("opendesignYesBox", "click", opendesign);
	YAHOO.util.Event.on("opendesignNoBox", "click", cancelopen);
	YAHOO.util.Event.on("opendesignYesBox2", "click", function () {opendesign('fromstock')});
	YAHOO.util.Event.on("opendesignNoBox2", "click", cancelopen);
	YAHOO.util.Event.on("leftjustBox", "click", leftjustline);
	YAHOO.util.Event.on("rightjustBox", "click", rightjustline);
	YAHOO.util.Event.on("centerjustBox", "click", centerjustline);
	YAHOO.util.Event.on("deletelineBox", "click", dellinecheck);
/* X */ YAHOO.util.Event.on("deletelineBoxT", "click", dellinecheck);
/* X */ YAHOO.util.Event.on("deleteimageBox", "click", dellinecheck);
	YAHOO.util.Event.on("moveforwardBox", "click", moveforward);
	YAHOO.util.Event.on("movebackBox", "click", moveback);
	YAHOO.util.Event.on("ObuydesignBox", "click", function () {fillcartBox2('O')});
	YAHOO.util.Event.on("SbuydesignBox", "click", fillcartBox1);
	YAHOO.util.Event.on("cancelDesignRetrieveBox", "click", cancelDesignRetrieve);
	YAHOO.util.Event.on("SnewdesignBox", "click", newdesign);
	YAHOO.util.Event.on("SeditdesignBox", "click", editdesign);	
	YAHOO.util.Event.on("WbuydesignBox", "click", function () {fillcartBox2('W')});
	YAHOO.util.Event.on("WnewdesignBox", "click", Wnewdesign);
	YAHOO.util.Event.on("WeditdesignBox", "click", Weditdesign);
	YAHOO.util.Event.on("WsearchdesignBox", "click", Wsearchdesign);
//	YAHOO.util.Event.on("updatedebugBox", "click", updatedebug);
	YAHOO.util.Event.on("searchdesignsBox2", "click", showsearchresults);
	YAHOO.util.Event.on("StocartBox", "click", addtoCart);
	YAHOO.util.Event.on("WimageViewDiv", "click", function () {previewThumb('W')});
	YAHOO.util.Event.on("OimageViewBox", "click", function () {previewThumb('O')});
	YAHOO.util.Event.on("homeBox", "click", function () {leaveWarn('home')});
	YAHOO.util.Event.on("checkoutBox", "click", function () {leaveWarn('checkout')});
	YAHOO.util.Event.on("flipVBox", "click", function () {flip1('V')});
	YAHOO.util.Event.on("flipHBox", "click", function () {flip1('H')});
	YAHOO.util.Event.on("rotateBoxCCW", "click", function () {rotate('CCW')});
	YAHOO.util.Event.on("rotateBoxCW", "click", function () {rotate('CW')});
	YAHOO.util.Event.on("removearchBox", "click", function () {archadjust('X')});
	YAHOO.util.Event.on("CFsubmitbox", "click", CFsubmit);
//	YAHOO.util.Event.on("QFsubmitbox", "click", QFsubmit);
//	YAHOO.util.Event.on("SquotedesignBox", "click", function () {QFformload('S')});
//	YAHOO.util.Event.on("refreshPriceDiv", "click", function () {getInstantQuote('wrk')});
	//CREATE BUTTONS
	
	var oButton = new YAHOO.widget.Button("savedesignButton"/*, {label: "Save &amp; Checkout"}*/);
	var oButton = new YAHOO.widget.Button("savedesignButton2", {label: "Save Design"});
	var oButton = new YAHOO.widget.Button("searchdesignsButton2", {label: "Search"})
	var oButton = new YAHOO.widget.Button("opendesignButton");
	var oButton = new YAHOO.widget.Button("opendesignButton2");
	var oButton = new YAHOO.widget.Button("opendesignYesButton", {label: "Continue"});
	var oButton = new YAHOO.widget.Button("opendesignNoButton", {label: "Cancel"});
	var oButton = new YAHOO.widget.Button("opendesignYesButton2", {label: "Continue"});
	var oButton = new YAHOO.widget.Button("opendesignNoButton2", {label: "Cancel"});
	var oButton = new YAHOO.widget.Button("searchdesignButton");
	var oButton = new YAHOO.widget.Button("showproductsButton"/*, {label: "Styles"}*/);
	var oButton = new YAHOO.widget.Button("showProductColorsButton"/*, {label: "Colours"}*/);
	var oButton = new YAHOO.widget.Button("fontsmenuButton");
	var oButton = new YAHOO.widget.Button("showtextButton");
	var oButton = new YAHOO.widget.Button("showCPButton");
	//var oButton = new YAHOO.widget.Button("strokeButton");
	var oButton = new YAHOO.widget.Button("launchIGButton");
	var oButton = new YAHOO.widget.Button("launchSIGButton");
	var oButton = new YAHOO.widget.Button("launchsymButton");
	var oButton = new YAHOO.widget.Button("launchSDButton", {label: "View Our Designs"});
	var oButton = new YAHOO.widget.Button("imagegalformAddButton", {label: "Add to Gallery"});
	var oButton = new YAHOO.widget.Button("leftjustButton"/*, {label: "AlignLeft"}*/);
	var oButton = new YAHOO.widget.Button("rightjustButton"/*, {label: "AlignRight"}*/);
	var oButton = new YAHOO.widget.Button("centerjustButton"/*, {label: "AlignCentre"}*/);
	var oButton = new YAHOO.widget.Button("deletelineButton"/*, {label: "Delete"}*/);
/* X */	var oButton = new YAHOO.widget.Button("deletelineButtonT", {label: "Delete"});
/* X */	var oButton = new YAHOO.widget.Button("deleteimageButton", {label: "Delete element"});
	var oButton = new YAHOO.widget.Button("moveforwardButton");
	var oButton = new YAHOO.widget.Button("movebackButton");
	var oButton = new YAHOO.widget.Button("newtextButton", {label: "Add your text"});
	var oButton = new YAHOO.widget.Button("replacetextButton", {label: "Replace"});
	var oButton = new YAHOO.widget.Button("ObuydesignButton");
	var oButton = new YAHOO.widget.Button("cancelDesignRetrieveButton");
	var oButton = new YAHOO.widget.Button("opendesignButton2");
	var oButton = new YAHOO.widget.Button("SbuydesignButton");
//	var oButton = new YAHOO.widget.Button("SquotedesignButton");
//	var oButton = new YAHOO.widget.Button("WquotedesignButton");
	var oButton = new YAHOO.widget.Button("SnewdesignButton");
	var oButton = new YAHOO.widget.Button("SeditdesignButton");
	var oButton = new YAHOO.widget.Button("WbuydesignButton");
	var oButton = new YAHOO.widget.Button("WnewdesignButton");
	var oButton = new YAHOO.widget.Button("WeditdesignButton");
	var oButton = new YAHOO.widget.Button("WsearchdesignButton");
	var oButton = new YAHOO.widget.Button("StocartButton", {label: "Add To Basket"});
//	var oButton = new YAHOO.widget.Button("updatedebugButton", {label: "Update Debug"});
	var oButton = new YAHOO.widget.Button("sel-Fbutton", {label: "Front"});
	var oButton = new YAHOO.widget.Button("sel-Bbutton", {label: "Back"});
	var oButton = new YAHOO.widget.Button("homeButton");
	var oButton = new YAHOO.widget.Button("helpButton");
	var oButton = new YAHOO.widget.Button("emailButton");
	var oButton = new YAHOO.widget.Button("priceSHButton");
	var oButton = new YAHOO.widget.Button("CFsubmitButton", {label: "Submit"});
//	var oButton = new YAHOO.widget.Button("QFsubmitButton", {label: "Submit"});
	if (showCKbutton.toLowerCase() == 'yes') {
      //var oButton = new YAHOO.widget.Button("checkoutButton");
      //	YAHOO.example.container.tt19 = new YAHOO.widget.Tooltip("tt19", 
      //						{ context:"checkoutBox", 
      //						  text:"Go To Checkout",
      //						  zIndex:1000});
	var oButton = new YAHOO.widget.Button("checkoutButton",  {label: "Checkout"});// new line

	}
	else {
		MSB.$('checkoutBox').style.visibility = 'hidden';
	}
	var oButton = new YAHOO.widget.Button("buydesignButton");
	var oButton = new YAHOO.widget.Button("WimageViewButton");
	var oButton = new YAHOO.widget.Button("OimageViewButton");
	var oButton = new YAHOO.widget.Button("rotateButton");
	var oButton = new YAHOO.widget.Button("flipVButton");
	var oButton = new YAHOO.widget.Button("flipHButton");
	var oButton = new YAHOO.widget.Button("launchTpathButton");
	var oButton = new YAHOO.widget.Button("rotateButtonCCW");
	var oButton = new YAHOO.widget.Button("rotateButtonCW");
	var oButton = new YAHOO.widget.Button("removearchButton");
	YAHOO.example.container.tt1 = new YAHOO.widget.Tooltip("tt1", 
							{ context:"showtextButton", 
							  text:"Show ALL Text options",
							  zIndex:1000});
	YAHOO.example.container.tt2 = new YAHOO.widget.Tooltip("tt2", 
							{ context:"showCPButton", 
							  text:"Open Text Colour Palette",
							  zIndex:1000});
	//YAHOO.example.container.tt3 = new YAHOO.widget.Tooltip("tt3", 
	//						{ context:"fontsizeDiv", 
	//						  text:"Choose Font before Text Size",
	//						  zIndex:1000});
	YAHOO.example.container.tt4 = new YAHOO.widget.Tooltip("tt4", 
							{ context:"leftjustButton", 
							  text:"Left Align Design",
							  zIndex:1000});
	YAHOO.example.container.tt5 = new YAHOO.widget.Tooltip("tt5", 
							{ context:"rightjustButton", 
							  text:"Right Align Design",
							  zIndex:1000});
	YAHOO.example.container.tt6 = new YAHOO.widget.Tooltip("tt6", 
							{ context:"centerjustButton", 
							  text:"Center Design",
							  zIndex:1000});
	YAHOO.example.container.tt7 = new YAHOO.widget.Tooltip("tt7", 
							{ context:"fontsmenuButton", 
							  text:"Open Font Selector",
							  zIndex:1000});
	YAHOO.example.container.tt8 = new YAHOO.widget.Tooltip("tt8", 
							{ context:"launchsymButton", 
							  text:"Open Symbols Gallery",
							  zIndex:1000});
	YAHOO.example.container.tt8 = new YAHOO.widget.Tooltip("tt8", 
							{ context:"launchIGButton", 
							  text:"Add an Image",
							  zIndex:1000});
	YAHOO.example.container.tt81 = new YAHOO.widget.Tooltip("tt81", 
							{ context:"launchSIGButton", 
							  text:"Open Our Image Gallery",
							  zIndex:1000});
	YAHOO.example.container.tt9 = new YAHOO.widget.Tooltip("tt9", 
							{ context:"savedesignButton", 
							  text:"Save Design",
							  zIndex:1000});
	YAHOO.example.container.tt10 = new YAHOO.widget.Tooltip("tt10", 
							{ context:"opendesignButton", 
							  text:"Open Design",
							  zIndex:1000});
	YAHOO.example.container.tt11 = new YAHOO.widget.Tooltip("tt11", 
							{ context:"searchdesignButton", 
							  text:"Search for your<br />previous Custom Design(s)",
							  zIndex:1000});
	YAHOO.example.container.tt12 = new YAHOO.widget.Tooltip("tt12", 
							{ context:"deletelineButton", 
							  text:"Delete Selected Object",
							  zIndex:3000});
	YAHOO.example.container.tt12T = new YAHOO.widget.Tooltip("tt12T", 
							{ context:"deletelineButtonT", 
							  text:"Delete selected text<br /> from your design",
							  zIndex:3000});
	YAHOO.example.container.tt12D = new YAHOO.widget.Tooltip("tt12D", 
							{ context:"deleteimageButton", 
							  text:"click here to Delete the Selected element<br /> from your design",
							  zIndex:3000});
	YAHOO.example.container.tt13 = new YAHOO.widget.Tooltip("tt13", 
							{ context:"showProductColorsButton", 
							  text:"Show garment Colour & Size options",
							  zIndex:1000});
	YAHOO.example.container.tt14 = new YAHOO.widget.Tooltip("tt14", 
							{ context:"moveforwardButton", 
							  text:"Move Item Forward",
							  zIndex:1000});
	YAHOO.example.container.tt15 = new YAHOO.widget.Tooltip("tt15", 
							{ context:"movebackButton", 
							  text:"Move Item Back",
							  zIndex:1000});
/*	YAHOO.example.container.tt16 = new YAHOO.widget.Tooltip("tt16", 
							{ context:"strokeButton", 
							  text:"Add Outline to Text",
							  zIndex:1000}); */
/*	YAHOO.example.container.tt17 = new YAHOO.widget.Tooltip("tt17", 
							{ context:"stksizeDiv", 
							  text:"Text Outline Width",
							  zIndex:1000}); */
	YAHOO.example.container.tt18 = new YAHOO.widget.Tooltip("tt18", 
							{ context:"homeBox", 
							  text:"Our Home Page",
							  zIndex:1000});
	YAHOO.example.container.tt20 = new YAHOO.widget.Tooltip("tt20", 
							{ context:"rotateBox", 
							  text:"Rotate Object",
							  zIndex:1000});
	YAHOO.example.container.tt21 = new YAHOO.widget.Tooltip("tt21", 
							{ context:"flipVBox", 
							  text:"Flip Vertically",
							  zIndex:1000});
	YAHOO.example.container.tt22 = new YAHOO.widget.Tooltip("tt22", 
							{ context:"flipHBox", 
							  text:"Flip Horizontally",
							  zIndex:1000});
	YAHOO.example.container.tt23 = new YAHOO.widget.Tooltip("tt23", 
							{ context:"launchTpathButton", 
							  text:"Curve Text",
							  zIndex:1000});
	YAHOO.example.container.tt24 = new YAHOO.widget.Tooltip("tt24", 
							{ context:"rotateButtonCCW", 
							  text:"Rotate CCW",
							  zIndex:1000});
	YAHOO.example.container.tt25 = new YAHOO.widget.Tooltip("tt25", 
							{ context:"rotateButtonCW", 
							  text:"Rotate CW",
							  zIndex:1000});
	YAHOO.example.container.tt26 = new YAHOO.widget.Tooltip("tt26", 
							{ context:"removearchButton", 
							  text:"Remove Curve",
							  zIndex:3000});
	YAHOO.example.container.tt27 = new YAHOO.widget.Tooltip("tt27", 
							{ context:"helpButton", 
							  text:"Help / Quick Guide",
							  zIndex:1000});
	YAHOO.example.container.tt28 = new YAHOO.widget.Tooltip("tt28", 
							{ context:"emailButton", 
							  text:"Contact Us",
							  zIndex:1000});
/*	YAHOO.example.container.tt29 = new YAHOO.widget.Tooltip("tt29", 
							{ context:"priceSHButton", 
							  text:"View Price List",
							  zIndex:1000}); */
	YAHOO.example.container.tt30 = new YAHOO.widget.Tooltip("tt30", 
							{ context:"showproductsButton", 
							  text:"Show Styles options",
							  zIndex:1000});

});
function Wnewdesign() {
	YAHOO.example.container.welcomeoverlay.hide();
}
function Weditdesign() {
	YAHOO.example.container.welcomeoverlay.hide();
	MSB.$('open-design-id').value = MSB.$('Wopen-design-id').value;
	opendesign();
}
function Wsearchdesign() {
	YAHOO.example.container.welcomeoverlay.hide();
	YAHOO.example.container.searchdesignsoverlay.show();
}
YAHOO.util.Event.onDOMReady(function() {
	YAHOO.namespace("example.container");
	if(7 > parseFloat(navigator.appVersion.split("MSIE")[1])) {
		YAHOO.example.container.panel23 = new YAHOO.widget.Panel("IEwarnDiv", { xy:[200,20], width:"500px", height:"300px", visible: false, zIndex: 906, close: true} );
		YAHOO.example.container.panel23.render();
		YAHOO.example.container.panel23.show();
	}
	previewThumb('W');
});
function previewThumb(from) {
	if (from == 'W') {
		var ID = MSB.$('Wopen-design-id').value;
	}
	if (from == 'O') {
		var ID = MSB.$('open-design-id').value;
	}
	if (ID.length > 0) {
		var root = loadMyXML("./saveddesigns/"+ID+"/"+ID+".xml");
		var numlinesFA = root.getElementsByTagName('numlinesfront');
		var numlinesF = numlinesFA[0].childNodes[0].nodeValue;
		var numlinesBA = root.getElementsByTagName('numlinesback');
		var numlinesB = numlinesBA[0].childNodes[0].nodeValue;
		var HTML = "";
		var HTML2 = "";
		var myDiv = MSB.$('WimageDiv');
		if (numlinesF > 0) {
			HTML = HTML + '<img src="./saveddesigns/'+ID+'/'+ID+'-F.png" />&nbsp;&nbsp;';
			HTML2 = HTML2 + '<img src="./saveddesigns/'+ID+'/'+ID+'-thumbF.png" />&nbsp;&nbsp;<!--<br /><br />-->';
		}
		if (numlinesB > 0) {
			HTML = HTML + '<img src="./saveddesigns/'+ID+'/'+ID+'-B.png" />&nbsp;&nbsp;<!--<br />-->';
			HTML2 = HTML2 + '<img src="./saveddesigns/'+ID+'/'+ID+'-thumbB.png" />&nbsp;&nbsp;<!--<br />-->';
		}
		if (from == 'W') {
			myDiv.innerHTML = HTML;
			YAHOO.example.container.designreviewoverlay.show();
		}
		if (from == 'O') {
			YAHOO.example.container.designreviewoverlay.show();
		}
		var myDiv = MSB.$('designreviewDiv');
		myDiv.innerHTML = HTML2;
	}
}
function myTime() {
	var mydate = new Date();
	var myhours = mydate.getHours();
	var mymins = mydate.getMinutes();
	var mysecs = mydate.getSeconds();
	var mymilli = mydate.getMilliseconds();
	var totaltime = myhours+mymins+mysecs+mymilli;
	return totaltime;
}
function pngMSIE(source,height,width,i) {
	var view = MSB.$('actloc').value;
	if (MSB.$('currentFMT').value == 'text' || MSB.$('currentFMT').value == 'symbol') {
		if (!document.body.filters) {
			MSB.$('divimg'+i).style.backgroundImage = 'url("' + source + '")';
			return; //not MSIE
		}
		if(7 <= parseFloat(navigator.appVersion.split("MSIE")[1])) {
			MSB.$('divimg'+i).style.backgroundImage = 'url("' + source + '")';
			return; //MSIE7 supports png
		}
		var mydiv = MSB.$('divimg' + i);
		mydiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + source + "',sizingMethod='image')";
		mydiv.style.paddingBottom = "10px";
	}
	if (MSB.$('currentFMT').value == 'image' || MSB.$('currentFMT').value == 'stock') {
		var newChild = document.createElement('IMG');
		var parent = MSB.$('divimg'+i);
		var newID = 'divimI'+i;
		newChild.setAttribute('id',newID);
		newChild.setAttribute('src',source);
		newChild.setAttribute('height',height);
		newChild.setAttribute('width',width);
		parent.appendChild(newChild);
		var newheight = height+"px";
		var newwidth = width+"px";
		YAHOO.util.Event.on(newID, "click", divdown);
		YAHOO.util.Event.on(newID, "mouseup", function() {divup(MSB.$('currentFMT').value);});
		//NEED TO ADD MSIE 6 transparency filter
	}
}
//handle ondown of each line of text
function divdown(e) {
	if (MSB.$('actline').value != 'none') {
		var actline = MSB.$('actline').value;
		var actindex = actline.substring(2);
		MSB.$('divimg' + actindex).style.border = "none";
	} 
	var elTarget = YAHOO.util.Event.getTarget(e);	
	elTarget = elTarget.id;
	var mydiv = "divimg"+elTarget.substring(6);
	MSB.$(mydiv).style.border = "dotted 1px #ffff00";
	var textind = "tx" + elTarget.substring(6);
	var ind = elTarget.substring(6);
	var mytext = MSB.$(textind).value;
	if (MSB.$('format' + ind).value == 'text') {
		MSB.$('currentFMT').value = 'text';
		MSB.$('edittextbox').value = mytext;
		MSB.$('fsedit').value = MSB.$("fs" + ind).value;
		MSB.$('stkedit').value = MSB.$("stkw" + ind).value;
	}
	if (MSB.$('format' + ind).value == 'symbol') {
		MSB.$('currentFMT').value = 'symbol';
		MSB.$('edittextbox').value = '';
		MSB.$('curSymCode').value = mytext;
		MSB.$('curSymFT').value = MSB.$('ft'+ind).value;
	}
	if (MSB.$('format' + ind).value == 'image') {
		MSB.$('currentFMT').value = 'image';
		MSB.$('edittextbox').value = '';
	}
	if (MSB.$('format' + ind).value == 'stock') {
		MSB.$('currentFMT').value = 'stock';
		MSB.$('edittextbox').value = '';
	}
	MSB.$('actline').value = textind;
}
function divup(who) {
	var format = MSB.$('currentFMT').value;
	var loc = MSB.$('actloc').value;
	var actindex = MSB.$('actline').value.substring(2);
	var newleft = parseInt(MSB.$('divimg'+actindex).style.left); // IE has error here - see call for divup function at line 741
	var newtop = parseInt(MSB.$('divimg'+actindex).style.top);
	var height = parseInt(MSB.$('divimg'+actindex).style.height);
	var width = parseInt(MSB.$('divimg'+actindex).style.width);
	var heightPX = height + "px";
	var widthPX = width + "px";
	MSB.$('left'+actindex).value = newleft;
	MSB.$('top'+actindex).value = newtop;
	if (format == 'image' || format == 'stock') {
		var myimg = MSB.$('divimI'+actindex);
		myimg.style.height = heightPX;
		myimg.style.width = widthPX;
		MSB.$('Himg'+actindex).value = height;
		MSB.$('Wimg'+actindex).value = width;	
	}
	checkboundaries();
}
function divup2(who) {
	var updatesize = 0;
	var actindex = MSB.$('actline').value.substring(2);
	var oldWidth = MSB.$('Wimg'+actindex).value;
	var newleft = parseInt(MSB.$('divimg'+actindex).style.left);
	var newtop = parseInt(MSB.$('divimg'+actindex).style.top);
	var height = parseInt(MSB.$('divimg'+actindex).style.height);
	var width = parseInt(MSB.$('divimg'+actindex).style.width);
	if (oldWidth != width) {
		MSB.$('Wimg'+actindex).value = width;
		updatesize = 1;
	}
	if (updatesize == 1) {
		MSB.$('fs' + actindex).value = width;
		editsymbol('fromeditfs');
	}
	MSB.$('left'+actindex).value = newleft;
	MSB.$('top'+actindex).value = newtop;
	checkboundaries();
}
function turnoffBorders() {
	var loc = MSB.$('actloc').value;
	var parent = MSB.$('printArea'+loc);
	var imgs = parent.getElementsByTagName('DIV');
	for (var i=0;i < parent.childNodes.length;i++) {
		MSB.$(imgs[i]).style.border = 'none';
	}
}		
function deletetext() {
	var lineindex = MSB.$('actline').value.substring(2);
//	YAHOO.util.Event.purgeElement('divimg'+lineindex, true);
	var loc = MSB.$('actloc').value;
	var i = lineindex.substring(1);
	if (MSB.$('numlines' + loc ).value != 0) {
		document.getElementById("tx" + lineindex).value = "";
		var newnumlines = parseInt(MSB.$('numlines' + loc ).value) - 1;
		MSB.$('numlines' + loc).value = newnumlines;
		MSB.$('actline').value = 'none';
		MSB.$('edittextbox').value = '';
		var mydiv = MSB.$('divimg' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('tx' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('loc' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('format' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('ft' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('fc' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('fs' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('left' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('top' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('Wimg' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('Himg' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('Zind' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('flipV' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('flipH' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('rot' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		if (MSB.$('stkc' + lineindex)) {
			mydiv = MSB.$('stkc' + lineindex);
			mydiv.parentNode.removeChild(mydiv);
		}
		if (MSB.$('stkw' + lineindex)) {
			mydiv = MSB.$('stkw' + lineindex);
			mydiv.parentNode.removeChild(mydiv);
		}
		if (MSB.$('arch' + lineindex)) {
			mydiv = MSB.$('arch' + lineindex);
			mydiv.parentNode.removeChild(mydiv);
		}
	}
}
function flip1(dir) {
	var ID = MSB.$('design_id').value;
	var lineindex = MSB.$('actline').value.substring(2);
    var fmt = MSB.$('format'+lineindex).value;
    var flipbool = MSB.$('flip'+dir+lineindex).value;
	if (flipbool == 'no') {
		MSB.$('flip'+dir+lineindex).value = 'yes';
	}
	else {
		MSB.$('flip'+dir+lineindex).value = 'no';
	}
    var wimg = MSB.$('Wimg'+lineindex).value;
    var himg = MSB.$('Himg'+lineindex).value;
    var ext = MSB.$('fs'+lineindex).value;
	var junk=myTime();
	if (fmt == 'text' || fmt == 'symbol') {
		var ind = lineindex;
	}
	if (fmt == 'image') {
		var ind = MSB.$('tx'+lineindex).value;
	}
	if (fmt == 'stock') {
		var indA = MSB.$('tx'+lineindex).value.split('.');
		var ind = indA[0];
		ext = indA[1];
	}
    var img = new Image();
    img.source = './encrypted/flip.php?fmt='+fmt+'&wimg='+wimg+'&himg='+himg+'&ind='+ind+'&F='+dir+'&ext='+ext+'&j='+junk+'&ID='+ID;
   	if (fmt == 'text' || fmt == 'symbol') {
		pngMSIE(img.source,himg,wimg,ind);
	}
	if (fmt == 'image' || fmt == 'stock') {
		//var source = './images/'+MSB.$('design_id').value+'/Cimageedit'+ind+ext;
		MSB.$('divimI'+lineindex).src = img.source;
		//alert(source);
	}
}
function rotate(dir) {
	var ID = MSB.$('design_id').value;
	var lineindex = MSB.$('actline').value.substring(2);
   	var fmt = MSB.$('format'+lineindex).value;
	if (fmt == 'text') {
		var rot = Math.abs(parseInt(MSB.$('rotedit').value));
	}
	else {
		var rot = 90;
	}
	if (dir == "CCW") {
		rot = "-"+rot;
		rot = parseInt(rot);
	}
	if (fmt == 'text') {
		var rot = parseInt(MSB.$('rot'+lineindex).value) + rot;
		if (Math.abs(rot) == 360) {
			rot = 0;
		}
		MSB.$('rot'+lineindex).value = rot;
		edittext('fromupdate');
	}
	if (fmt == 'symbol') {
		var rot = parseInt(MSB.$('rot'+lineindex).value) + rot;
		if (Math.abs(rot) == 360) {
			rot = 0;
		}
		MSB.$('rot'+lineindex).value = rot;
		editsymbol('fromeditrot');
	}    
	if (fmt == 'image' || fmt == 'stock') {
		if (Math.abs(parseInt(MSB.$('rot'+lineindex).value) + rot) == 360) {
			MSB.$('rot'+lineindex).value = '0';
		}
		else {
			MSB.$('rot'+lineindex).value = parseInt(MSB.$('rot'+lineindex).value) + rot;
		}
		var junk=myTime();
		var myimg = MSB.$('divimI'+lineindex);
		var ind = MSB.$('tx'+lineindex).value;
		var ext = MSB.$('fs'+lineindex).value;
		if (fmt == 'stock') {
			var indA = MSB.$('tx'+lineindex).value.split('.');
			var ind = indA[0];
			var ext = indA[1];
		}
		var oldH = MSB.$("Himg" + lineindex).value;
		var oldW = MSB.$("Wimg" + lineindex).value;
		var img = new Image();
		img.source = './encrypted/rotate.php?ind='+ind+'&F='+dir+'&ext='+ext+'&j='+junk+'&rot='+rot+'&ID='+ID+'&fmt='+fmt;
		myimg.src = img.source;
		myimg.style.height = oldW + "px";
		myimg.style.width = oldH + "px";
		MSB.$("divimg" + lineindex).style.height = oldW + "px";
		MSB.$("divimg" + lineindex).style.width = oldH + "px";
		MSB.$("Himg" + lineindex).value = oldW;
		MSB.$("Wimg" + lineindex).value = oldH;
	} 
}
function archadjust(dir) {
	var cancel = false;
	var ID = MSB.$('design_id').value;
	var lineindex = MSB.$('actline').value.substring(2);
   	var fmt = MSB.$('format'+lineindex).value;
	if (fmt == 'text') {
		var junk=myTime();
		if (dir == 'X') {
			MSB.$('arch'+lineindex).value = '0';
			var arch = '0';
			var img = new Image();
			//img.source = './images/'+ID+'/tx'+lineindex+'.png';
			var W = MSB.$('Wimg'+lineindex).value;
			var H = MSB.$('Himg'+lineindex).value;
			img.source = './encrypted/gettx.php?ID='+ID+'&ind='+lineindex+'&j='+junk;
			MSB.$('divimg'+lineindex).style.height = H + "px";
			pngMSIE(img.source,H,W,lineindex);
		}
		else {	
			var H1 = parseInt(MSB.$('Himg'+lineindex).value)*.20; // H1 is amount of arch
			H1 = Math.round(H1);
			
			if (dir == 'upOne') { // ----- UP 1 -----
				var arch = parseInt(MSB.$('arch'+lineindex).value) - H1;
				if (arch != (-6)) {	// expanded
					arch = (-6)	//
				}			//
				MSB.$('arch'+lineindex).value = arch;
			}
			if (dir == 'upTwo') { // ----- UP 2 -----
				var arch = parseInt(MSB.$('arch'+lineindex).value) - H1;
				if (arch != (-8)) {	// expanded
					arch = (-8)	//
				}			//
				MSB.$('arch'+lineindex).value = arch;
			}
			if (dir == 'upThree') { // ----- UP 3 -----
				var arch = parseInt(MSB.$('arch'+lineindex).value) - H1;
				if (arch != (-12)) {	// expanded
					arch = (-12)	//
				}			//
				MSB.$('arch'+lineindex).value = arch;
			}

			if (dir == 'downOne') { // ----- DOWN 1 -----
				var arch = parseInt(MSB.$('arch'+lineindex).value) + H1;
				if (arch != (6)) {	// expanded
					arch = (6)	//
				}			//
				MSB.$('arch'+lineindex).value = arch;
			}
			if (dir == 'downTwo') { // ----- DOWN 2 -----
				var arch = parseInt(MSB.$('arch'+lineindex).value) + H1;
				if (arch != (8)) {	// expanded
					arch = (8)	//
				}			//
				MSB.$('arch'+lineindex).value = arch;
			}
			if (dir == 'downThree') { // ----- DOWN 3 -----
				var arch = parseInt(MSB.$('arch'+lineindex).value) + H1;
				if (arch != (12)) {	// expanded
					arch = (12)	//
				}			//
				MSB.$('arch'+lineindex).value = arch;
			}

			/* else {// ----- DOWN 1 -----
				var arch = parseInt(MSB.$('arch'+lineindex).value) + H1;
				if (arch != 6) {	// expand function here
					arch = (6)	//
				}			//
				MSB.$('arch'+lineindex).value = arch;



			} */
			if (cancel === true) {
				MSB.$('arch'+lineindex).value = '0';
				var arch = '0';
				var img = new Image();
				//img.source = './images/'+ID+'/tx'+lineindex+'.png';
				var W = MSB.$('Wimg'+lineindex).value;
				var H = MSB.$('Himg'+lineindex).value;
				img.source = './encrypted/gettx.php?ID='+ID+'&ind='+lineindex+'&j='+junk;
				MSB.$('divimg'+lineindex).style.height = H + "px";
				pngMSIE(img.source,H,W,lineindex);
			}
			else {
				var W = MSB.$('Wimg'+lineindex).value;
				var W2 = Math.round(2*W);
				var H = parseInt(MSB.$('Himg'+lineindex).value)+Math.abs(arch);
				//MSB.$('Himg'+lineindex).value = H;
				MSB.$('divimg'+lineindex).style.height = H + "px";
				var img = new Image();
				img.source = './encrypted/arch.php?ar='+arch+'&W='+W2+'&ind='+lineindex+'&j='+junk+'&ID='+ID;
				pngMSIE(img.source,H,W,lineindex);
				//MSB.$("divimg" + lineindex).style.backgroundPosition = "0px 5px";
			}
		}
	}
}
//add event trigers for text editing buttons
YAHOO.util.Event.on("replacetextButtonDiv", "click", updatetext);
YAHOO.util.Event.on("delB", "click", deletetext);
YAHOO.util.Event.on("newtextButtonDiv", "click", addnewtext);
YAHOO.util.Event.on("imagegalformAddBox", "click", togallery);
function makedragable() {
	var myDiv = "divimg" + MSB.$('actline').value.substring(2);
	var dd = new YAHOO.util.DD(myDiv);
}
function leaveWarn(mylink) {
	mySimpleDialog = new YAHOO.widget.SimpleDialog("leaveWarnOverlay", { 
//	width: "300px", 
	fixedcenter:true,
	modal:false,
    visible:false,
	draggable:false,
	zIndex:1001
	});
	mySimpleDialog.setHeader("Warning!");
	mySimpleDialog.setBody("You will lose any unsaved edits! Do you want to leave without saving?");
	mySimpleDialog.cfg.setProperty("icon",YAHOO.widget.SimpleDialog.ICON_WARN);
	var handleYes = function() {
		this.hide();
	 	switch (mylink) {
			case 'home':
			window.location= './php/go-home.php';
			break;
			case 'checkout':
			window.location ='./php/go-cart.php';
			//window.location ='./index.php?Clothing=DisplayBasket';
			break;
		}
	}
	var handleNo = function() {
	 this.hide();
	}
	var myButtons = [ {text:"No", 
						handler:handleNo,
						isDefault:true },
						{text:"Yes", 
						handler:handleYes,
						isDefault:false }];
	mySimpleDialog.cfg.queueProperty("buttons", myButtons);
	mySimpleDialog.render(MSB.$('designtool'));
	mySimpleDialog.show();
}
function designerrorcheck() {
	var error = 'no';
	if (MSB.$('numlinesF').value == '0' && MSB.$('numlinesB').value == '0') {
		alert('Design is blank. Cannot save blank designs!');
		return;
	}
	error = checktextwidthErr();
	if (error != 'no') {
		alert('Design has errors - object is '+error);
	}
	if (error == 'no') {

		YAHOO.example.container.savedesignoverlay.show();

		YAHOO.example.container.productsoverlay.hide();
		YAHOO.example.container.productcolorsoverlay.hide();
		YAHOO.example.container.fontboxoverlay.hide();
		YAHOO.example.container.imagegalleryoverlay.hide(); /* imagegalleryoverlay */

		MSB.$('textboxoverlay').style.visibility = "hidden";
		MSB.$('textHint').style.visibility = "hidden";
		MSB.$('symoverlay').style.visibility = "hidden";
		MSB.$('TCpicker_bd').style.visibility = "hidden";

		MSB.$('fontsmenubox').style.visibility = "hidden";
		//MSB.$('archoverlay').style.visibility = "hidden";
		YAHOO.example.container.archoverlay.hide();
		MSB.$('imagegalleryoverlay').style.visibility = "hidden";
	}
}
function checktextwidthErr() {
	var err = 'no';
	var list = MSB.$('designParList');
	var elements = list.getElementsByTagName('INPUT');
	for (var i=0;i < elements.length;i++) {
		var par = elements.item(i).getAttribute('id');
		var par2 = par.substring(0,4);
		if (par2 == 'Wimg') {
			var W = parseInt(MSB.$(par).value);
			var loc = MSB.$('loc'+par.substring(4)).value;
			if (W > MSB.$('printarea'+loc+'W').value) {
				err = 'too wide.\nReduce the size of font, or move the text to within the print area.';
			}
		}
		if (par2 == 'Himg') {
			var H = parseInt(MSB.$(par).value);
			var loc = MSB.$('loc'+par.substring(4)).value;
			if (H > MSB.$('printarea'+loc+'H').value) {
				err = 'too tall';
			}
		}
	}
	return err;
}
function savedesign() {
	if (MSB.$('colorCalc').value == 'yes') {
		calcNumColors();
	}
	else {
		savedesignA();
	}
}
function savedesignA() {
	if (MSB.$('colorCalc').value == 'yes') {
		getInstantQuote('S');
	}

	/* HACK - add this to snag KidsShirts_3to5yrs & KidsShirts_7to9yrs or wad-evar */
	/*if (MSB.$('actprod').value == 'KidsShirts_3to5yrs' || MSB.$('actprod').value == 'KidsShirts_7to9yrs') {*/
	if (MSB.$('actprod').value != 'BabiesShortSleeve') {
		MSB.$('actprod').value = 'KidsShortSleeve';
	/*}
	else {  not sure is this is ness' 
		MSB.$('actprod2').value = MSB.$('actprod').value;*/
	}
	/* end kids hack */



	//cleanup design
	var isvalid = true;
	isvalid = WAValidateAN(document.formSaveDesign.design_name,document.formSaveDesign.design_name.value,'- Invalid Design Name: No special characters allowed',true,true,true,true,'',document.formSaveDesign.design_name,1,true);
	if (isvalid == false) {
		alert('Invalid Design Name - No special characters allowed alpha-nums only.');
	}
	if (isvalid == true) {
		isvalid = WAValidateEM(document.formSaveDesign.emailadd,document.formSaveDesign.emailadd.value,'- Invalid email address',document.formSaveDesign.emailadd,1,true);
		if (isvalid == false) {
			alert('Invalid Email Address');
		}
		if (isvalid == true) {
			YAHOO.example.container.savewaitoverlay.show();
			MSB.$('prodFW').value = MSB.$('printareaFW').value;
			MSB.$('prodFH').value = MSB.$('printareaFH').value;
			MSB.$('prodBW').value = MSB.$('printareaBW').value;
			MSB.$('prodBH').value = MSB.$('printareaBH').value;
			var successHandler = function(o) {
				var status = o.responseText;
			//	alert(status);
				var myDiv = MSB.$('savedinfoBox');
				var HTML = "<strong>You have been emailed this design for your reference.</strong><br />Design ID: "+ MSB.$('design_id').value + '<br />Design Name: ' + MSB.$('design_name').value + '<br />Email: '+MSB.$('emailadd').value + '<br /><br />Note: <em>Only print areas display at this stage.</em><br />';
				if (MSB.$('numlinesF').value > 0) {
					HTML = HTML + '<div style="float:left;">FRONT:<br /><img src="./saveddesigns/'+MSB.$('design_id').value+'/'+MSB.$('design_id').value+'-F.png"/>&nbsp;</div>'; /* WAS -thumbF.png*/
				}
				if (MSB.$('numlinesB').value > 0) {
					HTML = HTML + 'BACK:<br /><img src="./saveddesigns/'+MSB.$('design_id').value+'/'+MSB.$('design_id').value+'-B.png"/>'; /* WAS -thumbB.png*/
				}
				myDiv.innerHTML = HTML
			//	MSB.$('fogDiv').style.visibility = "visible";
				YAHOO.example.container.savewaitoverlay.hide();
				YAHOO.example.container.savedesignoverlay.hide();
				YAHOO.example.container.savecompleteoverlay.show();
			//	getprodSizes();
			}
			var failureHandler = function(o) {
				alert ('Failed Connection')
			}
			var callback = {
				success: successHandler,
				failure: failureHandler
			}
			YAHOO.util.Connect.setForm("formSaveDesign");
			var cObj = YAHOO.util.Connect.asyncRequest('POST', 'save-dataSQL.php', callback);
		}
	}
}
function CFsubmit() {
	MSB.$('CFshopemail').value = MSB.$('shopemail').value;
	MSB.$('CFshopdomain').value = MSB.$('shopdomain').value;
	MSB.$('CFdesignID').value = MSB.$('design_id').value;
	var isvalid = true;
	isvalid = WAValidateAN(document.contactForm.CFname,document.contactForm.CFname.value,'- Invalid Design Name: No special characters allowed',true,true,true,true,'',document.contactForm.CFname,1,true);
	if (isvalid == false) {
		alert('Invalid Name - No special characters allowed alpha-nums only.');
	}
	if (isvalid == true) {
		isvalid = WAValidateEM(document.contactForm.CFemail,document.contactForm.CFemail.value,'- Invalid email address',document.contactForm.CFemail,1,true);
		if (isvalid == false) {
			alert('Invalid Email Address');
		}
		if (isvalid == true) {
			var successHandler = function(o) {
				var status = o.responseText;
				YAHOO.example.container.panel26.hide();
				alert('Your question has been sent to us');
			}
			var failureHandler = function(o) {
				alert ('Failed Connection')
			}
			var callback = {
				success: successHandler,
				failure: failureHandler
			}
			YAHOO.util.Connect.setForm("contactForm");
			var cObj = YAHOO.util.Connect.asyncRequest('POST', './WA_Universal_Email/contact-us.php', callback);
		}
	}
}
function quoteformsave() {
	YAHOO.example.container.panel29.hide();
	YAHOO.example.container.savedesignoverlay.show();
}
function showquoteform() {
	YAHOO.example.container.panel29.hide();
	QFformload('S');
}
function QFformload(from) {
	if (from == 'S') {
		MSB.$('QFdesignIDDiv').innerHTML = "Design ID: "+MSB.$('design_id').value;
		MSB.$('QFdesignnameDiv').innerHTML = "Design Name: "+MSB.$('design_name').value;
		MSB.$('QFemail').value = MSB.$('emailadd').value;
		MSB.$('QFdesignID').value = MSB.$('design_id').value;
		MSB.$('QFdesignname').value = MSB.$('design_name').value;
	}
	YAHOO.example.container.panel28.show();
}
function QFsubmit() {
	MSB.$('QFshopemail').value = MSB.$('shopemail').value;
	MSB.$('QFshopdomain').value = MSB.$('shopdomain').value;
	MSB.$('QFmyFQDN').value = MSB.$('myFQDN').value;
	MSB.$('QFnumlinesF').value = MSB.$('numlinesF').value;
	MSB.$('QFnumlinesB').value = MSB.$('numlinesB').value;
	var isvalid = true;
	isvalid = WAValidateAN(document.quoteForm.QFname,document.quoteForm.QFname.value,'- Invalid Design Name: No special characters allowed',true,true,true,true,'',document.contactForm.CFname,1,true);
	if (isvalid == false) {
		alert('Invalid Name - No special characters allowed alpha-nums only.');
	}
	if (isvalid == true) {
		isvalid = WAValidateEM(document.quoteForm.QFemail,document.quoteForm.QFemail.value,'- Invalid email address',document.contactForm.CFemail,1,true);
		if (isvalid == false) {
			alert('Invalid Email Address');
		}
		if (isvalid == true) {
			var successHandler = function(o) {
				var status = o.responseText;
				YAHOO.example.container.panel28.hide();
				alert('Your request for a quote has been submitted.');
			}
			var failureHandler = function(o) {
				alert ('Failed Connection')
			}
			var callback = {
				success: successHandler,
				failure: failureHandler
			}
			YAHOO.util.Connect.setForm("quoteForm");
			var cObj = YAHOO.util.Connect.asyncRequest('POST', './WA_Universal_Email/quote-design.php', callback);
		}
	}
}
function fillcartBox1() {
	var HTML = "";
	MSB.$('productColor2').value = MSB.$('productColor').value;
	MSB.$('productSize2').value = MSB.$('productSize').value;
	MSB.$('actprod2').value = MSB.$('actprod').value;
	MSB.$('design_name2').value = MSB.$('design_name').value;
	MSB.$('design_id2').value = MSB.$('design_id').value;
	MSB.$('productPrice2').value = MSB.$('productPrice').value;
	MSB.$('numlinesF2').value = MSB.$('numlinesF').value;
	MSB.$('numlinesB2').value = MSB.$('numlinesB').value;
	MSB.$('numcolorsF2').value = MSB.$('numcolorsF').value;
	MSB.$('numcolorsB2').value = MSB.$('numcolorsB').value;
	var myDiv = MSB.$('cartimageDiv1');
	if (MSB.$('numlinesF').value > 0) {
		HTML = HTML + '<strong>You have been emailed this design for your reference.</strong><br />Design ID: '+ MSB.$('design_id').value + '<br />Design Name: ' + MSB.$('design_name').value + '<br />Email: '+MSB.$('emailadd').value + '<br /><br />Note: <em>Only print areas display at this stage.</em><br /><div style="float:left;">FRONT:<br /><img src="./saveddesigns/'+MSB.$('design_id').value+'/'+MSB.$('design_id').value+'-thumbF.png" />&nbsp;</div>';
	}
	if (MSB.$('numlinesB').value > 0) {
		HTML = HTML + 'BACK:<br /><img src="./saveddesigns/'+MSB.$('design_id').value+'/'+MSB.$('design_id').value+'-thumbB.png" /><br />';
	}
	myDiv.innerHTML = HTML
	if (MSB.$('colorCalc').value == 'yes') {
		getInstantQuote('S');
	}
	getprodSizes();
	YAHOO.example.container.addtocartoverlay.show();
	YAHOO.example.container.savecompleteoverlay.hide();
}
function fillcartBox2(from) {
	if (from == 'O') {
		var ID = MSB.$('open-design-id').value;
		MSB.$('design_id2').value = ID;
			YAHOO.example.container.opendesignAlert.hide();
			YAHOO.example.container.opendesignAlert2.hide();
			YAHOO.example.container.designreviewoverlay.hide();
			YAHOO.example.container.opendesignoverlay.hide();

	}
	if (from == 'W') {
		var ID = MSB.$('Wopen-design-id').value;
		MSB.$('design_id2').value = ID;
			YAHOO.example.container.opendesignAlert.hide();
			YAHOO.example.container.opendesignAlert2.hide();
			YAHOO.example.container.designreviewoverlay.hide();
			YAHOO.example.container.opendesignoverlay.hide();

	}
	var root = loadMyXML("./saveddesigns/"+ID+"/"+ID+".xml");
	var emailA = root.getElementsByTagName('email');
	var email = emailA[0].childNodes[0].nodeValue;
	var designNameA = root.getElementsByTagName('designname');
	var designName = designNameA[0].childNodes[0].nodeValue;
	MSB.$('design_name2').value = designName;
	var productTypeA = root.getElementsByTagName('producttype');
	var productType = productTypeA[0].childNodes[0].nodeValue;
	MSB.$('actprod2').value = productType;
	var productColorA = root.getElementsByTagName('productcolor');
	var productColor = productColorA[0].childNodes[0].nodeValue;
	MSB.$('productColor2').value = productColor;
	var productSizeA = root.getElementsByTagName('productsize');
	var productSize = productSizeA[0].childNodes[0].nodeValue;
	MSB.$('productSize2').value = productSize;	
	var numlinesFA = root.getElementsByTagName('numlinesfront');
	var numlinesF = numlinesFA[0].childNodes[0].nodeValue;
	MSB.$('numlinesF2').value = numlinesF;	
	var numlinesBA = root.getElementsByTagName('numlinesback');
	var numlinesB = numlinesBA[0].childNodes[0].nodeValue;
	MSB.$('numlinesB2').value = numlinesB;
	var numcolorsFA = root.getElementsByTagName('numcolorsfront');
	if (numcolorsFA.length > 0) {
		MSB.$('numcolorsF2').value = numcolorsFA[0].childNodes[0].nodeValue;
	}
	var numcolorsBA = root.getElementsByTagName('numcolorsback');
	if (numcolorsBA.length > 0) {
		MSB.$('numcolorsB2').value = numcolorsBA[0].childNodes[0].nodeValue;
	}
	var HTML = "";
	var myDiv = MSB.$('cartimageDiv1');
	if (MSB.$('numlinesF2').value > 0) {
		HTML = HTML + '<img src="./saveddesigns/'+ID+'/'+ID+'-thumbF.png" />&nbsp;&nbsp;';
	}
	if (MSB.$('numlinesB2').value > 0) {
		HTML = HTML + '<img src="./saveddesigns/'+ID+'/'+ID+'-thumbB.png" /><br />';
	}
	myDiv.innerHTML = HTML
	if (MSB.$('colorCalc').value == 'yes') {
		getInstantQuote('S');
	}
	getprodSizes();
	YAHOO.example.container.addtocartoverlay.show();
}
function addtoCart() {
	if (MSB.$('colorCalc').value == 'yes') {
		if (parseInt(MSB.$('ADTCqtyPrice').value) == 0) {
			alert('Must Add Design to Cart First!');
			return;
		}
	} 
	MSB.$('Quantity_Add2').value = MSB.$('qtytoAdd').value;
	var successHandler = function(o) {
		if (o.responseText != 'design not in cart') {
			var status = o.responseText.split("+");
			MSB.$('quickCartItemDiv').innerHTML = "Items: "+status[0];
			MSB.$('quickCartCostDiv').innerHTML = "Cost: "+MSB.$('moneySymbol').value+status[1];
		}
		else {
			alert('Please Add Design to Cart before indivual sizes.');
		}
	}
	var failureHandler = function(o) {
		alert ('Failed Connection')
	}
	var callback = {
		success: successHandler,
		failure: failureHandler
	}
	YAHOO.util.Connect.setForm("formSaveDesign2");
//	var cObj = YAHOO.util.Connect.asyncRequest('POST', './php/addtocart.php', callback);
	parent.location.href = "http://www.savagelondon.com/index.php?AddToBasket=Custom,"+MSB.$('design_id2').value+","+MSB.$('productSize2').value+","+MSB.$('productPrice2').value+","+MSB.$('Quantity_Add2').value;
}
function getprodSizes() {
	var Event = YAHOO.util.Event;
	var color = MSB.$('productColor2').value;
	var picker3 = MSB.$('sizeOpts2');
	var product = MSB.$('actprod2').value;
	var curSize =  MSB.$('productSize2').value;
	var numlinesF =  MSB.$('numlinesF2').value;
	var numlinesB =  MSB.$('numlinesB2').value;
	picker3.innerHTML = '';
	var root = loadMyXML("./products/"+product+".xml");
	var mycolors = root.getElementsByTagName('color');
	var mexcludeA = "NONE";
	for (var i=0;i<mycolors.length;i++) {
		if (mycolors[i].getAttribute('name') == color) {
			var myexcludeA = mycolors[i].getElementsByTagName('excludesize')[0].childNodes[0].nodeValue;
		} 
	} 
	var exSizes = myexcludeA.split(" ");
	var html2 = '';
	var sizestring = root.getElementsByTagName('sizes')[0].childNodes[0].nodeValue;
	var sizes = sizestring.split(" ");
	var textsizes = new Object();
	textsizes.sizeData = {};
	var clickstring;
	for (var q=0;q<sizes.length;q++) {
		textsizes.sizeData[sizes[q]] = sizes[q];
	}	
	for (var i in textsizes.sizeData) {
		html2 += '<a id="sel-siz2-'+product+'-'+i+'">' + i + '</a>';
		YAHOO.util.Event.on("sel-siz2-"+product+'-'+i, "click", changeproductsize2);
	}
	picker3.innerHTML = html2; 
	if (exSizes != 'none') {
		for (var t=0;t<exSizes.length;t++) {
			MSB.$('sel-siz2-'+product+'-'+exSizes[t]).style.visibility = "hidden";
		}
	}
	MSB.$('sel-siz2-'+product+'-'+curSize).style.backgroundColor = "#A5CBFF";
	var price = pricechange(MSB.$('actprod2').value,MSB.$('productColor2').value,curSize,numlinesF,numlinesB);
	if (MSB.$('colorCalc').value.toLowerCase() == 'yes') {
		price = '0';
	}
	else {
		MSB.$('priceDiv2').innerHTML = "Price: "+MSB.$('moneySymbol').value+price;
	}
	MSB.$('productPrice2').value = price;
}
function changeproductsize2(e) {
	var elTarget = YAHOO.util.Event.getTarget(e);
	elTarget = elTarget.id; 
	var mysplit = elTarget.split("-");
	var index = mysplit.length - 1;
	var size = mysplit[index];
	var oldSize = MSB.$('productSize2').value;
	var product = MSB.$('actprod2').value;
	var numlinesF = MSB.$('numlinesF2').value;
	var numlinesB = MSB.$('numlinesB2').value;
	if (oldSize != size) {
		MSB.$('sel-siz2-'+product+'-'+oldSize).style.backgroundColor = "#eeeeee";
		MSB.$('productSize2').value = size;
		MSB.$('sel-siz2-'+product+'-'+size).style.backgroundColor = "#A5CBFF";
		var price = pricechange(MSB.$('actprod2').value,MSB.$('productColor2').value,size,numlinesF,numlinesB);
		MSB.$('productPrice2').value = price;
		if (MSB.$('colorCalc').value.toLowerCase() != 'yes') {
			MSB.$('priceDiv2').innerHTML = "Price: "+MSB.$('moneySymbol').value+price;
		}
	}
}
function checkboundaries() {
	//the xy coords are relative to the printarea box
	var loc = MSB.$('actloc').value;
	var myI = MSB.$('actline').value.substring(2);
	var curX = parseInt(MSB.$('divimg'+myI).style.left);
	var curY = parseInt(MSB.$('divimg'+myI).style.top);
	var curW = parseInt(MSB.$('divimg'+myI).style.width);
	var curH = parseInt(MSB.$('divimg'+myI).style.height);
	var minX = 0;
	var maxX = MSB.$('printarea'+loc+'W').value;
	var minY = 0;
	var maxY = MSB.$('printarea'+loc+'H').value;
	var RE = curX + curW;
	var BE = curY + curH;
	if (curX < 0) {
		MSB.$('divimg'+myI).style.left = "0px";
	}
	if (RE > maxX) {
		var newX = Math.round(maxX - curW);
		MSB.$('divimg'+myI).style.left = newX + "px";
	}
	if (curY < 0) {
		MSB.$('divimg'+myI).style.top = "0px";
	}
	if (BE > maxY) {
		var newY = Math.round(maxY - curH)
		MSB.$('divimg'+myI).style.top = newY + "px";
	}
}
function leftjustline() {
	var actline = MSB.$('actline').value.substring(2);
	MSB.$('divimg'+actline).style.left = "0px";
	MSB.$('left'+actline).value = "0";
}
function rightjustline() {
	var loc = MSB.$('actloc').value;
	var actline = MSB.$('actline').value.substring(2);
	var myDiv = MSB.$('divimg'+actline);
	var curW = parseInt(MSB.$('divimg'+actline).style.width);
	var maxX = MSB.$('printarea'+loc+'W').value;
	var newX = Math.round(maxX - curW);
	MSB.$('divimg'+actline).style.left = newX + "px";
	MSB.$('left'+actline).value = newX;
}
function centerjustline() {
	var loc = MSB.$('actloc').value;
	var actline = MSB.$('actline').value.substring(2);
	var myDiv = MSB.$('divimg'+actline);
	var curW = parseInt(MSB.$('divimg'+actline).style.width);
	var curWhalf = Math.round(curW/2);
	var width = MSB.$('printarea'+loc+'W').value;
	var widthhalf = Math.round(width/2);
	var newX = widthhalf - curWhalf;
	MSB.$('divimg'+actline).style.left = newX + "px";
	MSB.$('left'+actline).value = newX;
}
function dellinecheck() {
	var loc = MSB.$('actloc').value;
	var numlines = parseInt(MSB.$('numlines'+loc).value);
	if (numlines > 0) {
		YAHOO.namespace("example.container");
		var handleYes = function() {
			deletetext();
			this.hide();
		};
		var handleNo = function() {
			this.hide();
		};
		simpledialog1 = new YAHOO.widget.SimpleDialog("deletedialog1", 
				 { width: "300px",
				   zIndex:9000,// MY ADDITION
				   fixedcenter: true,
				   visible: false,
				   draggable: true,
				   close: false,
				   text: "Do you want to Delete the selected item?<br /><br />",
				   icon: YAHOO.widget.SimpleDialog.ICON_HELP,
				   constraintoviewport: true,
				   buttons: [ { text:"Yes", handler:handleYes, isDefault:true },
							  { text:"No",  handler:handleNo } ]
				 } );
		simpledialog1.setHeader("Confirm Deletion");
		simpledialog1.render("designtool");
		simpledialog1.show();
	}
}
function createDOM(tx,ft,fs,fc,left,top,himg,wimg,zindA,fmt,fh,fv,rot) {
	var loc = MSB.$('actloc').value;
	var numlines = parseInt(MSB.$('numlines'+loc).value);
	var i;
	var newindex = MSB.$('currentInd').value;
	MSB.$('currentInd').value = parseInt(newindex) + 1;
	if (zindA == '0') {
		var Zind = '13';
	}
	else {
		var Zind = zindA;
	}
	var newID = 'divimg'+newindex;
	var newloc = 'loc'+newindex;
	var newFT = 'ft'+newindex;
	var newFC = 'fc'+newindex;
	var newFS = 'fs'+newindex;
	var newTX = 'tx'+newindex;
	var topID = 'top'+newindex;
	var leftID = 'left'+newindex;
	var wimgID = 'Wimg'+newindex;
	var himgID = 'Himg'+newindex;
	var formatID = 'format'+newindex;
	var zindID = 'Zind'+newindex;
	var flipHID = "flipH"+newindex;
	var flipVID = "flipV"+newindex;
	var rotID = "rot"+newindex;
	var archID = "arch"+newindex;
	var textind = "tx"+newindex;
	if (MSB.$('actline').value != 'none') {
		var actline = MSB.$('actline').value;
		var actindex = actline.substring(2);
		MSB.$('divimg' + actindex).style.border = "none";
	} 
	MSB.$('actline').value = "tx"+newindex;
	var newChild = document.createElement('DIV');
	newChild.setAttribute('id',newID);
	if (fmt != 'text') {
		newChild.setAttribute('class','yui-skin-sam');
	}
	var parent = MSB.$('printArea'+loc);
	parent.appendChild(newChild);
	MSB.$(newID).style.zIndex = Zind;
	MSB.$(newID).style.width = wimg + "px";
	MSB.$(newID).style.height = himg + "px";
	var parent2 = MSB.$('designParList');
	var locchild = document.createElement('INPUT');
	locchild.setAttribute('id',newloc);
	locchild.setAttribute('name',newloc);
	locchild.setAttribute('type','hidden');
	locchild.setAttribute('value',loc);
	parent2.appendChild(locchild);
	var ftchild = document.createElement('INPUT');
	ftchild.setAttribute('id',newFT);
	ftchild.setAttribute('name',newFT);
	ftchild.setAttribute('type','hidden');
	ftchild.setAttribute('value',ft);
	parent2.appendChild(ftchild);
	var fcchild = document.createElement('INPUT');
	fcchild.setAttribute('id',newFC);
	fcchild.setAttribute('name',newFC);
	fcchild.setAttribute('type','hidden');
	fcchild.setAttribute('value',fc);
	parent2.appendChild(fcchild);
	var fschild = document.createElement('INPUT');
	fschild.setAttribute('id',newFS);
	fschild.setAttribute('name',newFS);
	fschild.setAttribute('type','hidden');
	fschild.setAttribute('value',fs);
	parent2.appendChild(fschild);
	var txchild = document.createElement('INPUT');
	txchild.setAttribute('id',newTX);
	txchild.setAttribute('name',newTX);
	txchild.setAttribute('type','hidden');
	txchild.setAttribute('value',tx);
	parent2.appendChild(txchild);
	var topchild = document.createElement('INPUT');
	topchild.setAttribute('id',topID);
	topchild.setAttribute('name',topID);
	topchild.setAttribute('type','hidden');
	topchild.setAttribute('value',top);
	parent2.appendChild(topchild);
	var leftchild = document.createElement('INPUT');
	leftchild.setAttribute('id',leftID);
	leftchild.setAttribute('name',leftID);
	leftchild.setAttribute('type','hidden');
	leftchild.setAttribute('value',left);
	parent2.appendChild(leftchild);
	var himgchild = document.createElement('INPUT');
	himgchild.setAttribute('id',himgID);
	himgchild.setAttribute('name',himgID);
	himgchild.setAttribute('type','hidden');
	himgchild.setAttribute('value',himg);
	parent2.appendChild(himgchild);
	var wimgchild = document.createElement('INPUT');
	wimgchild.setAttribute('id',wimgID);
	wimgchild.setAttribute('name',wimgID);
	wimgchild.setAttribute('type','hidden');
	wimgchild.setAttribute('value',wimg);
	parent2.appendChild(wimgchild);
	var fmtchild = document.createElement('INPUT');
	fmtchild.setAttribute('id',formatID);
	fmtchild.setAttribute('name',formatID);
	fmtchild.setAttribute('type','hidden');
	fmtchild.setAttribute('value',fmt);
	parent2.appendChild(fmtchild);
	var zindchild = document.createElement('INPUT');
	zindchild.setAttribute('id',zindID);
	zindchild.setAttribute('name',zindID);
	zindchild.setAttribute('type','hidden');
	zindchild.setAttribute('value',Zind);
	parent2.appendChild(zindchild);
	var fhchild = document.createElement('INPUT');
	fhchild.setAttribute('type','hidden');
	fhchild.setAttribute('id',flipHID);
	fhchild.setAttribute('name',flipHID);
	fhchild.setAttribute('value',fh);
	parent2.appendChild(fhchild);
	var fvchild = document.createElement('INPUT');
	fvchild.setAttribute('type','hidden');
	fvchild.setAttribute('id',flipVID);
	fvchild.setAttribute('name',flipVID);
	fvchild.setAttribute('value',fv);
	parent2.appendChild(fvchild);
	var rotchild = document.createElement('INPUT');
	rotchild.setAttribute('type','hidden');
	rotchild.setAttribute('id',rotID);
	rotchild.setAttribute('name',rotID);
	rotchild.setAttribute('value',rot);
	parent2.appendChild(rotchild);
	if (fmt == 'text') {
		var stkcID = 'stkc'+newindex;
		var stkwID = 'stkw'+newindex;
		var stkcchild = document.createElement('INPUT');
		stkcchild.setAttribute('id',stkcID);
		stkcchild.setAttribute('name',stkcID);
		stkcchild.setAttribute('type','hidden');
		stkcchild.setAttribute('value',MSB.$('actstkc').value);
		parent2.appendChild(stkcchild);
		var stkwchild = document.createElement('INPUT');
		stkwchild.setAttribute('id',stkwID);
		stkwchild.setAttribute('name',stkwID);
		stkwchild.setAttribute('type','hidden');
		stkwchild.setAttribute('value',MSB.$('actstkw').value);
		parent2.appendChild(stkwchild);
		var archchild = document.createElement('INPUT');
		archchild.setAttribute('id',archID);
		archchild.setAttribute('name',archID);
		archchild.setAttribute('type','hidden');
		archchild.setAttribute('value',MSB.$('actarch').value);
		parent2.appendChild(archchild);
	}
	MSB.$(newID).style.top = top + "px";
	MSB.$(newID).style.left = left + "px";
	var numlinesA = parseInt(MSB.$('numlines' + loc).value);
	MSB.$('numlines' + loc).value = numlinesA + 1;
	MSB.$(newID).style.position = 'absolute';
	MSB.$(newID).style.border = "dotted 1px #ffff00";
	MSB.$(newID).style.backgroundRepeat = "no-repeat";
	return newID;
}
function showsearchresults() {
	YAHOO.example.container.searchdesignsoverlay.show();
	var successHandler = function(o) {
		var myDiv = MSB.$('searchresultsArea');
		myDiv.innerHTML = "";
		var file = './images/'+MSB.$('design_id').value+'/results.xml';
		var root = loadMyXML(file);
		var designsA = root.getElementsByTagName('design');
		if (designsA.length < 1) {
			myDiv.innerHTML = "No Results";
		}
		else {
			var myHTML = '<table width="440px" align="left" bgcolor="#FFFFFF">'+
					'<tr><td align = "left"><b>Your Designs:</b></td><td></td><td></td></tr>'+
					'<tr><td align = "left"><b>Design ID</b></td>'+
					'<td align = "left"><b>Design Name</b></td>'+
					'<td align = "left"></td></tr>';
			for (var x=0;x<designsA.length;x++) {
				var designIDA = root.getElementsByTagName('designid');
				var designID = designIDA[x].childNodes[0].nodeValue;
				var designNameA = root.getElementsByTagName('designname');
				var designName = designNameA[x].childNodes[0].nodeValue;		
				myHTML = myHTML + '<tr><td align = "left">'+designID+'</td>'+
					'<td align = "left">'+designName+'</td>'+
					'<td align = "left"><a id="open-'+designID+'" onclick="openfromsearch(this.id)">Open Design</a></td></tr>';
			}
			myHTML = myHTML + '</table>';
			myDiv.innerHTML = myHTML;
		} 
	}
	var failureHandler = function(o) {
		alert ('Failed Connection');
	}
	var callback = {
		success: successHandler,
		failure: failureHandler
	}
	var email = MSB.$('search-email').value;
	var ID = MSB.$('design_id').value;
	//validate email in js
	var sUrl = "./php/searchdesigns.php?ID="+ID+"&email="+email;
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
}
function moveforward() {
	var index = MSB.$('actline').value.substring(2);
	if (actline != 'none') {
		var curZind = parseInt(MSB.$('Zind'+index).value);
		MSB.$('Zind'+index).value = curZind + 1;
		MSB.$('divimg'+index).style.zIndex = curZind + 1;
	}
}
function moveback() {
	var actline = MSB.$('actline').value;
	var index = MSB.$('actline').value.substring(2);
	if (actline != 'none') {
		var curZind = parseInt(MSB.$('Zind'+index).value);
		if (curZind > 10) {
			MSB.$('Zind'+index).value = curZind - 1;
			MSB.$('divimg'+index).style.zIndex = curZind - 1;
		}
	}
}
//DT START JS
YAHOO.util.Event.onDOMReady(function() {
	var successHandler = function(o) {
		var status = o.responseText.split("+");
		MSB.$('quickCartItemDiv').innerHTML = "Items: "+status[0];
		MSB.$('quickCartCostDiv').innerHTML = "Cost: "+MSB.$('moneySymbol').value+status[1];
	}
	var failureHandler = function(o) {
		//alert ('Failed Connection')
	}
	var callback = {
		success: successHandler,
		failure: failureHandler
	}
	var cObj = YAHOO.util.Connect.asyncRequest('GET', './php/getcart.php', callback); 
});
YAHOO.util.Event.onDOMReady(function() {
	var prodConfigLoad = MSB.$('prodConfigLoad').value;
	if (MSB.$('prodConfigLoad').value == 'default') {
		var root = loadMyXML('./products/products-list.xml');
	}
	else {
		var root = loadMyXML('./configs/'+prodConfigLoad+'/products/products-list.xml');
	}
	var myprods = root.getElementsByTagName('product');
	var newChild;
	var parent;
	var prodDiv1, prodDiv;
	var prodLI,offset;
	for (var i=0;i<myprods.length;i++) {
		prodDiv1 = myprods[i].getAttribute('id');
		prodDiv = prodDiv1.replace(/\s/g,"-");
		newChild = document.createElement('DIV');
		parent = MSB.$('carousel');
			newChild.setAttribute('id','carousel-LI'+i);
			newChild.setAttribute('title',myprods[i].getAttribute('id').replace(/\s/g,"-"));
			parent.appendChild(newChild);
				offset = -100*i;
				MSB.$('carousel-LI'+i).className = "productitem"; // border-bottom:2px solid #ccc;"
				MSB.$('carousel-LI'+i).style.backgroundPosition = offset + "px 15px"; // was px 15px
				//MSB.$('carousel-LI'+i).style.cursor = "pointer"; // NEW
				YAHOO.util.Event.on('carousel-LI'+i, "click", changeproductA); // CLICK !!!
				newChild = document.createElement('DIV');
					parent = MSB.$('carousel-LI'+i);
					newChild.setAttribute('id','carousel-LI-text'+i);
					parent.appendChild(newChild);
						MSB.$('carousel-LI-text'+i).innerHTML = prodDiv1;
						MSB.$('carousel-LI-text'+i).style.paddingTop = "0px";
						MSB.$('carousel-LI-text'+i).className = "productitemText";
						// this line below WAS remmed out
						YAHOO.util.Event.on('carousel-LI-text'+i, "click", changeproductA);
	}
	//MSB.$('defaultProduct').value = myprods[0].getAttribute('id').replace(/\s/g,"-");
	MSB.$('defaultProduct').value = myprods[0].getAttribute('id').replace(/\s/g,"-");
	var product = MSB.$('defaultProduct').value;
	MSB.$('actprod').value = product;
	changeproduct('fromdefault');



});
function updatecolors(product) {
	var Event = YAHOO.util.Event;
	var picker = MSB.$('productCP');
	YAHOO.util.Event.purgeElement(picker, true);
	picker.innerHTML = '';
	var picker2 = MSB.$('productSP'); /* productSizePicker */
	YAHOO.util.Event.purgeElement(picker2, true);
	picker2.innerHTML = '';
//	var picker3 = MSB.$('sizeselDiv2');
//	picker3.innerHTML = '';
	var root = loadMyXML("./products/"+product+".xml");
	var mycolors = root.getElementsByTagName('color');
	var myrgb; 
	var textcolors = new Object();
	textcolors.colorData = {};
	for (var t=0;t<mycolors.length;t++) {
		myrgb = mycolors[t].getElementsByTagName('productRGB')[0].childNodes[0].nodeValue;
	//	textcolors.colorData[mycolors[t].getAttribute('name')] = mycolors[t].getAttribute('name');
		textcolors.colorData[myrgb] = mycolors[t].getAttribute('name');
	}	
	var html ='';
	var color;
	html += '<span><strong>Please pick a colour by clicking here...</strong></span>'; // the colour hint
	for (var i in textcolors.colorData) {
	//	color = i.replace(/\s/,"-");
	//	html += '<a style="background-image:url(./toolimages/blanks/'+product+'/box-' + color + '.gif)">' + color + '</a>';
	color = textcolors.colorData[i].replace(/\s/g,"-");
		html += '<a style="background-color:'+i+'">'+i+'</a>';
	}
	//html += '<span><strong>Please pick a colour by clicking here...</strong></span>'; // the colour hint
	//var picker = MSB.$('CP-'+product);
	picker.innerHTML = html;
	var em = picker.getElementsByTagName('em')[0];
	var strong = picker.getElementsByTagName('strong')[0];
	Event.on(picker, 'mouseover', function(ev) {
		var tar = Event.getTarget(ev);
		if (tar.tagName.toLowerCase() == 'a') {
			var color = textcolors.colorData[tar.innerHTML];
		//	alert(tar.innerHTML);
			strong.innerHTML = color;
		}
	}, this, true);
	Event.on(picker, 'focus', function(ev) {
		Event.stopEvent(ev);
	});
//	Event.on(picker, 'click', function(ev) {
//		Event.stopEvent(ev);
//	});
	Event.on(picker, 'click', function(ev) {
		Event.stopEvent(ev);
		var tar = Event.getTarget(ev);
		if (tar.tagName.toLowerCase() == 'a') {
			MSB.$('productColor').value = textcolors.colorData[tar.innerHTML];
			MSB.$('prodRGB').value = tar.innerHTML;
			changeproductcolor();
		}
	}, this, true); 
	html = "";
//	var html2 = '';
	var sizestring = root.getElementsByTagName('sizes')[0].childNodes[0].nodeValue;
	var sizes = sizestring.split(" ");
	var textsizes = new Object();
	textsizes.sizeData = {};
	var clickstring;
	for (var q=0;q<sizes.length;q++) {
		textsizes.sizeData[sizes[q]] = sizes[q];
	}	
	for (var i in textsizes.sizeData) {
	//	clickstring = "changeproductsize("+i+")";
		html += '<a id="sel-size-'+product+'-'+i+'">' + i + '</a>';/*each size */
	//	html2 += '<a id="sel-siz2-'+product+'-'+i+'">' + i + '</a>';
		YAHOO.util.Event.on("sel-size-"+product+'-'+i, "click", changeproductsize);
		YAHOO.util.Event.on("sel-size-"+product+'-'+i, "click", highlightinsizechart);
	//	YAHOO.util.Event.on("sel-siz2-"+product+'-'+i, "click", changeproductsize);
	}
	picker2.innerHTML = html; 
//	picker3.innerHTML = html2; 
}


function highlightinsizechart(){

		for (var i=0;i<MSB.$('productSP').childNodes.length;i++) {
		              //HTML = HTML + '<option value="'+fsizes[i]+'" >'+fsizes[i]+'</option>';
				//HTML = HTML + '<option value="'+productSP[i]+'" >'+fsizesName[i]+'</option>';
	}


//function highlightinsizechart(e) {
//	var elTarget = YAHOO.util.Event.getTarget(e);
//	elTarget = elTarget.id; 

		// clue:
		//YAHOO.util.Event.on("sel-size-"+product+'-'+i, "click", notesizeclicked);
		// notesizeclicked =  ...
		var sizecount = MSB.$('productSP').childNodes.length;
		
	//	var sizenote = 	MSB.$('productSP').childNodes[0].textContent;
		var sizenote = 	MSB.$('productSize').value;
		
		
		//d = document.getElementById("iframeholder");
 
 		//alert(d.contentWindow.document.getElementById("atable").innerHTML);
 		
 		//document.getElementById('iframe').contentWindow.document.getElementById('txt').value = 'test successful';
		
		var sizeRow = document.getElementById('sizeChart');
		var row01= sizeRow.contentWindow.document.getElementById('tr01');
		var row02= sizeRow.contentWindow.document.getElementById('tr02');		
		var row03= sizeRow.contentWindow.document.getElementById('tr03');				
		var row04= sizeRow.contentWindow.document.getElementById('tr04');		
		if (sizenote == "S") {
			row01.style.fontWeight= "bold";
			row02.style.fontWeight= "normal";
			row03.style.fontWeight= "normal";
			row04.style.fontWeight= "normal";
			}
		if (sizenote == "M") {
			row01.style.fontWeight= "normal";
			row02.style.fontWeight= "bold";
			row03.style.fontWeight= "normal";
			row04.style.fontWeight= "normal";
			}
		if (sizenote == "L") {
			row01.style.fontWeight= "normal";
			row02.style.fontWeight= "normal";
			row03.style.fontWeight= "bold";
			row04.style.fontWeight= "normal";
			}
		if (sizenote == "XL") {
			row01.style.fontWeight= "normal";
			row02.style.fontWeight= "normal";
			row03.style.fontWeight= "normal";
			row04.style.fontWeight= "bold";
			}
		
		if (sizenote == "G1") {
			row01.style.fontWeight= "bold";
			row02.style.fontWeight= "normal";
			row03.style.fontWeight= "normal";
			}
		if (sizenote == "G2") {
			row01.style.fontWeight= "normal";
			row02.style.fontWeight= "bold";
			row03.style.fontWeight= "normal";
			}
		if (sizenote == "G3") {
			row01.style.fontWeight= "normal";
			row02.style.fontWeight= "normal";
			row03.style.fontWeight= "bold";
			}
}

YAHOO.util.Event.onDOMReady(function() {
	var root = loadMyXML("./fonts/fonts.xml");
/*	if (MSB.$('prodConfigLoad').value == 'default') {
		var root = loadMyXML('./fonts/fonts.xml');
	}
	else {
		var root = loadMyXML('./configs/'+prodConfigLoad+'/fonts/fonts.xml');
	} */
	var myfonts = root.getElementsByTagName('font');
	var myfont;
	var parent;
	var newChild;
	var offset;
	for (var i=0;i<myfonts.length;i++) {
		myfont = myfonts[i].childNodes[0].nodeValue;
	//	alert(myfont);
		myfont = myfont.replace(/\s/g,"-");
		parent = MSB.$('fontslist');
		var newChild = document.createElement('DIV');
		newChild.setAttribute('id','selfont-'+myfont);
		newChild.setAttribute('title',myfont);
		parent.appendChild(newChild);
		offset = -220*i; /* was -150 width of font img list */
		MSB.$('selfont-'+myfont).className = "fontlistIMG";
		MSB.$('selfont-'+myfont).style.backgroundPosition = offset + "px 0px";
		YAHOO.util.Event.on('selfont-'+myfont,'click',fontselect);
	} 
	loadFontSizeMenu('default');
});

YAHOO.util.Event.onDOMReady(function() {
	var root = loadMyXML("./stockimages/imagegroups.xml");
	var mysyms = root.getElementsByTagName('group');
	var parent = MSB.$('changestockgroup');
	if (mysyms.length == 0) {
		parent.innerHTML = 'No Images Available';
	}
	else {
		var mysymA = new Array();
		var newChild;
		var mysym;
		var mysymB;
		for (var i=0;i<mysyms.length;i++) {
			mysym = mysyms[i].childNodes[0].nodeValue;
			mysymB = mysym.replace(/\s/g,"-");
			newChild = document.createElement('A');
			newChild.setAttribute('id','selstockgroup-'+mysymB);
			parent.appendChild(newChild);
			MSB.$('selstockgroup-'+mysymB).innerHTML = mysym+'&nbsp;&nbsp;';
			YAHOO.util.Event.on('selstockgroup-'+mysymB, 'click', changeStockGroup);
		}
	}
 });
function loadourdesigns() {
	var root = loadMyXML("ourdesigns/our-designs-categories.xml");
	var mysyms = root.getElementsByTagName('category');
	var parent = MSB.$('changeODgroup');
	if (mysyms.length == 0) {
		parent.innerHTML = 'No Designs Available';
	}
	else {
		var mysymA = new Array();
		var newChild;
		var mysym;
		var mysymB;
		for (var i=0;i<mysyms.length;i++) {
			mysym = mysyms[i].childNodes[0].nodeValue;
			mysymB = mysym.replace(/\s/g,"-");
			newChild = document.createElement('A');
			newChild.setAttribute('id','selODgroup-'+mysymB);
			parent.appendChild(newChild);
			MSB.$('selODgroup-'+mysymB).innerHTML = mysym+'&nbsp;&nbsp;';
			YAHOO.util.Event.on('selODgroup-'+mysymB, 'click', changeODGroup);
		}
	}
 }
YAHOO.util.Event.onDOMReady(function() {
	var root = loadMyXML("./symbols/symbolgroups.xml");
	var mysyms = root.getElementsByTagName('group');
	var mysymA = new Array();
	var parent = MSB.$('changesymgroup');
	var newChild;
	var mysym;
	var mysymB;
	for (var i=0;i<mysyms.length;i++) {
		mysym = mysyms[i].childNodes[0].nodeValue;
		mysymB = mysym.replace(/\s/g,"-");
		newChild = document.createElement('A');
		newChild.setAttribute('id','selsymgroup-'+mysymB);
		parent.appendChild(newChild);
		MSB.$('selsymgroup-'+mysymB).innerHTML = mysym+'&nbsp;&nbsp;';
		YAHOO.util.Event.on('selsymgroup-'+mysymB, 'click', changeSymGroup);
	}
 });
function changeSymGroup(e) {
	if (e) {
		var elTarget = YAHOO.util.Event.getTarget(e);
		elTarget = elTarget.id;
		var mysymgroup = elTarget.substring(12);
	}
	else {
		var mysymgroup = "Basics";
	}
		var root = loadMyXML("./symbols/"+mysymgroup+".xml");
		var mysymbol;
		var mysyms = root.getElementsByTagName('symbol');
		var parent = MSB.$('symscrollgallery');
		parent.innerHTML = "";
		var newChild;
		for (var i=0;i<mysyms.length;i++) {
			mysymbol = mysyms[i].childNodes[0].nodeValue;
			newChild = document.createElement('IMG');
			newChild.setAttribute('id','selsym-'+mysymbol);
			newChild.setAttribute('name','selsym-'+mysymbol);
			newChild.setAttribute('src','./symbols/symimages/'+mysymbol+'-thumb.png');
			parent.appendChild(newChild);
			YAHOO.util.Event.on('selsym-'+mysymbol,'click', symbolselect);
		}
}
function changeStockGroup(e) {
	if (e) {
		var elTarget = YAHOO.util.Event.getTarget(e);
		elTarget = elTarget.id;
		var mysymgroup = elTarget.substring(14);
	}
	else {
		var mysymgroup = "Basics";
	}
	var root = loadMyXML("./stockimages/"+mysymgroup+".xml");
		var mysymbol;
		var mysyms = root.getElementsByTagName('image');
		var parent = MSB.$('stockscrollgal');
		parent.innerHTML = "";
		var newChild;
		for (var i=0;i<mysyms.length;i++) {
			mysymbol = mysyms[i].childNodes[0].nodeValue;
			newChild = document.createElement('IMG');
			newChild.setAttribute('id','selstock-'+mysymbol);
			newChild.setAttribute('name','selstock-'+mysymbol);
			newChild.setAttribute('src','./stockimages/'+mysymgroup+'/'+mysymbol);
			newChild.setAttribute('alt',mysymgroup);
			parent.appendChild(newChild);
			YAHOO.util.Event.on('selstock-'+mysymbol,'click', stockimgselect);
		}
}
function changeODGroup(e) {
	if (e) {
		var elTarget = YAHOO.util.Event.getTarget(e);
		elTarget = elTarget.id;
		var mysymgroup = elTarget.substring(11);
	}
	else {
		var root = loadMyXML("ourdesigns/our-designs-categories.xml");
		var mysymgroup = root.getElementsByTagName('category')[0].childNodes[0].nodeValue;
	}
	var root = loadMyXML("ourdesigns/"+mysymgroup+".xml");
	var mydiv = MSB.$('SDscrollgal');
	mydiv.innerHTML = "";
	var newChild;
	var mydesigns = root.getElementsByTagName('designThumb');
	var innerHTML='';
	var A,myID,mythumb;
	for (var i=0;i<mydesigns.length;i++) {
		mythumb = mydesigns[i].childNodes[0].nodeValue;
		A = mydesigns[i].childNodes[0].nodeValue.split('-');
		innerHTML = innerHTML + '<span id="SD-'+A[0]+'" onclick="loadSD(this.id)" class="SDimg"><a><img src="ourdesigns/'+A[0]+'/'+mythumb+'" /></a></span>';
	}
	mydiv.innerHTML = innerHTML;
}
function changefonts(e) {
	var elTarget = YAHOO.util.Event.getTarget(e);
	elTarget = elTarget.id;
}
YAHOO.util.Event.onDOMReady(function() {
	getnewID();
});
function editdesign() {
	MSB.$('design_id_old').value = MSB.$('design_id').value; 
	var root = loadMyXML("./includes/shop-defaults.xml");
	var shopcodeA = root.getElementsByTagName('shopcode');
	var shopcode = shopcodeA[0].childNodes[0].nodeValue;
	var serverType = 'php'; 
	if (serverType == "php") {
		var successHandler2 = function(o) {			
			var designID = o.responseText;
			MSB.$('design_id').value = designID;
			copydesigntoNew();
			MSB.$('fogDiv').style.visibility = "hidden";
		}
		var callback2 = {
			success: successHandler2
		};
		var sUrl = "./php/getepoc.php?sc="+shopcode;
		var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback2);
	}
	YAHOO.example.container.productsoverlay.show();
	YAHOO.example.container.savedesignoverlay.hide();
	YAHOO.example.container.savecompleteoverlay.hide();
	YAHOO.example.container.addtocartoverlay.hide(); 
	//MSB.$('addtocartoverlay').style.visibility = "hidden";
	MSB.$('showProductsbox').style.backgroundColor = '#A5CBFF';
		MSB.$('showProductsbox').style.opacity = '1';
		MSB.$('showProductsbox').style.filter = 'alpha(opacity= 100)'; //IE

	MSB.$('showProductColorsbox').style.backgroundColor = 'transparent';
		MSB.$('showProductColorsbox').style.opacity = '0.5';
		MSB.$('showProductColorsbox').style.filter = 'alpha(opacity= 50)'; //IE

	MSB.$('textEditorDiv').style.backgroundColor = 'transparent';
	MSB.$('showtextbox').style.backgroundColor = 'transparent';
		MSB.$('showtextbox').style.opacity = '0.5';
		MSB.$('showtextbox').style.filter = 'alpha(opacity= 50)'; //IE
		MSB.$('launchIGbox').style.opacity = '0.5';
		MSB.$('launchIGbox').style.filter = 'alpha(opacity= 50)'; //IE
}
function newdesign() {
	MSB.$('design_id_old').value = MSB.$('design_id').value;
	getnewID();
	cleardesign();
	var myIDIV;
	MSB.$('fogDiv').style.visibility = "hidden";
	YAHOO.example.container.productsoverlay.show();
	YAHOO.example.container.savecompleteoverlay.hide();
	YAHOO.example.container.addtocartoverlay.hide();

	MSB.$('showProductsbox').style.backgroundColor = '#A5CBFF';
		MSB.$('showProductsbox').style.opacity = '1';
		MSB.$('showProductsbox').style.filter = 'alpha(opacity= 100)'; //IE

	MSB.$('showProductColorsbox').style.backgroundColor = 'transparent';
		MSB.$('showProductsbox').style.opacity = '1';
		MSB.$('showProductsbox').style.filter = 'alpha(opacity= 100)'; //IE

	MSB.$('sel-F').style.visibility = 'hidden';
	MSB.$('sel-B').style.visibility = 'hidden';
	MSB.$('deleteimageBox').style.visibility = 'hidden';
	
	MSB.$('textEditorDiv').style.visibility = 'hidden';
	/*MSB.$('andOr').style.visibility = 'hidden';*/
	MSB.$('launchIGbox').style.visibility = 'hidden';
	MSB.$('savedesignbox').style.visibility = 'hidden';

}
function cleardesign() {
	var ID = MSB.$('design_id').value
	var myDiv = MSB.$('printAreaF');
	while (myDiv.hasChildNodes()) {
		myDiv.removeChild(myDiv.lastChild);
	}
	var myDiv = MSB.$('printAreaB');
	while (myDiv.hasChildNodes()) {
		myDiv.removeChild(myDiv.lastChild);
	}
	var myDiv = MSB.$('designParList');
	while (myDiv.hasChildNodes()) {
		myDiv.removeChild(myDiv.lastChild);
	}
	var myDiv = MSB.$('imageframe');
	while (myDiv.hasChildNodes()) {
		myDiv.removeChild(myDiv.lastChild);
	}
	MSB.$('numlinesF').value = "0";
	MSB.$('numlinesB').value = "0";
	MSB.$('actline').value = "none";
	MSB.$('currentFMT').value = 'text';
	MSB.$('curImCode').value = '1';
	MSB.$('imageInd').value = '1';
	MSB.$('curImExt').value = 'jpg';
	var successHandler2 = function(o) {			
		var status = o.responseText;
	}
	var callback2 = {
		success: successHandler2
	};
	var sUrl = "./php/cleardesign.php?ID="+ID;
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback2);	
}
function loadSD(e) {
	var A = e.split('-');
	var ID = A[1];
	MSB.$('open-design-id').value = ID;
	YAHOO.example.container.opendesignAlert2.show();
}
function opendesign(where) {
	if (where == 'fromstock') {
		YAHOO.example.container.opendesignAlert2.hide();
		YAHOO.example.container.designreviewoverlay.hide();
	}
	YAHOO.example.container.opendesignAlert.hide();
	YAHOO.example.container.designreviewoverlay.hide();
		YAHOO.example.container.savecompleteoverlay.hide();
		YAHOO.example.container.addtocartoverlay.hide();
	MSB.$('design_id_old').value = MSB.$('open-design-id').value;
	var oldID = MSB.$('design_id_old').value;
	cleardesign();
	copydesigntoNew(where);
	//var xml = Sarissa.getDomDocument();
	//xml.async = false;
	if (where == 'fromstock') {
	//	xml.load("./ourdesigns/"+oldID+"/"+oldID+".xml");
		var root = loadMyXML("./ourdesigns/"+oldID+"/"+oldID+".xml");
	}
	else {
		var root = loadMyXML("./saveddesigns/"+oldID+"/"+oldID+".xml");
	}
	//var root = xml.documentElement;
	var myfmt, mytxA, mytx, myextA, myext, myfile;
	var emailA = root.getElementsByTagName('email');
	var email = emailA[0].childNodes[0].nodeValue;
	MSB.$('emailadd').value = email;
	var designNameA = root.getElementsByTagName('designname');
	var designName = designNameA[0].childNodes[0].nodeValue;
	MSB.$('design_name').value = designName;
	var productTypeA = root.getElementsByTagName('producttype');
	var productType = productTypeA[0].childNodes[0].nodeValue;
	MSB.$('actprod').value = productType;
	var productColorA = root.getElementsByTagName('productcolor');
	var productColor = productColorA[0].childNodes[0].nodeValue;
	MSB.$('productColor').value = productColor;
	var productRGBA = root.getElementsByTagName('productRGB');
	var productRGB = productRGBA[0].childNodes[0].nodeValue;
	MSB.$('prodRGB').value = productRGB;
	var productSizeA = root.getElementsByTagName('productsize');
	var productSize = productSizeA[0].childNodes[0].nodeValue;
	MSB.$('productSize').value = productSize;
	changeproduct('fromopen');
	var numlinesFA = root.getElementsByTagName('numlinesfront');
	var numlinesF = numlinesFA[0].childNodes[0].nodeValue;
	var numlinesBA = root.getElementsByTagName('numlinesback');
	var numlinesB = numlinesBA[0].childNodes[0].nodeValue;
	var frontA = root.getElementsByTagName('lines');
	var linesFA = frontA[0].getElementsByTagName('line');
	var numlines = parseInt(numlinesF) + parseInt(numlinesB);
	var tx,ft,fc,fs,/*fsizesName,*/top,left,W,H,fmt,stkc,stkw,flipv,fliph,rot,arch,ind;
	for (var i=0;i<numlines;i++) {
		ind = linesFA[i].getAttribute('ind');
		tx = linesFA[i].getElementsByTagName('text').item(0).childNodes[0].nodeValue;
		loc = linesFA[i].getElementsByTagName('location').item(0).childNodes[0].nodeValue;
		fmt = linesFA[i].getElementsByTagName('format').item(0).childNodes[0].nodeValue;
		fc = linesFA[i].getElementsByTagName('fontColor').item(0).childNodes[0].nodeValue;
		ft = linesFA[i].getElementsByTagName('font').item(0).childNodes[0].nodeValue;
		fs = linesFA[i].getElementsByTagName('fontSize').item(0).childNodes[0].nodeValue;
	/*fsizesName = linesFA[i].getElementsByTagName('fontSizeName').item(0).childNodes[0].nodeValue;*/
		top = linesFA[i].getElementsByTagName('top').item(0).childNodes[0].nodeValue;
		left = linesFA[i].getElementsByTagName('left').item(0).childNodes[0].nodeValue;
		flipv = linesFA[i].getElementsByTagName('flipV').item(0).childNodes[0].nodeValue;
		fliph = linesFA[i].getElementsByTagName('flipH').item(0).childNodes[0].nodeValue;
		rot = linesFA[i].getElementsByTagName('rotate').item(0).childNodes[0].nodeValue;
		wimg = linesFA[i].getElementsByTagName('wimg').item(0).childNodes[0].nodeValue;
		himg = linesFA[i].getElementsByTagName('himg').item(0).childNodes[0].nodeValue;
		zind = linesFA[i].getElementsByTagName('zIndex').item(0).childNodes[0].nodeValue;
		MSB.$('edittextbox').value = tx;
		MSB.$('currentFMT').value = fmt;
		MSB.$('actfc').value = fc;
		MSB.$('actfs').value = fs;
		MSB.$('actft').value = ft;
		MSB.$('acttop').value = top;
		MSB.$('actleft').value = left;
		MSB.$('actflipv').value = flipv;
		MSB.$('actfliph').value = fliph;
		MSB.$('actrot').value = rot;
		MSB.$('actloc').value = loc;
		MSB.$('actwimg').value = wimg;
		MSB.$('acthimg').value = himg;
		MSB.$('actzind').value = zind;
		if (fmt == 'text') {
			stkc = linesFA[i].getElementsByTagName('strokeColor').item(0).childNodes[0].nodeValue;
			stkw = linesFA[i].getElementsByTagName('strokeWidth').item(0).childNodes[0].nodeValue;
			arch = linesFA[i].getElementsByTagName('arch').item(0).childNodes[0].nodeValue;
			MSB.$('actstkc').value = stkc;
			MSB.$('actstkw').value = stkw;
			MSB.$('actarch').value = arch;
		}
		switch (fmt) {
			case 'text':
			loadtext(ind);
			break;
			case 'symbol':
			loadsymbol();
			break;
			case 'image':
			loadimage();
			break;
			case 'stock':
			loadstock();
			break;
		}
	}
	if (numlinesF > 0) {
		MSB.$('actloc').value = 'F';
	}
	else {
		MSB.$('actloc').value = 'B';
	}
}
function getnewID() {
	var root = loadMyXML("./includes/shop-defaults.xml");
	var shopcodeA = root.getElementsByTagName('shopcode');
	var shopcode = shopcodeA[0].childNodes[0].nodeValue;
	var successHandler2 = function(o) {			
		var designID = o.responseText;
		MSB.$('design_id').value = designID;
	}
	var callback2 = {
		success: successHandler2
	};
	var sUrl = "./php/getepoc.php?sc="+shopcode;
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback2);	
}
function copydesigntoNew(where) {
	var successHandler2 = function(o) {			
			var status = o.responseText;
	}
	var callback2 = {
		success: successHandler2
	};
	var oldID = MSB.$('design_id_old').value;
	var newID = MSB.$('design_id').value;
	var sUrl = "./php/copydesign.php?old="+oldID+"&new="+newID+"&SD="+where;
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback2);
}
function openwarn() {
	YAHOO.example.container.opendesignAlert.show();
	YAHOO.example.container.opendesignoverlay.hide();
}
function cancelopen() {
	YAHOO.example.container.opendesignAlert.hide();
	YAHOO.example.container.opendesignAlert2.hide();
	YAHOO.example.container.designreviewoverlay.hide();

}
function openfromsearch(e) {
	var myID = e.substring(5);
	MSB.$('open-design-id').value = myID;
	openwarn();
}
//PRODUCT OPTIONS JS
YAHOO.util.Event.on("sel-F", "click", changeproductloc);
YAHOO.util.Event.on("sel-B", "click", changeproductloc);
function changeproductcolor() {
	var productcolor = MSB.$('productColor').value.replace(/\s/g,"-");
	var productcolorA = MSB.$('productColor').value; //DO NOT REMOVE WHITESPACE for XML CHECK
	var product = MSB.$('actprod').value;
	var myelementF = MSB.$('mediaLayerF');
	var myelementB = MSB.$('mediaLayerB');
	var currentview = MSB.$('printloc').value;
	var numlinesF = MSB.$('numlinesF').value;
	var numlinesB = MSB.$('numlinesB').value;
	var size = MSB.$('productSize').value;
	var validsize = checksizeexclusion(product,productcolorA,size);
	myelementF.style.backgroundImage = "url(./toolimages/blanks/" + product + "/" + productcolor + "-front.png)";
	myelementB.style.backgroundImage = "url(./toolimages/blanks/" + product + "/" + productcolor + "-back.png)";
	if (validsize != "isvalid") {
		alert("The current size is invalid for "+productcolorA+". The size has been changed to "+validsize+'.');
		MSB.$('productSize').value = validsize;
		MSB.$('sel-size-'+product+'-'+size).style.backgroundColor = "#eeeeee";
		MSB.$('sel-size-'+product+'-'+validsize).style.backgroundColor = "#A5CBFF";
		var price = pricechange(product,productcolorA,validsize,numlinesF,numlinesB);
		MSB.$('productPrice').value = price;
		MSB.$('priceDiv').innerHTML = "1 Side: "+MSB.$('moneySymbol').value+MSB.$('pricetemp1').value+'<br />2 Sides: '+MSB.$('moneySymbol').value+MSB.$('pricetemp2').value;
	}
	else {
		var price = pricechange(product,productcolorA,size,numlinesF,numlinesB);
		MSB.$('productPrice').value = price;
		MSB.$('priceDiv').innerHTML = "1 Side: "+MSB.$('moneySymbol').value+MSB.$('pricetemp1').value+'<br />2 Sides: '+MSB.$('moneySymbol').value+MSB.$('pricetemp2').value;
	}
}

function changeproductloc(e) {
	if (MSB.$('actline').value != 'none') {
		var actline = MSB.$('actline').value;
		var actindex = actline.substring(2);
		MSB.$('divimg' + actindex).style.border = "none";
		MSB.$('actline').value = 'none';
	} 
	var loc = e;
	if (loc == 'F') {
		if (MSB.$('actloc').value != "F") {
			MSB.$('actloc').value = "F";
			MSB.$('mediaLayerF').style.visibility = 'visible';
			MSB.$('mediaLayerB').style.visibility = 'hidden';
			MSB.$('actline').value = 'none';
			MSB.$('edittextbox').value = '';
			
			MSB.$('sel-Fbutton-button').style.color = '#000';
			MSB.$('sel-Fbutton').style.backgroundColor = '#fff';
			MSB.$('sel-Fbutton-button').style.fontWeight = 'bold';
			
			MSB.$('sel-Bbutton-button').style.color = '#666';
			MSB.$('sel-Bbutton').style.backgroundColor = '#ddd';
			MSB.$('sel-Bbutton-button').style.fontWeight = 'normal';
		}
	}
	if (loc == 'B') {
		if (MSB.$('actloc').value != "B") {
			MSB.$('actloc').value = "B";
			MSB.$('mediaLayerF').style.visibility = 'hidden';
			MSB.$('mediaLayerB').style.visibility = 'visible';
			MSB.$('actline').value = 'none';
			MSB.$('edittextbox').value = '';
			
			MSB.$('sel-Fbutton-button').style.color = '#666';
			MSB.$('sel-Fbutton').style.backgroundColor = '#ddd';
			MSB.$('sel-Fbutton-button').style.fontWeight = 'normal';
			
			MSB.$('sel-Bbutton-button').style.color = '#000';
			MSB.$('sel-Bbutton').style.backgroundColor = '#fff';
			MSB.$('sel-Bbutton-button').style.fontWeight = 'bold';
		}
	}
}

var Event = YAHOO.util.Event;

function changeproductA(e) {

	var elTarget = YAHOO.util.Event.getTarget(e);
	elTarget = elTarget.id; 
	var product = MSB.$(elTarget).getAttribute('title');
	if (product == MSB.$('actprod').value) {
		return;
	}
	MSB.$('actprod').value = product;
	changeproduct('fromchange');
	//NEW LINES
	YAHOO.example.container.productsoverlay.hide();
	YAHOO.example.container.productcolorsoverlay.show();
	MSB.$('showProductsbox').style.backgroundColor = "transparent";
	MSB.$('showProductsbox').style.opacity = "0.5";
	MSB.$('showProductsbox').style.filter = "alpha(opacity= 50)"; //IE
				     //filter:alpha(opacity=12);-moz-opacity:0.125;-khtml-opacity: 0.12;opacity: 0.12;

	MSB.$('showProductColorsbox').style.backgroundColor = "#A5CBFF";
	MSB.$('showProductColorsbox').style.opacity = "1";
	MSB.$('showProductColorsbox').style.filter = "alpha(opacity= 100)"; //IE
	MSB.$('textEditorDiv').style.visibility = "inherit";
	MSB.$('fontsmenuButton').style.visibility = "hidden";
	
	//Help:detailed Size Chart in pop-up
	//MSB.$('sizeChartLink').innerHTML = 'Help: <span>Hover here to see a detailed Size Chart</span>';
	MSB.$('sizeChart').src = 'products/'+MSB.$("actprod").value+'_SIZECHART.html';
	
	MSB.$('pickedHint').innerHTML ="Selected style: " + MSB.$('actprod').value;


}

function changeproduct(where) {
	var product = MSB.$('actprod').value;
	updatecolors(product);
	var root = loadMyXML("./products/"+product+".xml");
	var frontloc = root.getElementsByTagName('front')[0].childNodes[0].nodeValue;
	var backloc = root.getElementsByTagName('back')[0].childNodes[0].nodeValue;
	var proddefault = root.getElementsByTagName('default')[0].childNodes[0].nodeValue;
	var proddefaultA = proddefault.split(", ");
	var newcolor = proddefaultA[0];
	var newrgb = proddefaultA[1];
	var newsize = proddefaultA[2];
	var newview = proddefaultA[3];
	var proddesc = root.getElementsByTagName('description')[0].childNodes[0].nodeValue;
	var FXYa = root.getElementsByTagName('FrontTopLeft')[0].childNodes[0].nodeValue;
	var BXYa = root.getElementsByTagName('BackTopLeft')[0].childNodes[0].nodeValue;
	var FW = root.getElementsByTagName('FrontWidth')[0].childNodes[0].nodeValue;
	var BW = root.getElementsByTagName('BackWidth')[0].childNodes[0].nodeValue;
	var FH = root.getElementsByTagName('FrontHeight')[0].childNodes[0].nodeValue;
	var BH = root.getElementsByTagName('BackHeight')[0].childNodes[0].nodeValue;
	var FXY = FXYa.split(" ");
	var BXY = BXYa.split(" ");
	if (where != 'fromopen') {
	//if ((where != 'fromopen')||(where == 'fromopen')) { //EVEN IF CURRENT
		MSB.$('prodRGB').value = newrgb;
	}
	MSB.$('printareaFX').value = FXY[1];
	MSB.$('printareaFY').value = FXY[0];
	MSB.$('printareaBX').value = BXY[1];
	MSB.$('printareaBY').value = BXY[0];
	MSB.$('printareaFW').value = FW;
	MSB.$('printareaFH').value = FH;
	MSB.$('printareaBW').value = BW;
	MSB.$('printareaBH').value = BH;
	MSB.$('printAreaF').style.top = FXY[0] + "px";
	MSB.$('printAreaF').style.left = FXY[1] + "px";
	MSB.$('printAreaF').style.width = FW + "px";
	MSB.$('printAreaF').style.height = FH + "px";
	MSB.$('printAreaB').style.top = BXY[0] + "px";
	MSB.$('printAreaB').style.left = BXY[1] + "px";
	MSB.$('printAreaB').style.width = BW + "px";
	MSB.$('printAreaB').style.height = BH + "px";
	if (where != 'fromopen') {
	//if ((where != 'fromopen')||(where == 'fromopen')) { //EVEN IF CURRENT
		MSB.$('productColor').value = newcolor;
		MSB.$('productSize').value = newsize;
		MSB.$('printloc').value = newview;
		MSB.$('sel-size-'+product+'-'+newsize).style.backgroundColor = "#A5CBFF";
	}
	//MSB.$('sel-F').style.visibility = 'visible';
	//MSB.$('sel-B').style.visibility = 'visible';
	if (frontloc != 'TRUE') {
		MSB.$('sel-F').style.visibility = 'hidden';
		MSB.$('mediaLayerF').style.visibility = 'hidden';
		MSB.$('mediaLayerB').style.visibility = 'visible';
		MSB.$('printloc').value = 'B';
	}
	if (backloc != 'TRUE') {
		MSB.$('sel-B').style.visibility = 'hidden';
		MSB.$('mediaLayerB').style.visibility = 'hidden';
		MSB.$('mediaLayerF').style.visibility = 'visible';
		MSB.$('printloc').value = 'F';
	}
	var html = '<strong>'+product.replace(/-/g," ")+'</strong><br />'+proddesc;
	MSB.$('proddescDiv').innerHTML = html;
	if (where == "fromchange") {
	//if ((where != 'fromchange')||(where == 'fromchange')) { //EVEN IF CURRENT
		YAHOO.example.container.productdescoverlay.hide(); /* WAS show  // productdescoverlay */
		//alert('fromchange');
	}
	changeproductcolor();
}
function changeproductsize(e) {
	var elTarget = YAHOO.util.Event.getTarget(e);
	elTarget = elTarget.id; 
	var mysplit = elTarget.split("-");
	var index = mysplit.length - 1;
	var size = mysplit[index];
	var color = MSB.$('productColor').value;
	var product = MSB.$('actprod').value;
	var validsize = checksizeexclusion(product,color,size);
	var numlinesF = MSB.$('numlinesF').value;
	var numlinesB = MSB.$('numlinesB').value;
	var price = pricechange(product,color,size,numlinesF,numlinesB);
	
	

	if (validsize == "isvalid") {
		var oldsize = MSB.$('productSize').value;
		MSB.$('sel-size-'+product+'-'+oldsize).style.backgroundColor = "#eeeeee";
		MSB.$('productSize').value = size;
		MSB.$('sel-size-'+product+'-'+size).style.backgroundColor = "#A5CBFF";
		MSB.$('productPrice').value = price;
		MSB.$('priceDiv').innerHTML = "1 Side: "+MSB.$('moneySymbol').value+MSB.$('pricetemp1').value+'<br />2 Sides: '+MSB.$('moneySymbol').value+MSB.$('pricetemp2').value;


	}
	else {
		alert('Invalid Size: '+size+' not available in '+color+'.');
	}
}
function checksizeexclusion(product,color,size) {
	var root = loadMyXML("./products/"+product+".xml");
	var mycolors = root.getElementsByTagName('color');
	var proddefault = root.getElementsByTagName('default')[0].childNodes[0].nodeValue;
	var proddefaultA = proddefault.split(", ");
	var defaultsize = proddefaultA[2];
	for (var i=0;i<mycolors.length;i++) {
		if (mycolors[i].getAttribute('name') == color) {
			var myexcludeA = mycolors[i].getElementsByTagName('excludesize');
			var myexclude = myexcludeA[0].childNodes[0].nodeValue;
			if (myexclude == size) {
				return(defaultsize);
			}
		} 
	} 
	return("isvalid");
}
function pricechange(product,color,size,numlinesF,numlinesB) {
	var numsides = 'oneside';
	if (numlinesF > 0 && numlinesB > 0) {
		numsides = 'twoside';
	}
	var root = loadMyXML("./products/"+product+".xml");
	var mycolors = root.getElementsByTagName('color');
	var myfront = root.getElementsByTagName('front')[0].childNodes[0].nodeValue;
	var myback = root.getElementsByTagName('back')[0].childNodes[0].nodeValue;
	for (var i=0;i<mycolors.length;i++) {
		if (mycolors[i].getAttribute('name') == color) {
			var myprices = mycolors[i].getElementsByTagName('prices')[0];

			var myF = myprices.getElementsByTagName('oneside')[0].childNodes[0].nodeValue;
			var spF1 = myF.split(" ");
			for (var t=0;t<spF1.length;t++) {
				var spF2 = spF1[t].split("=");
				if (spF2[0] == size) {
					var newprice1 = spF2[1];
					MSB.$('pricetemp1').value = parseFloat(newprice1).toFixed(2);
				}
			}

			var myB = myprices.getElementsByTagName('twoside')[0].childNodes[0].nodeValue;
			if (myB.charAt(0) == '+') {
				var extra = myB.substring(1);
				var newprice2 = parseFloat(newprice1) + parseFloat(extra);
				MSB.$('pricetemp2').value = parseFloat(newprice2).toFixed(2);
			}
			else {
				var spB1 = myB.split(" ");
				for (var t=0;t<spB1.length;t++) {
					var spB2 = spB1[t].split("=");
					if (spB2[0] == size) {
						var newprice2 = spB2[1];
						MSB.$('pricetemp2').value = parseFloat(newprice2).toFixed(2);
					}
				}
			}
		} 
	} 
	if (myback == 'FALSE' || myfront == 'FALSE') {
		MSB.$('pricetemp2').value = "N/A";
	}
	if (numsides == 'oneside') {
		var newprice = newprice1;
	}
	else {
		var newprice = newprice2;
	}
	return parseFloat(newprice).toFixed(2);
}
//TEXT UTIL
function addnewtext() {
	var loc = MSB.$('actloc').value;
	MSB.$('currentFMT').value = 'text';
	var mytext = MSB.$('edittextbox').value;
	var numchars = mytext.length;
	var lineGood = false;
	for (var x=0; x<numchars; x++)  {
		var charCode = mytext.charCodeAt(x);
		if (charCode >= 33 && charCode <= 126)  {
			lineGood = true;
		}
	}
	if (lineGood == false) {
		alert("No empty lines allowed.");
	}	
	else {
		var fs,fc,ft,top,left,tx,newID,himg,wimg,zind,fh,fv,rot;
		tx = MSB.$('edittextbox').value;
		MSB.$('acttop').value = MSB.$('lowY').value;
		top = MSB.$('lowY').value;
		MSB.$('actleft').value = '10';
		MSB.$('actstkw').value = '0';
		MSB.$('actarch').value = '0';
		MSB.$('actstkc').value = MSB.$('defaultTextColor').value;
		left = '10';
		fc = MSB.$('defaultTextColor').value;
		ft = 'Squad-Caps'; /* WAS Arial */
		fs = '49'; /* WAS 16 */
		himg = '1';
		wimg = '1';
		zind = '0';
		fh = 'no';
		fv = 'no';
		rot = '0';
		newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"text",fh,fv,rot);
		edittext('fromnewline');
		MSB.$("fsedit").value = fs;
		YAHOO.util.Event.on(newID, "click", divdown);
		YAHOO.util.Event.on(newID, "mouseout", function() {divup(newID); });
	}
}
function checkwidth(Wgifold) {
	return Wgifold;
}
function edittext(fromwho) {
	var ID = MSB.$('design_id').value;
	var whichline = MSB.$('actline').value;
	var loc = MSB.$('actloc').value;
	var lineindex = whichline.substring(2);
	var numloadedimages = 0;
	var ft = MSB.$('ft' + lineindex).value;
	var fs = MSB.$('fs' + lineindex).value;
	var fc = MSB.$('fc' + lineindex).value;
	var fv = MSB.$('flipV' + lineindex).value;
	var fh = MSB.$('flipH' + lineindex).value;
	var rot = MSB.$('rot' + lineindex).value;
	var stkc = MSB.$('stkc' + lineindex).value;
	var stkw = MSB.$('stkw' + lineindex).value;
	if (fromwho != 'fromexisting') {
		var mytext = MSB.$('edittextbox').value;
	}
	else {
		if (fromwho == "fromexisting") {
			MSB.$('divimg'+lineindex).style.left = MSB.$('actleft').value + "px";
			MSB.$('left'+lineindex).value = MSB.$('actleft').value;
			MSB.$('divimg'+lineindex).style.top = MSB.$('acttop').value + "px";
			MSB.$('top'+lineindex).value = MSB.$('acttop').value;
		}
		var mytext = MSB.$('edittextbox').value;
		fromwho = 'fromeditfs';
	}
	var junk = myTime();
	if (whichline != 'none') {
		function countimages2() {
			if(++numloadedimages == 1) measureimages2(textimage);
		}
		for (var z=0;z < 1;z++) {
			var textimage = new Image();
			MSB.addEvent(textimage,'load',function () {countimages2();})
			textimage.src = "./encrypted/createtext.php?ft=" + ft + "&fc=" + fc + "&fs=" + fs + "&junk=" + junk + "&tx=" + encodeURIComponent(mytext) + "&stkc=" + stkc + "&stkw=" + stkw+"&ind="+lineindex+"&fh="+fh+"&fv="+fv+"&rot="+rot+"&ID="+ID;
		}
		function measureimages2() {
			var newWidth = parseInt(checkwidth(textimage.width));
			document.getElementById("divimg" + lineindex).style.height = textimage.height + "px";
			document.getElementById("divimg" + lineindex).style.width = newWidth + "px";
			if (fromwho != 'fromcolorchange') {
				if (fromwho == 'fromnewline') {
					var halfW = parseInt(MSB.$('printarea'+MSB.$('actloc').value+'W').value)/2;
					var newleft = halfW - Math.round(textimage.width/2);
					MSB.$("left" + lineindex).value = newleft;
					MSB.$("divimg" + lineindex).style.left = newleft + "px";
					makedragable();
				}
			}
			pngMSIE(textimage.src,textimage.height,textimage.width,lineindex);
			MSB.$("Himg" + lineindex).value = textimage.height;
			MSB.$("Wimg" + lineindex).value = newWidth;
		}
	}
}
function updatetext() {
	var whichline = MSB.$('actline').value;
	var lineindex = whichline.substring(2);
	if (MSB.$('arch'+lineindex).value == '0') {
		if (MSB.$('actline').value != 'none' && MSB.$('currentFMT').value == 'text') {
			var mytext = MSB.$('edittextbox').value;
			var txdiv = MSB.$('actline').value;
			MSB.$(txdiv).value = mytext;
			var numchars = mytext.length;
			var lineGood = false;
			for (var x=0; x<numchars; x++)  {
				var charCode = mytext.charCodeAt(x);
				if (charCode >= 33 && charCode <= 126)  {
					lineGood = true;
				}
			}
			if (lineGood == false) {
				alert("Empty line has been removed.");
				deletetext();
				return;
			}	
			edittext('fromupdate');
		}
	}
}
function editfs() {
	var newfs = parseInt(MSB.$('fsedit').value);
	var whichline = MSB.$('actline').value;
	var lineindex = whichline.substring(2);
	if (MSB.$('arch'+lineindex).value == '0') {
		if (newfs >= 10 && newfs <= 200) {
			var whichline = MSB.$('actline').value;
			var lineindex = whichline.substring(2);
			MSB.$('fs' + lineindex).value = newfs;
			edittext('fromeditfs');
		}
		if (newfs > 200) {
			MSB.$('fsedit').value = '200';
			MSB.$('fs' + lineindex).value = '200';
			edittext('fromeditfs');
		}
		if (newfs < 10) {
			MSB.$('fsedit').value = '10';
			MSB.$('fs' + lineindex).value = '10';
			edittext('fromeditfs');
		}
	}
}
function fsIncrease() {
	var lineindex = MSB.$('actline').value.substring(2);
	if (MSB.$('arch'+lineindex).value == '0') {
		var format = MSB.$('currentFMT').value;
		var loc = MSB.$('actloc').value;
		if (loc == 'F') {
			var maxW = MSB.$('printareaFW').value;
		}
		if (loc == 'B') {
			var maxW = MSB.$('printareaBW').value;
		}
		if (format == 'text') {
			var newfs = parseInt(MSB.$('fsedit').value);
			var curW = parseInt(MSB.$('Wimg'+lineindex).value);
			if (curW < maxW) {
				newfs = newfs + 1;
				MSB.$('fsedit').value = newfs;
				MSB.$('oldfs').value = MSB.$('fs' + lineindex).value;
				MSB.$('fs' + lineindex).value = newfs;
				edittext('fromeditfs');
			}
		}
	}
}
function fsDecrease() {
	var lineindex = MSB.$('actline').value.substring(2);
	if (MSB.$('arch'+lineindex).value == '0') {
		var format = MSB.$('currentFMT').value;
		if (format == 'text') {
			var newfs = parseInt(MSB.$('fsedit').value);
			if (newfs > 10) {
				newfs = newfs - 1;
				MSB.$('fsedit').value = newfs;
				var whichline = MSB.$('actline').value;
				var lineindex = whichline.substring(2);
				MSB.$('oldfs').value = MSB.$('fs' + lineindex).value;
				MSB.$('fs' + lineindex).value = newfs;
				edittext('fromeditfs');
			}
		}
	}
}
function fontselect(e) {
	loadFontSizeMenu(e);
	/*var lineindex = MSB.$('actline').value.substring(2);
	if (MSB.$('arch'+lineindex).value == '0') {
		var elTarget = YAHOO.util.Event.getTarget(e);
		elTarget = elTarget.id;
		var myfont = MSB.$(elTarget).getAttribute('title');
		if (MSB.$('currentFMT').value == 'text' && MSB.$('actline').value != 'none') {
			var lineindex = MSB.$('actline').value.substring(2);
			MSB.$('oldfont').value = MSB.$('ft' + lineindex).value;
			MSB.$('ft' + lineindex).value = myfont;
			edittext('fromeditft');
		}
	}*/
	// reveal Save Button 
	//MSB.$('savedesignbox').style.visibility = 'visible';
	//MSB.$('savedesignbox').style.backgroundColor = '#B0F299'; /* GREEN 54BB5A */

}

YAHOO.util.Event.onDOMReady(function() {
	var ID = document.getElementById("fsedit");
	var fsboxEnter = new YAHOO.util.KeyListener(ID,{keys:13},function() {
		var newfs = Math.abs(parseInt(MSB.$('fsedit').value));
		if (newfs < 10) {
			newfs = 10;
		}
		if (newfs >200) {
			newfs = 200;
		}
		var lineindex = MSB.$('actline').value.substring(2);
		if (MSB.$('arch'+lineindex).value == '0') {
			MSB.$('fs' + lineindex).value = newfs;
			if (MSB.$('currentFMT').value == 'text') {
				edittext('fromeditfs'); 
			}
		}
	}
  );
	fsboxEnter.enable();
});
function loadtext(ind) {
	var ID = MSB.$('design_id').value;
	var fs,fc,ft,top,left,tx,newID,himg,wimg,zind,fh,fv,rot,arch;
	tx = MSB.$('edittextbox').value;
	top = MSB.$('acttop').value;
	left = MSB.$('actleft').value;
	ft = MSB.$('actft').value;
	fc = MSB.$('actfc').value;
	fs = MSB.$('actfs').value;
	fv = MSB.$('actflipv').value;
	fh = MSB.$('actfliph').value;
	rot = MSB.$('actrot').value;
	stkc = MSB.$('actstkc').value;
	stkw = MSB.$('actstkw').value;
	himg = MSB.$('acthimg').value;
	wimg = MSB.$('actwimg').value;
	zind = MSB.$('actzind').value;
	arch = MSB.$('actarch').value;
	newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"text",fh,fv,rot);
	var i = newID.substring(6); //divimgF0
	var junk = myTime();
	var textimage = new Image();
	if (arch == '0') {
		textimage.src = "./encrypted/createtext.php?ft=" + ft + "&fc=" + fc + "&fs=" + fs + "&junk=" + junk + "&tx=" + encodeURIComponent(tx) + "&stkc=" + stkc + "&stkw=" + stkw+"&ind="+i+"&fh="+fh+"&fv="+fv+"&rot="+rot+"&ID="+ID;
		pngMSIE(textimage.src,himg,wimg,i);
	}
	else {
		textimage.src = './images/'+MSB.$('design_id').value+'/tx'+ind+'-arch.png';
		//alert(textimage.src);
		var H = parseInt(himg)+Math.abs(parseInt(arch));
		MSB.$('divimg'+i).style.height = H + "px";
		MSB.$('divimg'+i).style.width = wimg + "px";
		pngMSIE(textimage.src,himg,wimg,i);
	}
	makedragable();
	MSB.$("fsedit").value = fs;
	YAHOO.util.Event.on(newID, "click", divdown);
	YAHOO.util.Event.on(newID, "mouseout", function() {divup(newID); });
}
function stkIncrease() {
	var lineindex = MSB.$('actline').value.substring(2);
	if (MSB.$('arch'+lineindex).value == '0') {
		var format = MSB.$('currentFMT').value;
		if (format == 'text') {
			var newstk = parseInt(MSB.$('stkedit').value);
			if (newstk < 10) {
				newstk = newstk + 1;
				MSB.$('stkedit').value = newstk;
				var whichline = MSB.$('actline').value;
				var lineindex = whichline.substring(2);
				MSB.$('stkw' + lineindex).value = newstk;
				edittext('fromeditfs');
			}
		}
	}
}
function stkDecrease() {
	var lineindex = MSB.$('actline').value.substring(2);
	if (MSB.$('arch'+lineindex).value == '0') {
		var format = MSB.$('currentFMT').value;
		if (format == 'text') {
			var newstk = parseInt(MSB.$('stkedit').value);
			if (newstk > 0) {
				newstk = newstk - 1;
				MSB.$('stkedit').value = newstk;
				var whichline = MSB.$('actline').value;
				var lineindex = whichline.substring(2);
				MSB.$('stkw' + lineindex).value = newstk;
				edittext('fromeditfs');
			}
		}
	}
}
//STOCK IMAGE UTIL
function stockimgselect(e) {
	var elTarget = YAHOO.util.Event.getTarget(e);
	elTarget = elTarget.id; 
	var mysym = elTarget.substring(9);
	var ext = mysym.split('.');
	var loc = MSB.$('actloc').value;
	MSB.$('curImExt').value = ext[1];
	var maxW = MSB.$('printarea'+loc+'W').value;
	var maxH = MSB.$('printarea'+loc+'H').value;
	var index = MSB.$('curStockCode').value;
	MSB.$('curStockCode').value = parseInt(MSB.$('curStockCode').value) + 1;
//	alert(MSB.$(elTarget).getAttribute('alt'));
	MSB.$('currentFMT').value = 'stock';
	var fs,fc,ft,top,left,tx,wimg,himg,zind;
	MSB.$('acttop').value = MSB.$('lowY').value;
	top = MSB.$('lowY').value;
	MSB.$('actleft').value = '10';
	left = '10';
	fc = mysym;
	ft = MSB.$(elTarget).getAttribute('alt');
	fs = '100';
	tx = 'Stock'+index+'.'+ext[1];
	himg = '1';
	wimg = '1';
	zind = '0';
	fh = 'no';
	fv = 'no';
	rot = '0';
	var newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"stock",fh,fv,rot);
	var resize = new YAHOO.util.Resize(newID, {
	  handles: ['tr','tl','br','bl'],
		knobHandles: true,
		hover: true,
		proxy: true,
		ratio: true,
		maxWidth: maxW,
		maxHeight: maxH
	}); 
	YAHOO.util.Event.on(newID, "click", divdown);
	YAHOO.util.Event.on(newID, "mouseout", function() {divup(newID); });
	resize.on('endResize',function() {divup(newID); },resize,true); 
	placestock();
}
function placestock() {
	var lineindex = MSB.$('actline').value.substring(2);
	var fileext = MSB.$('curImExt').value;
	var newImg = MSB.$('tx'+lineindex).value.split('.');
	var oldImg = MSB.$('fc'+lineindex).value.split('.');
	var group = MSB.$('ft'+lineindex).value;
	var successHandler = function(o) {
		var lineindex = MSB.$('actline').value.substring(2);
		var imgID = MSB.$('tx'+lineindex).value;
		var loc = MSB.$('actloc').value;
		var numloadedimages = 0;
		var fileext = MSB.$('curImExt').value;
		function countimages2() {
			if(++numloadedimages == 1) measureimages2(textimage);
		}
		for (var z=0;z < 1;z++) {
			var textimage = new Image();
			MSB.addEvent(textimage,'load',function () {countimages2();})
			textimage.src = "./images/"+MSB.$('design_id').value+"/" + imgID;
		}
		function measureimages2() {
			var newWidth = textimage.width;
			document.getElementById("divimg" + lineindex).style.height = textimage.height + "px";
			document.getElementById("divimg" + lineindex).style.width = newWidth + "px";
			var halfW = parseInt(MSB.$('printarea'+MSB.$('actloc').value+'W').value)/2;
			var newleft = halfW - Math.round(textimage.width/2);
			document.getElementById("divimg" + lineindex).style.left = newleft + "px";
			document.getElementById("left" + lineindex).value = newleft;
			makedragable();
			pngMSIE(textimage.src,textimage.height,textimage.width,lineindex);
			document.getElementById("Himg" + lineindex).value = textimage.height;
			document.getElementById("Wimg" + lineindex).value = newWidth;
			document.getElementById("tx" + lineindex).value = imgID;
		}
	}
	var callback = {
		success: successHandler
	};
	var sUrl = "./encrypted/copystock.php?old="+oldImg[0]+"&new="+newImg[0]+"&ext="+fileext+"&g="+group+"&ID="+MSB.$('design_id').value;
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
}
function loadstock() {
	var ID = MSB.$('design_id').value;
	var fs,fc,ft,top,left,tx,wimg,himg,zind,fv,fh,rot;
	var junk = myTime();
	MSB.$('curStockCode').value = parseInt(MSB.$('curStockCode').value)+1;
	MSB.$('currentFMT').value = 'stock';
	top = MSB.$('acttop').value;
	left = MSB.$('actleft').value;
	ft = MSB.$('actft').value;
	fc = MSB.$('actfc').value;
	fs = MSB.$('actfs').value;
	fh = MSB.$('actfliph').value;
	fv = MSB.$('actflipv').value;
	rot = MSB.$('actrot').value;
	tx = MSB.$('edittextbox').value;
	himg = MSB.$('acthimg').value;
	wimg = MSB.$('actwimg').value;
	zind = MSB.$('actzind').value;
	//MSB.$('curSymCode').value = tx;
	MSB.$('edittextbox').value = "";
	var newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"stock",fh,fv,rot);
	var i = newID.substring(6);
	var textimage = new Image();
	textimage.src = "./images/"+ID+"/"+tx;
	pngMSIE(textimage.src,himg,wimg,i);
	makedragable();
	var loc = MSB.$('actloc').value;
	var maxW = MSB.$('printarea'+loc+'W').value;
	var maxH = MSB.$('printarea'+loc+'H').value;
	var resize = new YAHOO.util.Resize(newID, {
	  handles: ['tr','tl','br','bl'],
		knobHandles: true,
		hover: true,
		proxy: true,
		ratio: true,
		maxWidth: maxW,
		maxHeight: maxH
	}); 
	YAHOO.util.Event.on(newID, "click", divdown);
	YAHOO.util.Event.on(newID, "mouseout", function() {divup(newID); });
	resize.on('endResize',function() {divup(newID); },resize,true);
}
//SYMBOL UTIL
function symbolselect(e) {
	var elTarget = YAHOO.util.Event.getTarget(e);
	elTarget = elTarget.id; 
	var mysym = elTarget.substring(7);
	MSB.$('curSymCode').value = mysym;
	MSB.$('currentFMT').value = 'symbol';
	var fs,fc,ft,top,left,tx,wimg,himg,zind;
	MSB.$('acttop').value = MSB.$('lowY').value;
	top = MSB.$('lowY').value;
	MSB.$('actleft').value = '10';
	left = '10';
	fc = MSB.$('defaultTextColor').value;
	ft = 'NA';
	fs = '50'; /*100*/
	tx = mysym;
	himg = '1';
	wimg = '1';
	zind = '0';
	fh = 'no';
	fv = 'no';
	rot = '0';
	var newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"symbol",fh,fv,rot);
	editsymbol('fromnewline');
	var loc = MSB.$('actloc').value;
	var maxW = MSB.$('printarea'+loc+'W').value;
	var maxH = MSB.$('printarea'+loc+'H').value;
	var resize = new YAHOO.util.Resize(newID, {
	  handles: ['tr','tl','br','bl'],
		knobHandles: true,
		hover: true,
		proxy: true,
		ratio: true,
		maxWidth: maxW,
		maxHeight: maxH
	}); 
	YAHOO.util.Event.on(newID, "click", divdown);
	YAHOO.util.Event.on(newID, "mouseout", function() {divup2(newID); });
	resize.on('endResize',function() {divup2(newID); },resize,true);
	MSB.$('deleteimageBox').style.visibility = 'visible';
	MSB.$('savedesignbox').style.visibility = 'visible';
	MSB.$('savedesignbox').style.backgroundColor = '#B0F299'; /* GREEN 54BB5A */


}
function editsymbol(fromwho) {
	var ID = MSB.$('design_id').value;
	var lineindex = MSB.$('actline').value.substring(2);
	var whichline = MSB.$('actline').value;
	var loc = MSB.$('actloc').value;
	var numloadedimages = 0;
	var fs = MSB.$('fs' + lineindex).value;
	var fc = MSB.$('fc' + lineindex).value;
	var fv = MSB.$('flipV' + lineindex).value;
	var fh = MSB.$('flipH' + lineindex).value;
	var rot = MSB.$('rot' + lineindex).value;
	var junk = myTime();
	if (whichline != 'none') {
		function countimages2() {
			if(++numloadedimages == 1) measureimages2(textimage);
		}
		for (var z=0;z < 1;z++) {
			var textimage = new Image();
			MSB.addEvent(textimage,'load',function () {countimages2();})
			textimage.src = "./encrypted/symbol-edit.php?sym=" + MSB.$('curSymCode').value + "&junk=" + junk + "&fc=" + fc + "&fs=" + fs+"&ind="+lineindex+"&fh="+fh+"&fv="+fv+"&rot="+rot+"&ID="+ID;
		}
		function measureimages2() {
			var newWidth = parseInt(checkwidth(textimage.width));
			document.getElementById("divimg" + lineindex).style.height = textimage.height + "px";
			document.getElementById("divimg" + lineindex).style.width = newWidth + "px";
			if (fromwho != 'fromcolorchange') {
				if (fromwho == 'fromnewline') {
					var halfW = parseInt(MSB.$('printarea'+MSB.$('actloc').value+'W').value)/2;
					var newleft = halfW - Math.round(textimage.width/2);
					document.getElementById("divimg" + lineindex).style.left = newleft + "px";
					document.getElementById("left" + lineindex).value = newleft;
					MSB.$('fs'+lineindex).value = newWidth;
					makedragable();
				}
			}
			pngMSIE(textimage.src,textimage.height,textimage.width,lineindex);
			document.getElementById("Himg" + lineindex).value = textimage.height;
			document.getElementById("Wimg" + lineindex).value = newWidth;
			document.getElementById("tx" + lineindex).value = MSB.$('curSymCode').value;
		}
	}
}
function loadsymbol() {
	var ID = MSB.$('design_id').value;
	var fs,fc,ft,top,left,tx,wimg,himg,zind,fv,fh,rot;
	var junk = myTime();
	MSB.$('currentFMT').value = 'symbol';
	top = MSB.$('acttop').value;
	left = MSB.$('actleft').value;
	ft = MSB.$('actft').value;
	fc = MSB.$('actfc').value;
	fs = MSB.$('actfs').value;
	fh = MSB.$('actfliph').value;
	fv = MSB.$('actflipv').value;
	rot = MSB.$('actrot').value;
	tx = MSB.$('edittextbox').value;
	himg = MSB.$('acthimg').value;
	wimg = MSB.$('actwimg').value;
	zind = MSB.$('actzind').value;
	MSB.$('curSymCode').value = tx;
	MSB.$('edittextbox').value = "";
	var newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"symbol",fh,fv,rot);
	var i = newID.substring(6);
	var textimage = new Image();
	textimage.src = "./encrypted/symbol-edit.php?sym=" + MSB.$('curSymCode').value + "&junk=" + junk + "&fc=" + fc + "&fs=" + fs+"&ind="+i+"&fh="+fh+"&fv="+fv+"&rot="+rot+"&ID="+ID;
	pngMSIE(textimage.src,himg,wimg,i);
	makedragable();
	var loc = MSB.$('actloc').value;
	var maxW = MSB.$('printarea'+loc+'W').value;
	var maxH = MSB.$('printarea'+loc+'H').value;
	var resize = new YAHOO.util.Resize(newID, {
	  handles: ['tr','tl','br','bl'],
		knobHandles: true,
		hover: true,
		proxy: true,
		ratio: true,
		maxWidth: maxW,
		maxHeight: maxH
	}); 
	YAHOO.util.Event.on(newID, "click", divdown);
	YAHOO.util.Event.on(newID, "mouseout", function() {divup2(newID); });
	resize.on('endResize',function() {divup2(newID); },resize,true);
}
//IMAGE UTIL
function placeimage() {
	var lineindex = MSB.$('actline').value.substring(2);
	var imgID = MSB.$('tx'+lineindex).value;
	var loc = MSB.$('actloc').value;
	var numloadedimages = 0;
	var fileext = MSB.$('curImExt').value;
	function countimages2() {
		if(++numloadedimages == 1) measureimages2(textimage);
	}
	for (var z=0;z < 1;z++) {
		var textimage = new Image();
		MSB.addEvent(textimage,'load',function () {countimages2();})
		textimage.src = "./images/"+MSB.$('design_id').value+"/Cimageedit" + imgID + fileext;
	}
	function measureimages2() {
		var newWidth = textimage.width;
		document.getElementById("divimg" + lineindex).style.height = textimage.height + "px";
		document.getElementById("divimg" + lineindex).style.width = newWidth + "px";
		var halfW = parseInt(MSB.$('printarea'+MSB.$('actloc').value+'W').value)/2;
		var newleft = halfW - Math.round(textimage.width/2);
		document.getElementById("divimg" + lineindex).style.left = newleft + "px";
		document.getElementById("left" + lineindex).value = newleft;
		makedragable();
		pngMSIE(textimage.src,textimage.height,textimage.width,lineindex);
		document.getElementById("Himg" + lineindex).value = textimage.height;
		document.getElementById("Wimg" + lineindex).value = newWidth;
		document.getElementById("tx" + lineindex).value = imgID;
	}
}
function togallery() {
	var ID = MSB.$('design_id').value;
	var ind = MSB.$('imageInd').value; //imageInd is index for gallery images
	MSB.$('imgloading1').style.visibility = "visible";
	MSB.$('imggalForm').action = "./encrypted/getimage1.php?ind="+ind+"&ID="+ID;
	MSB.$('imggalForm').target = 'Hframe1';
	YAHOO.util.Connect.setForm(MSB.$('imggalForm'),true,true);
	var successHandler = function(o) {
		var fileext = o.responseText;
		if (o.responseText == 'error:filetype') {
			MSB.$('imgloading1').style.visibility = "hidden";
			alert('Incorrect image file type. The file must be a jpg.');
		}
		else {
			var newDiv = 'divDiv' + ind;
			var newImg = 'Gimg' + ind;
			var newSrc = "./images/"+MSB.$('design_id').value+"/Cimagethumb"+ind+fileext;
			var parent = MSB.$('imageframe');
			var newChild = document.createElement('IMG');
			newChild.setAttribute('id',newImg);
			newChild.setAttribute('name',newImg);
			newChild.setAttribute('src',newSrc);
			newChild.setAttribute('alt',fileext);
			parent.appendChild(newChild);
			YAHOO.util.Event.on(newImg, "click", addimage);
			MSB.$('imageInd').value = parseInt(ind) + 1;
			parent = MSB.$('workingParams');
			newChild = document.createElement('INPUT');
			newChild.setAttribute('id','countCimage'+ind);
			newChild.setAttribute('name','countCimage'+ind);
			newChild.setAttribute('type','hidden');
			newChild.setAttribute('value','0');
			parent.appendChild(newChild);
			MSB.$('imgloading1').style.visibility = "hidden";
		}
	}
	var callback = {
		upload: successHandler
	};
	var designID = MSB.$('design_id').value;
	var canvasFW = MSB.$('printareaFW').value;
	var canvasBW = MSB.$('printareaBW').value;
	var myW;
	if (canvasFW > canvasBW) {
		myW = canvasBW;
	}
	else {
		myW = canvasFW;
	}
	var sUrl = "./encrypted/getimage1.php?ind="+ind+'&W='+myW+"&ID="+ID;
	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback);
}
function addimage(e) {
	var elTarget = YAHOO.util.Event.getTarget(e);
	elTarget = elTarget.id; 
	var id = elTarget.substring(4);
	MSB.$('currentFMT').value = 'image';
	MSB.$('curImCode').value = id; // curImCode is index for images placed on shirt
	MSB.$('curImExt').value = MSB.$(elTarget).getAttribute('alt');
	var dup = parseInt(MSB.$('countCimage'+id).value);
			// reveal Save Button 
			MSB.$('savedesignbox').style.visibility = 'visible';
			MSB.$('savedesignbox').style.backgroundColor = '#B0F299'; /* GREEN 54BB5A */
			MSB.$('deleteimageBox').style.visibility = 'visible';
	if (dup > 0) {
		var ind = id+'-'+dup;
		addDupImage(ind,MSB.$('curImExt').value);
		MSB.$('countCimage'+id).value = parseInt(dup) + 1;
	}
	else {
		var ind = id+'-0';
		addFirstImage(ind);
		MSB.$('countCimage'+id).value = parseInt(dup) + 1;
	}
}
function addFirstImage(ind) {
	var loc = MSB.$('actloc').value;
	var maxW = MSB.$('printarea'+loc+'W').value;
	var maxH = MSB.$('printarea'+loc+'H').value;
	var fs,fc,ft,top,left,tx,wimg,himg,zind,fh,fv,rot;
	MSB.$('acttop').value = MSB.$('lowY').value;
	top = MSB.$('lowY').value;
	MSB.$('actleft').value = '10';
	left = '10';
	fc = 'NA';
	ft = 'Cimage';
	fs = MSB.$('curImExt').value;
	tx = ind;
	himg = '1';
	wimg = '1';
	zind = '0';
	fh = 'no';
	fv = 'no';
	rot = '0';
	var newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"image",fh,fv,rot);
	var resize = new YAHOO.util.Resize(newID, {
			  handles: ['tr','tl','br','bl'],
				knobHandles: true,
				hover: true,
				proxy: true,
				ratio: true,
				maxWidth: maxW,
				maxHeight: maxH
			}); 
	resize.on('endResize',function() {divup(newID); },resize,true);
	placeimage();
}
function addDupImage(ind,ext) {
	var successHandler = function(o) {
		var status = o.responseText;
		if (status == 'good') {
			addFirstImage(ind);
		}
	}
	var callback = {
		success: successHandler
	}
	var sUrl = "./encrypted/dupimage.php?ind="+ind+"&ext="+ext+"&ID="+MSB.$('design_id').value;
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
}
function loadimage() {
	var indA = MSB.$('edittextbox').value.split('-');
	var ind = indA[0];
	var newImg = 'Gimg' + ind;
	var ext = MSB.$('actfs').value;
	if (MSB.$('Gimg'+ind)) {
		MSB.$('countCimage'+ind).value = parseInt(MSB.$('countCimage'+ind).value) + 1;
	}
	else {
		var newSrc = "./images/"+MSB.$('design_id').value+"/Cimagethumb"+ind+ext;
		var parent = MSB.$('imageframe');
		var newChild = document.createElement('IMG');
		newChild.setAttribute('id',newImg);
		newChild.setAttribute('name',newImg);
		newChild.setAttribute('src',newSrc);
		newChild.setAttribute('alt',ext);
		parent.appendChild(newChild);
		parent = MSB.$('workingParams');
		newChild = document.createElement('INPUT');
		newChild.setAttribute('id','countCimage'+ind);
		newChild.setAttribute('name','countCimage'+ind);
		newChild.setAttribute('type','hidden');
		newChild.setAttribute('value','1');
		parent.appendChild(newChild);
		MSB.$('imageInd').value = parseInt(MSB.$('imageInd').value) + 1;
		YAHOO.util.Event.on(newImg, "click", addimage);
	}	
	var wimg = MSB.$('actwimg').value;
	var loc = MSB.$('actloc').value;
	var fileext = MSB.$('actfs').value;
	var newDiv = 'divDiv' + ind;
	var fs,fc,ft,top,left,tx,wimg,himg,zind,fh,fv,rot;
	MSB.$('currentFMT').value = 'image';
	top = MSB.$('acttop').value;
	left = MSB.$('actleft').value;
	ft = MSB.$('actft').value;
	fc = MSB.$('actfc').value;
	fs = MSB.$('actfs').value;
	fh = MSB.$('actfliph').value;
	fv = MSB.$('actflipv').value;
	rot = MSB.$('actrot').value;
	tx = MSB.$('edittextbox').value;
	himg = MSB.$('acthimg').value;
	wimg = MSB.$('actwimg').value;
	zind = MSB.$('actzind').value;
	MSB.$('curImCode').value = tx;
	MSB.$('edittextbox').value = "";
	var newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"image",fh,fv,rot); 
	var i = newID.substring(6);
	var textimage = new Image();
	textimage.src = "./images/"+MSB.$('design_id').value+"/Cimageedit" + tx + fs;
	var maxW = MSB.$('printarea'+loc+'W').value;
	var maxH = MSB.$('printarea'+loc+'H').value;
	var resize = new YAHOO.util.Resize(newID, {
		  handles: ['tr','tl','br','bl'],
			knobHandles: true,
			hover: true,
			proxy: true,
			ratio: true,
			maxWidth: maxW,
			maxHeight: maxH
		}); 
	resize.on('endResize',function() {divup(newID); },resize,true);
	pngMSIE(textimage.src,himg,wimg,i);
	makedragable(); 
		/* NEW LINE for showing TB2Div */
		//	YAHOO.example.container.panel34.show();/* TB2Div */

}
//MSB JS
(function(){
if(!window['MSB']) {
    window['MSB'] = {};
}
function isCompatible(other) {
    if( other===false 
        || !Array.prototype.push
        || !Object.hasOwnProperty
        || !document.createElement
        || !document.getElementsByTagName
        ) {
        return false;
    }
    return true;
}
window['MSB']['isCompatible'] = isCompatible;
function $() {
    var elements = new Array();
    for (var i = 0; i < arguments.length; i++) {
        var element = arguments[i];
        if (typeof element == 'string') {
            element = document.getElementById(element);
        }
        if (arguments.length == 1) {
            return element;
        }
        elements.push(element);
    }
    return elements;
};
window['MSB']['$'] = $;
function addEvent( node, type, listener ) {
    if(!isCompatible()) { return false }
    if(!(node = $(node))) return false;
    if (node.addEventListener) {
        // W3C method
        node.addEventListener( type, listener, false );
        return true;
    } else if(node.attachEvent) {
        // MSIE method
        node['e'+type+listener] = listener;
        node[type+listener] = function(){node['e'+type+listener]( window.event );}
        node.attachEvent( 'on'+type, node[type+listener] );
        return true;
    }
    return false;
};
window['MSB']['addEvent'] = addEvent;
})();
//Form Validation
function WAAddError(formElement,errorMsg,focusIt,stopIt)  {
  if (document.WAFV_Error)  {
	  document.WAFV_Error += "\n" + errorMsg;
  }
  else  {
    document.WAFV_Error = errorMsg;
  }
  if (!document.WAFV_InvalidArray)  {
    document.WAFV_InvalidArray = new Array();
  }
  document.WAFV_InvalidArray[document.WAFV_InvalidArray.length] = formElement;
  if (focusIt && !document.WAFV_Focus)  {
	document.WAFV_Focus = focusIt;
  }

  if (stopIt == 1)  {
	document.WAFV_Stop = true;
  }
  else if (stopIt == 2)  {
	formElement.WAFV_Continue = true;
  }
  else if (stopIt == 3)  {
	formElement.WAFV_Stop = true;
	formElement.WAFV_Continue = false;
  }
}
function WAValidateAN(formElement,value,errorMsg,allowUpper,allowLower,allowNumbers,allowSpace,extraChars,focusIt,stopIt,required)  {
  var isValid = true;
  extraChars = extraChars.replace(/&quot;/g,'"');
    for (var x=0; x<value.length; x++)  {
	  var charGood = false;
	  var nextChar = value.charAt(x);
	  var charCode = value.charCodeAt(x);
	  if (allowLower)  {
	    if (charCode >= 97 && charCode <= 122)  {
		  charGood = true;
		}
	  }
	  if (allowUpper)  {
	    if (charCode >= 65 && charCode <= 90)  {
		  charGood = true;
		}
	  }
	  if (allowNumbers)  {
	    if (charCode >= 48 && charCode <= 57)  {
		  charGood = true;
		}
	  }
	  if (allowSpace)  {
	    if (nextChar == " ")  {
		  charGood = true;
		}
	  }
	  if (extraChars)  {
	    if (unescape(extraChars).indexOf(nextChar) >= 0)  {
		  charGood = true;
		}
	  }
	  if (!charGood)  {
	    isValid = false;
		x = value.length;
	  }
	}
	if (required && value=="") {
	  isValid = false;
  }
  if (!isValid)  {
  }
  return isValid;
}
function WAValidateEM(formElement,value,errorMsg,focusIt,stopIt,required) {
  var isValid = true;
	var knownDomsPat = /^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat = /^(.+)@(.+)$/;
	var accepted = "\[^\\s\\(\\)><@,;:\\\\\\\"\\.\\[\\]\]+";
	var quotedUser = "(\"[^\"]*\")";
	var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var section = "(" + accepted + "|" + quotedUser + ")";
	var userPat = new RegExp("^" + section + "(\\." + section + ")*$");
	var domainPat = new RegExp("^" + accepted + "(\\." + accepted +")*$");
	var theMatch = value.match(emailPat);
	var acceptedPat = new RegExp("^" + accepted + "$");
	var userName = "";
	var domainName = "";
	if (theMatch==null) {
	  isValid = false;
	}
	else  {
	  userName = theMatch[1];
	  domainName = theMatch[2];
	  var domArr = domainName.split(".");
	  var IPArray = domainName.match(ipDomainPat);
	  for (x=0; x < userName.length; x++) {
		if (userName.charCodeAt(x) > 127) {
		  isValid = false;
		}
	  }
	  for (x=0; x < domainName.length; x++) {
		if (domainName.charCodeAt(x) > 127) {
		  isValid = false;
		}
	  }
	  if (userName.match(userPat) == null) {
		isValid = false;
	  }
	  if (IPArray != null) {
		for (var x=1; x<=4; x++) {
		  if (IPArray[x] > 255) {
			isValid = false;
		  }
		}
	  }
	  for (x=0; x < domArr.length; x++) {
		if (domArr[x].search(acceptedPat) == -1 || domArr[x].length == 0) {
		  isValid = false;
		}
	  }
	  if (domArr[domArr.length-1].length !=2 && domArr[domArr.length-1].search(knownDomsPat) == -1) {
		isValid = false;
	  }
	  if (domArr.length < 2) {
		isValid = false;
	  }
	}
	return isValid;
}
function loadMyXML (file) {
	var xmlDoc;
	xmlDoc=new window.XMLHttpRequest();
	xmlDoc.open("GET",file,false);
	xmlDoc.send("null");
	return xmlDoc.responseXML;
}
function getInstantQuote(from) {
	var successHandler = function(o) {
		var HTML ='';
		var HTML2 ='';
		var HTML3 ='';
		var size, sizePrice;
		var status = o.responseText;
		if (from == 'wrk') {
			var colors = status.split(':');
		}
		if (from == 'S') {
			var colors = new Array();
			colors[0] = MSB.$('numcolorsF2').value;
			colors[1] = MSB.$('numcolorsB2').value;
			if ((colors[0] == '0') && (colors[1] == '0')) {
				colors[2] = '1';
			}
		}
		MSB.$('numcolorsF').value = colors[0];
		MSB.$('numcolorsB').value = colors[1];
		if (colors[2] == '1') {
			HTML = 'Can not provide instant pricing if design includes an image. Use the <a class="JSlink" onclick="openGetQForm()" >Get Quote Form</a>.<br />';
			MSB.$('numcolorsF').value = '0';
			MSB.$('numcolorsB').value = '0';
		}
		else {
			var prod = MSB.$('actprod').value;
			var root = loadMyXML('products/'+prod+'-pricesheet.xml');
			var setup = parseInt(root.getElementsByTagName('setupPerColor')[0].childNodes[0].nodeValue);
			var setupCharges = setup*colors[0] + setup*colors[1];
			var breaks = root.getElementsByTagName('priceBreaks');
			var breakA = breaks[0].getElementsByTagName('breakPoint');
			var Iprices = root.getElementsByTagName('blankPrices');
			var IpriceA = Iprices[0].getElementsByTagName('blank');
			var Sprices = root.getElementsByTagName('sizePrices');
			var SpriceA = Sprices[0].getElementsByTagName('size');
			HTML3 = '<select id="ADTCsizeSelect" name="ADTCsizeSelect">';
			for (var i=0;i<SpriceA.length;i++) {
				size = SpriceA[i].getAttribute('name');
				sizePrice = SpriceA[i].childNodes[0].nodeValue;
				HTML3 = HTML3 + '<option value="'+size+':'+sizePrice+'" onclick="ADTCchangeSize()" >'+size+"&nbsp;&nbsp;&nbsp;"+'+ '+sizePrice+'</option';
			}
			HTML3 = HTML3 + '</select>';
			var Iprice = 0.00;
			var Iprice = parseFloat(IpriceA[0].childNodes[0].nodeValue);
			var color;
			for (var i=0;i<IpriceA.length;i++) {
				color = IpriceA[i].getAttribute('color');
				if (color == MSB.$('productColor').value) {
					Iprice = parseFloat(IpriceA[i].childNodes[0].nodeValue);
				}
			}
			MSB.$('ADTCsetupCharges').value = setupCharges;
			HTML = 'Setup Charges: '+MSB.$('moneySymbol').value+setupCharges+'<br /><table class="IQtable">';
			HTML = HTML + '<tr class="head"><td>Qty</td><td>per item</td></tr>';
			HTML2 = '<select id="IQadtcQtySelect" name="IQadtcQtySelect">';
			var qty;
			var Pprice = 0.00;
			var price = 0.00;
			for (var i=0;i<breakA.length;i++) {
				qty = breakA[i].getAttribute('qty');					
				Pprice = breakA[i].childNodes[0].nodeValue*colors[0]+breakA[i].childNodes[0].nodeValue*colors[1];
				Pprice = parseFloat(Pprice);
				price = parseFloat(Pprice + Iprice).toFixed(2);
				HTML = HTML + '<tr><td>'+qty+'</td><td id="IQamount'+qty+'">'+MSB.$('moneySymbol').value+price+'</td></tr>';
				HTML2 = HTML2 + '<option value="'+qty+'_'+price+'" >'+qty+'</option>';
			}
			HTML = HTML + '</table>';
			HTML2 = HTML2 + '</select>';
		}
		if (from == 'wrk') {
			MSB.$('IQresultsDiv').innerHTML = HTML;
		}
		if (from == 'S') {
			MSB.$('SmatrixPricing').innerHTML = HTML;
			MSB.$('IQadtcQtySelDiv').innerHTML = HTML2;
			MSB.$('ADTCsizeOpts').innerHTML = HTML3;
		}
	}
	var failureHandler = function(o) {
		alert ('Failed Connection')
	}
	var callback = {
		success: successHandler,
		failure: failureHandler
	}
	YAHOO.util.Connect.setForm("formSaveDesign");
	var cObj = YAHOO.util.Connect.asyncRequest('POST', 'php/get-instant-quote.php', callback);
} 
function calcNumColors() {
	var successHandler = function(o) {
		var status = o.responseText;
		var colors = status.split(':');
		MSB.$('numcolorsF').value = colors[0];
		MSB.$('numcolorsB').value = colors[1];
		MSB.$('numcolorsF2').value = colors[0];
		MSB.$('numcolorsB2').value = colors[1];
		if (colors[2] == '1') {
			HTML = 'Can not provide instant pricing if design includes an image. Use the <a class="JSlink" onclick="openGetQForm()" >Get Quote Form</a>.<br />';
			MSB.$('numcolorsF').value = '0';
			MSB.$('numcolorsB').value = '0';
			MSB.$('numcolorsF2').value = '0';
			MSB.$('numcolorsB2').value = '0';
			MSB.$('IQadtcDiv').style.display = 'none';
			MSB.$('IQadtcDivA').style.display = 'none';
		}
		else {
			if (MSB.$('IQadtcDiv').style.display == 'none') {
				MSB.$('IQadtcDiv').style.display = 'inline';
				MSB.$('IQadtcDivA').style.display = 'inline';
			}
		}
		savedesignA();
	}
	var failureHandler = function(o) {
		alert ('Failed Connection')
	}
	var callback = {
		success: successHandler,
		failure: failureHandler
	}
	YAHOO.util.Connect.setForm("formSaveDesign");
	var cObj = YAHOO.util.Connect.asyncRequest('POST', 'php/get-instant-quote.php', callback);
}
function openGetQForm() {
	YAHOO.example.container.panel29.show();
} 
function addDesigntoCart() {
	MSB.$('ADTC_design_ID').value = MSB.$('design_id2').value;
	MSB.$('ADTCprod').value = MSB.$('actprod2').value;
	MSB.$('ADTCcolor').value = MSB.$('productColor2').value;
//	MSB.$('ADTCwepDirectory').value = MSB.$('wepDirectory').value
	var price = MSB.$('IQadtcQtySelect').options[MSB.$('IQadtcQtySelect').selectedIndex].value.split('_')[1];
	MSB.$('ADTCqtyPrice').value = price;
	ADTCchangeSize();
	var successHandler = function(o) {
		var status = o.responseText.split("+");
		MSB.$('quickCartItemDiv').innerHTML = "Items: "+status[0];
		MSB.$('quickCartCostDiv').innerHTML = "Cost: "+MSB.$('moneySymbol').value+status[1];
	}
	var failureHandler = function(o) {
		alert ('Failed Connection')
	}
	var callback = {
		success: successHandler,
		failure: failureHandler
	}
	YAHOO.util.Connect.setForm("ADTCform1");
	var cObj = YAHOO.util.Connect.asyncRequest('POST', './php/designtocart.php', callback); 
}
function ADTCchangeSize() {
	MSB.$('productSize2').value = MSB.$('ADTCsizeSelect').options[MSB.$('ADTCsizeSelect').selectedIndex].value.split(':')[0];
	var Xprice = parseFloat(MSB.$('ADTCsizeSelect').options[MSB.$('ADTCsizeSelect').selectedIndex].value.split(':')[1]);
	MSB.$('productPrice2').value = Xprice + parseFloat(MSB.$('ADTCqtyPrice').value);
}
function loadFontSizeMenu(e) {
	MSB.$('fontsizeDiv').innerHTML = '';
	if (e != 'default') {
		var elTarget = YAHOO.util.Event.getTarget(e);
		elTarget = elTarget.id;
		var myfont = MSB.$(elTarget).getAttribute('title');
	}
	else {
		var myfont = 'default';
	}
	var fsizes = new Array();
	var defaultFS, defaultFSi;
	switch (myfont) {  /* KIDS only have 2 font sizes, 2.5 and 3.8 -- kid 8 @ 2.5 and 6 @ 3.8 letters, babies 7 and 5 letters*/
		case 'Squad-Caps':
		fsizes = [49,65]; // scaled to suit KIDS
		fsizesName = ['2.5cm (Squad-Caps)','3.8cm (Squad-Caps)'];
		defaultFS = '49';
		defaultFSi = '1';
		break;
		case 'Boston55':
		fsizes = [55,75];
		fsizesName = ['2.5cm (Boston55)','3.8cm (Boston55)'];
		defaultFS = '55';
		defaultFSi = '1';
		break;
		case 'Typewriter-Condensed':
		fsizes = [45,59];
		fsizesName = ['2.5cm (Typewriter)','3.8cm (Typewriter)'];
		defaultFS = '44';
		defaultFSi = '1';
		break;
		case 'Diamante-Caps':
		fsizes = [30];
		fsizesName = ['3.8cm'];
		defaultFS = '30';
		defaultFSi = '1';
		break;
		default:
		fsizes = [49]; /* Default */
		fsizesName = ['Text Size (Select Font BEFORE text size)'];
		defaultFS = '49';
		defaultFSi = '1';
		break;
	}
	var HTML='<select name="fsedit1" id="fsedit1" onchange="changeFS()" onclick="revealSaveButton()">';
	for (var i=0;i<fsizes.length;i++) {
		//HTML = HTML + '<option value="'+fsizes[i]+'" >'+fsizes[i]+'</option>';
		HTML = HTML + '<option value="'+fsizes[i]+'" >'+fsizesName[i]+'</option>';
	}
	HTML = HTML + '</select>';
	MSB.$('fontsizeDiv').innerHTML = HTML;
	MSB.$('fsedit').value = defaultFS;
//	MSB.$('fsedit1').selectedIndex = defaultFSi;
	if (MSB.$('currentFMT').value == 'text' && MSB.$('actline').value != 'none') {
		var lineindex = MSB.$('actline').value.substring(2);
		MSB.$('oldfont').value = MSB.$('ft' + lineindex).value;
		MSB.$('ft' + lineindex).value = myfont;
		MSB.$('fs' + lineindex).value = defaultFS;
		edittext('fromeditft');
	}
	
}
function changeFS() {
	MSB.$('fsedit').value = MSB.$('fsedit1').options[MSB.$('fsedit1').selectedIndex].value;
	var lineindex = MSB.$('actline').value.substring(2);
	MSB.$('fs' + lineindex).value = MSB.$('fsedit').value;
	edittext('fromeditfs');
		// reveal Save Button 
		//MSB.$('savedesignbox').style.visibility = 'visible';
		//MSB.$('savedesignbox').style.backgroundColor = '#B0F299'; /* GREEN 54BB5A */

}
function revealSaveButton() {
		// reveal Save Button 
		MSB.$('savedesignbox').style.visibility = 'visible';
		MSB.$('savedesignbox').style.backgroundColor = '#B0F299'; /* GREEN 54BB5A */
}

function cancelDesignRetrieve() {
			YAHOO.example.container.opendesignAlert.hide();
			YAHOO.example.container.opendesignAlert2.hide();
			YAHOO.example.container.designreviewoverlay.hide();
			YAHOO.example.container.opendesignoverlay.hide();
}
